Пример #1
0
void ItemsManager::Start() {
    thread_ = std::make_unique<QThread>();
    worker_ = std::make_unique<ItemsManagerWorker>(app_, thread_.get());
    connect(thread_.get(), SIGNAL(started()), worker_.get(), SLOT(Init()));
    connect(this, SIGNAL(UpdateSignal()), worker_.get(), SLOT(Update()));
    connect(worker_.get(), SIGNAL(StatusUpdate(ItemsFetchStatus)), this, SLOT(OnStatusUpdate(ItemsFetchStatus)));
    connect(worker_.get(), SIGNAL(ItemsRefreshed(Items, std::vector<std::string>)), this, SLOT(OnItemsRefreshed(Items, std::vector<std::string>)));
    worker_->moveToThread(thread_.get());
    thread_->start();
}
Пример #2
0
void UpdateUI::run()
{
    emit UpdateSignal(pathList_); //update ui in main thread use signal/slots
    for (int i = 0; i < pathList_.size(); ++i)
    {
        QString path = QDir::toNativeSeparators(pathList_.at(i));
        QString fileName = path.split("/").last();
        (*(music->csqlite3))->execDML(QString ("insert into playlist values(\"" + fileName + "\",\"" + path + "\");").toStdString().c_str());
    }
}
Пример #3
0
DlgLoadRegistry::DlgLoadRegistry(SoaWg *_wg, unsigned int _regId) : QDialog(_wg),
	wg(_wg),
	regId(_regId),
	loading(false) {

	ui.setupUi(this);
	setWindowTitle("Load run-time registry");

	ui.mergeButton->setEnabled(false);

	connect(ui.loadButton, SIGNAL(clicked()), this, SLOT(LoadSlot()));
	connect(&loader, SIGNAL(DoneSignal(QString)), this, SLOT(DoneSlot(QString)));
	connect(&loader, SIGNAL(UpdateSignal(QString)), this, SLOT(UpdateSlot(QString)));
	connect(ui.mergeButton, SIGNAL(clicked()), this, SLOT(MergeSlot()));
}
Пример #4
0
void ItemsManager::Update() {
    emit UpdateSignal();
}
Пример #5
0
void Layer7::LoadSlot(QNetworkReply *reply) {

    switch (op) {

    case lsoStart:

        emit UpdateSignal("Loading started...");
        Logger::ins.Header() << "Loading registry data from " << http.Url() << "data/ started...\r\n";
        http.Propfind(http.Url() + "data/");
        op = lsoListDomains;

        break;

    case lsoListDomains:

        if (reply->error() == QNetworkReply::NoError) {

            QString replyString(reply->readAll());
            sl::log << "lsoListDomains: " << SQ(replyString) << sl::end;

            Propfinds elements = http.ParsePropfindReply(replyString);
            for (Propfinds::iterator e = elements.begin(); e != elements.end(); ++e)
                if (e->href != http.Url()) {
                    domains.push_back(GtDomain(SQ(e->href), SQ(e->name)));
                    Logger::ins.Info() << "Service domain: " << e->name << "\r\n";
                    emit UpdateSignal("Service Domain: " + e->name);
                }

            if (SelectFirstDomain()) {

                loaded = true;

                // check if all domains match domains from the db

                for (unsigned int d = 0; d < domains.size(); ++d)
                    if (!sdoms.contains(QS(domains[d].name))) {
                        loaded = false;
                        Logger::ins.Error() << "Repository does not contain service domain named " << QS(domains[d].name) << "\r\n";
                        emit DoneSignal("Repository does not contain service domain named " + QS(domains[d].name));
                    }

                if (loaded) {
                    op = lsoListServices;
                    http.Propfind(QS(SelectedDomain().href) + "web/");
                }
            }
        }
        else
            emit UpdateSignal(reply->errorString());

        break;

    case lsoListServices:

        if (reply->error() == QNetworkReply::NoError) {

            QString replyString(reply->readAll());
            sl::log << "lsoListServices: " << SQ(replyString) << sl::end;

            Propfinds elements = http.ParsePropfindReply(replyString);
            for (Propfinds::iterator e = elements.begin(); e != elements.end(); ++e)
                if (e->href != http.Url() && e->name != "OLD" && e->name != "REMOVED") {

                    endpoints.push_back(GtEndpoint(item++ * 100 + REPO_TB_IDX, SelectedDomain().name, SQ(e->href), SQ(e->name)));
                    Logger::ins.Info() << "Service: " << e->name << "\r\n";
                    emit UpdateSignal("Service: " + e->name);
                }
        }
        else
            emit UpdateSignal(reply->errorString());

        if (SelectNextDomain())
            http.Propfind(QS(SelectedDomain().href) + "web/");
        else if (SelectFirstEndpoint()) {
            Logger::ins.Info() << "Parsing index files...\r\n";
            emit UpdateSignal("Parsing index files...");
            op = lsoGetIndexXml;
            Logger::ins.Info() << "Parsing " << QS(SelectedEndpoint().urlRegistryFolder) << "index.xml...\r\n";
            http.Get(QS(SelectedEndpoint().urlRegistryFolder) + "index.xml");
        }

        break;

    case lsoGetIndexXml:

        if (reply->error() == QNetworkReply::NoError) {

            QString replyString(reply->readAll());
            sl::log << "lsoGetIndexXml: " << SQ(replyString) << sl::end;

            QDomDocument doc;
            doc.setContent(replyString);

            for (QDomElement r = doc.firstChildElement(); !r.isNull(); r = r.nextSiblingElement()) {

                if (r.nodeName() == "service") {

                    for (QDomElement e = r.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) {

                        if (e.nodeName() == "files") {

                            for (QDomElement f = e.firstChildElement(); !f.isNull(); f = f.nextSiblingElement()) {

                                QDomAttr r = f.attributeNode("root"), t = f.attributeNode("type");
                                if (!r.isNull() && r.nodeValue() == "true" && !t.isNull() && t.value() == "WSDL")
                                    SelectedEndpoint().urlWSDL = SQ(f.text());
                            }
                        }
                        else if (e.nodeName() == "name")
                            SelectedEndpoint().intGivenName = SQ(e.text());
                        else if (e.nodeName() == "version")
                            SelectedEndpoint().intGivenVersion = SQ(e.text());
                        else if (e.nodeName() == "policyVersion")
                            SelectedEndpoint().policyVersion = SQ(e.text());
                        else if (e.nodeName() == "enabled")
                            SelectedEndpoint().enabled = SQ(e.text());
                        else if (e.nodeName() == "soap")
                            SelectedEndpoint().soap = SQ(e.text());
                        else if (e.nodeName() == "resolutionPath")
                            SelectedEndpoint().resolutionPath = SQ(e.text());
                        else if (e.nodeName() == "id")
                            SelectedEndpoint().intGivenId = SQ(e.text());
                        else if (e.nodeName() == "protectedEndpoint")
                            SelectedEndpoint().protectedEndpoint = SQ(e.text());
                    }

                    break;
                }
            }

            if (SelectedEndpoint().urlWSDL == "") {
                Logger::ins.Warning() << "WSDL file url not found for endpoint '" << QS(SelectedEndpoint().intGivenName) << "'\r\n";
                emit UpdateSignal("WSDL file url not found for endpoint '" + QS(SelectedEndpoint().intGivenName) + "'");
                SelectedEndpoint().serviceName = SelectedEndpoint().intGivenName;
            }

            if (SelectedEndpoint().protectedEndpoint == "") {
                Logger::ins.Warning() << "Ignoring non-protected endpoint '" << QS(SelectedEndpoint().intGivenName) << "'\r\n";
                emit UpdateSignal("Ignoring non-protected endpoint '" + QS(SelectedEndpoint().intGivenName) + "'");
                RemoveSelectedEndpoint();
            }
        }
        else {
            Logger::ins.Error() << reply->errorString() << "\r\n";
            emit UpdateSignal(reply->errorString());
        }

        if (SelectNextEndpoint()) {
            Logger::ins.Info() << "Parsing " << QS(SelectedEndpoint().urlRegistryFolder) << "index.xml...\r\n";
            http.Get(QS(SelectedEndpoint().urlRegistryFolder) + "index.xml");
        }
        else if (SelectFirstEndpoint()) {
            Logger::ins.Info() << "Parsing WSDL files...\r\n";
            emit UpdateSignal("Parsing WSDL files...");
            op = lsoGetWsdl;
            Logger::ins.Info() << "Parsing " << QS(SelectedEndpoint().urlRegistryFolder + SelectedEndpoint().urlWSDL) << "\r\n";
            http.Get(QS(SelectedEndpoint().urlRegistryFolder + SelectedEndpoint().urlWSDL));
        }

        break;

    case lsoGetWsdl:

        if (reply->error() == QNetworkReply::NoError) {

            QString replyString(reply->readAll());
            sl::log << "lsoGetWsdl: " << SQ(replyString) << sl::end;

            QDomDocument doc;
            doc.setContent(replyString);

            for (QDomElement r = doc.firstChildElement(); !r.isNull(); r = r.nextSiblingElement()) {
                if (r.nodeName() == "definitions" || r.nodeName() == "wsdl:definitions") {

                    QDomAttr n = r.attributeNode("targetNamespace");
                    if (!n.isNull())
                        SelectedEndpoint().targetNamespace = SQ(n.nodeValue());

                    n = r.attributeNode("name");
                    if (!n.isNull())
                        SelectedEndpoint().definitionName = SQ(n.nodeValue());

                    // find all service names

                    std::vector<std::string> serviceNames;
                    for (QDomElement e = r.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) {

                        if (e.nodeName() == "service" || e.nodeName() == "wsdl:service") {
                            QDomAttr a = e.attributeNode("name");
                            if (!a.isNull())
                                serviceNames.push_back(SQ(a.nodeValue()));
                        }
                    }

                    // assign service name

                    if (serviceNames.size() == 1)
                        SelectedEndpoint().serviceName = serviceNames[0];
                    else if (serviceNames.size() > 1) {

                        // search service node name with best fit to protected endpoint string

                        std::map<int, std::string> m;
                        for (std::vector<std::string>::iterator s = serviceNames.begin(); s != serviceNames.end(); ++s)
                            m.insert(std::pair<int, std::string>(LevenshteinDistance(SelectedEndpoint().protectedEndpoint, *s, true), *s));

                        SelectedEndpoint().serviceName = m.begin()->second;
                    }
                    else {
                        Logger::ins.Warning() << "Service name not found for endpoint '" << QS(SelectedEndpoint().intGivenName) + "'\r\n";
                        emit UpdateSignal("Service name not found for endpoint '" + QS(SelectedEndpoint().intGivenName) + "'");
                        SelectedEndpoint().serviceName = SelectedEndpoint().intGivenName;
                    }

                    break;
                }
            }
        }
        else {
            Logger::ins.Error() << reply->errorString() << "\r\n";
            emit UpdateSignal(reply->errorString());
        }

        if (SelectNextEndpoint()) {
            Logger::ins.Info() << "Parsing " << QS(SelectedEndpoint().urlRegistryFolder + SelectedEndpoint().urlWSDL) << "\r\n";
            http.Get(QS(SelectedEndpoint().urlRegistryFolder + SelectedEndpoint().urlWSDL));
        }
        else {
            Logger::ins.Info() << "Finished loading registry.\r\n";
            emit DoneSignal("Finished loading.");
        }

        break;

    default:
        ;
    }
}
Пример #6
0
void Layer7::ErrorSlot(const QString &text) {
    emit UpdateSignal(text);
    emit DoneSignal("Stopped.");
}
Пример #7
0
UpdateUI::UpdateUI(QObject *parent)
{
    music = dynamic_cast<Music*>(parent);
    connect(this, SIGNAL(UpdateSignal(QStringList)), music, SLOT(UpdateSignal(QStringList)));
}
Пример #8
0
void MythEventHandler::ImpMythEventHandler::Action(void)
{
  const char* events[]={	"CMYTH_EVENT_UNKNOWN",\
    "CMYTH_EVENT_CLOSE",\
    "CMYTH_EVENT_RECORDING_LIST_CHANGE",\
    "CMYTH_EVENT_RECORDING_LIST_CHANGE_ADD",\
    "CMYTH_EVENT_RECORDING_LIST_CHANGE_UPDATE",\
    "CMYTH_EVENT_RECORDING_LIST_CHANGE_DELETE",\
    "CMYTH_EVENT_SCHEDULE_CHANGE",\
    "CMYTH_EVENT_DONE_RECORDING",\
    "CMYTH_EVENT_QUIT_LIVETV",\
    "CMYTH_EVENT_WATCH_LIVETV",\
    "CMYTH_EVENT_LIVETV_CHAIN_UPDATE",\
    "CMYTH_EVENT_SIGNAL",\
    "CMYTH_EVENT_ASK_RECORDING",\
    "CMYTH_EVENT_SYSTEM_EVENT",\
    "CMYTH_EVENT_UPDATE_FILE_SIZE",\
    "CMYTH_EVENT_GENERATED_PIXMAP",\
    "CMYTH_EVENT_CLEAR_SETTINGS_CACHE"};
  cmyth_event_t myth_event;
  char databuf[2049];
  databuf[0]=0;
  timeval timeout;
  timeout.tv_sec=0;
  timeout.tv_usec=100000;

  while(Running())
  {

    if(CMYTH->EventSelect(m_conn_t,&timeout)>0)
    {
      myth_event=CMYTH->EventGet(m_conn_t,databuf,2048);
      XBMC->Log(LOG_DEBUG,"EVENT ID: %s, EVENT databuf: %s",events[myth_event],databuf);
      if(myth_event==CMYTH_EVENT_LIVETV_CHAIN_UPDATE)
      {
        Lock();
        if(!m_rec.IsNull())
        {
          bool retval=m_rec.LiveTVChainUpdate(CStdString(databuf));
          XBMC->Log(LOG_NOTICE,"%s: CHAIN_UPDATE: %i",__FUNCTION__,retval);
        }
        else
          XBMC->Log(LOG_NOTICE,"%s: CHAIN_UPDATE - No recorder",__FUNCTION__);
        Unlock();
      }
      if(myth_event==CMYTH_EVENT_SIGNAL)
      {
        CStdString signal=databuf;
        UpdateSignal(signal);
      }
      if(myth_event==CMYTH_EVENT_SCHEDULE_CHANGE)
      {
        XBMC->Log(LOG_NOTICE,"Schedule change",__FUNCTION__);
      }
      databuf[0]=0;

    }
    //Restore timeout
    timeout.tv_sec=0;
    timeout.tv_usec=100000;
  }
}