/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights.  These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/

#ifndef USERINFO_H
#define USERINFO_H

#define Q_OS_LINUX

#include <QApplication>
#include <QProcess>
#include <QLineEdit>
#include <QStringList>
#include <QPushButton>
#include <QTextCodec>
#include <QByteArray>
#include <QByteArray>
#include <QtSql>
#include <QSqlQueryModel>
#include "utility.h"


//! [0]
class PUserInfo
{
   
public:

   	PUserInfo();
   	~PUserInfo();
   	void SetNameSurname(const QString &t_name,const QString &t_surname);
	void SetFingerprint(QByteArray fpr);
	void SetRFID(QByteArray rfid);
	void SetRights(QChar rights);
	void SetGroup(int group);
	void SetPIN(int pin);
	void SetUserID(int id);
	
	int ObtainUserID();
	bool ObtainUserData();
	//QChar Permissions;
	//int Group;
	QString GetName() const;	
	QString GetSurname() const; 
	int GetID() const; 
	QString GetFprDate() const;
	QString GetRFID() const;
	QChar GetRights() const;
	int GetGroup() const;
 	
	void dbReconnect(void);
	
	QStringList* CheckNoFprUsers(void);
	int UserExist();
	bool UserFprUpdate();
	bool UserDataUpdate();
	QStringList* GetGroupList(void);

	bool DownloadFprToReader();
   	bool UserStore();
	bool UserDelete();
	QSqlQueryModel* GetUserList(PRights * rights, QString filter="%"); 
	
	
private:
enum Action {ActInsert, ActReplace, ActUpdate, ActDataUpdate};
int InsertType;
QString Name;
QByteArray RFID;
int PIN;
QChar Rights;
int Group;
QString FprDate;
QString Surname;
QSqlDatabase* db;
QByteArray Fpr;
QStringList* users;
int ID;

bool RemoveFprFromReader(int fpr_id);

};
//! [0]

#endif
