void PluginsListModel::replyFinished(QNetworkReply *reply) { QString contentType = reply->header(QNetworkRequest::ContentTypeHeader).toString();; if(contentType.contains("application/xml")) { QString replyText = reply->readAll(); if(reply->error() != QNetworkReply::NoError) { //Parse servers response QDomDocument doc("error"); if (!doc.setContent(replyText)) { //No XML to parse, user is probably disconnected return; }else { QDomElement docElem = doc.documentElement(); QDomElement message = docElem.firstChildElement("message"); if(!message.text().isEmpty()) { QMessageBox msgBox; msgBox.setWindowTitle("Failed to get plugin list"); msgBox.setIcon(QMessageBox::Warning); msgBox.setText("Failed to get plugin list from server.\nError was: " + message.text()); msgBox.exec(); } } }else { beginInsertRows(QModelIndex(), pluginList.count(), pluginList.count()); //No error in request QDomDocument doc("response"); if(!doc.setContent(replyText)) { qDebug() << "Failed to parse XML"; } QDomElement docElem = doc.documentElement(); QDomNode appPluginsNode = docElem.firstChildElement("AppPlugins"); QDomNode pluginNode = appPluginsNode.firstChild(); while(!pluginNode.isNull()) { parsePluginNode(pluginNode); pluginNode = pluginNode.nextSibling(); } endInsertRows(); emit layoutChanged(); } }else { QByteArray data = reply->readAll(); QPixmap p; p.loadFromData(data); QIcon icon = QIcon(p); //pluginList.at(idIconDowloading).icon = icon; } }
void PluginDialog::replyFinished(QNetworkReply *reply) { QString replyText = reply->readAll(); if(reply->error() != QNetworkReply::NoError) { //Parse servers response QDomDocument doc("error"); if (!doc.setContent(replyText)) { //No XML to parse, user is probably disconnected return; }else { QDomElement docElem = doc.documentElement(); QDomElement message = docElem.firstChildElement("message"); if(!message.text().isEmpty()) { WARNING("Failed to get plugin list from server. Error was: " + message.text()); QMessageBox::warning(this, "Failed to get plugin list", "Failed to get plugin list from server.\nError was: " + message.text()); } } }else { //No error in request addDefaultNodes(); QDomDocument doc("response"); if(!doc.setContent(replyText)) { WARNING("Failed to get plugin list from " + reply->request().url().toString() + ".\n Failed to parse reply as XML"); QMessageBox::warning(this, "Failed to get plugin list", "Failed to get plugin list from " + reply->request().url().toString() + ". Failed to parse reply as XML."); } QDomElement docElem = doc.documentElement(); QDomNode pluginNode = docElem.firstChild(); while(!pluginNode.isNull()) { parsePluginNode(pluginNode); pluginNode = pluginNode.nextSibling(); } //Show the plugins in the tree stdModel.removeRow(0); buildTree(); } }