예제 #1
0
void getdatacommand::run()
{
    FILE *fpipe;
    char* line = 0;
    size_t len = 0;
    QString string;

    if ( inRun != TRUE )
    {
        inRun = TRUE;

        fpipe = popen(theQuery.toUtf8(), "r");
        if(fpipe != NULL)
        {
            int findfile = 0;
            // delimiter is null character.
            while( getdelim(&line, &len, 0, fpipe) != -1 )
            {
                findfile++;
                string = QString::fromUtf8(line);
                theListBoxResults->addItem( string );
            }
            delete(line);
            pclose(fpipe);
            emit queryComplete(findfile);
        }

        inRun = FALSE;
    }
}
void MsgAudioSelectionEngine::HandleQueryCompletedL(CMdEQuery& aQuery,
        TInt aError)
    {
    iNameList.clear();
    iUriList.clear();
    if (aError == KErrCancel)
        {
        emit queryError(aError);
        return;
        }
    else
        {
        QMap<QString,QString> nameUriList;
        CMdEObjectQuery* query = static_cast<CMdEObjectQuery*> (&aQuery);
        TInt count = query->Count();
        for (TInt i = 0; i < count; ++i)
            {
            CMdEObject* object =
                    (CMdEObject*) query->TakeOwnershipOfResult(i);
            CleanupStack::PushL(object);
            CMdEPropertyDef& propDef = MsgAudioSelectionEngine::PropertyDefL(
                    iSession, MsgAudioSelectionEngine::EAttrFileName);

            CMdEProperty* property = 0;
            TInt err = object->Property(propDef, property, 0);
            if (err != KErrNotFound && property)
                {
                QString songName(XQConversions::s60DescToQString(
                        property->TextValueL()));
                QString uriValue(XQConversions::s60DescToQString(
                        object->Uri()));
                
                //insert into the map
                nameUriList.insertMulti(uriValue, songName);
                }
            CleanupStack::PopAndDestroy(object);
            }
        
        //now get all the song names and sort them
        iNameList = nameUriList.values();
        iNameList.sort();
        
        // go through the song list and get the associated uri
        // insert into the uri list
        int nameListTotal = iNameList.count();
        for(int nameListCount = 0; 
                nameListCount<nameListTotal;
                nameListCount++)
            {
            QString key = nameUriList.key(iNameList.at(nameListCount));
            iUriList.append(key);
            nameUriList.remove(key);                        
            }
        
        // emit the list to the model
        emit queryComplete(iNameList, iUriList);
        }
    }
void DroneshareAPIBroker::httpFinished()
{
    QLOG_DEBUG() << "DroneshareUpload::httpFinished()";
    if (!m_httpRequestAborted) {
        // Finished uploading the log
        if (m_networkReply->error()) {
            // upload failed
            emit queryFailed(m_networkReply->errorString());
        } else {
            // Upload success
            QString reply = QString(m_networkReply->readAll());
            QLOG_DEBUG() << "Droneshare: JSON reply: " << reply;
            emit queryComplete(reply);
        }
    }
    if(m_networkReply) {
        m_networkReply->deleteLater();
        m_networkReply = NULL;
    }
}
void DroneshareUploadDialog::acceptUserLogin(QString& username, QString& password, int indexNumber)
{
    QLOG_DEBUG() << "Droneshare: " << username << " pass: XXXXXXX" << "index: " << indexNumber;
    m_username = username;
    m_password = password;

    QSettings settings;
    settings.beginGroup("Droneshare");
    settings.setValue("username", m_username);
    settings.endGroup();
    settings.sync();

    m_droneshareQuery = new DroneshareAPIBroker();
    connect(m_droneshareQuery, SIGNAL(queryComplete(QString)),
            this, SLOT(vehicleQueryComplete(QString)));
    connect(m_droneshareQuery, SIGNAL(queryFailed(QString)),
            this, SLOT(vehicleQueryFailed(QString)));

    m_droneshareQuery->addBaseUrl(DroneshareBaseUrl);
    m_droneshareQuery->addQuery("/user/" + m_username);
    m_droneshareQuery->addQueryItem("api_key", DroneshareAPIKey);
    m_droneshareQuery->sendQueryRequest();
    QLOG_DEBUG() << "droneshare: user request: " << m_droneshareQuery->getUrl();
}