Use enum for perform_update() return code. Made function protected
[bpdyndnsd] / src / service_gnudip.cpp
index e72ee5a..76b9420 100644 (file)
@@ -221,7 +221,7 @@ string ServiceGnudip::assemble_update_url(const string& salt, const string& curr
  * @param ip IP Address to set.
  * @return 0 if all is fine, -1 otherwise.
  */
-int ServiceGnudip::perform_update(const std::string& ip)
+Service::UpdateErrorCode ServiceGnudip::perform_update(const std::string& ip)
 {
     if ( HTTPHelp->is_initialized() )
     {
@@ -241,7 +241,7 @@ int ServiceGnudip::perform_update(const std::string& ip)
             if ( salt_time_sign.empty() )
             {
                 get_logger()->print_could_not_parse_received_data(curl_data);
-                return -1;
+                return GenericError;
             }
 
             // at this point we have salt, time and sign parsed successfully
@@ -271,12 +271,12 @@ int ServiceGnudip::perform_update(const std::string& ip)
             catch ( exception& e )
             {
                 get_logger()->print_exception_md5_sum(e.what());
-                return -1;
+                return GenericError;
             }
             catch ( ... )
             {
                 get_logger()->print_exception_md5_sum("Unknown exception");
-                return -1;
+                return GenericError;
             }
 
             // append "." and salt and compute md5 sum and get the HEX representation
@@ -291,12 +291,12 @@ int ServiceGnudip::perform_update(const std::string& ip)
             catch ( exception& e )
             {
                 get_logger()->print_exception_md5_sum(e.what());
-                return -1;
+                return GenericError;
             }
             catch ( ... )
             {
                 get_logger()->print_exception_md5_sum("Unknown exception");
-                return -1;
+                return GenericError;
             }
 
             // Now its time to issue the second http_get operation
@@ -314,7 +314,7 @@ int ServiceGnudip::perform_update(const std::string& ip)
                 string update_return_code = parse_return_code(curl_data);
                 if ( update_return_code == "0" )
                 {
-                    return 0;
+                    return UpdateOk;
                 }
                 else if ( update_return_code == "1" )
                 {
@@ -342,5 +342,5 @@ int ServiceGnudip::perform_update(const std::string& ip)
         get_logger()->print_httphelper_not_initialized();
         HTTPHelp->re_initialize();
     }
-    return -1;
+    return GenericError;
 }