Hi All,

right now I'm writing a Qt 4.6 based application that might help us a bit with 
the patchwork queue.

The idea of the script is to have two things at the end:
        1.) a branch with all the patches that applied and that can be published
        2.) a list of patches that don't apply.


What people are supposed to:

1.) Cherry pick from the branch
2.) Send updated patches, close the reports on patchwork...



The current version is able to download the information of all pending 
patches, the next thing is to do is to apply them and keep track of the 
result...


/*
 * Copyright (C) 2010 Holger Hans Peter Freyther
 *
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include <QApplication>
#include <QWebFrame>
#include <QWebElement>
#include <QWebPage>

class Worker : public QObject {
    Q_OBJECT
public:
    Worker()
        : m_currentPage(1)
    {
        m_page = new QWebPage(this);
        connect(m_page, SIGNAL(loadFinished(bool)), SLOT(loadFinished(bool)));
    }

    void start()
    {
        qWarning("Trying to download page %d from patchwork", m_currentPage);
        QUrl url("http://patchwork.openembedded.org/project/openembedded/list/?order=date&page="; + QByteArray::number(m_currentPage));
        m_page->mainFrame()->load(url);
    }

    void startNext()
    {
        ++m_currentPage;
        start();
    }

    void handleCurrentPatch(QWebElement patch)
    {
        QWebElement link = patch.findFirst("a");
        QList<QWebElement> table = patch.findAll("td").toList();
        QString date, author, state;

        if (table.size() == 5) {
            date = table[1].toPlainText();
            author = table[2].toPlainText();
            state = table[4].toPlainText();
        }

        qWarning("\tDate: %s Author: '%s' State: %s '%s'", qPrintable(date), qPrintable(author), qPrintable(state), qPrintable(link.toPlainText()));
    }

    // query for all patches..
    void handleCurrentPage()
    {
        QWebElementCollection patches = m_page->mainFrame()->findAllElements("tr[id*=patch_row]");
        foreach(QWebElement element, patches)
            handleCurrentPatch(element);
    }

public Q_SLOTS:
    void loadFinished(bool result)
    {
        // Verify that we got the page we wanted
        QWebElement currentPage = m_page->mainFrame()->findFirstElement("span[title='Current Page']");
        if (currentPage.isNull()) {
            qWarning("Failed to find the current page.");
            return QApplication::exit(-1);
        }
        int currentPageNo = currentPage.toPlainText().toInt();
        if (currentPageNo != m_currentPage) {
            qWarning("The end was reached.");
            return QApplication::exit(0);
        }

        qWarning("Finished the download of page %d with status: %d", m_currentPage, result);
        handleCurrentPage();

        startNext();
    }

private:
    QWebPage* m_page;
    int m_currentPage;
};

int main(int argc, char **argv)
{
    QApplication app(argc, argv);

    Worker worker;
    worker.start();
    app.exec();
}

#include "main.moc"
_______________________________________________
Openembedded-devel mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-devel

Reply via email to