Пример #1
0
void Drf1600::processPacket(const QByteArray &dataRead)
{
	Command cmd = mCurrentCommand;
	resetStateEngine();
	switch (cmd) {
	case GetDeviceType:
	{
		int c = toUInt16(dataRead[0], dataRead[2]);
		switch (c)
		{
		case 0x436F:
			emit deviceTypeRetrieved(ZigbeeCoordinator);
			break;
		case 0x5275:
			emit deviceTypeRetrieved(ZigbeeRouter);
			break;
		default:
			emit errorReceived(Drf1600IncorrectReply);
			break;
		}
		break;
	}
	case ReadPanId:
		emit panIdRead(toUInt16(dataRead[0], dataRead[1]));
		break;
	case ReadShortAddress:
		emit shortAddressRead(toUInt16(dataRead[0], dataRead[1]));
		break;
	case SetBaudRate:
		/// @todo EV Check retrieved data
		emit baudrateSet();
		break;
	case SetDeviceType:
		static quint8 MsgCoord[] = { 0x43, 0x6F, 0x6F, 0x72, 0x64, 0x3B, 0x00, 0x19 };
		static quint8 MsgRouter[] = { 0x52, 0x6F, 0x75, 0x74, 0x65, 0x3B, 0x00, 0x19 };
		if (checkReply(dataRead, MsgCoord, sizeof(MsgCoord)/sizeof(MsgCoord[0])) ||
			checkReply(dataRead, MsgRouter, sizeof(MsgRouter)/sizeof(MsgRouter[0]))) {
			emit deviceTypeSet();
		} else {
			emit errorReceived(Drf1600IncorrectReply);
		}
		break;
	case TestBaudrate:
		emit baudrateTested(toUInt16(dataRead[6], dataRead[7]));
		break;
	case WritePanId:
		emit panIdWritten(toUInt16(dataRead[0], dataRead[1]));
		break;
	default:
		break;
	}
}
Пример #2
0
void FsoPhoneBook::retrievePhonebookFinished(QFsoDBusPendingCall & call)
{
    QFsoDBusPendingReply < QFsoSIMEntryList > reply = call;

    if (!checkReply(reply)) {
        return;
    }

    QFsoSIMEntryList pb = reply.value();
    QList < QPhoneBookEntry > list;

    qDebug() << "pb.count()=" << pb.count();
    freeIndex = -1;
    numUsed = pb.count();

    for (int i = 0; i < pb.count(); i++) {
        QFsoSIMEntry entry = pb.at(i);

        qDebug() << "entry i=" << i << ", index=" << entry.index << ", name=" <<
            entry.name << ", number=" << entry.number;

        QPhoneBookEntry item;
        item.setIndex(entry.index);
        item.setNumber(entry.number);
        item.setText(entry.name);
        list.append(item);

        if (freeIndex < 0 || entry.index == freeIndex) {
            freeIndex = entry.index + 1;
        }
    }
    emit entries("SM", list);
}
Пример #3
0
void FsoPhoneCall::initiateFinished(QFsoDBusPendingCall & call)
{
    QFsoDBusPendingReply<int> reply = call;
    if(checkReply(reply, "Initiate"))
    {
        id = reply.value();
    }   
}
Пример #4
0
QString WebResourceManager::getMatchingImage(const QString& requestedURL) const {
    // if something explicitly on the disk is requested, then return it
    if(requestedURL.length() > 10 && requestedURL.mid(0, 9).compare("asset:///") == 0) {
        return requestedURL;
    }

    // check if cache folder exists, if not, creates it
    QString directory = QDir::homePath() + "/../native/assets/TMP/";
    if (!QFile::exists(directory)) {
        QDir dir;
        dir.mkpath(directory);
    }


    // check if image already available
    QUrl url = QUrl(requestedURL);
    // Check if image is stored on disc
    // The qHash is a bucket type hash so the doubling is to remove possible collisions.
    QString diskPath = QDir::homePath() + "/../native/assets/TMP/"
            + QString::number(qHash(url.host())) + "_"
            + QString::number(qHash(url.path())) + ".PNG";

    QFile imageFile(diskPath);

    // If the file exists, send a signal the image is ready
    if (imageFile.exists()) {
        qDebug() << requestedURL << "...existing";
        qDebug() << diskPath;
        return "asset:///TMP/" + QString::number(qHash(url.host())) + "_"
                + QString::number(qHash(url.path())) + ".PNG";
    } else {
        // check if the file is being downloaded, if so, skip it
        m_EditQueue->lockForRead();
        for(int i = 0 ; i < m_DownloadQueue->length() ; ++i)
            if(m_DownloadQueue->at(i).compare(requestedURL) == 0) {
                m_EditQueue->unlock();
                return "asset:///TMP/" + QString::number(qHash(url.host())) + "_"
                + QString::number(qHash(url.path())) + ".PNG";;
            }
        m_EditQueue->unlock();

        // otherwise let's download the file
        QNetworkRequest request(url);
        request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");


        QNetworkReply* reply = HFRNetworkAccessManager::get()->get(request);
        bool ok = connect(reply, SIGNAL(finished()), this, SLOT(checkReply()));
        Q_ASSERT(ok);
        Q_UNUSED(ok);

        return "file://" + diskPath;

        qDebug() << requestedURL << "...dowload";
    }

    return "";
}
Пример #5
0
void FsoPhoneCall::hangup( QPhoneCall::Scope scope)
{
    qDebug() << "FsoPhoneCall::hangup()";

    if(scope == QPhoneCall::CallOnly)
    {
        QFsoDBusPendingReply<> reply = service->gsmCall.Release(id);
        checkReply(reply);
    }
    else
    {
        // TODO: not sure if ReleaseAll() is ok
        QFsoDBusPendingReply<> reply = service->gsmCall.ReleaseAll();
        checkReply(reply);
    }
    id = -1;
    setState(QPhoneCall::HangupLocal);
}
Пример #6
0
void OFonoSimInfo::getSimInfoFinished(QOFonoDBusPendingCall & call)
{
    QOFonoDBusPendingReply < QVariantMap > reply = call;
    if (!checkReply(reply)) {
        return;
    }
    info = reply.value();
    setIdentity(info.value("imsi").toString());
}
Пример #7
0
QNetworkReply* Connection::connectToAccount(const QString &email,
                                            const QString &password,
                                            PMS::SimpleResultHandler handler)
{
    QUrlQuery query;
    query.addQueryItem("api_subscription[email]", email);
    query.addQueryItem("api_subscription[password]", password);
    query.addQueryItem("api_subscription[client_name]", qApp->applicationName());
    query.addQueryItem("api_subscription[client_vendor]", qApp->organizationName());
    QNetworkRequest request(apiUrl_);
    request.setHeader(QNetworkRequest::KnownHeaders::ContentTypeHeader, "application/x-www-form-urlencoded");
    auto reply = client_->post(request, query.toString().toUtf8());

    QPointer<QObject> self = this;
    QObject::connect(reply, &QNetworkReply::finished, [self, this, reply, handler]()
    {
        if (!self)
            return;
        try
        {
            checkReply(reply);
            auto str = reply->readAll().trimmed();

            QRegExp apiKeyRx("^API key: (.+)$");
            if (apiKeyRx.exactMatch(str))
            {
                setApiKey(apiKeyRx.cap(1));
                handler(Error());
                return;
            }

            QRegExp errorRx("^Error Code: (\\d+)$");
            if (errorRx.exactMatch(str))
            {
                int code = errorRx.cap(1).toInt();
                QString error;
                switch (code)
                {
                    case 1: error = tr("Client details not set"); break;
                    case 2: error = tr("Unknown user"); break;
                    case 3: error = tr("Invalid password"); break;
                    case 4: error = tr("Not allowed for given User and their System Role"); break;
                    default: error = tr("Unknown error"); break;
                }
                throw Error(Error::Authorization, error);
            }

            throw Error(Error::Authorization, tr("Unknown error"));
        }
        catch (const Error& err)
        {
            handler(err);
        }
    });
}
Пример #8
0
void RefImage::thumbFromReply()
{
    if (checkReply(thumbReply()))
    {
        thumbItem()->stopDownload(false);
        QPixmap pixmap;
        pixmap.loadFromData(thumbReply()->readAll());
        insertThumb(pixmap);
        thumbReply()->deleteLater();
    }
}
Пример #9
0
void FsoPhoneBook::remove(uint index, const QString & store, bool flush)
{
    qDebug() << "FsoPhoneBook::remove index=" << index << "store=" << store <<
        "flush=" << flush;

    QFsoDBusPendingReply <> reply =
        service->gsmSim.DeleteEntry("contacts", index);

    checkReply(reply);
    getEntries(store);
}
Пример #10
0
void FsoPhoneBook::update(const QPhoneBookEntry & entry, const QString & store,
                          bool flush)
{
    qDebug() << "FsoPhoneBook::update entry.text()=" << entry.text() << "store="
        << store << "flush=" << flush;

    QFsoDBusPendingReply <> reply =
        service->gsmSim.StoreEntry("contacts", entry.index(), entry.text(),
                                   entry.number());
    checkReply(reply);
    getEntries(store);
}
Пример #11
0
void RefImage::imageFromReply()
{
    if (checkReply(imageReply()))
    {
        QPixmap pixmap;
        pixmap.loadFromData(imageReply()->readAll());
        insertImage(pixmap,nameFromUrl(imageReply()->url()));
        imageReply()->deleteLater();
        m_imageReply = NULL;
        thumbItem()->stopDownload(true);
    }
}
Пример #12
0
QList<Audio> VKAudio::getAudios(QUrl url) {
    QList<Audio> list;
    QJsonObject result;
    last_request = url;
    do {
        bool ok = checkReply(getFile(last_request), result);
        if(ok) {
            list = parseAudio(result);
            emit statusChanged(tr("Finished"), STATUS_SHOW_TIME);
        }
    } while(retry_last_request);
    if(list.isEmpty()) emit statusChanged(tr("Nothing is found by your request"), STATUS_SHOW_TIME);
    return list;
}
Пример #13
0
void FsoTelephonyService::getDeviceStatusFinished(QFsoDBusPendingCall & call)
{
    QFsoDBusPendingReply < QString > reply = call;
    if (!checkReply(reply)) {
        return;
    }
    QString status = reply.value();
    if (!deviceStatusInitialized) {
        deviceStatusChange(reply.value());
    }
    if (status == "closed") {
        QFsoDBusPendingCall call = fsoUsage.SetResourcePolicy("GSM", "enabled");
        watchFsoCall(call, this,
                     SLOT(setResourcePolicyFinished(QFsoDBusPendingCall &)));
    }
void GoogleConnectController::getToken() {

    QNetworkRequest request(QUrl("https://accounts.google.com/o/oauth2/token"));
    request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");

    QUrl params;
    params.addQueryItem("code",         m_Settings->value("key").value<QString>());
    params.addQueryItem("client_id",    m_Settings->value("Client_ID").value<QString>());
    params.addQueryItem("client_secret", m_Settings->value("ClientSecret").value<QString>());
    params.addQueryItem("redirect_uri", "urn:ietf:wg:oauth:2.0:oob");
    params.addQueryItem("grant_type", "authorization_code");

    QNetworkReply* reply = HFRNetworkAccessManager::get()->post(request, params.encodedQuery());
    bool ok = connect(reply, SIGNAL(finished()), this, SLOT(checkReply()));
    Q_ASSERT(ok);
    Q_UNUSED(ok);
}
Пример #15
0
QDomDocument checkReplyAndParseXml(QNetworkReply *reply)
{
    checkReply(reply);

    QString errorMsg;
    int errorLine = 0;
    int errorColumn = 0;

    QDomDocument doc;
    if (!doc.setContent(reply, &errorMsg, &errorLine, &errorColumn))
        throw Error(Error::Network, QObject::tr("Error of parsing reply"),
                    QObject::tr("%1 line:%2 col:%3").arg(errorMsg).arg(errorLine).arg(errorColumn));

    qDebug() << "<8e4686ac>" << doc.toString();

    return doc;
}
Пример #16
0
void LoginController::login(const QString &login, const QString &password) {
	m_User = login;

	const QUrl url(DefineConsts::HARDWARE_FR_URL + "/membres/popupLogin.php");


	QNetworkRequest request(url);
	request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");

	QUrl params;
	params.addQueryItem("pseudo", login);
	params.addQueryItem("pwd", password);
	params.addQueryItem("action", "send");
	params.addQueryItem("login", "Se connecter");

	QNetworkReply* reply = HFRNetworkAccessManager::get()->post(request, params.encodedQuery());
	bool ok = connect(reply, SIGNAL(finished()), this, SLOT(checkReply()));
	Q_ASSERT(ok);
	Q_UNUSED(ok);
}
Пример #17
0
void FsoPhoneBook::requestLimits(const QString & store)
{
    qDebug() << "FsoPhoneBook::requestLimits store=" << store;

    if (!simReady) {
        wantLimits = true;
        return;
    }

    QFsoDBusPendingReply < int, int, int >reply =
        service->gsmSim.GetPhonebookInfo("contacts");

    if (!checkReply(reply)) {
        return;
    }
    QPhoneBookLimits l;
    l.setUsed(numUsed);
    l.setFirstIndex(1);
    l.setLastIndex(reply.argumentAt(0).toInt());
    l.setNumberLength(reply.argumentAt(1).toInt());
    l.setTextLength(reply.argumentAt(2).toInt());
    emit limits(store, l);
}
Пример #18
0
void DefinitionUpdater::update() {
  reply = qnam.head(QNetworkRequest(url));
  connect(reply, SIGNAL(finished()),
          this, SLOT(checkReply()));
}
Пример #19
0
void ScreenManager::slot_onReadyRead()
{
    checkReply();
}
Пример #20
0
void FsoPhoneCall::hold()
{
    qDebug() << "FsoPhoneCall::hold()";
    QFsoDBusPendingReply<> reply = service->gsmCall.HoldActive();
    checkReply(reply);
}
Пример #21
0
void FsoPhoneCall::activate( QPhoneCall::Scope )
{
    qDebug() << "FsoPhoneCall::activate()";
    QFsoDBusPendingReply<> reply = service->gsmCall.Activate(id);
    checkReply(reply);
}
Пример #22
0
RedisReply::RedisReply(DBConnector *db, string command)
{
    redisAppendCommand(db->getContext(), command.c_str());
    redisGetReply(db->getContext(), (void**)&m_reply);
    guard([&]{checkReply();}, command.c_str());
}
Пример #23
0
RedisReply::RedisReply(DBConnector *db, const RedisCommand& command)
{
    redisAppendFormattedCommand(db->getContext(), command.c_str(), command.length());
    redisGetReply(db->getContext(), (void**)&m_reply);
    guard([&]{checkReply();}, command.c_str());
}