kpilot
kpilotConfig.ccGo to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "options.h"
00031
00032 #include <stdlib.h>
00033
00034 #include <qlineedit.h>
00035 #include <qcombobox.h>
00036 #include <qcheckbox.h>
00037
00038 #include <kstandarddirs.h>
00039 #include <kconfig.h>
00040 #include <ksimpleconfig.h>
00041 #include <kcmdlineargs.h>
00042 #include <kmessagebox.h>
00043 #include <kglobalsettings.h>
00044
00045 #include "kpilotSettings.h"
00046 #include "kpilotConfig.h"
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 const uint KPilotConfig::ConfigurationVersion = 443;
00058
00059 int KPilotConfig::getConfigVersion()
00060 {
00061 FUNCTIONSETUP;
00062
00063 uint version = KPilotSettings::configVersion();
00064
00065 if (version < ConfigurationVersion)
00066 {
00067 WARNINGKPILOT << "Config file has old version " << version << endl;
00068 }
00069 else
00070 {
00071 #ifdef DEBUG
00072 DEBUGKPILOT << fname
00073 << ": Config file has version " << version << endl;
00074 #endif
00075 }
00076
00077 return version;
00078 }
00079
00080 void KPilotConfig::updateConfigVersion()
00081 {
00082 FUNCTIONSETUP;
00083 KPilotSettings::setConfigVersion( ConfigurationVersion );
00084 }
00085
00086 QString KPilotConfig::getDefaultDBPath()
00087 {
00088 FUNCTIONSETUP;
00089 QString lastUser = KPilotSettings::userName();
00090 QString dbsubpath = CSL1("kpilot/DBBackup/");
00091 QString defaultDBPath = KGlobal::dirs()->
00092 saveLocation("data", dbsubpath + lastUser + CSL1("/"));
00093 return defaultDBPath;
00094 }
00095
00096 int KPilotConfig::getDebugLevel(KCmdLineArgs *p)
00097 {
00098 FUNCTIONSETUP;
00099
00100 if (p)
00101 {
00102 if (p->isSet("debug"))
00103 {
00104 debug_level = p->getOption("debug").toInt();
00105 }
00106 }
00107
00108 return debug_level;
00109 }
00110
00111 static QFont *thefont = 0L;
00112
00113 const QFont & KPilotConfig::fixed()
00114 {
00115 FUNCTIONSETUP;
00116
00117 if (!thefont)
00118 thefont = new QFont(KGlobalSettings::fixedFont());
00119
00120 return *thefont;
00121 }
00122
00123
00124 void KPilotConfig::addDirtyDatabase(QString db)
00125 {
00126 FUNCTIONSETUP;
00127 QStringList l(KPilotSettings::dirtyDatabases());
00128 if (!l.contains(db))
00129 {
00130 l.append(db);
00131 KPilotSettings::setDirtyDatabases(l);
00132 }
00133 }
00134
00135
00136 void KPilotConfig::addAppBlockChangedDatabase(QString db)
00137 {
00138 QStringList l(KPilotSettings::appBlockChangedDatabases());
00139 if (!l.contains(db))
00140 {
00141 l.append(db);
00142 KPilotSettings::setAppBlockChangedDatabases(l);
00143 }
00144 }
00145
00146 void KPilotConfig::addFlagsChangedDatabase(QString db)
00147 {
00148 QStringList l(KPilotSettings::flagsChangedDatabases());
00149 if (!l.contains(db))
00150 {
00151 l.append(db);
00152 KPilotSettings::setFlagsChangedDatabases(l);
00153 }
00154 }
00155
00156
00157
00158
00159 QString KPilotConfig::versionDetails(int fileversion, bool run)
00160 {
00161 FUNCTIONSETUP;
00162 QString s = CSL1("<qt><p>");
00163 s += i18n("The configuration file is outdated.");
00164 s += ' ';
00165 s += i18n("The configuration file has version %1, while KPilot "
00166 "needs version %2.").arg(fileversion).arg(ConfigurationVersion);
00167 if (run)
00168 {
00169 s += ' ';
00170 s += i18n("Please run KPilot and check the configuration carefully "
00171 "to update the file.");
00172 }
00173 s += CSL1("</p><p>");
00174 s += i18n("Important changes to watch for are:");
00175 s += ' ';
00176 if (fileversion < 440)
00177 {
00178 s += i18n("Renamed conduits, Kroupware and file installer have "
00179 "been made conduits as well.");
00180 s += ' ';
00181 s += i18n("Conflict resolution is now a global setting.");
00182 s += ' ';
00183 }
00184 if (fileversion < 443)
00185 {
00186 s += i18n("Changed format of no-backup databases.");
00187 s += ' ';
00188 }
00189
00190
00191
00192 return s;
00193 }
00194
00195 void KPilotConfig::sorryVersionOutdated(int fileversion)
00196 {
00197 FUNCTIONSETUP;
00198 KMessageBox::detailedSorry(0L,
00199 i18n("The configuration file for KPilot is out-of "
00200 "date. Please run KPilot to update it."),
00201 KPilotConfig::versionDetails(fileversion,true),
00202 i18n("Configuration File Out-of Date"));
00203 }
00204
00205 static void update440()
00206 {
00207
00208 {
00209 QStringList conduits( KPilotSettings::installedConduits() );
00210 KConfig*c = KPilotSettings::self()->config();
00212 c->setGroup( QString::null );
00213 bool installFiles = c->readBoolEntry("SyncFiles",true);
00214 if (installFiles) conduits.append( CSL1("internal_fileinstall") );
00215 c->deleteEntry("SyncFiles");
00216 KPilotSettings::setInstalledConduits(conduits);
00217 c->sync();
00218 if (installFiles)
00219 KMessageBox::information(0L,
00220 i18n("The settings for the file installer have been moved to the "
00221 "conduits configuration. Check the installed "
00222 "conduits list."),
00223 i18n("Settings Updated"));
00224
00225 }
00226
00227
00228
00229
00230 {
00231 QStringList foundlibs ;
00232 static const char *oldconduits[] = { "null", "address", "doc",
00233 "knotes", "sysinfo", "time", "todo", "vcal", 0L } ;
00234 const char **s = oldconduits;
00235 while (*s)
00236 {
00237 QString libname = CSL1("kde3/lib%1conduit.so").arg(QString::fromLatin1(*s));
00238 QString foundlib = ::locate("lib",libname);
00239 if (!foundlib.isEmpty())
00240 {
00241 foundlibs.append(foundlib);
00242 }
00243 s++;
00244 }
00245
00246 if (!foundlibs.isEmpty())
00247 KMessageBox::informationList(0L,
00248 i18n("<qt>The following old conduits were found on "
00249 "your system. It is a good idea to remove "
00250 "them and the associated <tt>.la</tt> "
00251 "and <tt>.so.0</tt> files.</qt>"),
00252 foundlibs,
00253 i18n("Old Conduits Found"));
00254 }
00255 }
00256
00257 static void update443()
00258 {
00259 FUNCTIONSETUP;
00260
00261 QStringList skip = KPilotSettings::skipBackupDB();
00262 QStringList fixSkip;
00263 bool fixedSome = false;
00264 #ifdef DEBUG
00265 DEBUGKPILOT << fname << ": Skip databases are: "
00266 << skip.join(CSL1(",")) << endl;
00267 #endif
00268
00269 for (QStringList::const_iterator i = skip.begin(); i!=skip.end(); ++i)
00270 {
00271 if ((*i).length()==4)
00272 {
00273 fixSkip.append(CSL1("[%1]").arg(*i));
00274 fixedSome = true;
00275 }
00276 else
00277 {
00278 fixSkip.append(*i);
00279 }
00280 }
00281
00282 if (fixedSome)
00283 {
00284 KMessageBox::informationList(0L,
00285 i18n("<qt>The no backup databases listed in your configuration file "
00286 "have been adjusted to the new format. Database creator IDs "
00287 "have been changed to use square brackets []."),
00288 fixSkip,
00289 i18n("No Backup Databases Updated"));
00290 }
00291 }
00292
00293 KPilotConfig::RunMode KPilotConfig::interactiveUpdate()
00294 {
00295 FUNCTIONSETUP;
00296
00297 int res = 0;
00298 unsigned int fileVersion = KPilotSettings::configVersion();
00299
00300
00301
00302 if (fileVersion >= KPilotConfig::ConfigurationVersion)
00303 {
00304 return Normal;
00305 }
00306
00307 if (0 == fileVersion)
00308 {
00309 res = KMessageBox::questionYesNoCancel(0L,
00310 i18n("KPilot is not configured for use. You may use "
00311 "the configuration wizard or the normal configure dialog "
00312 "to configure KPilot."),
00313 i18n("Not Configured"),
00314 i18n("Use &Wizard"),
00315 i18n("Use &Dialog"));
00316 if (res == KMessageBox::Yes) return WizardAndContinue;
00317 if (res == KMessageBox::No) return ConfigureAndContinue;
00318
00319 return Cancel;
00320 }
00321
00322 res = KMessageBox::warningContinueCancel(0L,
00323 i18n("The configuration file for KPilot is out-of "
00324 "date. KPilot can update some parts of the "
00325 "configuration automatically. Do you wish to "
00326 "continue?"),
00327 i18n("Configuration File Out-of Date"));
00328 if (res!=KMessageBox::Continue) return Cancel;
00329
00330 #ifdef DEBUG
00331 DEBUGKPILOT << fname << ": Updating from "
00332 << fileVersion << " to " << ConfigurationVersion << endl;
00333 #endif
00334
00335 if (fileVersion < 440) update440();
00336 if (fileVersion < 443) update443();
00337
00338 KPilotConfig::updateConfigVersion();
00339 KPilotSettings::writeConfig();
00340 return ConfigureAndContinue;
00341 }
00342
00343 void KPilotConfig::sync()
00344 {
00345 KPilotSettings::self()->config()->sync();
00346 }
|