Save one indent level in ServiceDyndns::perform_update()
authorThomas Jarosch <thomas.jarosch@intra2net.com>
Mon, 18 Oct 2010 09:40:00 +0000 (11:40 +0200)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Mon, 18 Oct 2010 09:40:00 +0000 (11:40 +0200)
src/service_dyndns.cpp

index 9fb1dfc..1ab80f6 100644 (file)
@@ -104,43 +104,43 @@ int ServiceDyndns::perform_update(const std::string& ip)
     string url = BaseUrl;
     url.append(ip);
 
-    if ( HTTPHelp->is_initialized() )
+    if ( !HTTPHelp->is_initialized() )
     {
-        // Perform curl operation on given url
-        long http_status_code = HTTPHelp->http_get(url);
+        get_logger()->print_httphelper_not_initialized();
+        HTTPHelp->re_initialize();
+        return -1;
+    }
 
-        get_logger()->print_http_status_code(url,http_status_code);
+    // Perform curl operation on given url
+    long http_status_code = HTTPHelp->http_get(url);
+
+    get_logger()->print_http_status_code(url,http_status_code);
+
+    // HTTP operation completed successful.
+    // Now we have to parse the data received by curl,
+    // cause http status code is not significant for dyndns update errors
+    if ( http_status_code == 200 )
+    {
+        // Get the received http data.
+        string curl_data = HTTPHelp->get_curl_data();
 
-        // HTTP operation completed successful.
-        // Now we have to parse the data received by curl,
-        // cause http status code is not significant for dyndns update errors
-        if ( http_status_code == 200 )
+        if ( curl_data == good )
         {
-            // Get the received http data.
-            string curl_data = HTTPHelp->get_curl_data();
-
-            if ( curl_data == good )
-            {
-                return 0;
-            }
-            else if ( curl_data == "badauth" )
-            {
-                get_logger()->print_service_not_authorized(url,get_login(),get_password());
-            }
-            else
-            {
-                get_logger()->print_update_failure(url, curl_data);
-            }
+            return 0;
+        }
+        else if ( curl_data == "badauth" )
+        {
+            get_logger()->print_service_not_authorized(url,get_login(),get_password());
         }
         else
         {
-            get_logger()->print_update_failure(url,http_status_code);
+            get_logger()->print_update_failure(url, curl_data);
         }
     }
     else
     {
-        get_logger()->print_httphelper_not_initialized();
-        HTTPHelp->re_initialize();
+        get_logger()->print_update_failure(url,http_status_code);
     }
+
     return -1;
 }