void BirthdayUpdater::onRequestStateChanged(qutim_sdk_0_3::InfoRequest::State state) { if (state == InfoRequest::RequestDone) { InfoRequest *request = sender_cast<InfoRequest*>(sender()); request->deleteLater(); Contact *contact = qobject_cast<Contact*>(request->object()); if (!contact) return; emit birthdayUpdated(contact, request->value("birthday", QDate())); } else if (state == InfoRequest::Canceled || state == InfoRequest::Error) { sender()->deleteLater(); } }
void ScriptInfoRequest::handleError(const char *name, const QString &text) { InfoRequest *request = qobject_cast<InfoRequest*>(parent()); Q_ASSERT(request); request->deleteLater(); debug() << Q_FUNC_INFO << m_error.isFunction(); if (m_error.isFunction()) { QScriptValue error = m_func.engine()->newObject(); error.setProperty(QLatin1String("name"), name); error.setProperty(QLatin1String("text"), text); QList<QScriptValue> args; args << error; m_error.call(m_error, args); } deleteLater(); }
void ScriptInfoRequest::onStateChanged(qutim_sdk_0_3::InfoRequest::State state) { debug() << Q_FUNC_INFO << state; if (state == InfoRequest::Requesting) return; InfoRequest *request = qobject_cast<InfoRequest*>(parent()); Q_ASSERT(request); if (state == InfoRequest::LoadedFromCache) { request->deleteLater(); } else if (state == InfoRequest::Canceled) { handleError("Canceled", "Request was canceled"); return; } else if (state == InfoRequest::Error) { handleError("Error", request->errorString().toString()); return; } DataItem item = request->dataItem(); QList<QScriptValue> args; args << m_func.engine()->toScriptValue(item); debug() << Q_FUNC_INFO; Q_ASSERT(m_func.isFunction()); m_func.call(m_func, args); deleteLater(); }