2
* Copyright (C) 2007 Petri Damsten <damu@iki.fi>
3
* Copyright (C) 2007 Christopher Blauvelt <cblauvelt@gmail.com>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU Library General Public License version 2 as
7
* published by the Free Software Foundation
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details
14
* You should have received a copy of the GNU Library General Public
15
* License along with this program; if not, write to the
16
* Free Software Foundation, Inc.,
17
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24
#include <QTimerEvent>
28
HddTemp::HddTemp(QObject* parent)
40
QStringList HddTemp::sources()
46
void HddTemp::timerEvent(QTimerEvent *event)
48
killTimer(event->timerId());
52
bool HddTemp::updateData()
57
if (m_failCount > 4) {
63
socket.connectToHost("localhost", 7634);
64
if (socket.waitForConnected(500)) {
65
while (data.length() < 1024) {
66
if (!socket.waitForReadyRead(500)) {
67
if (data.length() > 0) {
70
//kDebug() << socket.errorString();
74
data += QString(socket.readAll());
76
socket.disconnectFromHost();
77
//on success retry fail count
81
//kDebug() << socket.errorString();
84
const QStringList list = data.split('|');
87
while (i + 4 < list.size()) {
88
m_data[list[i]].append(list[i + 2]);
89
m_data[list[i]].append(list[i + 3]);
98
QVariant HddTemp::data(const QString source, const DataType type) const
100
return m_data[source][type];
103
#include "hddtemp.moc"