Ejemplo n.º 1
0
/*++
* @method: twitCurl::performPost
*
* @description: method to send http POST request. this is an internal method.
*               twitcurl users should not use this method.
*
* @input: postUrl - url,
*         dataStr - data to be posted
*
* @output: none
*
* @remarks: internal method
*
*--*/
bool twitCurl::performPost( const std::string& postUrl, std::string dataStr )
{
    std::string oAuthHttpHeader( "" );
    struct curl_slist* pOAuthHeaderList = NULL;

    /* Prepare standard params */
    prepareStandardParams();

    /* urlencode data */
    if( dataStr.length() > 0 )
    {
        /* Data should already be urlencoded once */
        std::string dataKey( "" );
        std::string dataValue( "" );
        size_t nPos = dataStr.find_first_of( "=" );
        if( std::string::npos != nPos )
        {
            dataKey = dataStr.substr( 0, nPos );
            dataValue = dataStr.substr( nPos + 1 );
            dataValue = urlencode( dataValue );
            dataStr.assign( dataKey );
            dataStr.append( "=" );
            dataStr.append( dataValue );
        }
    }

    /* Set OAuth header */
    m_oAuth.getOAuthHeader( eOAuthHttpPost, postUrl, dataStr, oAuthHttpHeader );
    if( oAuthHttpHeader.length() > 0 )
    {
        pOAuthHeaderList = curl_slist_append( pOAuthHeaderList, oAuthHttpHeader.c_str() );
        if( pOAuthHeaderList )
        {
            curl_easy_setopt( m_curlHandle, CURLOPT_HTTPHEADER, pOAuthHeaderList );
        }
    }

    /* Set http request, url and data */
    curl_easy_setopt( m_curlHandle, CURLOPT_POST, 1 );
    curl_easy_setopt( m_curlHandle, CURLOPT_URL, postUrl.c_str() );
    if( dataStr.length() )
    {
        curl_easy_setopt( m_curlHandle, CURLOPT_COPYPOSTFIELDS, dataStr.c_str() );
    }

    /* Send http request */
    if( CURLE_OK == curl_easy_perform( m_curlHandle ) )
    {
        if( pOAuthHeaderList )
        {
            curl_slist_free_all( pOAuthHeaderList );
        }
        return true;
    }
    if( pOAuthHeaderList )
    {
        curl_slist_free_all( pOAuthHeaderList );
    }
    return false;
}
Ejemplo n.º 2
0
void MainWindow::addToList(int value){
    vector<SokoGenerator::Level> levels = Generator.getLevels();
    int millis = levels[value-1].generationTime % 1000;
    int seconds = ((int)levels[value-1].generationTime / 1000) % 60 ;
    int minutes = ((int)levels[value-1].generationTime / (1000*60)) % 60;
    QString padMillis = QString("%1").arg(millis, 3, 10, QChar('0'));
    QString padSeconds = QString("%1").arg(seconds, 2, 10, QChar('0'));
    QString padMinutes = QString("%1").arg(minutes, 2, 10, QChar('0'));
    QString diff = levels[value-1].difficulty;
    ui->list_LevelSet->addItem("Level " + QString::number(value) + " - " + padMinutes + ":" + padSeconds + ":" + padMillis + " - " + diff);
    QVariant dataValue(value-1);
    ui->list_LevelSet->item(value-1)->setData(Qt::UserRole, dataValue);
}
Ejemplo n.º 3
0
void FixDialog::reject(bool b){ emit dataValue(m_lastFix); emit rejected(); }
Ejemplo n.º 4
0
void FixDialog::newData(int f) { emit dataValue(m_spinBox->value()); }