File indexing completed on 2023-11-26 04:55:46

0001 /*
0002  * Copyright (C) 2012 Dan Vrátil <dvratil@redhat.com>
0003  *
0004  * This library is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU Lesser General Public
0006  * License as published by the Free Software Foundation; either
0007  * version 2.1 of the License, or (at your option) any later version.
0008  *
0009  * This library is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012  * Lesser General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU Lesser General Public
0015  * License along with this library; if not, write to the Free Software
0016  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
0017  */
0018 
0019 #ifndef KTP_LOGSIMPORTER_PRIVATE_H
0020 #define KTP_LOGSIMPORTER_PRIVATE_H
0021 
0022 #include <QThread>
0023 #include <QStringList>
0024 #include <QDomDocument>
0025 
0026 #include "logs-importer.h"
0027 
0028 namespace KTp {
0029 
0030 class LogsImporter::Private: public QThread
0031 {
0032     Q_OBJECT
0033 
0034   public:
0035     Private(LogsImporter* parent);
0036     ~Private() override;
0037 
0038     void setAccountId(const QString &accountId);
0039     QStringList findKopeteLogs(const QString &accountId) const;
0040 
0041   Q_SIGNALS:
0042     void error(const QString &error);
0043 
0044   protected:
0045     void run() override;
0046 
0047   private:
0048 
0049     QString accountIdToProtocol(const QString &accountId) const;
0050     QString accountIdToAccountName(const QString &accountId) const;
0051 
0052     void initKTpDocument();
0053     void saveKTpDocument();
0054     QDateTime parseKopeteTime(const QDomElement &kopeteMessage) const;
0055     QDomElement convertKopeteMessage(const QDomElement &kopeteMessage);
0056     void convertKopeteLog(const QString &filepath);
0057 
0058     QString m_accountId;
0059     QString m_meId;
0060     QString m_contactId;
0061 
0062     QDomDocument m_ktpDocument;
0063     QDomDocument m_kopeteDocument;
0064     QDomElement m_ktpLogElement;
0065 
0066     int m_day;
0067     int m_month;
0068     int m_year;
0069 
0070     bool m_isMUCLog;
0071 
0072     friend class KTp::LogsImporter;
0073 };
0074 
0075 } /* namespace KTp */
0076 
0077 #endif // KTP_LOGSIMPORTER_PRIVATE_H