#include <QJsonObject>
#include <QDebug>

#include <kysdk/applications/kabase/buried_point.hpp>

#include "information_collector.h"

kdk::kabase::BuriedPoint::PT enumConvert(const InformationCollector::P &point);

InformationCollector::InformationCollector(/* args */)
{
    m_bp = new kdk::kabase::BuriedPoint();
    if (m_bp->functionBuriedPoint(kdk::kabase::KylinPrinter, kdk::kabase::BuriedPoint::TestFunPoint) != 0) {
        qDebug() << "打点测试失败！";
    }
}

InformationCollector::~InformationCollector(/* args */)
{

}

void InformationCollector::addPoint(P point) const
{
    m_bp->functionBuriedPoint(kdk::kabase::KylinPrinter, enumConvert(point));
}

void InformationCollector::addMessage(const QString &str) const
{
    QJsonObject obj;
    obj.insert(QString("kylin-printer"), str);
    m_bp->uploadMessage(kdk::kabase::KylinPrinter, kdk::kabase::BuriedPoint::BuriedPointType::FunctionType, obj);
}

kdk::kabase::BuriedPoint::PT enumConvert(const InformationCollector::P &point)
{
    switch (point)
    {
    case InformationCollector::P::ManuallyInstallPrinter: 
        return kdk::kabase::BuriedPoint::PT::KylinPrinterManuallyInstallPrinter; 
    case InformationCollector::P::SetResolution:
        return kdk::kabase::BuriedPoint::PT::KylinPrinterSetResolution; 
    case InformationCollector::P::SetPaperSize:
        return kdk::kabase::BuriedPoint::PT::KylinPrinterSetPaperSize; 
    case InformationCollector::P::SetPaperType:
        return kdk::kabase::BuriedPoint::PT::KylinPrinterSetPaperType; 
    case InformationCollector::P::SetCationSource:
        return kdk::kabase::BuriedPoint::PT::KylinPrinterSetCationSource; 
    case InformationCollector::P::SetDuplexPrint:
        return kdk::kabase::BuriedPoint::PT::KylinPrinterSetDuplexPrint; 
    case InformationCollector::P::SetInkType:
        return kdk::kabase::BuriedPoint::PT::KylinPrinterSetInkType; 
    case InformationCollector::P::ADDRemovePrinter:
        return kdk::kabase::BuriedPoint::PT::KylinPrinterADDRemovePrinter; 
    case InformationCollector::P::SetShareStartup:
        return kdk::kabase::BuriedPoint::PT::KylinPrinterSetShareStartup; 
    case InformationCollector::P::PrintTestPage:
        return kdk::kabase::BuriedPoint::PT::KylinPrintTestPage; 
    case InformationCollector::P::CancelPrintJob:
        return kdk::kabase::BuriedPoint::PT::KylinPrinterCancelPrintJob; 
    case InformationCollector::P::DeletePrintJob:
        return kdk::kabase::BuriedPoint::PT::KylinPrinterDeletePrintJob; 
    case InformationCollector::P::RePrint:
        return kdk::kabase::BuriedPoint::PT::KylinPrinterRePrint; 
    case InformationCollector::P::ManualyModifyDrive:
        return kdk::kabase::BuriedPoint::PT::KylinPrinterManualyModifyDrive; 
    case InformationCollector::P::Rename:
        return kdk::kabase::BuriedPoint::PT::KylinPrinterRename; 
    default:
        return kdk::kabase::BuriedPoint::PT::TestFunPoint;
        break;
    }
    return kdk::kabase::BuriedPoint::TestFunPoint;
}