Example #1
0
void PublishToMePlugin::getDownloadRequest(const QString &url, const QVariantMap &settings) {
    m_redirects = 0;
    m_url = QUrl::fromUserInput(url);

    if (settings.value("Account/useLogin", false).toBool()) {
        const QString username = settings.value("Account/username").toString();
        const QString password = settings.value("Account/password").toString();

        if ((username.isEmpty()) || (password.isEmpty())) {
            QVariantList list;
            QVariantMap usernameMap;
            usernameMap["type"] = "text";
            usernameMap["label"] = tr("Username");
            usernameMap["key"] = "username";
            list << usernameMap;
            QVariantMap passwordMap;
            passwordMap["type"] = "password";
            passwordMap["label"] = tr("Password");
            passwordMap["key"] = "password";
            list << passwordMap;
            emit settingsRequest(tr("Login"), list, "submitLogin");
        }   
        else {
            login(username, password);
        }

        return;
    }
    
    fetchDownloadRequest(m_url);
}
Example #2
0
void SoundCloudSearchPlugin::search(const QVariantMap &settings) {
    if (!settings.value("useDefaultSearchOptions", false).toBool()) {
        QVariantMap searchQuery;
        searchQuery["type"] = "text";
        searchQuery["label"] = tr("Search query");
        searchQuery["key"] = "searchQuery";
        QVariantMap searchType;
        QVariantMap playlists;
        playlists["label"] = tr("Sets");
        playlists["value"] = "/playlists";
        QVariantMap tracks;
        tracks["label"] = tr("Tracks");
        tracks["value"] = "/tracks";
        searchType["type"] = "list";
        searchType["label"] = tr("Search type");
        searchType["key"] = "searchType";
        searchType["value"] = "/tracks";
        searchType["options"] = QVariantList() << playlists << tracks;
        emit settingsRequest(tr("Choose search options"), QVariantList() << searchQuery << searchType, "submitSettings");
        return;
    }
    
    QVariantMap filters;
    filters["q"] = settings.value("searchQuery").toString();
    filters["limit"] = 20;
    filters["representation"] = "compact";
    filters["linked_partitioning"] = true;
    request()->get(settings.value("searchType", "/tracks").toString(), filters);
}
Example #3
0
DownloadRequestDialog::DownloadRequestDialog(QWidget *parent) :
    QDialog(parent),
    m_view(new QTreeView(this)),
    m_progressBar(new QProgressBar(this)),
    m_statusLabel(new QLabel(this)),
    m_buttonBox(new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this)),
    m_layout(new QVBoxLayout(this))
{
    setWindowTitle(tr("Download requests"));

    m_view->setModel(DownloadRequestModel::instance());
    m_view->setAlternatingRowColors(true);
    m_view->setSelectionBehavior(QTreeView::SelectRows);
    m_view->setContextMenuPolicy(Qt::CustomContextMenu);
    m_view->setEditTriggers(QTreeView::NoEditTriggers);
    m_view->setItemsExpandable(false);
    m_view->setUniformRowHeights(true);
    m_view->setAllColumnsShowFocus(true);
    m_view->setRootIsDecorated(false);
    m_view->header()->setStretchLastSection(false);
    m_view->header()->resizeSection(1, 32);
#if QT_VERSION >= 0x050000
    m_view->header()->setSectionResizeMode(0, QHeaderView::Stretch);
#else
    m_view->header()->setResizeMode(0, QHeaderView::Stretch);
#endif

    m_progressBar->setRange(0, 100);
    m_progressBar->setValue(DownloadRequestModel::instance()->progress());

    m_layout->addWidget(m_view);
    m_layout->addWidget(m_progressBar);
    m_layout->addWidget(m_statusLabel);
    m_layout->addWidget(m_buttonBox);

    connect(DownloadRequestModel::instance(), SIGNAL(progressChanged(int)), m_progressBar, SLOT(setValue(int)));
    connect(DownloadRequestModel::instance(), SIGNAL(captchaRequest(int, QByteArray)),
            this, SLOT(showCaptchaDialog(int, QByteArray)));
    connect(DownloadRequestModel::instance(), SIGNAL(captchaTimeoutChanged(int)), this, SLOT(updateStatusLabel()));
    connect(DownloadRequestModel::instance(), SIGNAL(requestedSettingsTimeoutChanged(int)),
            this, SLOT(updateStatusLabel()));
    connect(DownloadRequestModel::instance(), SIGNAL(settingsRequest(QString, QVariantList)),
            this, SLOT(showPluginSettingsDialog(QString, QVariantList)));
    connect(DownloadRequestModel::instance(), SIGNAL(statusChanged(DownloadRequestModel::Status)),
            this, SLOT(onStatusChanged(DownloadRequestModel::Status)));
    connect(DownloadRequestModel::instance(), SIGNAL(waitTimeChanged(int)), this, SLOT(updateStatusLabel()));
    connect(m_view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
    connect(m_buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(reject()));

    onStatusChanged(DownloadRequestModel::instance()->status());
}
Example #4
0
void VimeoPlugin::onStreamsRequestFinished() {
    if (m_streamsRequest->status() == QVimeo::StreamsRequest::Ready) {
        const QVariantList streams = m_streamsRequest->result().toList();
        
        if (streams.isEmpty()) {
            emit error(tr("No streams found"));
            return;
        }

        if (m_settings.value("useDefaultVideoFormat", true).toBool()) {
            const QString format = m_settings.value("videoFormat", "1080p").toString();

            for (int i = 0; i < VIDEO_FORMATS.indexOf(format); i++) {
                for (int j = 0; j < streams.size(); j++) {
                    const QVariantMap stream = streams.at(j).toMap();

                    if (stream.value("id") == format) {
                        emit downloadRequest(QNetworkRequest(stream.value("url").toString()));
                        return;
                    }
                }
            }

            emit error(tr("No stream found for the chosen video format"));
        }
        else {
            QVariantList settingsList;
            QVariantList options;
            QVariantMap list;
            list["type"] = "list";
            list["label"] = tr("Video format");
            list["key"] = "videoFormat";
            list["value"] = streams.first().toMap().value("url");
            
            for (int i = 0; i < streams.size(); i++) {
                const QVariantMap stream = streams.at(i).toMap();
                QVariantMap option;
                option["label"] = QString("%1P").arg(stream.value("height").toString());
                option["value"] = stream.value("url");
                options << option;
            }

            list["options"] = options;
            settingsList << list;
            emit settingsRequest(tr("Choose video format"), settingsList, "submitFormat");
        }
    }
    else if (m_streamsRequest->status() == QVimeo::StreamsRequest::Failed) {
        emit error(m_streamsRequest->errorString());
    }   
}
bool JavaScriptDecaptchaPlugin::init() {
    if (m_initted) {
        return true;
    }

    if (!m_plugin.property("cancelCurrentOperation").isFunction()) {
        Logger::log("JavaScriptDecaptchaPlugin::init(): No cancelCurrentOperation() function found");
        return false;
    }

    if (!m_plugin.property("getCaptchaResponse").isFunction()) {
        Logger::log("JavaScriptDecaptchaPlugin::init(): No getCaptchaResponse() function found");
        return false;
    }

    if (!m_plugin.property("reportCaptchaResponse").isFunction()) {
        Logger::log("JavaScriptDecaptchaPlugin::init(): No reportCaptchaResponse() function found");
        return false;
    }

    QObject *obj = m_plugin.toQObject();

    if ((!obj) || (!connect(obj, SIGNAL(captchaResponse(QString, QString)),
                    this, SIGNAL(captchaResponse(QString, QString))))
            || (!connect(obj, SIGNAL(captchaResponseReported(QString)),
                    this, SIGNAL(captchaResponseReported(QString))))
            || (!connect(obj, SIGNAL(error(QString)), this, SIGNAL(error(QString))))
            || (!connect(obj, SIGNAL(settingsRequest(QString, QVariantList, QScriptValue)),
                    this, SLOT(onSettingsRequest(QString, QVariantList, QScriptValue))))) {
        Logger::log("JavaScriptDecaptchaPlugin::init(): Not a valid DecaptchaPlugin");
        return false;
    }

    Logger::log("JavaScriptDecaptchaPlugin::init(): DecaptchaPlugin initialized OK", Logger::HighVerbosity);
    m_initted = true;
    return true;
}
Example #6
0
SearchPage::SearchPage(QWidget *parent) :
    Page(parent),
    m_model(new SearchModel(this)),
    m_splitter(new QSplitter(Qt::Horizontal, this)),
    m_view(new QListView(m_splitter)),
    m_browser(new QWebView(m_splitter)),
    m_layout(new QHBoxLayout(this))
{
    setWindowTitle(tr("Search"));
    
    m_splitter->addWidget(m_view);
    m_splitter->addWidget(m_browser);
    
    m_view->setModel(m_model);
    m_view->setItemDelegate(new ItemDelegate(m_view));
    m_view->setContextMenuPolicy(Qt::CustomContextMenu);
    m_view->setUniformItemSizes(true);

    m_browser->setContextMenuPolicy(Qt::CustomContextMenu);
    m_browser->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
    m_browser->settings()->setAttribute(QWebSettings::JavascriptEnabled, false);
    m_browser->settings()->setUserStyleSheetUrl(QUrl::fromEncoded(STYLE_SHEET));
    
    m_layout->addWidget(m_splitter);
    m_layout->setContentsMargins(0, 0, 0, 0);
    
    m_splitter->restoreState(Settings::searchPageState());
    
    connect(m_model, SIGNAL(settingsRequest(QString, QVariantList)),
            this, SLOT(showPluginSettingsDialog(QString, QVariantList)));
    connect(m_model, SIGNAL(statusChanged(SearchModel::Status)), this, SLOT(onModelStatusChanged()));
    connect(m_view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
    connect(m_view->selectionModel(), SIGNAL(currentRowChanged(QModelIndex, QModelIndex)),
            this, SLOT(showItemDetails(QModelIndex)));
    connect(m_browser, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showBrowserContextMenu(QPoint)));
}
int main(void)
{
    uint8_t cmdBuf[128];
    uint8_t i;

    // Init peripherals.
    // Clock is set to 32MHz.
    clockInit();
    // This UART is connected to the UC3 device and provides connectivity
    // via USB.
    uartInit(&UARTC0, 8);	// 115,200 BAUD
    // This UART will be connected to the RadioBlocks device.
    uartInit(&UARTF0, 8); // 115,200 BAUD

    // Init the globals.
    isrLen = 0;
    cmdLen = 0;
    cmdFlag = 0;
    testCmd = 0;
    wakeCmd = 0;
    isrCmd = 0;
    ackStatus = 0;

    // Fun!
    ledFlag = 0;

    // These are used to help in debug. Used to print strings
    // to USARTC0 which is connected to the xplained-a1 usb
    // port through the on-board UC3.
    userEnd = 0;
    userStart = 0;

    // DEBUG - Create delay timer.
    //startTimer(1000); // One millisecond test.

    // Configure PORTA as output to measure delay timer...
    // These pins are on Xplained header J2
    PORT_SetPinsAsOutput( &PORTA, 0xFF );

    // Use one of the Xplained-A1 pins. SW4 - PD4
    PORT_SetPinsAsInput( &PORTD, 0x10 );

    // Check UART operation
    //testUartTx();

    // Enable global interrupts.
    sei();

    // Create a function pointer to use with the user uart (UARTC0).
    void (*puartBuf)(uint8_t* , uint8_t);

    // Assign that function pointer to the send data to RadioBlocks.
    puartBuf = &sendUARTF0;

    ///////////////////////	TEST CODE //////////////////
#if 0
    for(uint16_t i=0; i<CIRCSIZE; i++)
        sniffBuff[i] = 255;

    toggleLed(puartBuf, LED_TOGGLE, uartBuf);
    testRequest(puartBuf, uartBuf);
    setAddress(puartBuf, 0x1234, uartBuf);
    getAddress(puartBuf, uartBuf);
    sleepRequest(puartBuf, 1000, uartBuf);
    settingsRequest(puartBuf, uartBuf, RESTORE_CURRENT_SETTINGS);
    configureUART(puartBuf, DATA_BITS_8, PARITY_NONE, STOP_BITS_1, BAUD_115200, uartBuf);
    setPanid(puartBuf, 0x5678, uartBuf);
    getPanid(puartBuf, uartBuf);
    setChannel(puartBuf, CHANNEL_16, uartBuf);
    getChannel(puartBuf,uartBuf);
    setTRXState(puartBuf, TX_ON, uartBuf);
    getTRXState(puartBuf, uartBuf);
    dataRequest(puartBuf, 0x0001, DATA_OPTION_NONE, 0x42, 6, testBuf, uartBuf);
    setTxPower(puartBuf, TX_POWER_2_8_DBM, uartBuf);
    getTxPower(puartBuf, uartBuf);
    //setSecurityKey(puartBuf, uint8_t* key, uartBuf); // max 16 bytes.
#endif

    toggleLed(puartBuf, LED_TOGGLE, uartBuf);
    processResponse();
    usartUartPrint();

    testRequest(puartBuf, uartBuf);
    processResponse();
    usartUartPrint();
    processResponse();
    usartUartPrint();

    setAddress(puartBuf, 0x1234, uartBuf);
    processResponse();
    usartUartPrint();

    getAddress(puartBuf, uartBuf);
    processResponse();
    usartUartPrint();
    processResponse();
    usartUartPrint();

    setPanid(puartBuf, 0x5678, uartBuf);
    processResponse();
    usartUartPrint();
    getPanid(puartBuf, uartBuf);
    processResponse();
    usartUartPrint();
    processResponse();
    usartUartPrint();

    setChannel(puartBuf, CHANNEL_16, uartBuf);
    processResponse();
    usartUartPrint();
    getChannel(puartBuf,uartBuf);
    processResponse();
    usartUartPrint();
    processResponse();
    usartUartPrint();

//	setTRXState(puartBuf, TX_ON, uartBuf);
//	processResponse();
//	getTRXState(puartBuf, uartBuf);
//	processResponse();
//	processResponse();

    setTxPower(puartBuf, TX_POWER_2_8_DBM, uartBuf);
    processResponse();
    usartUartPrint();
    getTxPower(puartBuf, uartBuf);
    processResponse();
    usartUartPrint();
    processResponse();
    usartUartPrint();

    dataRequest(puartBuf, 0x0001, DATA_OPTION_NONE, 0x42, 6, testBuf, uartBuf);
    processResponse();
    usartUartPrint();

    setTRXState(puartBuf, RX_ON, uartBuf);
    processResponse();
    usartUartPrint();
    getTRXState(puartBuf, uartBuf);
    processResponse();
    usartUartPrint();
    processResponse();
    usartUartPrint();

    while(1)
    {
        processResponse();
        usartUartPrint();
        // Fun.
//		toggleLed(puartBuf, LED_TOGGLE, uartBuf);
//		timerLoop(100);	// WARNING, can BLOCK a loooong time.
//		processResponse();
//		testBuf[5]++;
//		setTRXState(puartBuf, TX_ON, uartBuf);
//		processResponse();
//		dataRequest(puartBuf, 0x0001, DATA_OPTION_NONE, 0x42, 6, testBuf, uartBuf);
//		processResponse();
//		setTRXState(puartBuf, RX_ON, uartBuf);
//		processResponse();



        /* USER CODE HERE! */

    }
}
void JavaScriptDecaptchaPlugin::onSettingsRequest(const QString &title, const QVariantList &settings,
        const QScriptValue &callback) {
    m_callback = callback;
    emit settingsRequest(title, settings, "submitSettingsRepsonse");
}
Example #9
0
void MainScreen::on_settingsButton_clicked()
{
    emit settingsRequest();
}