Generalized print_http_not_authorized to print_service_not_authorized.
authorBjoern Sikora <bjoern.sikora@intra2net.com>
Tue, 15 Sep 2009 15:30:09 +0000 (17:30 +0200)
committerBjoern Sikora <bjoern.sikora@intra2net.com>
Tue, 15 Sep 2009 15:30:09 +0000 (17:30 +0200)
Added Log messages.

src/logger.cpp
src/logger.h
src/service_dhs.cpp
src/service_dyndns.cpp
src/service_dyns.cpp
src/service_easydns.cpp
src/service_gnudip.cpp
src/service_tzo.cpp
src/service_zoneedit.cpp

index f265eae..c8ca7d8 100644 (file)
@@ -831,7 +831,7 @@ void Logger::print_own_ipv6(const string& ip_addr_v6, const string& hostname) co
  */
 void Logger::print_error_hostname_to_ip(const string& exception, const string& hostname) const
 {
-    int level = 1;
+    int level = 0;
     if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
     {
         ostringstream msg;
@@ -1256,18 +1256,18 @@ void Logger::print_curl_data(const string& curl_writedata_buff) const
 
 
 /**
- * Not authorized to perform requested http operation
- * @param url The requested url
+ * Not authorized to perform requested update operation
+ * @param service The requested service.
  * @param username Username
  * @param password Password
  */
-void Logger::print_http_not_authorized(const string& url, const string& username, const string& password) const
+void Logger::print_service_not_authorized(const string& service, const string& username, const string& password) const
 {
     int level = 0;
     if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
     {
         ostringstream msg;
-        msg << "Not authorized to perform update operation on url: " << url << " Please check username and password: " << username << ":" << password << endl;
+        msg << "Not authorized to perform update operation on service: " << service << " Please check username and password: " << username << ":" << password << endl;
         log_warning(msg.str(),level);
     }
 }
@@ -1450,3 +1450,36 @@ void Logger::print_exception_md5_sum(const std::string& what) const
         log_error(msg.str(),level);
     }
 }
+
+
+/**
+ * An network exception occured.
+ * @param what The exception occured.
+ */
+void Logger::print_network_error(const std::string& what) const
+{
+    int level = 0;
+    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    {
+        ostringstream msg;
+        msg << "An netowrk exception occured: " << what << endl;
+        log_error(msg.str(),level);
+    }
+}
+
+
+/**
+ * An undefined protocol error occured.
+ * @param protocol The protocol
+ * @param error The error
+ */
+void Logger::print_undefined_protocol_error(const std::string& protocol, const std::string& error) const
+{
+    int level = 0;
+    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    {
+        ostringstream msg;
+        msg << "An undefined protocol error occured. Protocol: " << protocol << " Error: " << error << endl;
+        log_error(msg.str(),level);
+    }
+}
index 7d85cdb..55cdfb3 100644 (file)
@@ -186,7 +186,7 @@ public:
 
     void print_curl_data(const std::string& curl_writedata_buff) const;
 
-    void print_http_not_authorized(const std::string& url, const std::string& username, const std::string& password) const;
+    void print_service_not_authorized(const std::string& service, const std::string& username, const std::string& password) const;
 
     void print_http_status_code(const std::string& url, const long http_code) const;
 
@@ -209,6 +209,10 @@ public:
     void print_gnudip_requires_servername() const;
 
     void print_exception_md5_sum(const std::string& what) const;
+
+    void print_network_error(const std::string& what) const;
+
+    void print_undefined_protocol_error(const std::string& protocol, const std::string& error) const;
 };
 
 #endif
index e0ac01d..337cca9 100644 (file)
@@ -152,7 +152,7 @@ int ServiceDhs::perform_update(const std::string& ip)
     }
     else if ( http_status_code == 401 )
     {
-        get_logger()->print_http_not_authorized(url,get_login(),get_password());
+        get_logger()->print_service_not_authorized(url,get_login(),get_password());
     }
     else
     {
index 74dafb4..2748e66 100644 (file)
@@ -120,7 +120,7 @@ int ServiceDyndns::perform_update(const std::string& ip)
         }
         else if ( curl_data == "badauth" )
         {
-            get_logger()->print_http_not_authorized(url,get_login(),get_password());
+            get_logger()->print_service_not_authorized(url,get_login(),get_password());
         }
         else
         {
index 00e85fc..c113027 100644 (file)
@@ -125,7 +125,7 @@ int ServiceDyns::perform_update(const std::string& ip)
         }
         else if ( status_code == "401" )
         {
-            get_logger()->print_http_not_authorized(url,get_login(),get_password());
+            get_logger()->print_service_not_authorized(url,get_login(),get_password());
         }
         else
         {
index ca19579..9332eb9 100644 (file)
@@ -204,7 +204,7 @@ int ServiceEasydns::perform_update(const std::string& ip)
         }
         else if ( curl_data == "NOACCESS" )
         {
-            get_logger()->print_http_not_authorized(url,get_login(),get_password());
+            get_logger()->print_service_not_authorized(url,get_login(),get_password());
         }
         else
         {
index fe5064a..6c2a517 100644 (file)
@@ -57,8 +57,7 @@ ServiceGnudip::ServiceGnudip(const string& _protocol, const string& _gnudip_serv
 
     // create http helper class
     HTTPHelper::Ptr _http_help(new HTTPHelper(_logger,_proxy,_proxy_port,_login,_password));
-    HTTPHelp = _http_help;
-    _http_help.reset();
+    HTTPHelp.swap(_http_help);
 
     BaseUrl = assemble_base_url(get_hostname(),_gnudip_server);
 }
@@ -271,7 +270,7 @@ int ServiceGnudip::perform_update(const std::string& ip)
             }
             else if ( update_return_code == "1" )
             {
-                get_logger()->print_http_not_authorized(url,get_login(),get_password());
+                get_logger()->print_service_not_authorized(url,get_login(),get_password());
             }
             else
             {
index 31b7c57..ce3cb2f 100644 (file)
@@ -125,7 +125,7 @@ int ServiceTzo::perform_update(const std::string& ip)
         }
         else if ( status_code == "401" )
         {
-            get_logger()->print_http_not_authorized(url,get_login(),get_password());
+            get_logger()->print_service_not_authorized(url,get_login(),get_password());
         }
         else
         {
index 47e5e8d..a714146 100644 (file)
@@ -124,7 +124,7 @@ int ServiceZoneedit::perform_update(const std::string& ip)
     }
     else if ( http_status_code == 401 )
     {
-        get_logger()->print_http_not_authorized(url,get_login(),get_password());
+        get_logger()->print_service_not_authorized(url,get_login(),get_password());
     }
     else
     {