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
|
/**
* Copyright (C) 2014, Pelagicore
*
* Author: Jonatan PÄlsson <jonatan.palsson@pelagicore.com>
*
* This file is part of the GENIVI project Browser Proof-Of-Concept
* For further information, see http://genivi.org/
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef ERRORLOGGER_H
#define ERRORLOGGER_H
#include <QObject>
#include <QDBusContext>
#include <QDateTime>
#include "../common/browserdefs.h"
class errorlogger : public QObject, protected QDBusContext
{
Q_OBJECT
public:
static errorlogger *instance()
{
if (!m_instance)
m_instance = new errorlogger();
return m_instance;
}
static void logError (qlonglong dateTime,
QString browserVersion,
QString connectionType,
QString code,
QString source,
QString desc)
{
conn::brw::ErrorItem err;
err.i64DateTime = dateTime;
err.strBrowserVersion = browserVersion;
err.strConnectionType = connectionType;
err.strCode = code;
err.strSource = source;
err.strDescription = desc;
errorlogger::logError(err);
}
static void logError(QString error)
{
errorlogger::logError(
QDateTime::currentMSecsSinceEpoch(),
"Unknown",
"Unknown",
"Unknown",
"Unknown",
error);
}
static void logError(conn::brw::ErrorItem item)
{
instance()->m_logError(item);
}
void clearErrors()
{
m_errors->clear();
emit onErrorListChanged();
}
signals:
void onErrorListChanged();
void onNewErrorItem (const conn::brw::ErrorItem);
public Q_SLOTS:
uint getItemsCount (qlonglong, qlonglong);
conn::brw::ERROR_IDS getItems (qlonglong timeFrom,
qlonglong timeTo,
conn::brw::ERROR_SORT_TYPE sortType,
uint startIndex,
uint itemsCount,
conn::brw::ErrorItemList &items);
private:
errorlogger(){
m_errors = new conn::brw::ErrorItemList();
}
static errorlogger *m_instance;
void m_logError(conn::brw::ErrorItem);
conn::brw::ErrorItemList *m_errors;
};
#endif // ERRORLOGGER_H
|