aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/logview/LogFile.h
blob: 53281af8a636fcba4bf1a7efa7c70cd1c30b7d0c (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#ifndef _LOGFILE_H_
#define _LOGFILE_H_
//=============================================================================
//
//   File : LogFile.h
//   Creation date : Thu Apr 14 2011 19:16:59 by Elvio Basello
//
//   This file is part of the KVIrc IRC client distribution
//   Copyright (C) 2011 Elvio Basello (hellvis69 at gmail dot com)
//
//   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.
//
//=============================================================================

/**
* \file LogFile.h
* \author Elvio Basello
* \brief Describes a log file
*
* This file was originally part of LogViewWindow.h
*/

#include <QDate>

class QString;

/**
* \typedef LogFileData
* \struct _LogFileData
* \brief A struct that contains the data of a log
*/
typedef struct _LogFileData
{
	QString szName; /**< the name of the log */
	QString szType; /**< the type of the log */
	QString szFile; /**< the name of the exported log */
} LogFileData;

/**
* \class LogFile
* \brief The LogFile class which handle any log file
*
* Log is in the format:
* $type_$nick.$network_$YYYY.$MM.$DD.log
* Examples:
* query_noldor.azzurra_2009.05.20.log
* channel_#slackware.azzurra_2009.11.03.log
*/
class LogFile
{
public:
	/**
	* \enum Type
	* \brief Holds the type of the log file
	*/
	enum Type
	{
		Channel = 0, /**< the log file of a channel */
		Console = 1, /**< the log file of a console */
		Query = 2,   /**< the log file of a query */
		DccChat = 3, /**< the log file of a dcc chat */
		Other = 4    /**< any other log file */
	};

	/**
	* \enum ExportType
	* \brief Holds the type of the exported log file
	*/
	enum ExportType
	{
		PlainText, /**< export log in plain text file */
		HTML       /**< export log in a HTML archive */
		           //XML        /**< export log in a XML file */
		           //DB         /**< export log in a database file */
	};

	/**
	* \brief Constructs the log file object
	* \param szName The name of the log
	* \return LogFile
	*/
	LogFile(const QString & szName);

private:
	Type m_eType;
	QString m_szType;
	QString m_szFilename;
	bool m_bCompressed;
	QString m_szName;
	QString m_szNetwork;
	QDate m_date;

public:
	/**
	* \brief Returns the type of the log
	* \return Type
	*/
	Type type() const { return m_eType; };

	/**
	* \brief Returns the type of the log
	* \return const QString &
	*/
	const QString & typeString() const { return m_szType; };

	/**
	* \brief Returns the filename of the log
	* \return const QString &
	*/
	const QString & fileName() const { return m_szFilename; };

	/**
	* \brief Returns the name of the log
	* \return const QString &
	*/
	const QString & name() const { return m_szName; };

	/**
	* \brief Returns the network of the log
	* \return const QString &
	*/
	const QString & network() const { return m_szNetwork; };

	/**
	* \brief Returns the date of the log
	* \return const QDate &
	*/
	const QDate & date() const { return m_date; };

	/**
	* \brief Returns the text of the log file
	* \param szText The buffer where to save the contents of the log
	* \return void
	*/
	void getText(QString & szText);
};

#endif // _LOGFILE_H_