You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
264 lines
7.9 KiB
264 lines
7.9 KiB
15 years ago
|
/***************************************************************************
|
||
|
errorlog.cpp - description
|
||
|
-------------------
|
||
|
begin : Sa Sep 13 2003
|
||
|
copyright : (C) 2003 by Martin Witte
|
||
|
email : witte@kawo1.rwth-aachen.de
|
||
|
***************************************************************************/
|
||
|
|
||
|
/***************************************************************************
|
||
|
* *
|
||
|
* 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. *
|
||
|
* *
|
||
|
***************************************************************************/
|
||
|
|
||
|
#include "errorlog.h"
|
||
|
|
||
14 years ago
|
#include <tqframe.h>
|
||
|
#include <tqdatetime.h>
|
||
13 years ago
|
#include <tqlayout.h>
|
||
15 years ago
|
|
||
12 years ago
|
#include <tdelocale.h>
|
||
15 years ago
|
#include <kiconloader.h>
|
||
13 years ago
|
#include <tqtextedit.h>
|
||
12 years ago
|
#include <tdefiledialog.h>
|
||
15 years ago
|
#include <kurl.h>
|
||
12 years ago
|
#include <tdetempfile.h>
|
||
12 years ago
|
#include <tdeio/netaccess.h>
|
||
15 years ago
|
|
||
|
#define PAGE_ID_INFO 0
|
||
|
#define PAGE_ID_WARN 1
|
||
|
#define PAGE_ID_ERROR 2
|
||
|
#define PAGE_ID_DEBUG 3
|
||
|
|
||
|
///////////////////////////////////////////////////////////////////////
|
||
|
|
||
12 years ago
|
PLUGIN_LIBRARY_FUNCTIONS(ErrorLog, "tderadio-gui-error-log", i18n("Error Logging Window for TDERadio"));
|
||
15 years ago
|
|
||
|
/////////////////////////////////////////////////////////////////////////////
|
||
|
|
||
14 years ago
|
ErrorLog::ErrorLog(const TQString &name)
|
||
15 years ago
|
: KDialogBase(KDialogBase::IconList,
|
||
|
"",
|
||
|
KDialogBase::Close|KDialogBase::User1,
|
||
|
KDialogBase::Close,
|
||
|
NULL,
|
||
|
name.ascii(),
|
||
|
false,
|
||
|
false,
|
||
10 years ago
|
KGuiItem(i18n("Save &as"), "document-save-as")
|
||
15 years ago
|
),
|
||
|
WidgetPluginBase(name, i18n("Error Logger")),
|
||
|
init_done(false)
|
||
|
{
|
||
12 years ago
|
TQWidget::setCaption(i18n("TDERadio Logger"));
|
||
14 years ago
|
TQFrame *info = addPage(i18n("Information"), i18n("Information"),
|
||
12 years ago
|
TDEGlobal::instance()->iconLoader()->loadIcon(
|
||
12 years ago
|
"messagebox_info", TDEIcon::NoGroup, TDEIcon::SizeMedium
|
||
15 years ago
|
)
|
||
|
);
|
||
|
|
||
14 years ago
|
TQGridLayout *linfo = new TQGridLayout(info);
|
||
15 years ago
|
linfo->setSpacing( 5 );
|
||
|
linfo->setMargin ( 0 );
|
||
14 years ago
|
m_teInfos = new TQTextEdit(info);
|
||
15 years ago
|
linfo->addWidget(m_teInfos, 0, 0);
|
||
|
m_teInfos->setReadOnly(true);
|
||
|
logInfo(i18n("logging started"));
|
||
|
|
||
|
|
||
14 years ago
|
TQFrame *warn = addPage(i18n("Warnings"), i18n("Warnings"),
|
||
12 years ago
|
TDEGlobal::instance()->iconLoader()->loadIcon(
|
||
12 years ago
|
"messagebox_warning", TDEIcon::NoGroup, TDEIcon::SizeMedium
|
||
15 years ago
|
)
|
||
|
);
|
||
14 years ago
|
TQGridLayout *lwarn = new TQGridLayout(warn);
|
||
15 years ago
|
lwarn->setSpacing( 5 );
|
||
|
lwarn->setMargin ( 0 );
|
||
14 years ago
|
m_teWarnings = new TQTextEdit(warn);
|
||
15 years ago
|
lwarn->addWidget(m_teWarnings, 0, 0);
|
||
|
m_teWarnings->setReadOnly(true);
|
||
|
logWarning(i18n("logging started"));
|
||
|
|
||
|
|
||
|
|
||
14 years ago
|
TQFrame *err = addPage(i18n("Errors"), i18n("Errors"),
|
||
12 years ago
|
TDEGlobal::instance()->iconLoader()->loadIcon(
|
||
12 years ago
|
"messagebox_critical", TDEIcon::NoGroup, TDEIcon::SizeMedium
|
||
15 years ago
|
)
|
||
|
);
|
||
14 years ago
|
TQGridLayout *lerr = new TQGridLayout(err);
|
||
15 years ago
|
lerr->setSpacing( 5 );
|
||
|
lerr->setMargin ( 0 );
|
||
14 years ago
|
m_teErrors = new TQTextEdit(err);
|
||
15 years ago
|
lerr->addWidget(m_teErrors, 0, 0);
|
||
|
m_teErrors->setReadOnly(true);
|
||
|
logError(i18n("logging started"));
|
||
|
|
||
14 years ago
|
TQFrame *debug = addPage(i18n("Debugging"), i18n("Debugging"),
|
||
12 years ago
|
TDEGlobal::instance()->iconLoader()->loadIcon(
|
||
10 years ago
|
"edit-find", TDEIcon::NoGroup, TDEIcon::SizeMedium
|
||
15 years ago
|
)
|
||
|
);
|
||
|
|
||
14 years ago
|
TQGridLayout *ldebug = new TQGridLayout(debug);
|
||
15 years ago
|
ldebug->setSpacing( 5 );
|
||
|
ldebug->setMargin ( 0 );
|
||
14 years ago
|
m_teDebug = new TQTextEdit(debug);
|
||
15 years ago
|
ldebug->addWidget(m_teDebug, 0, 0);
|
||
|
m_teDebug->setReadOnly(true);
|
||
|
logDebug(i18n("logging started"));
|
||
|
|
||
|
init_done = true;
|
||
|
}
|
||
|
|
||
|
|
||
|
ErrorLog::~ErrorLog()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
bool ErrorLog::connectI (Interface *i)
|
||
|
{
|
||
|
bool a = IErrorLog::connectI(i);
|
||
|
bool b = PluginBase::connectI(i);
|
||
|
return a || b;
|
||
|
}
|
||
|
|
||
|
bool ErrorLog::disconnectI (Interface *i)
|
||
|
{
|
||
|
bool a = IErrorLog::disconnectI(i);
|
||
|
bool b = PluginBase::disconnectI(i);
|
||
|
return a || b;
|
||
|
}
|
||
|
|
||
12 years ago
|
void ErrorLog::restoreState (TDEConfig *config)
|
||
15 years ago
|
{
|
||
14 years ago
|
config->setGroup(TQString("errorlog-") + WidgetPluginBase::name());
|
||
15 years ago
|
WidgetPluginBase::restoreState(config, false);
|
||
|
}
|
||
|
|
||
|
|
||
12 years ago
|
void ErrorLog::saveState (TDEConfig *config) const
|
||
15 years ago
|
{
|
||
14 years ago
|
config->setGroup(TQString("errorlog-") + WidgetPluginBase::name());
|
||
15 years ago
|
WidgetPluginBase::saveState(config);
|
||
|
}
|
||
|
|
||
|
|
||
|
void ErrorLog::show()
|
||
|
{
|
||
|
WidgetPluginBase::pShow();
|
||
|
KDialogBase::show();
|
||
|
}
|
||
|
|
||
|
void ErrorLog::showOnOrgDesktop()
|
||
|
{
|
||
|
WidgetPluginBase::pShowOnOrgDesktop();
|
||
|
//KDialogBase::show();
|
||
|
}
|
||
|
|
||
|
void ErrorLog::hide()
|
||
|
{
|
||
13 years ago
|
logDebug(TQString("%1, ErrorLog::hide: all: %2, desktop: %3, visible:%4, anywherevisible:%5, cachevalid: %6").arg(name()).arg(m_saveSticky).arg(m_saveDesktop).arg(isReallyVisible()).arg(isAnywhereVisible()).arg(m_geoCacheValid));
|
||
15 years ago
|
WidgetPluginBase::pHide();
|
||
|
KDialogBase::hide();
|
||
|
}
|
||
|
|
||
14 years ago
|
void ErrorLog::showEvent(TQShowEvent *e)
|
||
15 years ago
|
{
|
||
|
KDialogBase::showEvent(e);
|
||
|
WidgetPluginBase::pShowEvent(e);
|
||
|
}
|
||
|
|
||
14 years ago
|
void ErrorLog::hideEvent(TQHideEvent *e)
|
||
15 years ago
|
{
|
||
|
KDialogBase::hideEvent(e);
|
||
|
WidgetPluginBase::pHideEvent(e);
|
||
|
}
|
||
|
|
||
|
// IErrorLog
|
||
|
|
||
14 years ago
|
bool ErrorLog::logError (const TQString &s)
|
||
15 years ago
|
{
|
||
13 years ago
|
m_teErrors->append("<i>" + TQDateTime::currentDateTime().toString(Qt::ISODate) + "</i> " + s + "\n");
|
||
15 years ago
|
if (init_done) {
|
||
|
showPage(PAGE_ID_ERROR);
|
||
|
show();
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
14 years ago
|
bool ErrorLog::logWarning(const TQString &s)
|
||
15 years ago
|
{
|
||
13 years ago
|
m_teWarnings->append("<i>" + TQDateTime::currentDateTime().toString(Qt::ISODate) + "</i> " + s + "\n");
|
||
15 years ago
|
return true;
|
||
|
}
|
||
|
|
||
14 years ago
|
bool ErrorLog::logInfo (const TQString &s)
|
||
15 years ago
|
{
|
||
13 years ago
|
m_teInfos->append("<i>" + TQDateTime::currentDateTime().toString(Qt::ISODate) + "</i> " + s + "\n");
|
||
15 years ago
|
return true;
|
||
|
}
|
||
|
|
||
14 years ago
|
bool ErrorLog::logDebug (const TQString &s)
|
||
15 years ago
|
{
|
||
13 years ago
|
m_teDebug->append("<i>" + TQDateTime::currentDateTime().toString(Qt::ISODate) + "</i> " + s + "\n");
|
||
15 years ago
|
return true;
|
||
|
}
|
||
|
|
||
|
// KDialogBase
|
||
|
|
||
|
|
||
|
// store Log Data
|
||
|
void ErrorLog::slotUser1()
|
||
|
{
|
||
|
KFileDialog fd("",
|
||
|
("*.log|" + i18n("Log Files") + "( *.log )").ascii(),
|
||
|
this,
|
||
|
i18n("Select Log File").ascii(),
|
||
|
true);
|
||
|
fd.setMode(KFile::File);
|
||
|
fd.setOperationMode(KFileDialog::Saving);
|
||
12 years ago
|
fd.setCaption (i18n("Save TDERadio Logging Data as ..."));
|
||
15 years ago
|
|
||
14 years ago
|
if (fd.exec() == TQDialog::Accepted) {
|
||
15 years ago
|
KURL url = fd.selectedURL();
|
||
|
|
||
|
KTempFile tmpFile;
|
||
|
tmpFile.setAutoDelete(true);
|
||
14 years ago
|
TQFile *outf = tmpFile.file();
|
||
15 years ago
|
|
||
14 years ago
|
TQTextStream outs(outf);
|
||
|
outs.setEncoding(TQTextStream::UnicodeUTF8);
|
||
15 years ago
|
|
||
|
switch (activePageIndex()) {
|
||
|
case PAGE_ID_INFO: outs << m_teInfos->text(); break;
|
||
|
case PAGE_ID_WARN: outs << m_teWarnings->text(); break;
|
||
|
case PAGE_ID_ERROR: outs << m_teErrors->text(); break;
|
||
|
case PAGE_ID_DEBUG: outs << m_teDebug->text(); break;
|
||
|
default: break;
|
||
|
}
|
||
|
|
||
|
if (outf->status() != IO_Ok) {
|
||
|
logError("ErrorLogger: " +
|
||
13 years ago
|
i18n("error writing to tempfile %1").arg(tmpFile.name()));
|
||
15 years ago
|
return;
|
||
|
}
|
||
|
|
||
|
// close hopefully flushes buffers ;)
|
||
|
outf->close();
|
||
|
|
||
12 years ago
|
if (!TDEIO::NetAccess::upload(tmpFile.name(), url, this)) {
|
||
15 years ago
|
logError("ErrorLogger: " +
|
||
13 years ago
|
i18n("error uploading preset file %1").arg(url.url()));
|
||
15 years ago
|
}
|
||
|
}
|
||
|
setIconListAllVisible(true);
|
||
|
}
|
||
|
|
||
|
|
||
|
#include "errorlog.moc"
|