unauthorizedAccept option
[dyskinesia.git] / src / k8history / k8history.h
blob29fd499574eb8c4937ef34057e2727f42bc2d5a8
1 /* coded by Ketmar // Vampire Avalon (psyc://ketmar.no-ip.org/~Ketmar)
2 * Understanding is not required. Only obedience.
4 * This program is free software. It comes without any warranty, to
5 * the extent permitted by applicable law. You can redistribute it
6 * and/or modify it under the terms of the Do What The Fuck You Want
7 * To Public License, Version 2, as published by Sam Hocevar. See
8 * http://sam.zoy.org/wtfpl/COPYING for more details.
9 */
10 #ifndef K8HISTORY_H
11 #define K8HISTORY_H
13 #ifndef HISTORY_OK
14 # error Please, select history module
15 #endif
17 #include <QDateTime>
18 #include <QFile>
19 #include <QString>
22 ///////////////////////////////////////////////////////////////////////////////
23 class HistoryMessage {
24 public:
25 enum Type {
26 Incoming=0,
27 Outgoing,
28 Server, // message from server
29 Info
32 public:
33 HistoryMessage () { clear(); }
34 ~HistoryMessage () { clear(); }
36 virtual void clear () {
37 valid = false;
38 uni = QString();
39 date = QDateTime();
40 type = Info;
41 text = QString();
42 action = QString();
43 date.setTimeSpec(Qt::LocalTime);
46 public:
47 bool valid;
48 QString uni;
49 QDateTime date; // must be localtime!
50 Type type;
51 QString text;
52 QString action;
56 ///////////////////////////////////////////////////////////////////////////////
57 class HistoryFileBase {
58 public:
59 enum OpenMode {
60 Read,
61 Write
64 public:
65 virtual ~HistoryFileBase ();
67 virtual bool open (OpenMode newmode)=0;
68 virtual bool isOpen () const=0;
69 virtual void close ()=0;
70 virtual void remove ()=0;
72 virtual int count ()=0;
74 virtual bool append (const HistoryMessage &msg)=0;
76 /* idx: 0..count-1; idx<0: idx += count; */
77 virtual bool read (int idx, HistoryMessage &msg)=0;
81 #ifdef JSON_HISTORY
82 # include "k8jshistory.h"
83 #endif
85 #ifdef LDB_HISTORY
86 # include "k8ldbhistory.h"
87 #endif
89 #ifdef BHF_HISTORY
90 # include "k8bhfhistory.h"
91 #endif
94 #endif