| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
#ifndef LOGVIEWERADAPTOR_H |
| 6 |
#define LOGVIEWERADAPTOR_H |
| 7 |
|
| 8 |
#include <QtCore/QObject> |
| 9 |
#include <QtDBus/QtDBus> |
| 10 |
QT_BEGIN_NAMESPACE |
| 11 |
class QByteArray; |
| 12 |
template<class T> class QList; |
| 13 |
template<class Key, class Value> class QMap; |
| 14 |
class QString; |
| 15 |
class QStringList; |
| 16 |
class QVariant; |
| 17 |
QT_END_NAMESPACE |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
class LogViewerAdaptor: public QDBusAbstractAdaptor |
| 23 |
{ |
| 24 |
Q_OBJECT |
| 25 |
Q_CLASSINFO("D-Bus Interface", "com.deepin.logviewer") |
| 26 |
Q_CLASSINFO("D-Bus Introspection", "" |
| 27 |
" <interface name=\"com.deepin.logviewer\">\n" |
| 28 |
" <method name=\"readLog\">\n" |
| 29 |
" <arg direction=\"out\" type=\"s\"/>\n" |
| 30 |
" <arg direction=\"in\" type=\"i\" name=\"fd\"/>\n" |
| 31 |
" </method>\n" |
| 32 |
" <method name=\"readLogLinesInRange\">\n" |
| 33 |
" <arg direction=\"out\" type=\"as\"/>\n" |
| 34 |
" <arg direction=\"in\" type=\"i\" name=\"fd\"/>\n" |
| 35 |
" <arg direction=\"in\" type=\"x\" name=\"startLine\"/>\n" |
| 36 |
" <arg direction=\"in\" type=\"x\" name=\"lineCount\"/>\n" |
| 37 |
" </method>\n" |
| 38 |
" <method name=\"exitCode\">\n" |
| 39 |
" <arg direction=\"out\" type=\"i\"/>\n" |
| 40 |
" </method>\n" |
| 41 |
" <method name=\"quit\"/>\n" |
| 42 |
" <method name=\"exportLog\">\n" |
| 43 |
" <arg direction=\"out\" type=\"b\"/>\n" |
| 44 |
" <arg direction=\"in\" type=\"s\" name=\"outDir\"/>\n" |
| 45 |
" <arg direction=\"in\" type=\"s\" name=\"in\"/>\n" |
| 46 |
" <arg direction=\"in\" type=\"b\" name=\"isFile\"/>\n" |
| 47 |
" </method>\n" |
| 48 |
" <method name=\"getFileInfo\">\n" |
| 49 |
" <arg direction=\"out\" type=\"as\"/>\n" |
| 50 |
" <arg direction=\"in\" type=\"s\" name=\"file\"/>\n" |
| 51 |
" <arg direction=\"in\" type=\"b\" name=\"unzip\"/>\n" |
| 52 |
" </method>\n" |
| 53 |
" <method name=\"openLogStream\">\n" |
| 54 |
" <arg direction=\"out\" type=\"s\"/>\n" |
| 55 |
" <arg direction=\"in\" type=\"s\" name=\"filePath\"/>\n" |
| 56 |
" </method>\n" |
| 57 |
" <method name=\"readLogInStream\">\n" |
| 58 |
" <arg direction=\"out\" type=\"s\"/>\n" |
| 59 |
" <arg direction=\"in\" type=\"s\" name=\"token\"/>\n" |
| 60 |
" </method>\n" |
| 61 |
" <method name=\"isFileExist\">\n" |
| 62 |
" <arg direction=\"out\" type=\"s\"/>\n" |
| 63 |
" <arg direction=\"in\" type=\"s\" name=\"filePath\"/>\n" |
| 64 |
" </method>\n" |
| 65 |
" <method name=\"getFileSize\">\n" |
| 66 |
" <arg direction=\"out\" type=\"t\"/>\n" |
| 67 |
" <arg direction=\"in\" type=\"s\" name=\"filePath\"/>\n" |
| 68 |
" </method>\n" |
| 69 |
" <method name=\"getLineCount\">\n" |
| 70 |
" <arg direction=\"out\" type=\"x\"/>\n" |
| 71 |
" <arg direction=\"in\" type=\"s\" name=\"filePath\"/>\n" |
| 72 |
" </method>\n" |
| 73 |
" <method name=\"executeCmd\">\n" |
| 74 |
" <arg direction=\"out\" type=\"s\"/>\n" |
| 75 |
" <arg direction=\"in\" type=\"s\" name=\"cmd\"/>\n" |
| 76 |
" </method>\n" |
| 77 |
" <method name=\"whiteListOutPaths\">\n" |
| 78 |
" <arg direction=\"out\" type=\"as\"/>\n" |
| 79 |
" </method>\n" |
| 80 |
" </interface>\n" |
| 81 |
"") |
| 82 |
public: |
| 83 |
LogViewerAdaptor(QObject *parent); |
| 84 |
virtual ~LogViewerAdaptor(); |
| 85 |
|
| 86 |
public: |
| 87 |
public Q_SLOTS: |
| 88 |
QString executeCmd(const QString &cmd); |
| 89 |
int exitCode(); |
| 90 |
bool exportLog(const QString &outDir, const QString &in, bool isFile); |
| 91 |
QStringList getFileInfo(const QString &file, bool unzip); |
| 92 |
qulonglong getFileSize(const QString &filePath); |
| 93 |
qlonglong getLineCount(const QString &filePath); |
| 94 |
QString isFileExist(const QString &filePath); |
| 95 |
QString openLogStream(const QString &filePath); |
| 96 |
void quit(); |
| 97 |
QString readLog(int fd); |
| 98 |
QString readLogInStream(const QString &token); |
| 99 |
QStringList readLogLinesInRange(int fd, qlonglong startLine, qlonglong lineCount); |
| 100 |
QStringList whiteListOutPaths(); |
| 101 |
Q_SIGNALS: |
| 102 |
}; |
| 103 |
|
| 104 |
#endif |