Merge branch 'dev_itkonma'
[qtmeetings] / src / Domain / Configuration / Configuration.cpp
index 0076e23..2a33998 100644 (file)
@@ -155,21 +155,41 @@ void Configuration::saveConnectionSettings( const QDomNode &aXML )
        {
                QDomElement e = node.toElement();
                QString tagName = e.tagName().toLower();
-
                if ( tagName == QString( "serverurl" ) )
                {
                        QDomText t = node.ownerDocument().createTextNode( iConnectionSettings->serverUrl().toString() );
-                       e.replaceChild( t, e.firstChild() );
+                       if ( e.hasChildNodes() )
+                       {
+                               e.replaceChild( t, e.firstChild() );
+                       }
+                       else
+                       {
+                               e.appendChild( e.firstChild() );
+                       }
                }
                else if ( tagName == QString( "username" ) )
                {
                        QDomText t = node.ownerDocument().createTextNode( iConnectionSettings->username() );
-                       e.replaceChild( t, e.firstChild() );
+                       if ( e.hasChildNodes() )
+                       {
+                               e.replaceChild( t, e.firstChild() );
+                       }
+                       else
+                       {
+                               e.appendChild( e.firstChild() );
+                       }
                }
                else if ( tagName == QString( "password" ) )
                {
                        QDomText t = node.ownerDocument().createTextNode( iConnectionSettings->password() );
-                       e.replaceChild( t, e.firstChild() );
+                       if ( e.hasChildNodes() )
+                       {
+                               e.replaceChild( t, e.firstChild() );
+                       }
+                       else
+                       {
+                               e.appendChild( e.firstChild() );
+                       }
                }
                else if ( tagName == QString( "refreshinterval" ) )
                {
@@ -190,7 +210,7 @@ void Configuration::saveRooms( const QDomNode &aXML )
        int count = root.childNodes().count();
        QDomNode node = root.firstChild();
        QDomNode next;
-       for (int i=0; i<count; i++)
+       for (int i = 0; i < count; i++)
        {
                qDebug() << "remove " << node.toElement().text();
                next = node.nextSibling();
@@ -198,6 +218,7 @@ void Configuration::saveRooms( const QDomNode &aXML )
                node = next;
        }
 
+       node = aXML;
        QList<Room*>::iterator i;
        for ( i = iRooms.begin(); i != iRooms.end(); ++i )
        {
@@ -619,7 +640,7 @@ DateTimeSettings * Configuration::readDateTimeSettings( const QDomNode &aXML )
                        
                        bool success = false;
                        unsigned int weekDayTmp = e.text().toUInt( &success );
-                       if( success && weekDayTmp >= 0 && weekDayTmp < 7)
+                       if( success && weekDayTmp < 7 )
                        {
                                dayOfWeek = (DateTimeSettings::weekDay)weekDayTmp;
                        }