Use enum for perform_update() return code. Made function protected
[bpdyndnsd] / src / service_dyndns.cpp
index 0939d84..5d7b8b8 100644 (file)
@@ -100,7 +100,7 @@ string ServiceDyndns::assemble_base_url(const string& fqhn) const
  * @param ip IP Address to set.
  * @return 0 if all is fine, -1 otherwise.
  */
-int ServiceDyndns::perform_update(const std::string& ip)
+Service::UpdateErrorCode ServiceDyndns::perform_update(const std::string& ip)
 {
     string url = BaseUrl;
     url.append(ip);
@@ -109,7 +109,7 @@ int ServiceDyndns::perform_update(const std::string& ip)
     {
         get_logger()->print_httphelper_not_initialized();
         HTTPHelp->re_initialize();
-        return -1;
+        return GenericError;
     }
 
     // Perform curl operation on given url
@@ -127,19 +127,21 @@ int ServiceDyndns::perform_update(const std::string& ip)
 
         if ( curl_data.compare(0,4,"good") == 0 )
         {
-            return 0;
+            return UpdateOk;
         }
         else if (curl_data.compare(0,5,"nochg") == 0 )
         {
             // IP didn't change, this might indicate a problem at the
             // dyndns backend or another client is running elsewhere.
-            return 0;
+            get_logger()->print_update_failure(url, curl_data);
+            return UpdateOk;
         }
         else if (curl_data.compare(0,5,"abuse") == 0 )
         {
             // Account is blocked. Log it as a successful update
             // so the IP address will be "burnt" until it changes.
-            return 0;
+            get_logger()->print_update_failure(url, curl_data);
+            return UpdateOk;
         }
         else if ( curl_data == "badauth" )
         {
@@ -155,5 +157,5 @@ int ServiceDyndns::perform_update(const std::string& ip)
         get_logger()->print_update_failure(url,http_status_code);
     }
 
-    return -1;
+    return GenericError;
 }