Esempio n. 1
0
    /** On a successful download converts the string into an XML tree.
     */
    void XMLRequest::afterOperation()
    {
        m_xml_data = file_manager->createXMLTreeFromString(getData());
        if (hadDownloadError())
        {
            Log::error("XMLRequest::afterOperation",
                       "curl_easy_perform() failed: %s",
                       getDownloadErrorMessage());
        }

        m_success = false;
        std::string rec_success;
        if (m_xml_data->get("success", &rec_success))
        {
            m_success = (rec_success == "yes");
            m_xml_data->get("info", &m_info);

            if (!m_success)
            {
                Log::debug("XMLRequest::afterOperation",
                           "Request returned error: %ls", m_info.c_str());
            }
        }
        else
        {
            m_info = _("Unable to connect to the server. Check your internet "
                       "connection or try again later.");
        }
        HTTPRequest::afterOperation();
    }   // afterOperation
Esempio n. 2
0
 /** Callback after the request has been executed.
  */
 virtual void callback()
 {
     // If the request contains incorrect data, it will not have a
     // download error, but return an error string as return value:
     if(hadDownloadError() || getData()=="<h1>Bad Request (400)</h1>")
     {
         Log::error("HW report", "Error uploading the HW report.");
         if(hadDownloadError())
             Log::error("HW report", "%s", getDownloadErrorMessage());
         else
             Log::error("HW report", "%s", getData().c_str());
     }
     else
     {
         Log::info("HW report", "Upload successful.");
         UserConfigParams::m_last_hw_report_version = m_version;
         // The callback is executed by the main thread, so no need
         // to worry about locks when writing the file.
         user_config->saveConfig();
     }
 }   // callback