Author: tgoettlicher
Date: Thu Jul 3 15:04:29 2008
New Revision: 48830
URL: http://svn.opensuse.org/viewcvs/yast?rev=48830&view=rev
Log:
added reading of configfiles
Added:
branches/tmp/jdsn/registration/src/ConfigEditor.cc
branches/tmp/jdsn/registration/src/ConfigEditor.h
branches/tmp/jdsn/registration/src/ConfigIni.h
branches/tmp/jdsn/registration/src/ConfigInstallInf.h
Modified:
branches/tmp/jdsn/registration/src/Makefile.am
branches/tmp/jdsn/registration/src/RegMain.cc
Added: branches/tmp/jdsn/registration/src/ConfigEditor.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/jdsn/registration/src/ConfigEditor.cc?rev=48830&view=auto
==============================================================================
--- branches/tmp/jdsn/registration/src/ConfigEditor.cc (added)
+++ branches/tmp/jdsn/registration/src/ConfigEditor.cc Thu Jul 3 15:04:29 2008
@@ -0,0 +1,97 @@
+// Class for reading and writing config files
+
+#include "ConfigEditor.h"
+
+ConfigEditor::ConfigEditor(const char* filename, char delimiter, char comment)
+{
+ configuration = new rude::Config();
+
+ configuration->setDelimiter(delimiter);
+ configuration->setCommentCharacter(comment);
+
+ // it is important to set the delimiter and
+ // commentcharacter before loading the file
+ configuration->load(filename);
+}
+
+
+
+void ConfigEditor::save()
+{
+ configuration->save();
+}
+
+
+ConfigEditor::~ConfigEditor()
+{
+ delete configuration;
+}
+
+
+bool ConfigEditor::getBool(const char* key, const char* section)
+{
+ configuration->setSection(section);
+ return configuration->getBoolValue(key);
+
+}
+
+
+const char* ConfigEditor::getString(const char* key, const char* section)
+{
+ configuration->setSection(section);
+ return configuration->getStringValue(key);
+
+}
+
+
+int ConfigEditor::getInt(const char* key, const char* section)
+{
+ configuration->setSection(section);
+ return configuration->getIntValue(key);
+
+}
+
+
+double ConfigEditor::getDouble(const char* key, const char* section)
+{
+ configuration->setSection(section);
+ return configuration->getDoubleValue(key);
+
+}
+
+
+bool ConfigEditor::exists(const char* key, const char* section)
+{
+ configuration->setSection(section);
+ return configuration->exists(key);
+}
+
+
+void ConfigEditor::setBool(bool value, const char* key, const char* section)
+{
+ configuration->setSection(section);
+ configuration->setBoolValue(key, value);
+}
+
+
+void ConfigEditor::setString(const char* value, const char* key, const char* section)
+{
+ configuration->setSection(section);
+ configuration->setStringValue(key, value);
+}
+
+
+void ConfigEditor::setInt(int value, const char* key, const char* section)
+{
+ configuration->setSection(section);
+ configuration->setIntValue(key, value);
+}
+
+
+void ConfigEditor::setDouble(double value, const char* key, const char* section)
+{
+ configuration->setSection(section);
+ configuration->setDoubleValue(key, value);
+}
+
+
Added: branches/tmp/jdsn/registration/src/ConfigEditor.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/jdsn/registration/src/ConfigEditor.h?rev=48830&view=auto
==============================================================================
--- branches/tmp/jdsn/registration/src/ConfigEditor.h (added)
+++ branches/tmp/jdsn/registration/src/ConfigEditor.h Thu Jul 3 15:04:29 2008
@@ -0,0 +1,49 @@
+// Base class for reading and writing config files
+
+#ifndef ConfigEditor_h
+#define ConfigEditor_h
+
+#include
+
+class ConfigEditor
+{
+public:
+ // save changes;
+ void save();
+
+ // Constuctor: open the config file and sets file attributes
+ ConfigEditor(const char* filename, char delimiter, char comment);
+
+ // Destructor: closes the config file
+ // use save() if you want to save changes
+ ~ConfigEditor();
+
+ // get values from the config file
+ // if no section is specified the untitled section in the beginning
+ // of the config file is used
+ bool getBool(const char* key, const char* section = "");
+ const char* getString(const char* key, const char* section = "");
+ int getInt(const char* key, const char* section = "");
+ double getDouble(const char* key, const char* section = "");
+
+ // check whether a key exists in the config file
+ // if no section is specified the untitled section in the beginning
+ // of the config file is used
+ bool exists(const char* key, const char* section = "");
+
+ // set values in the config file
+ // if no section is specified the untitled section in the beginning
+ // of the config file is used
+ // use save() if you want to write the file
+ void setBool(bool value, const char* key, const char* section = "");
+ void setString(const char* value, const char* key, const char* section = "");
+ void setInt(int value, const char* key, const char* section = "");
+ void setDouble(double value, const char* key, const char* section = "");
+
+private:
+ // pointer to our rudeconfig object
+ rude::Config* configuration;
+
+};
+
+#endif // ConfigEditor_h
Added: branches/tmp/jdsn/registration/src/ConfigIni.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/jdsn/registration/src/ConfigIni.h?rev=48830&view=auto
==============================================================================
--- branches/tmp/jdsn/registration/src/ConfigIni.h (added)
+++ branches/tmp/jdsn/registration/src/ConfigIni.h Thu Jul 3 15:04:29 2008
@@ -0,0 +1,19 @@
+// Class for reading install.inf
+// See ConfigEditor.h for more information
+
+#ifndef ConfigIni_h
+#define ConfigIni_h
+
+#include "ConfigEditor.h"
+
+class ConfigIni : public ConfigEditor
+{
+public:
+ ConfigIni(const char* filename )
+ : ConfigEditor::ConfigEditor(filename, // name of config file
+ '=', // delimiter character
+ '#') // comment character
+ {};
+};
+
+#endif // ConfigInstallInf_h
Added: branches/tmp/jdsn/registration/src/ConfigInstallInf.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/jdsn/registration/src/ConfigInstallInf.h?rev=48830&view=auto
==============================================================================
--- branches/tmp/jdsn/registration/src/ConfigInstallInf.h (added)
+++ branches/tmp/jdsn/registration/src/ConfigInstallInf.h Thu Jul 3 15:04:29 2008
@@ -0,0 +1,19 @@
+// Class for reading install.inf
+// See ConfigEditor.h for more information
+
+#ifndef ConfigInstallInf_h
+#define ConfigInstallInf_h
+
+#include "ConfigEditor.h"
+
+class ConfigInstallInf : public ConfigEditor
+{
+public:
+ ConfigInstallInf(const char* filename )
+ : ConfigEditor::ConfigEditor(filename, // name of config file
+ ':', // delimiter character
+ '#') // comment character
+ {};
+};
+
+#endif // ConfigInstallInf_h
Modified: branches/tmp/jdsn/registration/src/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/jdsn/registration/src/Makefile.am?rev=48830&r1=48829&r2=48830&view=diff
==============================================================================
--- branches/tmp/jdsn/registration/src/Makefile.am (original)
+++ branches/tmp/jdsn/registration/src/Makefile.am Thu Jul 3 15:04:29 2008
@@ -11,8 +11,12 @@
RegWizard.cc \
RegWizardPage.cc \
RegUpdateRepoPage.cc \
+ WizardEmulation.cc \
+ ConfigEditor.cc \
+ ConfigInstallInf.h \
+ ConfigIni.h \
RegHWInfoPage.cc \
WizardEmulation.cc
-yast2_registration_LDADD = -L$(top_srcdir)/src -lyui
+yast2_registration_LDADD = -L$(top_srcdir)/src -lyui -lrudeconfig
Modified: branches/tmp/jdsn/registration/src/RegMain.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/jdsn/registration/src/RegMain.cc?rev=48830&r1=48829&r2=48830&view=diff
==============================================================================
--- branches/tmp/jdsn/registration/src/RegMain.cc (original)
+++ branches/tmp/jdsn/registration/src/RegMain.cc Thu Jul 3 15:04:29 2008
@@ -18,6 +18,7 @@
#include "RegWizard.h"
#include "RegUpdateRepoPage.h"
#include "RegHWInfoPage.h"
+#include "ConfigIni.h"
int main( int argc, char **argv )
@@ -25,7 +26,13 @@
YUILog::setLogFileName( "/tmp/registration.log" );
YUILog::enableDebugLogging();
- RegUpdateRepoPage updateRepoPage( true, "http://download.opensuse.org/update/11.0/" );
+ ConfigIni productFeatures("/etc/YaST2/ProductFeatures");
+
+
+
+
+ RegUpdateRepoPage updateRepoPage( true,
+ productFeatures.getString("external_sources_link", "software" ));
RegHWInfoPage hwInfoPage;
RegUpdateRepoPage updateRepoPage2( true, "Page 2" );
RegUpdateRepoPage updateRepoPage3( true, "Page 3" );
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org