/***************************************************************************
 *   Copyright (C) 2007 by Arnold Kraschinski                              *
 *   arnold.kra67@gmx.de                                                   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.          *
 ***************************************************************************/

#ifndef KVERBOSUSER_H_
#define KVERBOSUSER_H_


#include <QDomDocument>
#include <QStringList>
#include <QDomNodeList>

/**
 * The class to read, store and save the information about
 * the user.
 *
 * The information contains:
 *  - name
 *  - statistic data about the learning process
 *  - a list of the selected verbs
 *  - information about the selected verbs, are they
 *    already well known by the user, ...
 *  - a list of kvtml files to find verb translations
 *
 * @short KVerbos user information
 * @author Kraschinski Arnold <arnold.kra67@gmx.de>
 * @version 2.00.00
 */
class KverbosUser
{
public:
    KverbosUser();
    ~KverbosUser();
    /** Returns a list of all group names in the userdata.
    */
    static QStringList groupNames();

    /** Returns a list of all user names in a specified group.
    */
    static QStringList userNames(QString group);

    /** Looks for the information about the user (group/username) and
    *   set it as the active user. The QDomNode within the userdata 
    *   with the user information is stored in m_activeUser.
    *   If the combination group/username couldn't be found the
    *   m_activeUser member will be a null node.
    */
    static bool setUser(QString group, QString username);

    /** Tests if an active user is set.
    */
    static bool userIsSet();
private:
    /** Read the user data from a userdata.xml file.
    *  If the userdata can't be read the function createUserData
    *  will be called to get a basic user information.
    */
    static void readUserData();

    /** Save the user data to a userdata.xml file
    */
    static void saveUserData();

    /** Creates a basic DOM-Document for the user data if the
    *  userdata.xml file couldn't be found.
    */
    static void createUserData();

    /** Returns a list of all QDomNodes with groupnames.
     */
    static QDomNodeList groupnameNodes();

    /** Returns a list of all QDomNodes with usernames.
     */
    static QDomNodeList usernameNodes();

    /** Stores the user and learning group information.
    */
    static QDomDocument            m_userDom;

    /** The information about the actual learning usre.
    */
    static QDomNode                m_activeUser;
};



#endif    // KVERBOSUSER_H_
