Website updated.
[irwi] / src / remote.cpp
index a3e66b5..f87c6c0 100644 (file)
@@ -62,6 +62,14 @@ Remote &Remote::operator=(const Remote &other)
     return *this;
 }
 
+bool Remote::operator==(const Remote &other) const
+{
+    return (m_name == other.m_name &&
+            m_mfg == other.m_mfg &&
+            m_rating == other.m_rating &&
+            m_voteCount == other.m_voteCount);
+}
+
 void Remote::saveToFile()
 {
     if (!m_name.isEmpty()) {
@@ -71,11 +79,13 @@ void Remote::saveToFile()
                     this, SLOT(remoteDownloadFinished(QNetworkReply*)));
         }
         QSettings settings(this);
-        QString url = settings.value("remoteUrl",
-            "http://mercury.wipsl.com/irwi/uploaded/").toString()
+        QString url = settings.value("baseUrl",
+            "http://mercury.wipsl.com/irwi/").toString()
+            + "uploaded/"
             + m_name;
         m_remoteNAM->get(QNetworkRequest(QUrl(url)));
         settings.setValue("remoteName", m_name);
+        settings.setValue("remoteMfg", m_mfg);
     }
 }
 
@@ -98,14 +108,17 @@ void Remote::updateInfo()
 
 void Remote::sendRating(Rating::Rating r)
 {
-    if (m_name != "") {
+    if (!m_name.isEmpty()) {
         if (!m_ratingNAM) {
             m_ratingNAM = new QNetworkAccessManager(this);
+            connect(m_ratingNAM, SIGNAL(finished(QNetworkReply *)),
+                    this, SIGNAL(ratingSent()));
+            connect(this, SIGNAL(ratingSent()), this, SLOT(updateInfo()));
         }
         QSettings settings(this);
         m_ratingNAM->get(QNetworkRequest(QUrl(
             settings.value("baseUrl",
-                "http://mercury.wipsl.com/irwi/db.xml").toString() 
+                "http://mercury.wipsl.com/irwi/").toString() 
             + "vote/"
             + ((r == Rating::Up) ? "up" : "down")
             + "?name=" 
@@ -136,6 +149,7 @@ void Remote::infoRequestFinished(QNetworkReply *reply)
     if (reply->error() == QNetworkReply::NoError) {
         m_rating    = QString(reply->readLine(20)).toInt();
         m_voteCount = QString(reply->readLine(20)).toInt();
+        m_mfg       = QString(reply->readLine(20)).trimmed();
     }
     reply->close();
     reply->deleteLater();