#include <QDebug>

#include <libkydiagnostics.h>

#include "common.h"
#include "information_collector.h"

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

}

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

}
void InformationCollector::addPoint(P point) const
{
    QString str;
    switch (point)
    {
    case InformationCollector::P::ManuallyInstallPrinter : str = "ManuallyInstallPrinter"; break;
    case InformationCollector::P::SetResolution          : str = "SetResolution";          break;
    case InformationCollector::P::SetPaperSize           : str = "SetPaperSize";           break;
    case InformationCollector::P::SetPaperType           : str = "SetPaperType";           break;
    case InformationCollector::P::SetCationSource        : str = "SetCationSource";        break;
    case InformationCollector::P::SetDuplexPrint         : str = "SetDuplexPrint";         break;
    case InformationCollector::P::SetInkType             : str = "SetInkType";             break;
    case InformationCollector::P::ADDRemovePrinter       : str = "ADDRemovePrinter";       break;
    case InformationCollector::P::SetShareStartup        : str = "SetShareStartup";        break;
    case InformationCollector::P::PrintTestPage          : str = "PrintTestPage";          break;
    case InformationCollector::P::CancelPrintJob         : str = "CancelPrintJob";         break;
    case InformationCollector::P::DeletePrintJob         : str = "DeletePrintJob";         break;
    case InformationCollector::P::RePrint                : str = "RePrint";                break;
    case InformationCollector::P::ManualyModifyDrive     : str = "ManualyModifyDrive";     break;
    case InformationCollector::P::Rename                 : str = "Rename";                 break;
    default:
        return;
    }
    sendMessage("point", str);
}

void InformationCollector::addMessage(const QString &str) const
{
    if (str.isEmpty()) {
        return ;
    }
    sendMessage("message", str);
}

void InformationCollector::sendMessage(const QString &key, const QString &value) const
{
    KBuriedPoint p[1];
    p[0].key = QTC(key);
    p[0].value = QTC(value);
    if (kdk_buried_point(const_cast<char *>("kylin-printer"), const_cast<char *>("FunctionType"), p, 1)) {
        qWarning() << "InformationCollector::sendMessage : kdk_buried_point failed!";
    }
}
