Index: branches/preferences/src/lib/parser/ini_parser/ini_parser.cc
===================================================================
--- branches/preferences/src/lib/parser/ini_parser/ini_parser.cc	(revision 6387)
+++ branches/preferences/src/lib/parser/ini_parser/ini_parser.cc	(revision 6388)
@@ -431,4 +431,79 @@
 }
 
+/**
+ * @brief edits the entry speciefied by entryName in sectionName/currentSection or creates it if it doesn't exist
+ * @param entryName the Name of the Entry to add
+ * @param value the value to assign to this entry
+ * @param sectionName if NULL then this entry will be set to the currentSection
+ * otherwise to the section refered to by sectionName.
+ * If both are NULL no entry will be added
+ * @return true if everything is ok false on error
+ */
+bool IniParser::editVar(const char* entryName, const char* value, const char* sectionName)
+{
+  std::list<IniSection>::iterator section;
+
+  if (sectionName != NULL)
+  {
+    for (section = this->sections.begin(); section != this->sections.end(); section++)
+      if (!strcmp((*section).name, sectionName))
+        break;
+  }
+  else
+    section = this->currentSection;
+
+  if (section == this->sections.end())
+  {
+    assert( sectionName != NULL );
+
+    IniSection sec;
+    sec.comment = NULL;
+    sec.name = new char[strlen(sectionName)+1];
+    strcpy(sec.name, sectionName);
+    section = this->sections.insert(this->sections.end(), sec);
+  }
+
+  if (section == this->sections.end())
+  {
+    PRINTF(2)("section '%s' not found for value '%s'\n", sectionName, entryName);
+    return false;
+  }
+  else
+  {
+    //try find item
+    std::list<IniEntry>::iterator entry;
+    for (entry = section->entries.begin(); entry!=section->entries.end(); entry++)
+      if (!strcmp( entry->name, entryName ))
+        break;
+
+    //found it?
+    if ( entry != section->entries.end() )
+    {
+      if ( entry->value != NULL )
+      {
+        delete[] entry->value;
+      }
+      entry->value = new char[strlen(value)+1];
+      strcpy(entry->value, value);
+
+      return true;
+    }
+
+    //not found -> create it
+    (*section).entries.push_back(IniEntry());
+    (*section).entries.back().comment = NULL;
+    (*section).entries.back().name = new char[strlen(entryName)+1];
+    strcpy((*section).entries.back().name, entryName);
+    (*section).entries.back().value = new char[strlen(value)+1];
+    strcpy((*section).entries.back().value, value);
+    PRINTF(5)("Added Entry %s with Value '%s' to Section %s\n",
+    (*section).entries.back().name,
+    (*section).entries.back().value,
+    (*section).name);
+    this->currentEntry = --(*section).entries.end();
+    return true;
+  }
+}
+
 
 /**
Index: branches/preferences/src/lib/parser/ini_parser/ini_parser.h
===================================================================
--- branches/preferences/src/lib/parser/ini_parser/ini_parser.h	(revision 6387)
+++ branches/preferences/src/lib/parser/ini_parser/ini_parser.h	(revision 6388)
@@ -67,4 +67,5 @@
 
     bool addVar(const char* entryName, const char* value, const char* sectionName = NULL);
+    bool editVar(const char* entryName, const char* value, const char* sectionName = NULL);
     const char* getVar(const char* entryName, const char* sectionName, const char* defaultValue = "") const;
     void setEntryComment(const char* comment, const char* entryName, const char* sectionName);
Index: branches/preferences/src/lib/parser/preferences/cmd_line_prefs_reader.cc
===================================================================
--- branches/preferences/src/lib/parser/preferences/cmd_line_prefs_reader.cc	(revision 6387)
+++ branches/preferences/src/lib/parser/preferences/cmd_line_prefs_reader.cc	(revision 6388)
@@ -36,9 +36,3 @@
 }
 
-/**
- * reads the commandline arguments and stores them in Preferences
- * @return true if commanline arguments have been interpreted correctly
- */
-bool CmdLinePrefsReader::readCmdLine()
-{
-}
+
Index: branches/preferences/src/lib/parser/preferences/cmd_line_prefs_reader.h
===================================================================
--- branches/preferences/src/lib/parser/preferences/cmd_line_prefs_reader.h	(revision 6387)
+++ branches/preferences/src/lib/parser/preferences/cmd_line_prefs_reader.h	(revision 6388)
@@ -14,6 +14,4 @@
    virtual ~CmdLinePrefsReader();
 
-   bool readCmdLine();
-
  private:
 
Index: branches/preferences/src/lib/parser/preferences/ini_file_prefs_reader.cc
===================================================================
--- branches/preferences/src/lib/parser/preferences/ini_file_prefs_reader.cc	(revision 6387)
+++ branches/preferences/src/lib/parser/preferences/ini_file_prefs_reader.cc	(revision 6388)
@@ -24,6 +24,31 @@
  * standard constructor
 */
-IniFilePrefsReader::IniFilePrefsReader ()
+IniFilePrefsReader::IniFilePrefsReader ( const char * fileName )
 {
+  IniParser iniParser;
+
+  if ( !iniParser.readFile( fileName ) )
+    return;
+
+  Preferences* prefs = Preferences::getInstance();
+
+  iniParser.firstSection();
+
+  do
+  {
+    do
+    {
+      prefs->setString( iniParser.getCurrentSection(), iniParser.getCurrentName(), iniParser.getCurrentValue(), true );
+    } while (iniParser.nextVar());
+  } while (iniParser.nextSection()!=NULL);
+
+  /*iniParser.firstVar();
+
+  Preferences* prefs = Preferences::getInstance();
+
+  while ( iniParser.nextVar() )
+  {
+    prefs->setString( iniParser.getCurrentSection(), iniParser.getCurrentName(), iniParser.getCurrentValue(), true );
+}*/
 }
 
@@ -36,25 +61,3 @@
 }
 
-/**
- * reads entries from inifile fileName into Preferences
- * @param fileName filename of inifile to read
- * @return true on success
- */
-bool IniFilePrefsReader::readIniFile( const char * fileName )
-{
-  IniParser iniParser;
 
-  if ( !iniParser.readFile( fileName ) )
-    return false;
-
-  iniParser.firstVar();
-
-  Preferences* prefs = Preferences::getInstance();
-
-  while ( iniParser.nextVar() )
-  {
-    prefs->setString( iniParser.getCurrentSection(), iniParser.getCurrentName(), iniParser.getCurrentValue() );
-  }
-
-  return true;
-}
Index: branches/preferences/src/lib/parser/preferences/ini_file_prefs_reader.h
===================================================================
--- branches/preferences/src/lib/parser/preferences/ini_file_prefs_reader.h	(revision 6387)
+++ branches/preferences/src/lib/parser/preferences/ini_file_prefs_reader.h	(revision 6388)
@@ -15,10 +15,7 @@
 
  public:
-   IniFilePrefsReader();
+   IniFilePrefsReader(const char* fileName);
    virtual ~IniFilePrefsReader();
 
-   bool readIniFile(const char* fileName);
-
- private:
 
 };
Index: branches/preferences/src/lib/util/preferences.cc
===================================================================
--- branches/preferences/src/lib/util/preferences.cc	(revision 6387)
+++ branches/preferences/src/lib/util/preferences.cc	(revision 6388)
@@ -28,4 +28,5 @@
    this->setClassID(CL_PREFERENCES, "Preferences");
    this->setName("Preferences");
+   this->fileName = NULL;
 }
 
@@ -41,4 +42,10 @@
 {
   Preferences::singletonRef = NULL;
+
+  if ( this->fileName )
+  {
+    delete this->fileName;
+    this->fileName = NULL;
+  }
 }
 
@@ -78,7 +85,8 @@
  * @param value value
  */
-void Preferences::setString(const char* section, const char* name, const char* value)
-{
-  setMultiType(section, name, MultiType(value));
+void Preferences::setString(const char* section, const char* name, const char* value, bool dontSetModified)
+{
+  MultiType t(value);
+  setMultiType(section, name, t, dontSetModified);
 }
 
@@ -89,7 +97,8 @@
  * @param value value
  */
-void Preferences::setInt(const char* section, const char* name, int value)
-{
-  setMultiType(section, name, MultiType(value));
+void Preferences::setInt(const char* section, const char* name, int value, bool dontSetModified)
+{
+  MultiType t(value);
+  setMultiType(section, name, t, dontSetModified);
 }
 
@@ -100,7 +109,8 @@
  * @param value value
  */
-void Preferences::setFloat(const char* section, const char* name, float value)
-{
-  setMultiType(section, name, MultiType(value));
+void Preferences::setFloat(const char* section, const char* name, float value, bool dontSetModified)
+{
+  MultiType t(value);
+  setMultiType(section, name, t, dontSetModified);
 }
 
@@ -147,5 +157,5 @@
  * @param value value
  */
-void Preferences::setMultiType(const char* section, const char* name, const MultiType& value)
+void Preferences::setMultiType(const char* section, const char* name, MultiType& value, bool dontSetModified)
 {
   std::list<prefSection>::iterator it = data.begin();
@@ -161,5 +171,9 @@
         if ( strcmp(it2->name, name) == 0 )
         {
+          if (!dontSetModified)
+            it2->modified = strcmp(value.getString(), it2->value.getString())!=0;
+
           it2->value = value;
+
           return;
         }
@@ -167,4 +181,5 @@
       prefItem item;
       item.value = value;
+      item.modified = !dontSetModified;
       item.name = new char[strlen(name)+1];
       strcpy( item.name, name );
@@ -176,4 +191,5 @@
   prefItem item;
   item.value = value;
+  item.modified = !dontSetModified;
   item.name = new char[strlen(name)+1];
   strcpy( item.name, name );
@@ -218,4 +234,51 @@
 }
 
+void Preferences::setUserIni(const char* fileName)
+{
+  if ( this->fileName != NULL )
+  {
+    delete this->fileName;
+  }
+
+  this->fileName = new char[strlen(fileName)+1];
+  strcpy(this->fileName, fileName);
+}
+
+bool Preferences::save()
+{
+  if ( this->fileName == NULL )
+  {
+    PRINTF(1)("You must call setUserIni before you can call save()\n");
+    return false;
+  }
+  IniParser iniParser(this->fileName);
+
+  if ( !iniParser.isOpen() )
+    return false;
+
+  std::list<prefSection>::iterator it = data.begin();
+  bool didChanges = false;
+  for ( ; it!=data.end(); it++)
+  {
+    std::list<prefItem>::iterator it2 = it->items.begin();
+
+    for ( ; it2!=it->items.end(); it2++)
+    {
+      if ( it2->modified )
+      {
+        iniParser.editVar(it2->name, it2->value.getString(), it->sectionName);
+        didChanges = true;
+      }
+    }
+  }
+
+  if ( didChanges )
+  {
+    iniParser.writeFile( this->fileName );
+  }
+
+  return true;
+}
+
 /**
  * prints out all section with its items and values
@@ -232,8 +295,8 @@
     for ( ; it2!=it->items.end(); it2++)
     {
-      PRINTF(0)("--> %s = '%s'\n", it2->name, it2->value.getString());
-    }
-  }
-}
-
-
+      PRINTF(0)("--> %s = '%s'%s\n", it2->name, it2->value.getString(), ((!it2->modified)?"":" <modified>"));
+    }
+  }
+}
+
+
Index: branches/preferences/src/lib/util/preferences.h
===================================================================
--- branches/preferences/src/lib/util/preferences.h	(revision 6387)
+++ branches/preferences/src/lib/util/preferences.h	(revision 6388)
@@ -9,11 +9,14 @@
 #include "base_object.h"
 #include "multi_type.h"
+#include "lib/parser/ini_parser/ini_parser.h"
 
 // FORWARD DECLARATION
 
+class IniFilePrefsReader;
 
 typedef struct {
   char* name;
   MultiType value;
+  bool modified;
 } prefItem;
 
@@ -35,8 +38,8 @@
    bool exists(const char* section, const char* name);
 
-   void setString(const char* section, const char* name, const char* value);
-   void setInt(const char* section, const char* name, int value);
-   void setFloat(const char* section, const char* name, float value);
-   void setMultiType(const char* section, const char* name, const MultiType& value);
+   void setString(const char* section, const char* name, const char* value, bool dontSetModified = false);
+   void setInt(const char* section, const char* name, int value, bool dontSetModified = false);
+   void setFloat(const char* section, const char* name, float value, bool dontSetModified = false);
+   void setMultiType(const char* section, const char* name, MultiType& value, bool dontSetModified = false);
 
    const char* getString(const char* section, const char* name, const char* defaultValue);
@@ -44,4 +47,8 @@
    float getFloat(const char* section, const char* name, float defaultValue);
    MultiType getMultiType(const char* section, const char* name, const MultiType& defaultValue);
+
+   void setUserIni(const char* fileName);
+
+   bool save();
 
 
@@ -54,4 +61,9 @@
 
    std::list<prefSection> data;
+
+   std::list<IniFilePrefsReader*> iniFilePrefsReaders;
+
+   char* fileName;
+
 };
 
