<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>src/bcpp.conf</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -19,21 +19,27 @@
 #include &quot;../database/Database.h&quot;
 #include &quot;../internal.h&quot;
 
-Cloud::Cloud(int myNodeID, mySQLData myDBData){
+Cloud::Cloud(int myNodeID, mySQLData myDBData)
+{
   nodeID = myNodeID;
   dbData = myDBData;
 }
 
-int Cloud::checkNodeID(unsigned int nodeID, Database db){
-  // Connected to database.  
+
+int Cloud::checkNodeID(unsigned int nodeID, Database db)
+{
+  // Connected to database.
   stringstream query;
   query &lt;&lt; &quot;SELECT id FROM nodes WHERE id = &quot; &lt;&lt; nodeID;
 
   // Count if there is a node with the given ID.
-  if(db.getNumOfResults(query.str()) == 1){
+  if(db.getNumOfResults(query.str()) == 1)
+  {
     // Yes.
     return 1;
-  }else{
+  }
+  else
+  {
     // No.
     return 0;
   }
@@ -42,159 +48,202 @@ int Cloud::checkNodeID(unsigned int nodeID, Database db){
   return -1;
 }
 
-bool Cloud::setTakeoff(unsigned int nodeID, Database db){
+
+bool Cloud::setTakeoff(unsigned int nodeID, Database db)
+{
   time_t rawtime;
-	time(&amp;rawtime);
-  
+  time(&amp;rawtime);
+
   stringstream query;
   query &lt;&lt; &quot;UPDATE nodes SET takeoff = &quot; &lt;&lt; rawtime &lt;&lt; &quot; WHERE id = &quot; &lt;&lt; nodeID;
 
   // Perform the query.
-  if(db.setQuery(db.getHandle(), query.str())){
+  if(db.setQuery(db.getHandle(), query.str()))
+  {
     // Query has been performed. No problems.
     return 1;
-  }else{
+  }
+  else
+  {
     // An error occured.
     return 0;
   }
 }
 
-bool Cloud::updateOwnStatus(Database db){
+
+bool Cloud::updateOwnStatus(Database db)
+{
   time_t rawtime;
-	time(&amp;rawtime);
-  
+  time(&amp;rawtime);
+
   stringstream query;
   query &lt;&lt; &quot;UPDATE nodes SET last_update = &quot;
-        &lt;&lt; rawtime
-        &lt;&lt; &quot;, consumption = 1 WHERE id = &quot;
-        &lt;&lt; nodeID;
+    &lt;&lt; rawtime
+    &lt;&lt; &quot;, consumption = 1 WHERE id = &quot;
+    &lt;&lt; nodeID;
 
   // Perform the query.
-  if(db.setQuery(db.getHandle(), query.str())){
+  if(db.setQuery(db.getHandle(), query.str()))
+  {
     // Query has been performed. No problems.
     return 1;
-  }else{
+  }
+  else
+  {
     // An error occured.
     return 0;
   }
 }
 
-unsigned int Cloud::getNumberOfOwnServices(Database db){
+
+unsigned int Cloud::getNumberOfOwnServices(Database db)
+{
   stringstream query;
   query &lt;&lt; &quot;SELECT id FROM services WHERE node_id = &quot; &lt;&lt; nodeID;
   return db.getNumOfResults(query.str());
 }
 
-unsigned int Cloud::getIdOfNodeWithMostServices(Database db){
+
+unsigned int Cloud::getIdOfNodeWithMostServices(Database db)
+{
   time_t rawtime;
-	time(&amp;rawtime);
+  time(&amp;rawtime);
 
   stringstream query;
   query &lt;&lt; &quot;SELECT s.node_id, count(*) AS count &quot;
-           &quot;FROM services AS s &quot;
-           &quot;LEFT JOIN nodes AS n ON s.node_id = n.id &quot;
-           &quot;WHERE n.last_update &gt;  &quot; &lt;&lt; rawtime-10 &lt;&lt; &quot; &quot;
-           &quot;GROUP BY s.node_id ORDER BY count DESC&quot;;
+    &quot;FROM services AS s &quot;
+    &quot;LEFT JOIN nodes AS n ON s.node_id = n.id &quot;
+    &quot;WHERE n.last_update &gt;  &quot; &lt;&lt; rawtime-10 &lt;&lt; &quot; &quot;
+    &quot;GROUP BY s.node_id ORDER BY count DESC&quot;;
   return(stringToInteger(db.sGetQuery(query.str())));
 }
- 
-unsigned int Cloud::getNumberOfServicesFromNode(unsigned int foreignNodeID, Database db){
+
+
+unsigned int Cloud::getNumberOfServicesFromNode(unsigned int foreignNodeID, Database db)
+{
   stringstream query;
   query &lt;&lt; &quot;SELECT id FROM services WHERE node_id = &quot;
-        &lt;&lt; foreignNodeID;
+    &lt;&lt; foreignNodeID;
   return db.getNumOfResults(query.str());
 }
 
-bool Cloud::action_requestServices(unsigned int count, unsigned int from_node, Database db){
+
+bool Cloud::action_requestServices(unsigned int count, unsigned int from_node, Database db)
+{
   return storeAction(from_node, &quot;service_request&quot;, integerToString(count), generateConversationID(), db);
 }
 
-bool Cloud::storeAction(unsigned int receiver, string type, string value, unsigned int conversation_id, Database db){
+
+bool Cloud::storeAction(unsigned int receiver, string type, string value, unsigned int conversation_id, Database db)
+{
   stringstream query;
   query &lt;&lt; &quot;INSERT INTO nodecommunications(sender_id, receiver_id, type, value, timestamp, conversation_id) &quot;
-           &quot;VALUES(&quot;
-        &lt;&lt; getOwnID()
-        &lt;&lt; &quot;,&quot;
-        &lt;&lt; receiver
-        &lt;&lt; &quot;,'&quot;
-        &lt;&lt; type
-        &lt;&lt; &quot;','&quot;
-        &lt;&lt; value
-        &lt;&lt; &quot;', NOW(), &quot;
-        &lt;&lt; conversation_id
-        &lt;&lt; &quot;)&quot;;
-
-   return db.setQuery(db.getHandle(), query.str());
-}
-
-bool Cloud::action_replyServiceRequest(unsigned int handoverRequester, string status, unsigned int conversationID, Database db){
+    &quot;VALUES(&quot;
+    &lt;&lt; getOwnID()
+    &lt;&lt; &quot;,&quot;
+    &lt;&lt; receiver
+    &lt;&lt; &quot;,'&quot;
+    &lt;&lt; type
+    &lt;&lt; &quot;','&quot;
+    &lt;&lt; value
+    &lt;&lt; &quot;', NOW(), &quot;
+    &lt;&lt; conversation_id
+    &lt;&lt; &quot;)&quot;;
+
+  return db.setQuery(db.getHandle(), query.str());
+}
+
+
+bool Cloud::action_replyServiceRequest(unsigned int handoverRequester, string status, unsigned int conversationID, Database db)
+{
   return storeAction(handoverRequester, &quot;service_request_response&quot;, status, conversationID, db);
 }
 
-void Cloud::action_logEvent(string message, Database db){
+
+void Cloud::action_logEvent(string message, Database db)
+{
   storeAction(0, &quot;log_message&quot;, message, generateConversationID(), db);
 }
 
-unsigned int Cloud::checkForServiceHandoverRequest(Database db){
+
+unsigned int Cloud::checkForServiceHandoverRequest(Database db)
+{
   stringstream query;
   query &lt;&lt; &quot;SELECT conversation_id &quot;
-           &quot;FROM nodecommunications &quot;
-           &quot;WHERE type = 'service_request' &quot;
-           &quot;AND receiver_id = &quot;
-        &lt;&lt; getOwnID()
-        &lt;&lt; &quot; AND TIMEDIFF(timestamp, NOW()) &lt; '00:00:15' ORDER BY timestamp DESC &quot;
-        &lt;&lt; &quot;LIMIT 1&quot;;
+    &quot;FROM nodecommunications &quot;
+    &quot;WHERE type = 'service_request' &quot;
+    &quot;AND receiver_id = &quot;
+    &lt;&lt; getOwnID()
+    &lt;&lt; &quot; AND TIMEDIFF(timestamp, NOW()) &lt; '00:00:15' ORDER BY timestamp DESC &quot;
+    &lt;&lt; &quot;LIMIT 1&quot;;
   string result = db.sGetQuery(query.str());
-  if(result == &quot;NULL&quot;){
+  if(result == &quot;NULL&quot;)
+  {
     return 0;
-  }else{
+  }
+  else
+  {
     return stringToInteger(result);
   }
 }
 
-unsigned int Cloud::getNumberOfRequestedServices(Database db, unsigned int conversationID){
+
+unsigned int Cloud::getNumberOfRequestedServices(Database db, unsigned int conversationID)
+{
   stringstream query;
   query &lt;&lt; &quot;SELECT value &quot;
-           &quot;FROM nodecommunications &quot;
-           &quot;WHERE conversation_id = &quot;
-        &lt;&lt; conversationID
-        &lt;&lt; &quot; ORDER BY timestamp DESC&quot;
-        &lt;&lt; &quot; LIMIT 1&quot;;
+    &quot;FROM nodecommunications &quot;
+    &quot;WHERE conversation_id = &quot;
+    &lt;&lt; conversationID
+    &lt;&lt; &quot; ORDER BY timestamp DESC&quot;
+    &lt;&lt; &quot; LIMIT 1&quot;;
   string result = db.sGetQuery(query.str());
-  if(result == &quot;NULL&quot;){
+  if(result == &quot;NULL&quot;)
+  {
     return 0;
-  }else{
+  }
+  else
+  {
     return stringToInteger(result);
   }
 }
 
-unsigned int Cloud::getNodeIdOfHandoverRequester(Database db, unsigned int conversationID){
+
+unsigned int Cloud::getNodeIdOfHandoverRequester(Database db, unsigned int conversationID)
+{
   stringstream query;
   query &lt;&lt; &quot;SELECT sender_id &quot;
-           &quot;FROM nodecommunications &quot;
-           &quot;WHERE conversation_id = &quot;
-        &lt;&lt; conversationID
-        &lt;&lt; &quot; ORDER BY timestamp DESC &quot;
-        &lt;&lt; &quot;LIMIT 1&quot;;
+    &quot;FROM nodecommunications &quot;
+    &quot;WHERE conversation_id = &quot;
+    &lt;&lt; conversationID
+    &lt;&lt; &quot; ORDER BY timestamp DESC &quot;
+    &lt;&lt; &quot;LIMIT 1&quot;;
   string result = db.sGetQuery(query.str());
-  if(result == &quot;NULL&quot;){
+  if(result == &quot;NULL&quot;)
+  {
     return 0;
-  }else{
+  }
+  else
+  {
     return stringToInteger(result);
   }
 }
 
-bool Cloud::handOverServices(unsigned int numberOfServices, unsigned int handoverRequester, Database db){
+
+bool Cloud::handOverServices(unsigned int numberOfServices, unsigned int handoverRequester, Database db)
+{
   stringstream query;
   query &lt;&lt; &quot;UPDATE services SET reserved_for = &quot; &lt;&lt; handoverRequester
-        &lt;&lt; &quot;, reserved_on = NOW() &quot;
-           &quot;WHERE node_id = &quot;
-        &lt;&lt; getOwnID()
-        &lt;&lt; &quot; LIMIT &quot; &lt;&lt; numberOfServices;
+    &lt;&lt; &quot;, reserved_on = NOW() &quot;
+    &quot;WHERE node_id = &quot;
+    &lt;&lt; getOwnID()
+    &lt;&lt; &quot; LIMIT &quot; &lt;&lt; numberOfServices;
   return db.setQuery(db.getHandle(), query.str());
 }
 
-unsigned int Cloud::generateConversationID(){
+
+unsigned int Cloud::generateConversationID()
+{
   // Generate random number.
   struct timeval tv;
   gettimeofday(&amp;tv, NULL);
@@ -208,7 +257,8 @@ unsigned int Cloud::generateConversationID(){
   return result;
 }
 
-unsigned int Cloud::getOwnID(){
+
+unsigned int Cloud::getOwnID()
+{
   return nodeID;
 }
-</diff>
      <filename>src/cloud/Cloud.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -21,7 +21,8 @@
 #include &quot;../internal.h&quot;
 #include &quot;../database/Database.h&quot;
 
-class Cloud{
+class Cloud
+{
   private:
     int nodeID;
     mySQLData dbData;
@@ -54,5 +55,4 @@ class Cloud{
     static int checkNodeID(unsigned int nodeID, Database db);
     static bool setTakeoff(unsigned int nodeID, Database db);
 };
-
-#endif /*CLOUD_H_*/
+#endif                                            /*CLOUD_H_*/</diff>
      <filename>src/cloud/Cloud.h</filename>
    </modified>
    <modified>
      <diff>@@ -44,7 +44,6 @@
 
 #include &quot;internal.h&quot;
 
-
 mySQLData dbData;
 mailingData mailData;
 XMPPData xmppData;
@@ -58,9 +57,11 @@ bool clientHandler = 0;
 
 gnutls_anon_server_credentials_t anoncred;
 
-int percentalDifference(int i1, int i2){
+int percentalDifference(int i1, int i2)
+{
   // Check if there is a difference.
-  if(i1 == i2){
+  if(i1 == i2)
+  {
     return 0;
   }
 
@@ -68,10 +69,13 @@ int percentalDifference(int i1, int i2){
   int less = 0;
 
   // Find out which is the higher value.
-  if(i1 &gt; i2){
+  if(i1 &gt; i2)
+  {
     more = i1;
     less = i2;
-  }else{
+  }
+  else
+  {
     more = i2;
     less = i1;
   }
@@ -80,116 +84,148 @@ int percentalDifference(int i1, int i2){
   return 100-((less*100)/more);
 }
 
-int stringToInteger(string st){
-	int result;
-	if(stringstream(st) &gt;&gt; result){
-		return result;
-	}else{
-		return 0;
-	}
+
+int stringToInteger(string st)
+{
+  int result;
+  if(stringstream(st) &gt;&gt; result)
+  {
+    return result;
+  }
+  else
+  {
+    return 0;
+  }
 }
 
-string integerToString(int i){
+
+string integerToString(int i)
+{
   stringstream res;
   res &lt;&lt; i;
   return res.str();
 }
 
-bool numOnly(string checkMe){
-	bool result;
-	if(checkMe.empty())
-		return 0;
-	int checkMe_length = checkMe.length();
-		for(int i=0; i &lt; checkMe_length; i++) {
-  			if(isdigit(checkMe.at(i))){
-				result = 1;
-  			}else{
-  				// Stop and return false if a non-digit char was detected.
-  				return 0;
-  				break;
-  			}
-  		}
-	return result;
+
+bool numOnly(string checkMe)
+{
+  bool result;
+  if(checkMe.empty())
+    return 0;
+  int checkMe_length = checkMe.length();
+  for(int i=0; i &lt; checkMe_length; i++)
+  {
+    if(isdigit(checkMe.at(i)))
+    {
+      result = 1;
+    }
+    else
+    {
+      // Stop and return false if a non-digit char was detected.
+      return 0;
+      break;
+    }
+  }
+  return result;
 }
 
-string selfTest(int port, int loglevel){
-	// Check if port is numOnly.
-	if(port &lt;= 0)
-		return &quot;Port is in wrong format. Only numbers allowed.&quot;;
-
-	// Check if logfile is writable.
-	ofstream testlog(LOGFILE, ios::app);
-	if(testlog.fail()){
-		testlog.close();
-		// Opening failed. Try to create the logfile.
-		if(fopen(LOGFILE,&quot;w&quot;) == NULL)
-			return &quot;Could not open logfile. Could not create logfile.&quot;;
-		ofstream testlog(LOGFILE, ios::app);
-		// Could not open (maybe) created file. Abort.
-		if(testlog.fail()) return &quot;Could not open logfile for writing.&quot;
-				&quot;						Check permissions and if file exists.&quot;;
-		testlog.close();
-	}
-
-	// Check if loglevel value is in range.
-	if(loglevel &lt; 0 || loglevel &gt; 1) return &quot;Loglevel must be between 0 or 1.&quot;;
-
-	return &quot;1&quot;;
+
+string selfTest(int port, int loglevel)
+{
+  // Check if port is numOnly.
+  if(port &lt;= 0)
+    return &quot;Port is in wrong format. Only numbers allowed.&quot;;
+
+  // Check if logfile is writable.
+  ofstream testlog(LOGFILE, ios::app);
+  if(testlog.fail())
+  {
+    testlog.close();
+    // Opening failed. Try to create the logfile.
+    if(fopen(LOGFILE,&quot;w&quot;) == NULL)
+      return &quot;Could not open logfile. Could not create logfile.&quot;;
+    ofstream testlog(LOGFILE, ios::app);
+    // Could not open (maybe) created file. Abort.
+    if(testlog.fail()) return &quot;Could not open logfile for writing.&quot;
+        &quot;						Check permissions and if file exists.&quot;;
+    testlog.close();
+  }
+
+  // Check if loglevel value is in range.
+  if(loglevel &lt; 0 || loglevel &gt; 1) return &quot;Loglevel must be between 0 or 1.&quot;;
+
+  return &quot;1&quot;;
 }
 
-string noSpaces(string str){
-	int i;
-	if(str.length() &gt; 0){
-		int strlen = str.length();
-		stringstream newstr;
-		for(i = 0; i &lt; strlen; i++){
-			if(!isspace(str.at(i))){
-				newstr &lt;&lt; str.at(i);
-			}
-		}
-		return newstr.str();
-	}
-	return &quot;err&quot;;
+
+string noSpaces(string str)
+{
+  int i;
+  if(str.length() &gt; 0)
+  {
+    int strlen = str.length();
+    stringstream newstr;
+    for(i = 0; i &lt; strlen; i++)
+    {
+      if(!isspace(str.at(i)))
+      {
+        newstr &lt;&lt; str.at(i);
+      }
+    }
+    return newstr.str();
+  }
+  return &quot;err&quot;;
 }
 
-char* noNewLine(char* str, int size ){
-    int i;
-    for (i = 0; i &lt; size; ++i){
-        if(str[i] == '\n' ){
-            str[i] = '\0';
-            return str;
-        }
+
+char* noNewLine(char* str, int size )
+{
+  int i;
+  for (i = 0; i &lt; size; ++i)
+  {
+    if(str[i] == '\n' )
+    {
+      str[i] = '\0';
+      return str;
     }
-    return str;
+  }
+  return str;
 }
 
-string noNewLineS(string str){
-	stringstream newStr;
-	istringstream iss(str);
-	string token;
 
-	while(getline(iss, token, '\n')){
-		newStr &lt;&lt; token &lt;&lt; &quot; &quot;;
-	}
+string noNewLineS(string str)
+{
+  stringstream newStr;
+  istringstream iss(str);
+  string token;
 
-    return newStr.str();
+  while(getline(iss, token, '\n'))
+  {
+    newStr &lt;&lt; token &lt;&lt; &quot; &quot;;
+  }
+
+  return newStr.str();
 }
 
-unsigned long resolveName(char* server){
-	if(strlen(server) &lt;= 0)
-		return 0;
-	struct hostent *host;
-	if((host = gethostbyname(server)) == NULL)
-		return 0;
-	return *((unsigned long*) host-&gt;h_addr_list[0]);
+
+unsigned long resolveName(char* server)
+{
+  if(strlen(server) &lt;= 0)
+    return 0;
+  struct hostent *host;
+  if((host = gethostbyname(server)) == NULL)
+    return 0;
+  return *((unsigned long*) host-&gt;h_addr_list[0]);
 }
 
-void* serviceHandler(void* arg){
+
+void* serviceHandler(void* arg)
+{
   Log::debug(debug, &quot;serviceHandler(): Started.&quot;);
-	Log log(LOGFILE, dbData);
-	Database db(dbData);
+  Log log(LOGFILE, dbData);
+  Database db(dbData);
 
-	// Calculate a kinda random ID for this handler.
+  // Calculate a kinda random ID for this handler.
   static timeval tv;
   static timeval tv2;
   static struct timezone tz;
@@ -201,10 +237,11 @@ void* serviceHandler(void* arg){
   handlerIDStringS &lt;&lt; handlerID;
   string handlerIDString = handlerIDStringS.str();
 
-	Services service(dbData, handlerID);
+  Services service(dbData, handlerID);
 
-	// Try to establish a database connection.
-	if(db.initConnection()){
+  // Try to establish a database connection.
+  if(db.initConnection())
+  {
     Log::debug(debug, &quot;serviceHandler() &quot; + handlerIDString + &quot;: Connected to database.&quot;);
     time_t rawtime;
     time(&amp;rawtime);
@@ -217,116 +254,133 @@ void* serviceHandler(void* arg){
     //         &quot;OR handler = 0 OR lastcheck &lt; &quot;
     //      &lt;&lt; twoMinutesAgo;
     query &lt;&lt; &quot;SELECT id FROM services WHERE handler = 0 OR handler IS NULL OR lastcheck &lt; &quot;
-          &lt;&lt; twoMinutesAgo;
-		if(mysql_real_query(db.getHandle(), query.str().c_str(), strlen(query.str().c_str())) == 0){
-      		Log::debug(debug, &quot;serviceHandler() &quot; + handlerIDString + &quot;: Initial query succeeded.&quot;);
-			// Query successful.
-			MYSQL_ROW serviceResult;
-			MYSQL_RES* res = mysql_store_result(db.getHandle());
-			serviceResult = mysql_fetch_row(res);
-			if(mysql_num_rows(res) &gt; 0){
-        		// We fetched a service to handle.
-        		Log::debug(debug, &quot;serviceHandler() &quot; + handlerIDString + &quot;: A service to handle has been fetched.&quot;);
-				if(serviceResult[0] == NULL){
-					// We got NULL fields.
-          			Log::debug(debug, &quot;serviceHandler() &quot; + handlerIDString + &quot;: ID is NULL. Terminating this thread.&quot;);
-					mysql_free_result(res);
-					mysql_close(db.getHandle());
-					return arg;
-				}
-				
+      &lt;&lt; twoMinutesAgo;
+    if(mysql_real_query(db.getHandle(), query.str().c_str(), strlen(query.str().c_str())) == 0)
+    {
+      Log::debug(debug, &quot;serviceHandler() &quot; + handlerIDString + &quot;: Initial query succeeded.&quot;);
+      // Query successful.
+      MYSQL_ROW serviceResult;
+      MYSQL_RES* res = mysql_store_result(db.getHandle());
+      serviceResult = mysql_fetch_row(res);
+      if(mysql_num_rows(res) &gt; 0)
+      {
+        // We fetched a service to handle.
+        Log::debug(debug, &quot;serviceHandler() &quot; + handlerIDString + &quot;: A service to handle has been fetched.&quot;);
+        if(serviceResult[0] == NULL)
+        {
+          // We got NULL fields.
+          Log::debug(debug, &quot;serviceHandler() &quot; + handlerIDString + &quot;: ID is NULL. Terminating this thread.&quot;);
+          mysql_free_result(res);
+          mysql_close(db.getHandle());
+          return arg;
+        }
+
         // Tell the service object it's own ID.
         service.setServiceID(stringToInteger(serviceResult[0]));
 
         // Initially fill with settings. This will be repeated before every check.
-        if(!service.updateSettings()){
+        if(!service.updateSettings())
+        {
           // Could not store the response time.
           Log::debug(debug, &quot;serviceHandler() &quot; + handlerIDString + &quot;: Could not initially set service settings.&quot;);
           log.putLog(2, &quot;xxx&quot;, &quot;Could not initially set service settings.&quot;);
           service.updateStatus(SERVICE_STATE_INTERR);
-				  mysql_free_result(res);
-				  mysql_close(db.getHandle());
-				  return arg;
+          mysql_free_result(res);
+          mysql_close(db.getHandle());
+          return arg;
         }
         Log::debug(debug, &quot;serviceHandler() &quot; + handlerIDString + &quot;: Service setings have been set initially.&quot;);
-		}else{
+      }
+      else
+      {
         Log::debug(debug, &quot;serviceHandler() &quot; + handlerIDString + &quot;: No service to handle found. Terminating this thread.&quot;);
-				// No services have been fetched.
-				mysql_free_result(res);
-				mysql_close(db.getHandle());
-				return arg;
-			}
-			mysql_free_result(res);
-		}else{
+        // No services have been fetched.
+        mysql_free_result(res);
+        mysql_close(db.getHandle());
+        return arg;
+      }
+      mysql_free_result(res);
+    }
+    else
+    {
       Log::debug(debug, &quot;serviceHandler() &quot; + handlerIDString + &quot;: Could not fetch service to handle. Terminating this thread.&quot;);
-			log.putLog(2, &quot;2000&quot;, &quot;Could not fetch service to handle.&quot;);
-			mysql_close(db.getHandle());
-			return arg;
-		}
-
-		// The service data is now available in MYSQL_ROW service.
-
-		// Announce that this handler handles the service.
-		stringstream announce;
-		announce	&lt;&lt; &quot;UPDATE services SET handler = &quot;
-					&lt;&lt; service.getHandlerID()
-          &lt;&lt; &quot;, node_id = &quot;
-          &lt;&lt; nodeID
-          &lt;&lt; &quot;, reserved_for = NULL, reserved_on = NULL&quot;
-					&lt;&lt; &quot; WHERE id = &quot;
-					&lt;&lt; service.getServiceID();
-
-		if(!db.setQuery(db.getHandle(), announce.str())){
+      log.putLog(2, &quot;2000&quot;, &quot;Could not fetch service to handle.&quot;);
+      mysql_close(db.getHandle());
+      return arg;
+    }
+
+    // The service data is now available in MYSQL_ROW service.
+
+    // Announce that this handler handles the service.
+    stringstream announce;
+    announce  &lt;&lt; &quot;UPDATE services SET handler = &quot;
+      &lt;&lt; service.getHandlerID()
+      &lt;&lt; &quot;, node_id = &quot;
+      &lt;&lt; nodeID
+      &lt;&lt; &quot;, reserved_for = NULL, reserved_on = NULL&quot;
+      &lt;&lt; &quot; WHERE id = &quot;
+      &lt;&lt; service.getServiceID();
+
+    if(!db.setQuery(db.getHandle(), announce.str()))
+    {
       Log::debug(debug, &quot;serviceHandler() &quot; + handlerIDString + &quot;: Could not announce handling of this service.&quot;);
-			log.putLog(2, &quot;3000&quot;, &quot;Could not update service handler.&quot;);
-			mysql_close(db.getHandle());
-			return arg;
-		}
-      
+      log.putLog(2, &quot;3000&quot;, &quot;Could not update service handler.&quot;);
+      mysql_close(db.getHandle());
+      return arg;
+    }
+
     Log::debug(debug, &quot;serviceHandler() &quot; + handlerIDString + &quot;: Handling of this service announced.&quot;);
 
-		mysql_close(db.getHandle());
+    mysql_close(db.getHandle());
 
-	}else{
-		// Could not establish a database connection. Close this thread.
+  }
+  else
+  {
+    // Could not establish a database connection. Close this thread.
     Log::debug(debug, &quot;serviceHandler() &quot; + handlerIDString + &quot;: Could not establish connection to database. Terminating this thread.&quot;);
-		return arg;
-	}
+    return arg;
+  }
 
-	// We got all the service data.
+  // We got all the service data.
 
-	// Run forever
-	while(1){
-		// Check if this service is still wanted to be checked for.
+  // Run forever
+  while(1)
+  {
+    // Check if this service is still wanted to be checked for.
     Log::debug(debug, &quot;serviceHandler() &quot; + handlerIDString + &quot;: Entered checking loop.&quot;);
-		if(db.initConnection()){
+    if(db.initConnection())
+    {
       Log::debug(debug, &quot;serviceHandler() &quot; + handlerIDString + &quot; [loop]: Connected to database.&quot;);
-			stringstream checkService;
-			checkService	&lt;&lt; &quot;SELECT id FROM services WHERE id = &quot;
-							&lt;&lt; service.getServiceID();
-            //&lt;&lt; &quot; AND (reserved_for = &quot; &lt;&lt; nodeID &lt;&lt; &quot; OR reserved_for IS NULL)&quot;;
-			unsigned int serviceState = db.getNumOfResults(checkService.str());
-			if(serviceState &lt;= 0){
-				stringstream message;
-				message	&lt;&lt; &quot;Closing service handler #&quot; &lt;&lt; service.getHandlerID()
-						&lt;&lt; &quot; as it is not needed anymore.&quot;;
+      stringstream checkService;
+      checkService  &lt;&lt; &quot;SELECT id FROM services WHERE id = &quot;
+        &lt;&lt; service.getServiceID();
+      //&lt;&lt; &quot; AND (reserved_for = &quot; &lt;&lt; nodeID &lt;&lt; &quot; OR reserved_for IS NULL)&quot;;
+      unsigned int serviceState = db.getNumOfResults(checkService.str());
+      if(serviceState &lt;= 0)
+      {
+        stringstream message;
+        message &lt;&lt; &quot;Closing service handler #&quot; &lt;&lt; service.getHandlerID()
+          &lt;&lt; &quot; as it is not needed anymore.&quot;;
         Log::debug(debug, &quot;serviceHandler() &quot; + handlerIDString + &quot; [loop]: Closing service handler because serviceState is &lt;= 0. Terminating this thread.&quot;);
-				log.putLog(0, &quot;NOTICE&quot;, message.str());
-				mysql_close(db.getHandle());
-				return arg;
-			}
-			mysql_close(db.getHandle());
-		}else{
+        log.putLog(0, &quot;NOTICE&quot;, message.str());
+        mysql_close(db.getHandle());
+        return arg;
+      }
+      mysql_close(db.getHandle());
+    }
+    else
+    {
       Log::debug(debug, &quot;serviceHandler() &quot; + handlerIDString + &quot; [loop]: Could not connect to database. Closing this handler.&quot;);
       log.putLog(2, &quot;xxx&quot;, &quot;Could not check if service still needs to be checked (Database error). Closing this handler.&quot;);
       return arg;
-		}
+    }
 
     Log::debug(debug, &quot;serviceHandler() &quot; + handlerIDString + &quot; [loop]: We still want to check this service.&quot;);
     Log::debug(debug, &quot;serviceHandler() &quot; + handlerIDString + &quot; [loop]: Updating service settings.&quot;);
 
     // Update settings.
-    if(!service.updateSettings()){
+    if(!service.updateSettings())
+    {
       // Could not store the response time.
       Log::debug(debug, &quot;serviceHandler() &quot; + handlerIDString + &quot; [loop]: Could not update service settings. Closing this handler.&quot;);
       log.putLog(2, &quot;xxx&quot;, &quot;Could not update service settings. Closing this handler.&quot;);
@@ -336,37 +390,46 @@ void* serviceHandler(void* arg){
     Log::debug(debug, &quot;serviceHandler() &quot; + handlerIDString + &quot; [loop]: Service settings updated.&quot;);
     Log::debug(debug, &quot;serviceHandler() &quot; + handlerIDString + &quot; [loop]: Starting check.&quot;);
 
-		// Check service twice and build an average response time.
+    // Check service twice and build an average response time.
     int serviceResult = SERVICE_STATE_INTERR;
     int firstServiceResult = SERVICE_STATE_INTERR;
     int secondServiceResult = SERVICE_STATE_INTERR;
-    for(int run = 0; run &lt;= 1; run++){
-			serviceResult = service.checkService(run);
-			if(run == 0){
-				firstServiceResult = serviceResult;
-				if(debug){
-	        stringstream srss;
-	        srss &lt;&lt; firstServiceResult;
-	        Log::debug(debug, &quot;serviceHandler() &quot; + handlerIDString + &quot; [loop]: Check result I: &quot; + srss.str());
-	      }	
-			}else{
-	      secondServiceResult = serviceResult;
-	      if(debug){
-	        stringstream srss;
-	          srss &lt;&lt; secondServiceResult;
-	          Log::debug(debug, &quot;serviceHandler() &quot; + handlerIDString + &quot; [loop]: Check result II: &quot; + srss.str());
-	      }
-			}
+    for(int run = 0; run &lt;= 1; run++)
+    {
+      serviceResult = service.checkService(run);
+      if(run == 0)
+      {
+        firstServiceResult = serviceResult;
+        if(debug)
+        {
+          stringstream srss;
+          srss &lt;&lt; firstServiceResult;
+          Log::debug(debug, &quot;serviceHandler() &quot; + handlerIDString + &quot; [loop]: Check result I: &quot; + srss.str());
+        }
+      }
+      else
+      {
+        secondServiceResult = serviceResult;
+        if(debug)
+        {
+          stringstream srss;
+          srss &lt;&lt; secondServiceResult;
+          Log::debug(debug, &quot;serviceHandler() &quot; + handlerIDString + &quot; [loop]: Check result II: &quot; + srss.str());
+        }
+      }
     }
 
     Log::debug(debug, &quot;serviceHandler() &quot; + handlerIDString + &quot; [loop]: Checking if the measured response time is higher than the defined maximum.&quot;);
 
     // Find out if the response time was too high.
-    if(service.checkResponseTime() == 0){
+    if(service.checkResponseTime() == 0)
+    {
       Log::debug(debug, &quot;serviceHandler() &quot; + handlerIDString + &quot; [loop]: Measured respone time is too high! Setting status to SERVICE_STATE_OKAYTIME.&quot;);
       // Mark service with &quot;Too high response time&quot;
       serviceResult = SERVICE_STATE_OKAYTIME;
-    }else{
+    }
+    else
+    {
       Log::debug(debug, &quot;serviceHandler() &quot; + handlerIDString + &quot; [loop]: Measured respone time is not too high!&quot;);
     }
 
@@ -377,53 +440,61 @@ void* serviceHandler(void* arg){
     Log::debug(debug, &quot;serviceHandler() &quot; + handlerIDString + &quot; [loop]: Storing response time.&quot;);
 
     // Store the response time in the database.
-    if(!service.storeResponseTime()){
+    if(!service.storeResponseTime())
+    {
       // Could not store the response time.
       Log::debug(debug, &quot;serviceHandler() &quot; + handlerIDString + &quot; [loop]: Could not store response time. Closing this handler.&quot;);
       log.putLog(2, &quot;008&quot;, &quot;Could not update service response time. Closing this handler.&quot;);
       return arg;
     }
 
-		if(serviceResult == SERVICE_STATE_CONFAIL || serviceResult == SERVICE_STATE_OKAYTIME
-                    || serviceResult == SERVICE_STATE_TIMEOUT){
-			/*
+    if(serviceResult == SERVICE_STATE_CONFAIL || serviceResult == SERVICE_STATE_OKAYTIME
+      || serviceResult == SERVICE_STATE_TIMEOUT)
+    {
+      /*
        * Check succeeded.
        *
-			 * The service is down, timed out or has a too high response time.
-			 * The method will find out if the response time was too high
-			 * or if the service is just down/not reachable.
-			 */
+       * The service is down, timed out or has a too high response time.
+       * The method will find out if the response time was too high
+       * or if the service is just down/not reachable.
+       */
       Log::debug(debug, &quot;serviceHandler() &quot; + handlerIDString + &quot; [loop]: Sending warnings.&quot;);
-			service.sendWarning();
-		}else if(serviceResult == SERVICE_STATE_INTERR){
-			/*
-			 * The service could not be checked because an internal error occured.
-			 * Send a general warning!
-			 */
+      service.sendWarning();
+    }
+    else if(serviceResult == SERVICE_STATE_INTERR)
+    {
+      /*
+       * The service could not be checked because an internal error occured.
+       * Send a general warning!
+       */
       Log::debug(debug, &quot;serviceHandler() &quot; + handlerIDString + &quot; [loop]: Sending general notifications because serviceResult is SERVICE_STATE_INTERR&quot;);
-			GeneralNotifications gn(dbData, mailData, xmppData, clickatellData);
-			gn.sendMessages(&quot;Critical failure&quot;, &quot;Could not check service because an &quot;
-					&quot;internal error occured&quot;);
-		}
-      
+      GeneralNotifications gn(dbData, mailData, xmppData, clickatellData);
+      gn.sendMessages(&quot;Critical failure&quot;, &quot;Could not check service because an &quot;
+        &quot;internal error occured&quot;);
+    }
+
     Log::debug(debug, &quot;serviceHandler() &quot; + handlerIDString + &quot; [loop]: Done. Next cycle in 60 seconds.&quot;);
 
-		// Wait 60 seconds until next check.
-		sleep(60);
-	}
+    // Wait 60 seconds until next check.
+    sleep(60);
+  }
 
-	return arg;
+  return arg;
 }
 
-void* serviceChecks(void* arg){
+
+void* serviceChecks(void* arg)
+{
   Log::debug(debug, &quot;serviceChecks(): Started&quot;);
-	Log log(LOGFILE, dbData);
-	Database db(dbData);
-	// Run forever.
-	while(1){
+  Log log(LOGFILE, dbData);
+  Database db(dbData);
+  // Run forever.
+  while(1)
+  {
     Log::debug(debug, &quot;serviceChecks(): In loop.&quot;);
-		// Try to establish a database connection.
-		if(db.initConnection()){
+    // Try to establish a database connection.
+    if(db.initConnection())
+    {
       Log::debug(debug, &quot;serviceChecks(): Connected to database.&quot;);
       time_t rawtime;
       time(&amp;rawtime);
@@ -436,64 +507,75 @@ void* serviceChecks(void* arg){
       //         &quot;OR handler = 0 OR lastcheck &lt; &quot;
       //      &lt;&lt; twoMinutesAgo;
       query &lt;&lt; &quot;SELECT id FROM services WHERE handler = 0 OR handler = NULL OR lastcheck &lt; &quot;
-            &lt;&lt; twoMinutesAgo &lt;&lt; &quot; LIMIT 100&quot;;
+        &lt;&lt; twoMinutesAgo &lt;&lt; &quot; LIMIT 100&quot;;
 
       unsigned int numOfServices = db.getNumOfResults(query.str());
-      if(debug){
+      if(debug)
+      {
         stringstream msg;
         msg &lt;&lt; &quot;serviceChecks(): Fetched &quot; &lt;&lt; numOfServices &lt;&lt; &quot; services that need to get a serviceHandler()&quot;;
         Log::debug(debug, msg.str());
       }
-			mysql_close(db.getHandle());
+      mysql_close(db.getHandle());
 
-			// Start a thread for every service that has no handler yet.
-			for(unsigned int i = 0;i &lt; numOfServices; i++){
-        if(debug){
+      // Start a thread for every service that has no handler yet.
+      for(unsigned int i = 0;i &lt; numOfServices; i++)
+      {
+        if(debug)
+        {
           stringstream msg;
           msg &lt;&lt; &quot;serviceChecks(): Starting serviceHandler() &quot; &lt;&lt; i;
           Log::debug(debug, msg.str());
         }
-				// Start thread.
-				pthread_t thread;
-				if(pthread_create(&amp;thread, 0, serviceHandler, NULL)) {
-					log.putLog(2, &quot;1000&quot;, &quot;Could not create service thread&quot;);
-          if(debug){
+        // Start thread.
+        pthread_t thread;
+        if(pthread_create(&amp;thread, 0, serviceHandler, NULL))
+        {
+          log.putLog(2, &quot;1000&quot;, &quot;Could not create service thread&quot;);
+          if(debug)
+          {
             stringstream msg;
             msg &lt;&lt; &quot;serviceChecks(): Starting of serviceHandler() &quot; &lt;&lt; i &lt;&lt; &quot; failed&quot;;
             Log::debug(debug, msg.str());
           }
-				}else{
-          if(debug){
+        }
+        else
+        {
+          if(debug)
+          {
             stringstream msg;
             msg &lt;&lt; &quot;serviceChecks(): Started serviceHandler() &quot; &lt;&lt; i;
             Log::debug(debug, msg.str());
           }
         }
 
-				// Wait one second before starting the next thread.
-				sleep(1);
-			}
-		}else{
-			// Could not connect to database.
-			log.putLog(2, &quot;018&quot;, &quot;Could not start service check module! (Database error) - &quot;
-										&quot;Retry in 5 minutes.&quot;);
+        // Wait one second before starting the next thread.
+        sleep(1);
+      }
+    }
+    else
+    {
+      // Could not connect to database.
+      log.putLog(2, &quot;018&quot;, &quot;Could not start service check module! (Database error) - &quot;
+        &quot;Retry in 5 minutes.&quot;);
       Log::debug(debug, &quot;serviceChecks(): Could not connect to database.&quot;);
-			GeneralNotifications gn(dbData, mailData, xmppData, clickatellData);
-			gn.sendMessages(&quot;Critical failure&quot;, &quot;Could not start service check module! &quot;
-					&quot;(Database error) Retry in 5 minutes.&quot;);
+      GeneralNotifications gn(dbData, mailData, xmppData, clickatellData);
+      gn.sendMessages(&quot;Critical failure&quot;, &quot;Could not start service check module! &quot;
+        &quot;(Database error) Retry in 5 minutes.&quot;);
 
-			// Sleep five minutes.
-			sleep(300);
-		}
+      // Sleep five minutes.
+      sleep(300);
+    }
 
-		// Everything went fine. Wait a minute for next check.
-		sleep(60);
+    // Everything went fine. Wait a minute for next check.
+    sleep(60);
 
-	}
+  }
 
-	return arg;
+  return arg;
 }
 
+
 int servSock;
 int clientSocket;
 struct sockaddr_in address;
@@ -506,21 +588,27 @@ bool blacklisting = 0;
 long double packageCountOK = 0;
 long double packageCountERR = 0;
 
-void* cloudStatusUpdater(void* args){
-	Log log(LOGFILE, dbData);
+void* cloudStatusUpdater(void* args)
+{
+  Log log(LOGFILE, dbData);
 
   Database db(dbData);
   Cloud cloud(nodeID, dbData);
 
-  while(1){
-    if(db.initConnection()){
-    	while(cloud.updateOwnStatus(db)){
+  while(1)
+  {
+    if(db.initConnection())
+    {
+      while(cloud.updateOwnStatus(db))
+      {
         sleep(10);
       }
       mysql_close(db.getHandle());
-    }else{
+    }
+    else
+    {
       // Could not connect to database.
-			log.putLog(2, &quot;xxx&quot;, &quot;Could not update own cloud status: Could not connect to database. Retry in one minute.&quot;);
+      log.putLog(2, &quot;xxx&quot;, &quot;Could not update own cloud status: Could not connect to database. Retry in one minute.&quot;);
     }
     sleep(60);
   }
@@ -528,16 +616,20 @@ void* cloudStatusUpdater(void* args){
   return (NULL);
 }
 
-void* cloudServiceManager(void* args){
-	Log log(LOGFILE, dbData);
+
+void* cloudServiceManager(void* args)
+{
+  Log log(LOGFILE, dbData);
 
   Database db(dbData);
 
-  while(1){
-    if(db.initConnection()){
+  while(1)
+  {
+    if(db.initConnection())
+    {
 
       Cloud cloud(nodeID, dbData);
-    
+
       /*
        * Service balance
        *
@@ -545,33 +637,41 @@ void* cloudServiceManager(void* args){
 
       // Get number of currently self monitored services.
       static unsigned int ownServices = cloud.getNumberOfOwnServices(db);
-      
+
       // Get ID of node with most services.
       static unsigned int nodeWithMostServices = cloud.getIdOfNodeWithMostServices(db);
 
       // Get the number of services the node with the most services currently handles.
       static unsigned int numberOfMostServices = cloud.getNumberOfServicesFromNode(nodeWithMostServices, db);
- 
+
       /*
        * Skip everything if we are the node with the highest number of services or
        * the other node has less services than we have.
        */
-      if(nodeID != nodeWithMostServices){
+      if(nodeID != nodeWithMostServices)
+      {
         unsigned int numberOfRequestedServices = 0;
-        if(ownServices &gt; 0 &amp;&amp; numberOfMostServices &gt; ownServices){
+        if(ownServices &gt; 0 &amp;&amp; numberOfMostServices &gt; ownServices)
+        {
           numberOfRequestedServices = ceil((numberOfMostServices-ownServices)/2);
-        }else{
+        }
+        else
+        {
           numberOfRequestedServices = ceil((numberOfMostServices)/2);
         }
 
-        if(numberOfRequestedServices &gt; 0){
+        if(numberOfRequestedServices &gt; 0)
+        {
           // Request.
-          if(cloud.action_requestServices(numberOfRequestedServices, nodeWithMostServices, db)){
+          if(cloud.action_requestServices(numberOfRequestedServices, nodeWithMostServices, db))
+          {
             // Request was sent successful. Log it.
             stringstream logmsg;
             logmsg &lt;&lt; &quot;Requested &quot; &lt;&lt; numberOfRequestedServices &lt;&lt; &quot; services from node &quot; &lt;&lt; nodeWithMostServices;
             cloud.action_logEvent(logmsg.str(), db);
-          }else{
+          }
+          else
+          {
             log.putLog(2, &quot;xxx&quot;, &quot;Could not request services from another node: Database error.&quot;);
           }
         }
@@ -579,20 +679,26 @@ void* cloudServiceManager(void* args){
 
       // Check if we need to hand over a service.
       unsigned int conversationID;
-      if((conversationID = cloud.checkForServiceHandoverRequest(db)) &gt; 0){
+      if((conversationID = cloud.checkForServiceHandoverRequest(db)) &gt; 0)
+      {
         unsigned int numberOfServices = cloud.getNumberOfRequestedServices(db, conversationID);
         unsigned int serviceHandoverRequester = cloud.getNodeIdOfHandoverRequester(db, conversationID);
 
-       // Hand over services.
-        if(cloud.handOverServices(numberOfServices, serviceHandoverRequester, db)){
-          if(!cloud.action_replyServiceRequest(serviceHandoverRequester, &quot;1&quot;, conversationID, db)){
+        // Hand over services.
+        if(cloud.handOverServices(numberOfServices, serviceHandoverRequester, db))
+        {
+          if(!cloud.action_replyServiceRequest(serviceHandoverRequester, &quot;1&quot;, conversationID, db))
+          {
             log.putLog(2, &quot;xxx&quot;, &quot;Could not reply to service request: Database error.&quot;);
           }
           stringstream logmsg;
           logmsg &lt;&lt; &quot;Accepted: Handing over &quot; &lt;&lt; numberOfServices &lt;&lt; &quot; services to node &quot; &lt;&lt; serviceHandoverRequester;
           cloud.action_logEvent(logmsg.str(), db);
-        }else{
-          if(!cloud.action_replyServiceRequest(serviceHandoverRequester, &quot;0&quot;, conversationID, db)){
+        }
+        else
+        {
+          if(!cloud.action_replyServiceRequest(serviceHandoverRequester, &quot;0&quot;, conversationID, db))
+          {
             log.putLog(2, &quot;xxx&quot;, &quot;Could not reply to service request: Database error.&quot;);
           }
           stringstream logmsg;
@@ -602,9 +708,11 @@ void* cloudServiceManager(void* args){
       }
 
       mysql_close(db.getHandle());
-    }else{
+    }
+    else
+    {
       // Could not connect to database.
-			log.putLog(2, &quot;xxx&quot;, &quot;Could not update own cloud status: Could not connect to database. Retry in one minute.&quot;);
+      log.putLog(2, &quot;xxx&quot;, &quot;Could not update own cloud status: Could not connect to database. Retry in one minute.&quot;);
       sleep(55);
     }
     sleep(5);
@@ -613,143 +721,168 @@ void* cloudServiceManager(void* args){
   return (NULL);
 }
 
-void* maintenanceThread(void* args){
 
-	Log log(LOGFILE, dbData);
+void* maintenanceThread(void* args)
+{
+
+  Log log(LOGFILE, dbData);
 
-	while(1){
+  while(1)
+  {
 
-		Database maintDB(dbData);
+    Database maintDB(dbData);
 
-		if(maintDB.initConnection()){
-			// Clear outdated sensor data.
-			if(!maintDB.clearSensorData()){
-				log.putLog(1, &quot;021&quot;, &quot;Could not delete old sensor data.&quot;);
-			}
+    if(maintDB.initConnection())
+    {
+      // Clear outdated sensor data.
+      if(!maintDB.clearSensorData())
+      {
+        log.putLog(1, &quot;021&quot;, &quot;Could not delete old sensor data.&quot;);
+      }
 
-			// Clear outdated service data.
-			if(!maintDB.clearServiceData()){
-				log.putLog(1, &quot;021&quot;, &quot;Could not delete old service data.&quot;);
-			}
+      // Clear outdated service data.
+      if(!maintDB.clearServiceData())
+      {
+        log.putLog(1, &quot;021&quot;, &quot;Could not delete old service data.&quot;);
+      }
 
-			mailData = Mail::fetchSettings(dbData);
-			xmppData = XMPP::fetchSettings(dbData);
-			clickatellData = Clickatell::fetchSettings(dbData);
+      mailData = Mail::fetchSettings(dbData);
+      xmppData = XMPP::fetchSettings(dbData);
+      clickatellData = Clickatell::fetchSettings(dbData);
 
-			// Update process statistics.
-			if(!maintDB.setQuery(maintDB.getHandle(), Information::updateHealth(nodeID, Health::getPID(),
-					clientHandler,Health::getVMSize(), Health::getThreads(), packageCountOK,
-					packageCountERR, -1, -1, -1))){
-				log.putLog(1, &quot;053&quot;, &quot;Could not update health statistics.&quot;);
+      // Update process statistics.
+      if(!maintDB.setQuery(maintDB.getHandle(), Information::updateHealth(nodeID, Health::getPID(),
+        clientHandler,Health::getVMSize(), Health::getThreads(), packageCountOK,
+        packageCountERR, -1, -1, -1)))
+      {
+        log.putLog(1, &quot;053&quot;, &quot;Could not update health statistics.&quot;);
       }
 
-			mysql_close(maintDB.getHandle());
-		}
+      mysql_close(maintDB.getHandle());
+    }
 
-		// Run every minute.
-		sleep(60);
-	}
+    // Run every minute.
+    sleep(60);
+  }
 
-	// Not reached.
+  // Not reached.
 
-	return (NULL);
+  return (NULL);
 }
 
-void killClient(int sig){
-	Log log(LOGFILE, dbData);
-	log.putLog(0, &quot;029&quot;, &quot;Closed connection to client that did not complete&quot;
-			&quot; transaction after 5 seconds.&quot;);
-	close(clientSocket);
+
+void killClient(int sig)
+{
+  Log log(LOGFILE, dbData);
+  log.putLog(0, &quot;029&quot;, &quot;Closed connection to client that did not complete&quot;
+    &quot; transaction after 5 seconds.&quot;);
+  close(clientSocket);
 }
 
-void handleClient(){
 
-	// Start maintenance thread.
-	pthread_t maintThread;
-	if(pthread_create(&amp;maintThread, 0, maintenanceThread, NULL)) {
-		cout &lt;&lt; &quot;Terminating: Could not create maintenance thread.&quot; &lt;&lt; endl;
-		exit(EXIT_FAILURE);
-	}
+void handleClient()
+{
+
+  // Start maintenance thread.
+  pthread_t maintThread;
+  if(pthread_create(&amp;maintThread, 0, maintenanceThread, NULL))
+  {
+    cout &lt;&lt; &quot;Terminating: Could not create maintenance thread.&quot; &lt;&lt; endl;
+    exit(EXIT_FAILURE);
+  }
 
-	Log log(LOGFILE, dbData);
+  Log log(LOGFILE, dbData);
 
-	// For closing connection to a client after 5sec.
-	signal(SIGALRM, killClient);
+  // For closing connection to a client after 5sec.
+  signal(SIGALRM, killClient);
 
-	// Run forever.
-	while(1){
+  // Run forever.
+  while(1)
+  {
 
-		// Accept connections with new socket &quot;clientSocket&quot;.
-		clientSocket = accept(servSock,(struct sockaddr *) &amp;address, &amp;addrlen);
+    // Accept connections with new socket &quot;clientSocket&quot;.
+    clientSocket = accept(servSock,(struct sockaddr *) &amp;address, &amp;addrlen);
 
-		if(clientSocket &lt;= 0){
-			log.putLog(1, &quot;030&quot;, &quot;Could not accept connection from client.&quot;);
-			close(clientSocket);
-			packageCountERR++;
-			continue;
-		}
+    if(clientSocket &lt;= 0)
+    {
+      log.putLog(1, &quot;030&quot;, &quot;Could not accept connection from client.&quot;);
+      close(clientSocket);
+      packageCountERR++;
+      continue;
+    }
 
-		// Create database object.
-		Database clientDB(dbData);
+    // Create database object.
+    Database clientDB(dbData);
 
-		// Try to open connection to database.
-		if(clientDB.initConnection()){
-			// We are connected to the database.
+    // Try to open connection to database.
+    if(clientDB.initConnection())
+    {
+      // We are connected to the database.
 
       Host host(dbData, clientSocket, address);
 
-			// Start the timer. The client now has five seconds to complete transaction. Go.
-			alarm(5);
+      // Start the timer. The client now has five seconds to complete transaction. Go.
+      alarm(5);
 
       // Skip if this host is blacklisted.
-      if(host.isBlacklisted(clientDB)){
+      if(host.isBlacklisted(clientDB))
+      {
         stringstream logmsg;
         logmsg &lt;&lt; &quot;Blacklisted host &quot;
-               &lt;&lt; host.getIPv4Address()
-               &lt;&lt; &quot; tried to connect. Blocked.&quot;;
+          &lt;&lt; host.getIPv4Address()
+          &lt;&lt; &quot; tried to connect. Blocked.&quot;;
         log.putLog(1, &quot;xxx&quot;, logmsg.str());
         host.refuse(&quot;Blacklisted&quot;);
         mysql_close(clientDB.getHandle());
-		    close(clientSocket);
+        close(clientSocket);
         // Reset the alarm timer.
         alarm(0);
         continue;
-      }else{
+      }
+      else
+      {
         host.notify(&quot;Okay&quot;);
       }
-      
+
       // Wait for host login. Skip if incorrect.
-      if(!host.checkLogin(clientDB)){
+      if(!host.checkLogin(clientDB))
+      {
         stringstream logmsg;
         string errorcode;
         // Blacklist host.
-        if(host.addToBlacklist(clientDB)){
+        if(host.addToBlacklist(clientDB))
+        {
           errorcode = &quot;xxx&quot;;
           logmsg &lt;&lt; &quot;Host &quot;
-                 &lt;&lt; host.getIPv4Address()
-                 &lt;&lt; &quot; sent wrong login credentials. Blocked and blacklisted.&quot;;
-        }else{
+            &lt;&lt; host.getIPv4Address()
+            &lt;&lt; &quot; sent wrong login credentials. Blocked and blacklisted.&quot;;
+        }
+        else
+        {
           errorcode = &quot;xxx&quot;;
           logmsg &lt;&lt; &quot;Host &quot;
-                 &lt;&lt; host.getIPv4Address()
-                 &lt;&lt; &quot; sent wrong login credentials. Blocked. Blacklisting failed.&quot;;
+            &lt;&lt; host.getIPv4Address()
+            &lt;&lt; &quot; sent wrong login credentials. Blocked. Blacklisting failed.&quot;;
         }
         log.putLog(3, errorcode, logmsg.str());
         host.refuse(&quot;Login incorrect&quot;);
         mysql_close(clientDB.getHandle());
-		    close(clientSocket);
+        close(clientSocket);
         // Reset the alarm timer.
         alarm(0);
         continue;
-      }else{
+      }
+      else
+      {
         host.notify(&quot;Okay&quot;);
       }
 
       // Wait for data.
-      if(!host.receiveAndStoreData(clientDB)){
+      if(!host.receiveAndStoreData(clientDB))
+      {
         stringstream logmsg;
         logmsg &lt;&lt; &quot;Could not receive and store data from host &quot;
-               &lt;&lt; host.getIPv4Address() &lt;&lt; &quot; (&quot; &lt;&lt; host.getLastError() &lt;&lt; &quot;)&quot;;
+          &lt;&lt; host.getIPv4Address() &lt;&lt; &quot; (&quot; &lt;&lt; host.getLastError() &lt;&lt; &quot;)&quot;;
         log.putLog(3, &quot;xxx&quot;, logmsg.str());
         host.refuse(&quot;Could not accept and store your data.&quot;);
         mysql_close(clientDB.getHandle());
@@ -757,7 +890,9 @@ void handleClient(){
         // Reset the alarm timer.
         alarm(0);
         continue;
-      }else{
+      }
+      else
+      {
         host.notify(&quot;Okay&quot;);
       }
 
@@ -767,440 +902,530 @@ void handleClient(){
       alarm(0);
 
       mysql_close(clientDB.getHandle());
-		}else{
-			// Could not connect to database.
-			log.putLog(2, &quot;049&quot;, &quot;Client handler: Could not connect to database! &quot;
-					&quot;Sensor package skipped.&quot;);
-		}
-		close(clientSocket);
-	}
+    }
+    else
+    {
+      // Could not connect to database.
+      log.putLog(2, &quot;049&quot;, &quot;Client handler: Could not connect to database! &quot;
+        &quot;Sensor package skipped.&quot;);
+    }
+    close(clientSocket);
+  }
 
-	// Not reached.
+  // Not reached.
 
-	exit(EXIT_FAILURE);
+  exit(EXIT_FAILURE);
 }
 
-void cleanUp(int sig){
-	remove(PIDFILE);
-	gnutls_anon_free_server_credentials (anoncred);
-	gnutls_global_deinit();
-	exit(EXIT_FAILURE);
+
+void cleanUp(int sig)
+{
+  remove(PIDFILE);
+  gnutls_anon_free_server_credentials (anoncred);
+  gnutls_global_deinit();
+  exit(EXIT_FAILURE);
 }
 
-void logTLS(int level, const char *message){
-	Log log(LOGFILE, dbData);
-	stringstream logmsg;
-	logmsg &lt;&lt; message;
-	log.putLog(1, &quot;TLS&quot;, message);
+
+void logTLS(int level, const char *message)
+{
+  Log log(LOGFILE, dbData);
+  stringstream logmsg;
+  logmsg &lt;&lt; message;
+  log.putLog(1, &quot;TLS&quot;, message);
 }
 
-int main(int argc, char *argv[]){
 
-	// So jung kommen wir nicht mehr zusammen.
+int main(int argc, char *argv[])
+{
 
-	// Check if we are root.
-	if(geteuid() != 0){
-		cout &lt;&lt;  &quot;The server needs to be started as root.&quot; &lt;&lt; endl;
-		exit(EXIT_FAILURE);
-	}
+  // So jung kommen wir nicht mehr zusammen.
+
+  // Check if we are root.
+  if(geteuid() != 0)
+  {
+    cout &lt;&lt;  &quot;The server needs to be started as root.&quot; &lt;&lt; endl;
+    exit(EXIT_FAILURE);
+  }
 
   // Find out if we are in debug mode.
-  for(int i = 0; i &lt; argc; i++){
-		if(strcmp(argv[i], &quot;--debug&quot;) == 0){
-			debug = 1;
-		}
-	}
-
-	// Check if config file is readable
-	ifstream configtest(CONFIGFILE);
-	if(configtest.fail()){
-	  cout &lt;&lt; &quot;Terminating: Could not read config file. Check permissions and if file exists.&quot; &lt;&lt; endl;
-		exit(EXIT_FAILURE);
-	}
-	configtest.close();
-
-	/*
-	 * Read config.
-	 *
-	 * To add a new config parameter just add
-	 * the name of the parameter to the vector.
-	 *
-	 * It will be accessible as string config[nr]
-	 *
-	 */
-
-	cout &lt;&lt; &quot;- Reading config:\t&quot;;
-	cout.flush();
-	vector&lt;string&gt; parameters;
-	parameters.push_back(&quot;serverport&quot;);
-	parameters.push_back(&quot;loglevel&quot;);
-	parameters.push_back(&quot;servicechecks&quot;);
-	parameters.push_back(&quot;blacklist&quot;);
-
-	parameters.push_back(&quot;mysqlhost&quot;);
-	parameters.push_back(&quot;mysqldb&quot;);
-	parameters.push_back(&quot;mysqluser&quot;);
-	parameters.push_back(&quot;mysqlpass&quot;);
-	parameters.push_back(&quot;mysqlport&quot;);
-
-	parameters.push_back(&quot;numprocs&quot;);
-
-	parameters.push_back(&quot;mail-alt&quot;);
-	parameters.push_back(&quot;xmpp-alt&quot;);
-	parameters.push_back(&quot;mobilec-alt&quot;);
-	
+  for(int i = 0; i &lt; argc; i++)
+  {
+    if(strcmp(argv[i], &quot;--debug&quot;) == 0)
+    {
+      debug = 1;
+    }
+  }
+
+  // Check if config file is readable
+  ifstream configtest(CONFIGFILE);
+  if(configtest.fail())
+  {
+    cout &lt;&lt; &quot;Terminating: Could not read config file. Check permissions and if file exists.&quot; &lt;&lt; endl;
+    exit(EXIT_FAILURE);
+  }
+  configtest.close();
+
+  /*
+   * Read config.
+   *
+   * To add a new config parameter just add
+   * the name of the parameter to the vector.
+   *
+   * It will be accessible as string config[nr]
+   *
+   */
+
+  cout &lt;&lt; &quot;- Reading config:\t&quot;;
+  cout.flush();
+  vector&lt;string&gt; parameters;
+  parameters.push_back(&quot;serverport&quot;);
+  parameters.push_back(&quot;loglevel&quot;);
+  parameters.push_back(&quot;servicechecks&quot;);
+  parameters.push_back(&quot;blacklist&quot;);
+
+  parameters.push_back(&quot;mysqlhost&quot;);
+  parameters.push_back(&quot;mysqldb&quot;);
+  parameters.push_back(&quot;mysqluser&quot;);
+  parameters.push_back(&quot;mysqlpass&quot;);
+  parameters.push_back(&quot;mysqlport&quot;);
+
+  parameters.push_back(&quot;numprocs&quot;);
+
+  parameters.push_back(&quot;mail-alt&quot;);
+  parameters.push_back(&quot;xmpp-alt&quot;);
+  parameters.push_back(&quot;mobilec-alt&quot;);
+
   parameters.push_back(&quot;nodeid&quot;);
 
-	ifstream configstream(CONFIGFILE);
-
-	int parsize = parameters.size();
-	string config[parsize];
-
-	if(!configstream.fail()){
-		int i = 0;
-		int j = 0;
-
-		string configline;
-
-		while(getline(configstream,configline)){
-			i = 0;
-			string token;
-			istringstream iss(configline);
-			while(j &lt; parsize){
-				if(configline.find(parameters[j], 0 ) != string::npos){
-					while(getline(iss, token, '=')){
-						// Read parameters.
-						if(i == 1 &amp;&amp; !token.empty()){
-							config[j] = token;
-						}
-						i++;
-					}
-				}
-				j++;
-			}
-			j = 0;
-		}
-	}
-
-	configstream.close();
-
-	// Working on the config.
-	// Convert strings to int.
-	int port;
-	if(!config[0].empty()){
-		port = stringToInteger(config[0].c_str());
-	}else{
-		cout &lt;&lt; &quot;Error. Port not set?&quot; &lt;&lt; endl;
-		exit(EXIT_FAILURE);
-	}
-
-	if(!config[1].empty()){
-		loglevel = stringToInteger(config[1].c_str());
-	}else{
-		cout &lt;&lt; &quot;Error. Loglevel not set?&quot; &lt;&lt; endl;
-		exit(EXIT_FAILURE);
-	}
-
-	// Find out if we want to enable service checks.
-	bool doServiceChecks = 0;
-	if(!config[2].empty()){
-		if(config[2] == &quot;1&quot;)
-			doServiceChecks = 1;
-	}else{
-		cout &lt;&lt; &quot;Error. Service check mode not set?&quot; &lt;&lt; endl;
-		exit(EXIT_FAILURE);
-	}
-
-	// Find out if we want to enable the blacklist.
-	if(!config[3].empty()){
-		if(config[3] == &quot;1&quot;)
-			blacklisting = 1;
-	}else{
-		cout &lt;&lt; &quot;Error. Blacklisting mode not set?&quot; &lt;&lt; endl;
-		exit(EXIT_FAILURE);
-	}
-
-	// Get MySQL host.
-	if(!config[4].empty()){
-		dbData.host = config[4].c_str();
-	}else{
-		cout &lt;&lt; &quot;Error. MySQL host not set?&quot; &lt;&lt; endl;
-		exit(EXIT_FAILURE);
-	}
-
-	// Get MySQL database.
-	if(!config[5].empty()){
-		dbData.db = config[5].c_str();
-	}else{
-		cout &lt;&lt; &quot;Error. MySQL database not set?&quot; &lt;&lt; endl;
-		exit(EXIT_FAILURE);
-	}
-
-	// Get MySQL user.
-	if(!config[6].empty()){
-		dbData.user = config[6].c_str();
-	}else{
-		cout &lt;&lt; &quot;Error. MySQL user not set?&quot; &lt;&lt; endl;
-		exit(EXIT_FAILURE);
-	}
-
-	// Get MySQL password.
-	if(!config[7].empty()){
-		dbData.pass = config[7].c_str();
-	}else{
-		cout &lt;&lt; &quot;Error. MySQL password not set?&quot; &lt;&lt; endl;
-		exit(EXIT_FAILURE);
-	}
-
-	// Get MySQL port.
-	if(!config[8].empty() &amp;&amp; numOnly(config[8])){
-		dbData.port = stringToInteger(config[8].c_str());
-	}else{
-		cout &lt;&lt; &quot;Error. MySQL port not set?&quot; &lt;&lt; endl;
-		exit(EXIT_FAILURE);
-	}
-
-	// Get number of processes to fork.
-	int numProcs = 0;
-	if(!config[9].empty() &amp;&amp; numOnly(config[9])){
-		numProcs = stringToInteger(config[9].c_str());
-	}else{
-		cout &lt;&lt; &quot;Error. Number of processes to fork not set?&quot; &lt;&lt; endl;
-		exit(EXIT_FAILURE);
-	}
-
-	// Get fallback email.
-	bool mailFallbackError = 0;
-	if(!config[10].empty()){
-		mailData.fallbackReceiver = config[10].c_str();
-	}else{
-		mailFallbackError = 1;
-		mailData.fallbackReceiver = &quot;&quot;;
-	}
-
-	// Get fallback JID.
-	bool xmppFallbackError = 0;
-	if(!config[11].empty()){
-		xmppData.fallbackReceiver = config[11].c_str();
-	}else{
-		xmppFallbackError = 1;
-		xmppData.fallbackReceiver = &quot;&quot;;
-	}
-
-	// Get fallback mobile number for Clickatell API.
-	bool mobilecFallbackError = 0;
-	if(!config[12].empty()){
-		clickatellData.fallbackNumber = config[12].c_str();
-	}else{
-		mobilecFallbackError = 1;
-		clickatellData.fallbackNumber = &quot;&quot;;
-	}
-	
-	if(!config[13].empty()){
-		nodeID = stringToInteger(config[13].c_str());
-	}else{
-		cout &lt;&lt; &quot;Error. Node ID not set?&quot; &lt;&lt; endl;
-		exit(EXIT_FAILURE);
-	}
-
-	// Finished parsing of config file.
-	cout &lt;&lt; &quot;[ OK ]&quot; &lt;&lt; endl;
-
-	// Perform a selftest.
-	cout &lt;&lt; &quot;- Selftest sequence:\t&quot;;
-	cout.flush();
-	if(selfTest(port, loglevel) != &quot;1&quot;){
-		// Selftest failed!
-		cout &lt;&lt; &quot;Terminating: &quot; &lt;&lt; selfTest(port, loglevel) &lt;&lt; endl;
-		exit(EXIT_FAILURE);
-	}else{
-		// No errors.
-		cout &lt;&lt; &quot;[ OK ]&quot; &lt;&lt; endl;
-	}
-
-	cout &lt;&lt; &quot;- TLS initialization:\t&quot;;
-	cout.flush();
-
-	// GnuTLS variables.
-	static gnutls_dh_params_t dh_params;
-
-	// GnuTLS initialization.
-	gnutls_global_init();
-	gnutls_global_set_log_function(logTLS);
-	gnutls_global_set_log_level(0);
-	gnutls_anon_allocate_server_credentials(&amp;anoncred);
-	gnutls_dh_params_init(&amp;dh_params);
-	gnutls_dh_params_generate2 (dh_params, DH_BITS);
-	gnutls_anon_set_server_dh_params (anoncred, dh_params);
-
-	cout &lt;&lt; &quot;[ OK ]&quot; &lt;&lt; endl;
-
-	// Display warnings about possibly missing fallback receivers.
-	if(mailFallbackError || xmppFallbackError || mobilecFallbackError)
-		cout &lt;&lt; &quot;- Some notification methods have no fallback receivers.&quot; &lt;&lt; endl;
-
-	Log log(LOGFILE, dbData);
-
-	// Start as daemon if we are not in debug mode.
-  if(!debug){
-  	if(daemon(0,0) &lt; 0){
-  		cout &lt;&lt; &quot;Terminated. Could not initialize daemon mode!&quot; &lt;&lt; endl;
-		  exit(EXIT_FAILURE);
-  	}
+  ifstream configstream(CONFIGFILE);
+
+  int parsize = parameters.size();
+  string config[parsize];
+
+  if(!configstream.fail())
+  {
+    int i = 0;
+    int j = 0;
+
+    string configline;
+
+    while(getline(configstream,configline))
+    {
+      i = 0;
+      string token;
+      istringstream iss(configline);
+      while(j &lt; parsize)
+      {
+        if(configline.find(parameters[j], 0 ) != string::npos)
+        {
+          while(getline(iss, token, '='))
+          {
+            // Read parameters.
+            if(i == 1 &amp;&amp; !token.empty())
+            {
+              config[j] = token;
+            }
+            i++;
+          }
+        }
+        j++;
+      }
+      j = 0;
+    }
   }
 
-	// We are a daemon from here on.
+  configstream.close();
 
-	pid_t pid = getpid();
+  // Working on the config.
+  // Convert strings to int.
+  int port;
+  if(!config[0].empty())
+  {
+    port = stringToInteger(config[0].c_str());
+  }
+  else
+  {
+    cout &lt;&lt; &quot;Error. Port not set?&quot; &lt;&lt; endl;
+    exit(EXIT_FAILURE);
+  }
 
-	// Write the pidfile.
-	ofstream pidwrite(PIDFILE, ios::out);
-	if(!pidwrite.fail()){
-		pidwrite &lt;&lt; pid &lt;&lt; endl;
-	}else{
-		log.putLog(2, &quot;50&quot;, &quot;Terminated. Could not create pidfile!&quot;);
-		exit(EXIT_FAILURE);
-	}
-	pidwrite.close();
+  if(!config[1].empty())
+  {
+    loglevel = stringToInteger(config[1].c_str());
+  }
+  else
+  {
+    cout &lt;&lt; &quot;Error. Loglevel not set?&quot; &lt;&lt; endl;
+    exit(EXIT_FAILURE);
+  }
+
+  // Find out if we want to enable service checks.
+  bool doServiceChecks = 0;
+  if(!config[2].empty())
+  {
+    if(config[2] == &quot;1&quot;)
+      doServiceChecks = 1;
+  }
+  else
+  {
+    cout &lt;&lt; &quot;Error. Service check mode not set?&quot; &lt;&lt; endl;
+    exit(EXIT_FAILURE);
+  }
+
+  // Find out if we want to enable the blacklist.
+  if(!config[3].empty())
+  {
+    if(config[3] == &quot;1&quot;)
+      blacklisting = 1;
+  }
+  else
+  {
+    cout &lt;&lt; &quot;Error. Blacklisting mode not set?&quot; &lt;&lt; endl;
+    exit(EXIT_FAILURE);
+  }
+
+  // Get MySQL host.
+  if(!config[4].empty())
+  {
+    dbData.host = config[4].c_str();
+  }
+  else
+  {
+    cout &lt;&lt; &quot;Error. MySQL host not set?&quot; &lt;&lt; endl;
+    exit(EXIT_FAILURE);
+  }
+
+  // Get MySQL database.
+  if(!config[5].empty())
+  {
+    dbData.db = config[5].c_str();
+  }
+  else
+  {
+    cout &lt;&lt; &quot;Error. MySQL database not set?&quot; &lt;&lt; endl;
+    exit(EXIT_FAILURE);
+  }
+
+  // Get MySQL user.
+  if(!config[6].empty())
+  {
+    dbData.user = config[6].c_str();
+  }
+  else
+  {
+    cout &lt;&lt; &quot;Error. MySQL user not set?&quot; &lt;&lt; endl;
+    exit(EXIT_FAILURE);
+  }
+
+  // Get MySQL password.
+  if(!config[7].empty())
+  {
+    dbData.pass = config[7].c_str();
+  }
+  else
+  {
+    cout &lt;&lt; &quot;Error. MySQL password not set?&quot; &lt;&lt; endl;
+    exit(EXIT_FAILURE);
+  }
+
+  // Get MySQL port.
+  if(!config[8].empty() &amp;&amp; numOnly(config[8]))
+  {
+    dbData.port = stringToInteger(config[8].c_str());
+  }
+  else
+  {
+    cout &lt;&lt; &quot;Error. MySQL port not set?&quot; &lt;&lt; endl;
+    exit(EXIT_FAILURE);
+  }
+
+  // Get number of processes to fork.
+  int numProcs = 0;
+  if(!config[9].empty() &amp;&amp; numOnly(config[9]))
+  {
+    numProcs = stringToInteger(config[9].c_str());
+  }
+  else
+  {
+    cout &lt;&lt; &quot;Error. Number of processes to fork not set?&quot; &lt;&lt; endl;
+    exit(EXIT_FAILURE);
+  }
+
+  // Get fallback email.
+  bool mailFallbackError = 0;
+  if(!config[10].empty())
+  {
+    mailData.fallbackReceiver = config[10].c_str();
+  }
+  else
+  {
+    mailFallbackError = 1;
+    mailData.fallbackReceiver = &quot;&quot;;
+  }
+
+  // Get fallback JID.
+  bool xmppFallbackError = 0;
+  if(!config[11].empty())
+  {
+    xmppData.fallbackReceiver = config[11].c_str();
+  }
+  else
+  {
+    xmppFallbackError = 1;
+    xmppData.fallbackReceiver = &quot;&quot;;
+  }
+
+  // Get fallback mobile number for Clickatell API.
+  bool mobilecFallbackError = 0;
+  if(!config[12].empty())
+  {
+    clickatellData.fallbackNumber = config[12].c_str();
+  }
+  else
+  {
+    mobilecFallbackError = 1;
+    clickatellData.fallbackNumber = &quot;&quot;;
+  }
+
+  if(!config[13].empty())
+  {
+    nodeID = stringToInteger(config[13].c_str());
+  }
+  else
+  {
+    cout &lt;&lt; &quot;Error. Node ID not set?&quot; &lt;&lt; endl;
+    exit(EXIT_FAILURE);
+  }
+
+  // Finished parsing of config file.
+  cout &lt;&lt; &quot;[ OK ]&quot; &lt;&lt; endl;
+
+  // Perform a selftest.
+  cout &lt;&lt; &quot;- Selftest sequence:\t&quot;;
+  cout.flush();
+  if(selfTest(port, loglevel) != &quot;1&quot;)
+  {
+    // Selftest failed!
+    cout &lt;&lt; &quot;Terminating: &quot; &lt;&lt; selfTest(port, loglevel) &lt;&lt; endl;
+    exit(EXIT_FAILURE);
+  }
+  else
+  {
+    // No errors.
+    cout &lt;&lt; &quot;[ OK ]&quot; &lt;&lt; endl;
+  }
+
+  cout &lt;&lt; &quot;- TLS initialization:\t&quot;;
+  cout.flush();
+
+  // GnuTLS variables.
+  static gnutls_dh_params_t dh_params;
+
+  // GnuTLS initialization.
+  gnutls_global_init();
+  gnutls_global_set_log_function(logTLS);
+  gnutls_global_set_log_level(0);
+  gnutls_anon_allocate_server_credentials(&amp;anoncred);
+  gnutls_dh_params_init(&amp;dh_params);
+  gnutls_dh_params_generate2 (dh_params, DH_BITS);
+  gnutls_anon_set_server_dh_params (anoncred, dh_params);
+
+  cout &lt;&lt; &quot;[ OK ]&quot; &lt;&lt; endl;
+
+  // Display warnings about possibly missing fallback receivers.
+  if(mailFallbackError || xmppFallbackError || mobilecFallbackError)
+    cout &lt;&lt; &quot;- Some notification methods have no fallback receivers.&quot; &lt;&lt; endl;
+
+  Log log(LOGFILE, dbData);
+
+  // Start as daemon if we are not in debug mode.
+  if(!debug)
+  {
+    if(daemon(0,0) &lt; 0)
+    {
+      cout &lt;&lt; &quot;Terminated. Could not initialize daemon mode!&quot; &lt;&lt; endl;
+      exit(EXIT_FAILURE);
+    }
+  }
+
+  // We are a daemon from here on.
+
+  pid_t pid = getpid();
+
+  // Write the pidfile.
+  ofstream pidwrite(PIDFILE, ios::out);
+  if(!pidwrite.fail())
+  {
+    pidwrite &lt;&lt; pid &lt;&lt; endl;
+  }
+  else
+  {
+    log.putLog(2, &quot;50&quot;, &quot;Terminated. Could not create pidfile!&quot;);
+    exit(EXIT_FAILURE);
+  }
+  pidwrite.close();
 
 #ifndef DEBUG
-	// Signal handling.  (could need improvements here!)
-	signal(SIGABRT, cleanUp);
-	signal(SIGFPE, cleanUp);
-	signal(SIGILL, cleanUp);
-	signal(SIGINT, cleanUp);
-	signal(SIGSEGV, cleanUp);
-	signal(SIGTERM, cleanUp);
+  // Signal handling.  (could need improvements here!)
+  signal(SIGABRT, cleanUp);
+  signal(SIGFPE, cleanUp);
+  signal(SIGILL, cleanUp);
+  signal(SIGINT, cleanUp);
+  signal(SIGSEGV, cleanUp);
+  signal(SIGTERM, cleanUp);
 #endif
 
-	Database db(dbData);
+  Database db(dbData);
 
-	if(db.initConnection()){
+  if(db.initConnection())
+  {
     // Check if our node ID exists
     int noderes = Cloud::checkNodeID(nodeID, db);
-    if(noderes &lt; 0){
+    if(noderes &lt; 0)
+    {
       cout &lt;&lt; &quot;Could not check for Node ID! (&quot; &lt;&lt; nodeID&lt;&lt; &quot;) Database error.&quot; &lt;&lt; endl;
-		  exit(EXIT_FAILURE);
-    }else if(noderes == 0){
+      exit(EXIT_FAILURE);
+    }
+    else if(noderes == 0)
+    {
       cout &lt;&lt; &quot;Invalid Node ID! (&quot; &lt;&lt; nodeID&lt;&lt; &quot;) Does not exist.&quot; &lt;&lt; endl;
-		  exit(EXIT_FAILURE);
+      exit(EXIT_FAILURE);
     }
 
-		db.setQuery(db.getHandle(), Information::clearHealth(nodeID));
+    db.setQuery(db.getHandle(), Information::clearHealth(nodeID));
 
-// REMOVE FOR CLOUD
+    // REMOVE FOR CLOUD
     db.setQuery(db.getHandle(), &quot;UPDATE services SET handler = 0&quot;);
 
-		// Update notification settings.
-		mailData = Mail::fetchSettings(dbData);
-		xmppData = XMPP::fetchSettings(dbData);
-		clickatellData = Clickatell::fetchSettings(dbData);
-
-		if((servSock = socket(AF_INET, SOCK_STREAM, 0)) == -1){
-			// Socket could not be created.
-			cout &lt;&lt; &quot;Could not create socket! Aborting.&quot; &lt;&lt; endl;
-		  exit(EXIT_FAILURE);
-		}else{
-			// Socket created.
-			const int y = 1;
-			setsockopt(servSock, SOL_SOCKET, SO_REUSEADDR, &amp;y, sizeof(int));
-			address.sin_family = AF_INET;
-			// On which IPs to listen (INADDR_ANY -&gt; any IP).
-			address.sin_addr.s_addr = INADDR_ANY;
-			// On which port to listen.
-			address.sin_port = htons(port);
-			if(bind (servSock,(struct sockaddr *) &amp;address,sizeof (address)) != 0) {
-				// Could not bind to socket.
-				cout &lt;&lt; &quot;Could not bind to socket. Is the server already running? Aborting.&quot; &lt;&lt; endl;
-		    exit(EXIT_FAILURE);
-			}else{
-				// Bound to socket! Listen.
-				listen(servSock, 50);
-
-				addrlen = sizeof(struct sockaddr_in);
+    // Update notification settings.
+    mailData = Mail::fetchSettings(dbData);
+    xmppData = XMPP::fetchSettings(dbData);
+    clickatellData = Clickatell::fetchSettings(dbData);
+
+    if((servSock = socket(AF_INET, SOCK_STREAM, 0)) == -1)
+    {
+      // Socket could not be created.
+      cout &lt;&lt; &quot;Could not create socket! Aborting.&quot; &lt;&lt; endl;
+      exit(EXIT_FAILURE);
+    }
+    else
+    {
+      // Socket created.
+      const int y = 1;
+      setsockopt(servSock, SOL_SOCKET, SO_REUSEADDR, &amp;y, sizeof(int));
+      address.sin_family = AF_INET;
+      // On which IPs to listen (INADDR_ANY -&gt; any IP).
+      address.sin_addr.s_addr = INADDR_ANY;
+      // On which port to listen.
+      address.sin_port = htons(port);
+      if(bind (servSock,(struct sockaddr *) &amp;address,sizeof (address)) != 0)
+      {
+        // Could not bind to socket.
+        cout &lt;&lt; &quot;Could not bind to socket. Is the server already running? Aborting.&quot; &lt;&lt; endl;
+        exit(EXIT_FAILURE);
+      }
+      else
+      {
+        // Bound to socket! Listen.
+        listen(servSock, 50);
+
+        addrlen = sizeof(struct sockaddr_in);
 
         // Fork client handler processes.
-				for(int threadCount = 0; threadCount &lt; numProcs; threadCount++){
-					// Fork client handlers.
-					pid_t processID;
-					if((processID = fork()) &lt; 0){
-						cout &lt;&lt; &quot;Could not fork client handlers.&quot; &lt;&lt; endl;
-						exit(EXIT_FAILURE);
-					}else if(processID == 0){
-						// This is the child process / Forking worked.
-						clientHandler = 1;
-						handleClient();
-					}
-				}
-
-				clientHandler = 0;
-
-				// Are service checks enabled in config file?
-				if(doServiceChecks){
-					// Start service check thread.
-					pthread_t serviceThread;
-					if(pthread_create(&amp;serviceThread, 0, serviceChecks, NULL)) {
-						cout &lt;&lt; &quot;Terminating: Could not create service checks thread.&quot; &lt;&lt; endl;
-		        exit(EXIT_FAILURE);
-					}
-				}
-
-
-				// Start maintenance thread.
-				pthread_t maintThread;
-				if(pthread_create(&amp;maintThread, 0, maintenanceThread, NULL)) {
-					cout &lt;&lt; &quot;Terminating: Could not create maintenance thread.&quot; &lt;&lt; endl;
-		      exit(EXIT_FAILURE);
-				}
+        for(int threadCount = 0; threadCount &lt; numProcs; threadCount++)
+        {
+          // Fork client handlers.
+          pid_t processID;
+          if((processID = fork()) &lt; 0)
+          {
+            cout &lt;&lt; &quot;Could not fork client handlers.&quot; &lt;&lt; endl;
+            exit(EXIT_FAILURE);
+          }
+          else if(processID == 0)
+          {
+            // This is the child process / Forking worked.
+            clientHandler = 1;
+            handleClient();
+          }
+        }
+
+        clientHandler = 0;
+
+        // Are service checks enabled in config file?
+        if(doServiceChecks)
+        {
+          // Start service check thread.
+          pthread_t serviceThread;
+          if(pthread_create(&amp;serviceThread, 0, serviceChecks, NULL))
+          {
+            cout &lt;&lt; &quot;Terminating: Could not create service checks thread.&quot; &lt;&lt; endl;
+            exit(EXIT_FAILURE);
+          }
+        }
+
+        // Start maintenance thread.
+        pthread_t maintThread;
+        if(pthread_create(&amp;maintThread, 0, maintenanceThread, NULL))
+        {
+          cout &lt;&lt; &quot;Terminating: Could not create maintenance thread.&quot; &lt;&lt; endl;
+          exit(EXIT_FAILURE);
+        }
 
         // Start thread for cloud status updating.
         pthread_t cloudStatusThread;
-				if(pthread_create(&amp;cloudStatusThread, 0, cloudStatusUpdater, NULL)) {
-					cout &lt;&lt; &quot;Terminating: Could not create cloud status updater.&quot; &lt;&lt; endl;
-		      exit(EXIT_FAILURE);
-				}
-
-// RE-ENABLE FOR CLOUD
-//        // Start thread for cloud service management.
-//        pthread_t cloudServiceManagerThread;
-//				if(pthread_create(&amp;cloudServiceManagerThread, 0, cloudServiceManager, NULL)) {
-//					cout &lt;&lt; &quot;Terminating: Could not create cloud service management thread.&quot; &lt;&lt; endl;
-//		      exit(EXIT_FAILURE);
-//				}
-
-        if(!Cloud::setTakeoff(nodeID, db)){
+        if(pthread_create(&amp;cloudStatusThread, 0, cloudStatusUpdater, NULL))
+        {
+          cout &lt;&lt; &quot;Terminating: Could not create cloud status updater.&quot; &lt;&lt; endl;
+          exit(EXIT_FAILURE);
+        }
+
+        // RE-ENABLE FOR CLOUD
+        //        // Start thread for cloud service management.
+        //        pthread_t cloudServiceManagerThread;
+        //				if(pthread_create(&amp;cloudServiceManagerThread, 0, cloudServiceManager, NULL)) {
+        //					cout &lt;&lt; &quot;Terminating: Could not create cloud service management thread.&quot; &lt;&lt; endl;
+        //		      exit(EXIT_FAILURE);
+        //				}
+
+        if(!Cloud::setTakeoff(nodeID, db))
+        {
           cout &lt;&lt; &quot;Terminating: Could not update startup timestamp.&quot; &lt;&lt; endl;
-		      exit(EXIT_FAILURE);
+          exit(EXIT_FAILURE);
         }
 
-				// Keep the main thread running.
-				//int fails = 0;
-				while(1){
-					XMPP xmpp(xmppData, dbData);
-
-					// Update health statistics.
-					if(!db.setQuery(db.getHandle(), Information::updateHealth(nodeID, Health::getPID(),
-							clientHandler,Health::getVMSize(), Health::getThreads(),
-							packageCountOK, packageCountERR,
-							Health::getDBSize(dbData, 1)/1024,
-							Health::getDBSize(dbData, 2)/1024,
-							Health::getDBSize(dbData, 3)/1024))){
-						log.putLog(1, &quot;052&quot;, &quot;Could not update health statistics.&quot;);
+        // Keep the main thread running.
+        //int fails = 0;
+        while(1)
+        {
+          XMPP xmpp(xmppData, dbData);
+
+          // Update health statistics.
+          if(!db.setQuery(db.getHandle(), Information::updateHealth(nodeID, Health::getPID(),
+            clientHandler,Health::getVMSize(), Health::getThreads(),
+            packageCountOK, packageCountERR,
+            Health::getDBSize(dbData, 1)/1024,
+            Health::getDBSize(dbData, 2)/1024,
+            Health::getDBSize(dbData, 3)/1024)))
+          {
+            log.putLog(1, &quot;052&quot;, &quot;Could not update health statistics.&quot;);
           }
 
-					sleep(60);
-				}
+          sleep(60);
+        }
+
+        close(servSock);
+      }
+    }
+  }
+  else
+  {
+    cout  &lt;&lt; &quot;Could not connect to database server. Aborting.&quot; &lt;&lt; endl
+      &lt;&lt; &quot;\tThe following error was reported: &quot; &lt;&lt; mysql_error(db.getHandle()) &lt;&lt; endl;
+    log.putLog(2, &quot;051&quot;, &quot;Could not connect to database server. Aborting.&quot;);
+  }
 
-				close(servSock);
-			}
-		}
-	}else{
-		cout 	&lt;&lt; &quot;Could not connect to database server. Aborting.&quot; &lt;&lt; endl
-				&lt;&lt; &quot;\tThe following error was reported: &quot; &lt;&lt; mysql_error(db.getHandle()) &lt;&lt; endl;
-		log.putLog(2, &quot;051&quot;, &quot;Could not connect to database server. Aborting.&quot;);
-	}
+  // Not reached.
 
-	// Not reached.
-  
   exit(EXIT_FAILURE);
 }</diff>
      <filename>src/core.cc</filename>
    </modified>
    <modified>
      <diff>@@ -19,143 +19,176 @@
 #include &quot;../internal.h&quot;
 #include &quot;../log/Log.h&quot;
 
-Database::Database(mySQLData sqlData){
-	mysql_host = sqlData.host;
-	mysql_user = sqlData.user;
-	mysql_password = sqlData.pass;
-	mysql_database = sqlData.db;
-	mysql_port = sqlData.port;
+Database::Database(mySQLData sqlData)
+{
+  mysql_host = sqlData.host;
+  mysql_user = sqlData.user;
+  mysql_password = sqlData.pass;
+  mysql_database = sqlData.db;
+  mysql_port = sqlData.port;
 }
 
-bool Database::initConnection(){
-	init = mysql_init(NULL);
-	if(init == NULL)
-		return 0;
-
-	// Connect to mysql database.
-	if(mysql_real_connect(	init,
-							mysql_host,
-							mysql_user,
-							mysql_password,
-							mysql_database,
-							mysql_port,
-							NULL,0) == NULL) {
-		// No connection was established.
-		return 0;
-	}else{
-		// Successfully connected to mysql database.
-		return 1;
-	}
-	return 0;
+
+bool Database::initConnection()
+{
+  init = mysql_init(NULL);
+  if(init == NULL)
+    return 0;
+
+  // Connect to mysql database.
+  if(mysql_real_connect(  init,
+    mysql_host,
+    mysql_user,
+    mysql_password,
+    mysql_database,
+    mysql_port,
+    NULL,0) == NULL)
+  {
+    // No connection was established.
+    return 0;
+  }
+  else
+  {
+    // Successfully connected to mysql database.
+    return 1;
+  }
+  return 0;
 }
 
-bool Database::setQuery(MYSQL* init, string query){
-	if(query.empty() || init == NULL)
-		return &quot;NULL&quot;;
 
-	if(mysql_real_query(init, query.c_str(), strlen(query.c_str())) == 0){
-		// Query successful.
-		return 1;
-	}
+bool Database::setQuery(MYSQL* init, string query)
+{
+  if(query.empty() || init == NULL)
+    return &quot;NULL&quot;;
+
+  if(mysql_real_query(init, query.c_str(), strlen(query.c_str())) == 0)
+  {
+    // Query successful.
+    return 1;
+  }
 
-	// Query failed.
+  // Query failed.
 
-	error = mysql_error(init);
+  error = mysql_error(init);
 
-	return 0;
+  return 0;
 }
 
-string Database::sGetQuery(string query){
-	if(query.empty())
-		return &quot;NULL&quot;;
-
-	if(mysql_real_query(init, query.c_str(), strlen(query.c_str())) == 0){
-		// Query successful.
-		MYSQL_RES* res = mysql_store_result(init);
-		MYSQL_ROW row;
-		row = mysql_fetch_row(res);
-		stringstream result;
-		if(mysql_num_rows(res) &gt; 0){
-			result &lt;&lt; row[0];
-		}else{
-			mysql_free_result(res);
-			return &quot;NULL&quot;;
-		}
-		mysql_free_result(res);
-		return result.str();
-	}
-	return &quot;NULL&quot;;
+
+string Database::sGetQuery(string query)
+{
+  if(query.empty())
+    return &quot;NULL&quot;;
+
+  if(mysql_real_query(init, query.c_str(), strlen(query.c_str())) == 0)
+  {
+    // Query successful.
+    MYSQL_RES* res = mysql_store_result(init);
+    MYSQL_ROW row;
+    row = mysql_fetch_row(res);
+    stringstream result;
+    if(mysql_num_rows(res) &gt; 0)
+    {
+      result &lt;&lt; row[0];
+    }
+    else
+    {
+      mysql_free_result(res);
+      return &quot;NULL&quot;;
+    }
+    mysql_free_result(res);
+    return result.str();
+  }
+  return &quot;NULL&quot;;
 }
 
-unsigned int Database::getNumOfResults(string query){
-	if(query.empty())
-		return 0;
 
-	if(mysql_real_query(init, query.c_str(), strlen(query.c_str())) == 0){
-		// Query successful.
-		MYSQL_RES* res = mysql_store_result(init);
-		unsigned int num = 0;
-    if((num = mysql_num_rows(res)) &lt;= 0){
+unsigned int Database::getNumOfResults(string query)
+{
+  if(query.empty())
+    return 0;
+
+  if(mysql_real_query(init, query.c_str(), strlen(query.c_str())) == 0)
+  {
+    // Query successful.
+    MYSQL_RES* res = mysql_store_result(init);
+    unsigned int num = 0;
+    if((num = mysql_num_rows(res)) &lt;= 0)
+    {
       num = 0;
     }
-		mysql_free_result(res);
-		return num;
-	}
-	return 0;
+    mysql_free_result(res);
+    return num;
+  }
+  return 0;
 }
 
-string Database::sGetQuery2(string query){
-	if(query.empty())
-		return &quot;NULL&quot;;
-	if(mysql_real_query(init, query.c_str(), strlen(query.c_str())) == 0){
-		// Query successful.
-		MYSQL_RES* res = mysql_store_result(init);
-		MYSQL_ROW row;
-		row = mysql_fetch_row(res);
-		stringstream result;
-		if(mysql_num_rows(res) &gt; 0){
-			result	&lt;&lt; row[0]
-					&lt;&lt; &quot; &quot;
-					&lt;&lt; row[1];
-		}else{
-			mysql_free_result(res);
-			return &quot;NULL&quot;;
-		}
-		mysql_free_result(res);
-		return result.str();
-	}
-	return &quot;NULL&quot;;
+
+string Database::sGetQuery2(string query)
+{
+  if(query.empty())
+    return &quot;NULL&quot;;
+  if(mysql_real_query(init, query.c_str(), strlen(query.c_str())) == 0)
+  {
+    // Query successful.
+    MYSQL_RES* res = mysql_store_result(init);
+    MYSQL_ROW row;
+    row = mysql_fetch_row(res);
+    stringstream result;
+    if(mysql_num_rows(res) &gt; 0)
+    {
+      result  &lt;&lt; row[0]
+        &lt;&lt; &quot; &quot;
+        &lt;&lt; row[1];
+    }
+    else
+    {
+      mysql_free_result(res);
+      return &quot;NULL&quot;;
+    }
+    mysql_free_result(res);
+    return result.str();
+  }
+  return &quot;NULL&quot;;
 }
 
-bool Database::clearSensorData(){
-	const char* query = &quot;DELETE FROM sensorvalues WHERE TIMEDIFF(CURRENT_TIMESTAMP, created_at) &gt; '730:00:00'&quot;;
 
-	if(mysql_real_query(init, query, strlen(query)) == 0){
-		// Query successful.
-		return 1;
-	}
+bool Database::clearSensorData()
+{
+  const char* query = &quot;DELETE FROM sensorvalues WHERE TIMEDIFF(CURRENT_TIMESTAMP, created_at) &gt; '730:00:00'&quot;;
 
-	// Query failed.
-	return 0;
+  if(mysql_real_query(init, query, strlen(query)) == 0)
+  {
+    // Query successful.
+    return 1;
+  }
+
+  // Query failed.
+  return 0;
 }
 
-bool Database::clearServiceData(){
-	unsigned int lastmonth = (time(NULL)-(86400*31));
 
-	stringstream query;
-	query	&lt;&lt; &quot;DELETE FROM servicerecords WHERE timestamp &lt; &quot;;
-	query	&lt;&lt; lastmonth;
+bool Database::clearServiceData()
+{
+  unsigned int lastmonth = (time(NULL)-(86400*31));
+
+  stringstream query;
+  query &lt;&lt; &quot;DELETE FROM servicerecords WHERE timestamp &lt; &quot;;
+  query &lt;&lt; lastmonth;
 
-	if(mysql_real_query(init, query.str().c_str(), strlen(query.str().c_str())) == 0){
-		// Query successful.
-		return 1;
-	}
+  if(mysql_real_query(init, query.str().c_str(), strlen(query.str().c_str())) == 0)
+  {
+    // Query successful.
+    return 1;
+  }
 
-	// Query failed.
-	return 0;
+  // Query failed.
+  return 0;
 }
 
-string Database::escapeString(string escapeMe){
+
+string Database::escapeString(string escapeMe)
+{
   stringstream result;
   char query[escapeMe.length()*2+1];
   mysql_escape_string(query, escapeMe.c_str(), escapeMe.length());</diff>
      <filename>src/database/Database.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -18,124 +18,124 @@
 //!  MySQL database connection and handling
 /*!
  * Connects to database and provides some general database methods for queries and table structure checks.
-*/
+ */
 
 #ifndef DATABASE_H_
 #define DATABASE_H_
 
 #include &quot;../internal.h&quot;
 
-class Database {
-	private:
-		//! Holds all names of tables that are checked in checkTables().
-		/*!
-		 * \sa checkTables()
-		 */
-		vector&lt;string&gt;	tables;
-
-		//! The MySQL handle.
-		MYSQL			*init;
-
-		//! Holds the last error message.
-		string			error;
-
-		//! Holds the name of a missing table if found by checkTables().
-		/*!
-		 * \sa checkTables()
-		 */
-		string			missingcol;
-
-		//! The host the MySQL database is running on.
-		const char*		mysql_host;
-
-		//! The user we want to connect with to the MySQL database.
-		const char*		mysql_user;
-
-		//! The MySQL user's password.
-		const char*		mysql_password;
-
-		//! The ScopePort database on the MySQL host.
-		const char*		mysql_database;
-
-		//! The port we want to use for MySQL connection. (0 means standard port)
-		int				mysql_port;
-	public:
-		//! Constructor. Converts sqlData values to single variables.
-		Database(mySQLData sqlData);
-
-		//! Opens connection to MySQL server
-		/*!
-		 * \return False if connection could not be established or creating the handle failed, true if connected to database.
-		 */
-		bool	initConnection();
-
-		//! Performs query and does not give back any data. Useful for INSERT, UPDATE or DELETE queries.
-		/*!
-		 * \param init A MySQL handle.
-		 * \param query The query string.
-		 * \return True if the query has been executed successfully or false if an error occured.
-		 */
-		bool	setQuery(MYSQL* init, string query);
-
-		//! Performs query and gives back result string of first requested field.
-		/*
-		 * \param query The query string.
-		 * \return &quot;NULL&quot; if an error occured (or nothing was fetched) or the result string.
-		 */
-		string	sGetQuery(string query);
-
-		//! Performs query and gives back number of fetched rows.
-		/*
-		 * \param query The query string.
-		 * \return The number of fetched rows.
-		 */
-		unsigned int getNumOfResults(string query);
-
-		//! Performs query and gives back result string of first and second requested field separated by a whitespace.
-		/*
-		 * \param query The query string.
-		 * \return &quot;NULL&quot; if an error occured (or nothing was fetched) or the result string.
-		 */
-		string	sGetQuery2(string query);
-
-		//! Deletes data from table &quot;sensordata&quot; that is older than 31 days.
-		/*
-		 * \return False in case of error, true if everything went fine.
-		 */
-		bool	clearSensorData();
-
-		//! Deletes data from table &quot;servicedata&quot; that is older than 24 hours.
-		/*
-		 * \return False in case of error, true if everything went fine.
-		 */
-		bool	clearServiceData();
-
-		//! Returns the MySQL handle.
-		/*!
-		 * \sa init
-		 * \sa initConnection()
-		 */
-		MYSQL*	getHandle() { return init; }
-
-		//! Returns the last error message.
-		/*!
-		 * \sa error
-		 */
-		string	getError() { return error; }
-
-		//! Returns the missing table reported by checkTables()
-		/*!
-		 * \sa checkTables()
-		 */
-		string	getMissingTable() { return missingcol; }
-
-		//! Returns the number of tables that should be checked.
-		/*!
-		 * \sa checkTables()
-		 */
-		int		getTableCount() { return tables.size(); }
+class Database
+{
+  private:
+    //! Holds all names of tables that are checked in checkTables().
+    /*!
+     * \sa checkTables()
+     */
+    vector&lt;string&gt;  tables;
+
+    //! The MySQL handle.
+    MYSQL     *init;
+
+    //! Holds the last error message.
+    string      error;
+
+    //! Holds the name of a missing table if found by checkTables().
+    /*!
+     * \sa checkTables()
+     */
+    string      missingcol;
+
+    //! The host the MySQL database is running on.
+    const char*   mysql_host;
+
+    //! The user we want to connect with to the MySQL database.
+    const char*   mysql_user;
+
+    //! The MySQL user's password.
+    const char*   mysql_password;
+
+    //! The ScopePort database on the MySQL host.
+    const char*   mysql_database;
+
+    //! The port we want to use for MySQL connection. (0 means standard port)
+    int       mysql_port;
+  public:
+    //! Constructor. Converts sqlData values to single variables.
+    Database(mySQLData sqlData);
+
+    //! Opens connection to MySQL server
+    /*!
+     * \return False if connection could not be established or creating the handle failed, true if connected to database.
+     */
+    bool  initConnection();
+
+    //! Performs query and does not give back any data. Useful for INSERT, UPDATE or DELETE queries.
+    /*!
+     * \param init A MySQL handle.
+     * \param query The query string.
+     * \return True if the query has been executed successfully or false if an error occured.
+     */
+    bool  setQuery(MYSQL* init, string query);
+
+    //! Performs query and gives back result string of first requested field.
+    /*
+     * \param query The query string.
+     * \return &quot;NULL&quot; if an error occured (or nothing was fetched) or the result string.
+     */
+    string  sGetQuery(string query);
+
+    //! Performs query and gives back number of fetched rows.
+    /*
+     * \param query The query string.
+     * \return The number of fetched rows.
+     */
+    unsigned int getNumOfResults(string query);
+
+    //! Performs query and gives back result string of first and second requested field separated by a whitespace.
+    /*
+     * \param query The query string.
+     * \return &quot;NULL&quot; if an error occured (or nothing was fetched) or the result string.
+     */
+    string  sGetQuery2(string query);
+
+    //! Deletes data from table &quot;sensordata&quot; that is older than 31 days.
+    /*
+     * \return False in case of error, true if everything went fine.
+     */
+    bool  clearSensorData();
+
+    //! Deletes data from table &quot;servicedata&quot; that is older than 24 hours.
+    /*
+     * \return False in case of error, true if everything went fine.
+     */
+    bool  clearServiceData();
+
+    //! Returns the MySQL handle.
+    /*!
+     * \sa init
+     * \sa initConnection()
+     */
+    MYSQL*  getHandle() { return init; }
+
+    //! Returns the last error message.
+    /*!
+     * \sa error
+     */
+    string  getError() { return error; }
+
+    //! Returns the missing table reported by checkTables()
+    /*!
+     * \sa checkTables()
+     */
+    string  getMissingTable() { return missingcol; }
+
+    //! Returns the number of tables that should be checked.
+    /*!
+     * \sa checkTables()
+     */
+    int   getTableCount() { return tables.size(); }
 
     static string escapeString(string escapeMe);
 };
-
-#endif /*DATABASE_H_*/
+#endif                                            /*DATABASE_H_*/</diff>
      <filename>src/database/Database.h</filename>
    </modified>
    <modified>
      <diff>@@ -19,42 +19,50 @@
 #include &quot;../internal.h&quot;
 #include &quot;Database.h&quot;
 
-string Information::getSensorName(string st){
-	stringstream query;
-	query	&lt;&lt; &quot;SELECT name FROM sensors WHERE st = &quot;
-			&lt;&lt; st
-			&lt;&lt; &quot; LIMIT 1&quot;;
-	return query.str();
+string Information::getSensorName(string st)
+{
+  stringstream query;
+  query &lt;&lt; &quot;SELECT name FROM sensors WHERE st = &quot;
+    &lt;&lt; st
+    &lt;&lt; &quot; LIMIT 1&quot;;
+  return query.str();
 }
 
-string Information::getHostName(string hostid){
-	stringstream query;
-	query	&lt;&lt; &quot;SELECT name FROM hosts WHERE hostid = &quot;
-			&lt;&lt; hostid
-			&lt;&lt; &quot; LIMIT 1&quot;;
 
-	return query.str();
+string Information::getHostName(string hostid)
+{
+  stringstream query;
+  query &lt;&lt; &quot;SELECT name FROM hosts WHERE hostid = &quot;
+    &lt;&lt; hostid
+    &lt;&lt; &quot; LIMIT 1&quot;;
+
+  return query.str();
 }
 
-string Information::getSensorCondition(string hostid, string st){
-	stringstream query;
-	query	&lt;&lt; &quot;SELECT type,value FROM sensor_conditions WHERE hostid = &quot;
-			&lt;&lt; hostid
-			&lt;&lt; &quot; AND st = &quot;
-			&lt;&lt; st;
-	return query.str();
+
+string Information::getSensorCondition(string hostid, string st)
+{
+  stringstream query;
+  query &lt;&lt; &quot;SELECT type,value FROM sensor_conditions WHERE hostid = &quot;
+    &lt;&lt; hostid
+    &lt;&lt; &quot; AND st = &quot;
+    &lt;&lt; st;
+  return query.str();
 }
 
-string Information::getReceiverGroup(string hostid, string st){
-	stringstream query;
-	query	&lt;&lt; &quot;SELECT warninggroup FROM sensor_conditions WHERE hostid = &quot;
-			&lt;&lt; hostid
-			&lt;&lt; &quot; AND st = &quot;
-			&lt;&lt; st;
 
-	return query.str();
+string Information::getReceiverGroup(string hostid, string st)
+{
+  stringstream query;
+  query &lt;&lt; &quot;SELECT warninggroup FROM sensor_conditions WHERE hostid = &quot;
+    &lt;&lt; hostid
+    &lt;&lt; &quot; AND st = &quot;
+    &lt;&lt; st;
+
+  return query.str();
 }
 
+
 /*
  *
  * getServiceReceiverGroup(string serviceID, int type)
@@ -64,17 +72,19 @@ string Information::getReceiverGroup(string hostid, string st){
  *
  */
 
-string Information::getServiceReceiverGroup(unsigned int serviceID){
+string Information::getServiceReceiverGroup(unsigned int serviceID)
+{
 
-	stringstream query;
+  stringstream query;
 
-	// RudeCheck.
-	query	&lt;&lt; &quot;SELECT warninggroup FROM services WHERE id = &quot;
-			&lt;&lt; serviceID;
+  // RudeCheck.
+  query &lt;&lt; &quot;SELECT warninggroup FROM services WHERE id = &quot;
+    &lt;&lt; serviceID;
 
-	return query.str();
+  return query.str();
 }
 
+
 /*
  *
  * getServiceName(string serviceID, int type)
@@ -84,48 +94,55 @@ string Information::getServiceReceiverGroup(unsigned int serviceID){
  *
  */
 
-string Information::getServiceName(unsigned int serviceID){
-	stringstream query;
+string Information::getServiceName(unsigned int serviceID)
+{
+  stringstream query;
 
-	query	&lt;&lt; &quot;SELECT name FROM services WHERE id = &quot;
-			&lt;&lt; serviceID;
+  query &lt;&lt; &quot;SELECT name FROM services WHERE id = &quot;
+    &lt;&lt; serviceID;
 
-	return query.str();
+  return query.str();
 }
 
-string Information::getLastWarn(string hostid, string st){
-	stringstream query;
-	query	&lt;&lt; &quot;SELECT lastwarn FROM sensor_conditions WHERE hostid = &quot;
-			&lt;&lt; hostid
-			&lt;&lt; &quot; AND st = &quot;
-			&lt;&lt; st;
 
-	return query.str();
+string Information::getLastWarn(string hostid, string st)
+{
+  stringstream query;
+  query &lt;&lt; &quot;SELECT lastwarn FROM sensor_conditions WHERE hostid = &quot;
+    &lt;&lt; hostid
+    &lt;&lt; &quot; AND st = &quot;
+    &lt;&lt; st;
+
+  return query.str();
 }
 
-string Information::getLastServiceWarn(unsigned int serviceID){
-	stringstream query;
 
+string Information::getLastServiceWarn(unsigned int serviceID)
+{
+  stringstream query;
 
-	// RudeCheck.
-	query	&lt;&lt; &quot;SELECT lastwarn FROM services WHERE id = &quot;
-			&lt;&lt; serviceID;
+  // RudeCheck.
+  query &lt;&lt; &quot;SELECT lastwarn FROM services WHERE id = &quot;
+    &lt;&lt; serviceID;
 
-	return query.str();
+  return query.str();
 }
 
-string Information::setLastWarn(time_t lastwarn, string hostid, string st){
-	stringstream query;
-	query	&lt;&lt; &quot;UPDATE sensor_conditions SET lastwarn = '&quot;
-			&lt;&lt; time(&amp;lastwarn)
-			&lt;&lt; &quot;' WHERE hostid = &quot;
-			&lt;&lt; hostid
-			&lt;&lt; &quot; AND st = &quot;
-			&lt;&lt; st;
 
-	return query.str();
+string Information::setLastWarn(time_t lastwarn, string hostid, string st)
+{
+  stringstream query;
+  query &lt;&lt; &quot;UPDATE sensor_conditions SET lastwarn = '&quot;
+    &lt;&lt; time(&amp;lastwarn)
+    &lt;&lt; &quot;' WHERE hostid = &quot;
+    &lt;&lt; hostid
+    &lt;&lt; &quot; AND st = &quot;
+    &lt;&lt; st;
+
+  return query.str();
 }
 
+
 /*
  *
  * setLastServiceWarn(time_t lastwarn, string serviceID, int type)
@@ -135,197 +152,222 @@ string Information::setLastWarn(time_t lastwarn, string hostid, string st){
  *
  */
 
-string Information::setLastServiceWarn(time_t lastwarn, unsigned int serviceID){
-	stringstream query;
+string Information::setLastServiceWarn(time_t lastwarn, unsigned int serviceID)
+{
+  stringstream query;
 
-	// SoftCheck.
-	query	&lt;&lt; &quot;UPDATE services SET lastwarn = '&quot;
-			&lt;&lt; time(&amp;lastwarn)
-			&lt;&lt; &quot;' WHERE id = &quot;
-			&lt;&lt; serviceID;
+  // SoftCheck.
+  query &lt;&lt; &quot;UPDATE services SET lastwarn = '&quot;
+    &lt;&lt; time(&amp;lastwarn)
+    &lt;&lt; &quot;' WHERE id = &quot;
+    &lt;&lt; serviceID;
 
-	return query.str();
+  return query.str();
 }
 
-string Information::getSensorSeverity(string hostID, string st){
-	stringstream query;
-	query	&lt;&lt; &quot;SELECT severity FROM sensor_conditions WHERE hostid = &quot;
-			&lt;&lt; hostID
-			&lt;&lt; &quot; AND st = &quot;
-			&lt;&lt; st;
 
-	return query.str();
+string Information::getSensorSeverity(string hostID, string st)
+{
+  stringstream query;
+  query &lt;&lt; &quot;SELECT severity FROM sensor_conditions WHERE hostid = &quot;
+    &lt;&lt; hostID
+    &lt;&lt; &quot; AND st = &quot;
+    &lt;&lt; st;
+
+  return query.str();
 }
 
+
 vector&lt;string&gt; Information::getMailWarningReceivers(MYSQL* init, string groupID,
-		string sevBorder){
-	stringstream query;
-	query	&lt;&lt;	&quot;SELECT mail FROM notificationgroups WHERE warninggroup = &quot;
-			&lt;&lt;	groupID
-			&lt;&lt;	&quot; AND sevborder &lt;= &quot;
-			&lt;&lt;	sevBorder
-			&lt;&lt;	&quot; AND email = 1&quot;
-				&quot; AND deleted = 0&quot;
-				&quot; LIMIT 500&quot;;
-
-	vector&lt;string&gt; result;
-
-	if(mysql_real_query(init, query.str().c_str(), strlen(query.str().c_str())) == 0){
-		// Query successful.
-		MYSQL_RES* res = mysql_store_result(init);
-		MYSQL_ROW  row;
-		if(mysql_num_rows(res) &gt; 0){
-			while((row = mysql_fetch_row(res))){
-				result.push_back(row[0]);
-			}
-		}
-		mysql_free_result(res);
-		return result;
-	}
-	result.push_back(&quot;NULL&quot;);
-	return result;
+string sevBorder)
+{
+  stringstream query;
+  query &lt;&lt;  &quot;SELECT mail FROM notificationgroups WHERE warninggroup = &quot;
+    &lt;&lt;  groupID
+    &lt;&lt;  &quot; AND sevborder &lt;= &quot;
+    &lt;&lt;  sevBorder
+    &lt;&lt;  &quot; AND email = 1&quot;
+    &quot; AND deleted = 0&quot;
+    &quot; LIMIT 500&quot;;
+
+  vector&lt;string&gt; result;
+
+  if(mysql_real_query(init, query.str().c_str(), strlen(query.str().c_str())) == 0)
+  {
+    // Query successful.
+    MYSQL_RES* res = mysql_store_result(init);
+    MYSQL_ROW  row;
+    if(mysql_num_rows(res) &gt; 0)
+    {
+      while((row = mysql_fetch_row(res)))
+      {
+        result.push_back(row[0]);
+      }
+    }
+    mysql_free_result(res);
+    return result;
+  }
+  result.push_back(&quot;NULL&quot;);
+  return result;
 }
 
+
 vector&lt;string&gt; Information::getXMPPWarningReceivers(MYSQL* init, string groupID,
-	string sevBorder){
-
-	stringstream query;
-	query	&lt;&lt; 	&quot;SELECT jid FROM notificationgroups WHERE warninggroup = &quot;
-			&lt;&lt; 	groupID
-			&lt;&lt; 	&quot; AND sevborder &lt;= &quot;
-			&lt;&lt; 	sevBorder
-			&lt;&lt; 	&quot; AND xmpp = 1&quot;
-				&quot; AND deleted = 0&quot;
-				&quot; LIMIT 500&quot;;
-
-	vector&lt;string&gt; result;
-
-	if(mysql_real_query(init, query.str().c_str(), strlen(query.str().c_str())) == 0){
-		// Query successful.
-		MYSQL_RES* res = mysql_store_result(init);
-		MYSQL_ROW  row;
-		if(mysql_num_rows(res) &gt; 0){
-			while((row = mysql_fetch_row(res))){
-				result.push_back(row[0]);
-			}
-		}
-		mysql_free_result(res);
-		return result;
-	}
-	result.push_back(&quot;NULL&quot;);
-	return result;
+string sevBorder)
+{
+
+  stringstream query;
+  query &lt;&lt;  &quot;SELECT jid FROM notificationgroups WHERE warninggroup = &quot;
+    &lt;&lt;  groupID
+    &lt;&lt;  &quot; AND sevborder &lt;= &quot;
+    &lt;&lt;  sevBorder
+    &lt;&lt;  &quot; AND xmpp = 1&quot;
+    &quot; AND deleted = 0&quot;
+    &quot; LIMIT 500&quot;;
+
+  vector&lt;string&gt; result;
+
+  if(mysql_real_query(init, query.str().c_str(), strlen(query.str().c_str())) == 0)
+  {
+    // Query successful.
+    MYSQL_RES* res = mysql_store_result(init);
+    MYSQL_ROW  row;
+    if(mysql_num_rows(res) &gt; 0)
+    {
+      while((row = mysql_fetch_row(res)))
+      {
+        result.push_back(row[0]);
+      }
+    }
+    mysql_free_result(res);
+    return result;
+  }
+  result.push_back(&quot;NULL&quot;);
+  return result;
 }
 
+
 vector&lt;string&gt; Information::getMobileCWarningReceivers(MYSQL* init, string groupID,
-	string sevBorder){
-
-	stringstream query;
-	query	&lt;&lt; 	&quot;SELECT numberc FROM notificationgroups WHERE warninggroup = &quot;
-			&lt;&lt; 	groupID
-			&lt;&lt; 	&quot; AND sevborder &lt;= &quot;
-			&lt;&lt; 	sevBorder
-			&lt;&lt; 	&quot; AND mobilec = 1&quot;
-				&quot; AND deleted = 0&quot;
-				&quot; LIMIT 500&quot;;
-
-	vector&lt;string&gt; result;
-
-	if(mysql_real_query(init, query.str().c_str(), strlen(query.str().c_str())) == 0){
-		// Query successful.
-		MYSQL_RES* res = mysql_store_result(init);
-		MYSQL_ROW  row;
-		if(mysql_num_rows(res) &gt; 0){
-			while((row = mysql_fetch_row(res))){
-				result.push_back(row[0]);
-			}
-		}
-		mysql_free_result(res);
-		return result;
-	}
-	result.push_back(&quot;NULL&quot;);
-	return result;
+string sevBorder)
+{
+
+  stringstream query;
+  query &lt;&lt;  &quot;SELECT numberc FROM notificationgroups WHERE warninggroup = &quot;
+    &lt;&lt;  groupID
+    &lt;&lt;  &quot; AND sevborder &lt;= &quot;
+    &lt;&lt;  sevBorder
+    &lt;&lt;  &quot; AND mobilec = 1&quot;
+    &quot; AND deleted = 0&quot;
+    &quot; LIMIT 500&quot;;
+
+  vector&lt;string&gt; result;
+
+  if(mysql_real_query(init, query.str().c_str(), strlen(query.str().c_str())) == 0)
+  {
+    // Query successful.
+    MYSQL_RES* res = mysql_store_result(init);
+    MYSQL_ROW  row;
+    if(mysql_num_rows(res) &gt; 0)
+    {
+      while((row = mysql_fetch_row(res)))
+      {
+        result.push_back(row[0]);
+      }
+    }
+    mysql_free_result(res);
+    return result;
+  }
+  result.push_back(&quot;NULL&quot;);
+  return result;
 }
 
-string Information::clearHealth(unsigned int nodeID){
+
+string Information::clearHealth(unsigned int nodeID)
+{
   stringstream sNodeID;
   sNodeID &lt;&lt; nodeID;
-	return &quot;DELETE FROM vitals WHERE node_id = &quot; + sNodeID.str();
+  return &quot;DELETE FROM vitals WHERE node_id = &quot; + sNodeID.str();
 }
 
+
 string Information::updateHealth(unsigned int nodeID, string pid, bool clienthandler, string vmem, string threads,
-		int packetsOK, int packetsERR, double dbTotalSize, double dbSensorSize,
-		double dbServiceSize){
-	time_t rawtime;
-	time(&amp;rawtime);
+int packetsOK, int packetsERR, double dbTotalSize, double dbSensorSize,
+double dbServiceSize)
+{
+  time_t rawtime;
+  time(&amp;rawtime);
 
   // Generate a NodePID: A PID that includes the NodeID separated by three zeros.
   stringstream node_pid;
   node_pid &lt;&lt; nodeID &lt;&lt; &quot;000&quot; &lt;&lt; pid;
   pid = node_pid.str();
 
-	stringstream query;
-
-	query 	&lt;&lt;	&quot;INSERT INTO vitals (node_id, pid, clienthandler, vmem, &quot;
-				&quot;threads, timestamp, packetsOK, packetsERR&quot;;
-
-	if(dbTotalSize &gt;= 0){
-		query	&lt;&lt; &quot;,dbtotalsize, dbsensorsize, dbservicesize&quot;;
-	}
-
-	query	&lt;&lt;	&quot;) VALUES ('&quot;
-			&lt;&lt;	nodeID
-      &lt;&lt;	&quot;', '&quot;
-			&lt;&lt;	pid
-			&lt;&lt;	&quot;', '&quot;
-			&lt;&lt;	clienthandler
-			&lt;&lt;	&quot;', '&quot;
-			&lt;&lt;	vmem
-			&lt;&lt;	&quot;', '&quot;
-			&lt;&lt;	threads
-			&lt;&lt;	&quot;', '&quot;
-			&lt;&lt;	rawtime
-			&lt;&lt;	&quot;', '&quot;
-			&lt;&lt;	packetsOK
-			&lt;&lt;	&quot;', '&quot;
-			&lt;&lt;	packetsERR;
-
-	if(dbTotalSize &gt;= 0){
-		query	&lt;&lt;	&quot;', '&quot;
-				&lt;&lt;	dbTotalSize
-				&lt;&lt;	&quot;', '&quot;
-				&lt;&lt;	dbSensorSize
-				&lt;&lt;	&quot;', '&quot;
-				&lt;&lt;	dbServiceSize;
-	}
-
-
-	query	&lt;&lt;	&quot;')&quot;
-				&quot; ON DUPLICATE KEY&quot;
-				&quot; UPDATE vmem = '&quot;
-			&lt;&lt; vmem
-			&lt;&lt; &quot;', threads = '&quot;
-			&lt;&lt; threads
-			&lt;&lt; &quot;', timestamp = '&quot;
-			&lt;&lt; rawtime
-			&lt;&lt; &quot;', packetsOK = '&quot;
-			&lt;&lt; packetsOK
-			&lt;&lt; &quot;', packetsERR = '&quot;
-			&lt;&lt; packetsERR;
-
-	if(dbTotalSize &gt;= 0){
-		query	&lt;&lt; &quot;', dbtotalsize= '&quot;
-				&lt;&lt; dbTotalSize
-				&lt;&lt; &quot;', dbsensorsize = '&quot;
-				&lt;&lt; dbSensorSize
-				&lt;&lt; &quot;', dbservicesize = '&quot;
-				&lt;&lt; dbServiceSize;
-	}
-
-	query	 &lt;&lt; &quot;'&quot;;
-
-	return query.str();
+  stringstream query;
+
+  query   &lt;&lt;  &quot;INSERT INTO vitals (node_id, pid, clienthandler, vmem, &quot;
+    &quot;threads, timestamp, packetsOK, packetsERR&quot;;
+
+  if(dbTotalSize &gt;= 0)
+  {
+    query &lt;&lt; &quot;,dbtotalsize, dbsensorsize, dbservicesize&quot;;
+  }
+
+  query &lt;&lt;  &quot;) VALUES ('&quot;
+    &lt;&lt;  nodeID
+    &lt;&lt;  &quot;', '&quot;
+    &lt;&lt;  pid
+    &lt;&lt;  &quot;', '&quot;
+    &lt;&lt;  clienthandler
+    &lt;&lt;  &quot;', '&quot;
+    &lt;&lt;  vmem
+    &lt;&lt;  &quot;', '&quot;
+    &lt;&lt;  threads
+    &lt;&lt;  &quot;', '&quot;
+    &lt;&lt;  rawtime
+    &lt;&lt;  &quot;', '&quot;
+    &lt;&lt;  packetsOK
+    &lt;&lt;  &quot;', '&quot;
+    &lt;&lt;  packetsERR;
+
+  if(dbTotalSize &gt;= 0)
+  {
+    query &lt;&lt;  &quot;', '&quot;
+      &lt;&lt;  dbTotalSize
+      &lt;&lt;  &quot;', '&quot;
+      &lt;&lt;  dbSensorSize
+      &lt;&lt;  &quot;', '&quot;
+      &lt;&lt;  dbServiceSize;
+  }
+
+  query &lt;&lt;  &quot;')&quot;
+    &quot; ON DUPLICATE KEY&quot;
+    &quot; UPDATE vmem = '&quot;
+    &lt;&lt; vmem
+    &lt;&lt; &quot;', threads = '&quot;
+    &lt;&lt; threads
+    &lt;&lt; &quot;', timestamp = '&quot;
+    &lt;&lt; rawtime
+    &lt;&lt; &quot;', packetsOK = '&quot;
+    &lt;&lt; packetsOK
+    &lt;&lt; &quot;', packetsERR = '&quot;
+    &lt;&lt; packetsERR;
+
+  if(dbTotalSize &gt;= 0)
+  {
+    query &lt;&lt; &quot;', dbtotalsize= '&quot;
+      &lt;&lt; dbTotalSize
+      &lt;&lt; &quot;', dbsensorsize = '&quot;
+      &lt;&lt; dbSensorSize
+      &lt;&lt; &quot;', dbservicesize = '&quot;
+      &lt;&lt; dbServiceSize;
+  }
+
+  query  &lt;&lt; &quot;'&quot;;
+
+  return query.str();
 }
 
+
 /*
  *
  * Available types:
@@ -335,62 +377,67 @@ string Information::updateHealth(unsigned int nodeID, string pid, bool clienthan
  *
  */
 
-string Information::getEmergencyInformation(int emergencyID, int type){
-
-	string whatToFetch;
-
-	switch(type){
-		case 0:
-			whatToFetch = &quot;emergencies.description&quot;;
-			break;
-		case 1:
-			whatToFetch = &quot;emergencies.timestamp&quot;;
-			break;
-		case 2:
-			whatToFetch = &quot;emergencies.severity&quot;;
-			break;
-		default:
-			return &quot;NULL&quot;;
-	}
-
-	stringstream query;
-
-	query	&lt;&lt;	&quot;SELECT &quot;
-			&lt;&lt; whatToFetch
-			&lt;&lt;	&quot; FROM emergencies&quot;
-				&quot; WHERE active = 1&quot;
-				&quot; AND emergencies.ID = &quot;
-			&lt;&lt; emergencyID;
-
-	return query.str();
+string Information::getEmergencyInformation(int emergencyID, int type)
+{
+
+  string whatToFetch;
+
+  switch(type)
+  {
+    case 0:
+      whatToFetch = &quot;emergencies.description&quot;;
+      break;
+    case 1:
+      whatToFetch = &quot;emergencies.timestamp&quot;;
+      break;
+    case 2:
+      whatToFetch = &quot;emergencies.severity&quot;;
+      break;
+    default:
+      return &quot;NULL&quot;;
+  }
+
+  stringstream query;
+
+  query &lt;&lt;  &quot;SELECT &quot;
+    &lt;&lt; whatToFetch
+    &lt;&lt;  &quot; FROM emergencies&quot;
+    &quot; WHERE active = 1&quot;
+    &quot; AND emergencies.ID = &quot;
+    &lt;&lt; emergencyID;
+
+  return query.str();
 }
 
-string Information::setReceiverMark(int ID, int status){
-	stringstream query;
-
-	stringstream setStatus;
-
-	// Find out what to set as status.
-	switch(status){
-		case 0:
-			setStatus &lt;&lt; &quot;0&quot;;
-			break;
-		case -1:
-			setStatus &lt;&lt; &quot;-1&quot;;
-			break;
-		case 1:
-			time_t rawtime;
-			setStatus &lt;&lt; time(&amp;rawtime);
-			break;
-		default:
-			return &quot;NULL&quot;;
-	}
-
-	query	&lt;&lt; &quot;UPDATE emergencynotifications&quot;
-				&quot; SET notifiedon = &quot;
-			&lt;&lt; setStatus.str()
-			&lt;&lt; &quot; WHERE ID = &quot;
-			&lt;&lt; ID;
-
-	return query.str();
+
+string Information::setReceiverMark(int ID, int status)
+{
+  stringstream query;
+
+  stringstream setStatus;
+
+  // Find out what to set as status.
+  switch(status)
+  {
+    case 0:
+      setStatus &lt;&lt; &quot;0&quot;;
+      break;
+    case -1:
+      setStatus &lt;&lt; &quot;-1&quot;;
+      break;
+    case 1:
+      time_t rawtime;
+      setStatus &lt;&lt; time(&amp;rawtime);
+      break;
+    default:
+      return &quot;NULL&quot;;
+  }
+
+  query &lt;&lt; &quot;UPDATE emergencynotifications&quot;
+    &quot; SET notifiedon = &quot;
+    &lt;&lt; setStatus.str()
+    &lt;&lt; &quot; WHERE ID = &quot;
+    &lt;&lt; ID;
+
+  return query.str();
 }</diff>
      <filename>src/database/Information.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -26,156 +26,156 @@
 #include &quot;../internal.h&quot;
 #include &quot;Database.h&quot;
 
-class Information{
-	public:
-		//! Returns query to get the name of a sensor with given sensor type.
-		/*!
-		 * \param st Sensor type ID
-		 * \return Query
-		 */
-		static string getSensorName(string st);
-
-		//! Returns the query to get the name of a host with given host ID
-		/*!
-		 * \param hostid Host ID
-		 * \return Query
-		 */
-		static string getHostName(string hostid);
-
-		//! Returns the query to get the sensor condition of a given sensor on a host.
-		/*!
-		 * \param hostid Host ID
-		 * \param st Sensor type ID
-		 * \return Query
-		 */
-		static string getSensorCondition(string hostid, string st);
-
-		//! Returns query to get the notification group that needs to be informed for warnings about given host and sensor type.
-		/*!
-		 * \param hostid Host ID.
-		 * \param st Sensor type ID.
-		 * \return Query
-		 */
-		static string getReceiverGroup(string hostid, string st);
-
-		//! Returns query to get the notification group that needs to be informed for warnings about given service.
-		/*!
-		 * \param serviceID The service ID
-		 * \return Query
-		 */
-		static string getServiceReceiverGroup(unsigned int serviceID);
-
-		//! Returns query to get the name of service with given ID.
-		/*!
-		 * \param serviceID The service ID
-		 * \return Query
-		 */
-		static string getServiceName(unsigned int serviceID);
-
-		//! Returns query to get the timestamp of when the last notification for a sensor was sent.
-		/*!
-		 * \param hostid Host ID
-		 * \param st Sensor type ID
-		 * \return Query
-		 */
-		static string getLastWarn(string hostid, string st);
-
-		//! Returns query to get the timestamp of when the last notification for a service was sent.
-		/*!
-		 * \param serviceID the service ID
-		 * \return Query
-		 */
-		static string getLastServiceWarn(unsigned int serviceID);
-
-		//! Returns query to set the timestamp of when the last notification for a sensor was sent.
-		/*!
-		 * \param lastwarn Timestamp to set
-		 * \param hostid Host ID
-		 * \param st Sensor type ID
-		 * \return Query
-		 */
-		static string setLastWarn(time_t lastwarn, string hostid, string st);
-
-		//! Returns query to set the timestamp of when the last notification for a service was sent.
-		/*!
-		 * \param lastwarn Timestamp to set
-		 * \param serviceID Service ID
-		 * \return Query
-		 */
-		static string setLastServiceWarn(time_t lastwarn, unsigned int serviceID);
-
-		//! Returns query to get the defined severity of a sensor.
-		/*!
-		 * \param hostid Host ID
-		 * \param st Sensor type ID
-		 * \return Query
-		 */
-		static string getSensorSeverity(string hostid, string st);
-
-		//! Returns vector of all mail addresses in a notification group.
-		/*!
-		 * \param init MySQL handle
-		 * \param groupID ID of notification group.
-		 * \param sevBorder Severity level of this alert. Used for selection of receivers because Receivers can have a minimum severity level.
-		 * \return vector of email adresses.
-		 */
-		static vector&lt;string&gt; getMailWarningReceivers(MYSQL* init, string groupID, string sevBorder);
-
-		//! Returns vector of all JIDs in a notification group.
-		/*!
-		 * \param init MySQL handle
-		 * \param groupID ID of notification group.
-		 * \param sevBorder Severity level of this alert. Used for selection of receivers because Receivers can have a minimum severity level.
-		 * \return vector of JIDs.
-		 */
-		static vector&lt;string&gt; getXMPPWarningReceivers(MYSQL* init, string groupID, string sevBorder);
-
-		//! Returns vector of all mobile phone numbers that use the Clickatell API in a notification group.
-		/*!
-		 * \param init MySQL handle
-		 * \param groupID ID of notification group.
-		 * \param sevBorder Severity level of this alert. Used for selection of receivers because Receivers can have a minimum severity level.
-		 * \return vector of phone numbers in international format.
-		 */
-		static vector&lt;string&gt; getMobileCWarningReceivers(MYSQL* init, string groupID, string sevBorder);
-
-		//! Returns query to delete all health data of this node from database.
-		static string clearHealth(unsigned int nodeID);
-
-		//! Returns query to update health data of given PID in database.
-		/*!
+class Information
+{
+  public:
+    //! Returns query to get the name of a sensor with given sensor type.
+    /*!
+     * \param st Sensor type ID
+     * \return Query
+     */
+    static string getSensorName(string st);
+
+    //! Returns the query to get the name of a host with given host ID
+    /*!
+     * \param hostid Host ID
+     * \return Query
+     */
+    static string getHostName(string hostid);
+
+    //! Returns the query to get the sensor condition of a given sensor on a host.
+    /*!
+     * \param hostid Host ID
+     * \param st Sensor type ID
+     * \return Query
+     */
+    static string getSensorCondition(string hostid, string st);
+
+    //! Returns query to get the notification group that needs to be informed for warnings about given host and sensor type.
+    /*!
+     * \param hostid Host ID.
+     * \param st Sensor type ID.
+     * \return Query
+     */
+    static string getReceiverGroup(string hostid, string st);
+
+    //! Returns query to get the notification group that needs to be informed for warnings about given service.
+    /*!
+     * \param serviceID The service ID
+     * \return Query
+     */
+    static string getServiceReceiverGroup(unsigned int serviceID);
+
+    //! Returns query to get the name of service with given ID.
+    /*!
+     * \param serviceID The service ID
+     * \return Query
+     */
+    static string getServiceName(unsigned int serviceID);
+
+    //! Returns query to get the timestamp of when the last notification for a sensor was sent.
+    /*!
+     * \param hostid Host ID
+     * \param st Sensor type ID
+     * \return Query
+     */
+    static string getLastWarn(string hostid, string st);
+
+    //! Returns query to get the timestamp of when the last notification for a service was sent.
+    /*!
+     * \param serviceID the service ID
+     * \return Query
+     */
+    static string getLastServiceWarn(unsigned int serviceID);
+
+    //! Returns query to set the timestamp of when the last notification for a sensor was sent.
+    /*!
+     * \param lastwarn Timestamp to set
+     * \param hostid Host ID
+     * \param st Sensor type ID
+     * \return Query
+     */
+    static string setLastWarn(time_t lastwarn, string hostid, string st);
+
+    //! Returns query to set the timestamp of when the last notification for a service was sent.
+    /*!
+     * \param lastwarn Timestamp to set
+     * \param serviceID Service ID
+     * \return Query
+     */
+    static string setLastServiceWarn(time_t lastwarn, unsigned int serviceID);
+
+    //! Returns query to get the defined severity of a sensor.
+    /*!
+     * \param hostid Host ID
+     * \param st Sensor type ID
+     * \return Query
+     */
+    static string getSensorSeverity(string hostid, string st);
+
+    //! Returns vector of all mail addresses in a notification group.
+    /*!
+     * \param init MySQL handle
+     * \param groupID ID of notification group.
+     * \param sevBorder Severity level of this alert. Used for selection of receivers because Receivers can have a minimum severity level.
+     * \return vector of email adresses.
+     */
+    static vector&lt;string&gt; getMailWarningReceivers(MYSQL* init, string groupID, string sevBorder);
+
+    //! Returns vector of all JIDs in a notification group.
+    /*!
+     * \param init MySQL handle
+     * \param groupID ID of notification group.
+     * \param sevBorder Severity level of this alert. Used for selection of receivers because Receivers can have a minimum severity level.
+     * \return vector of JIDs.
+     */
+    static vector&lt;string&gt; getXMPPWarningReceivers(MYSQL* init, string groupID, string sevBorder);
+
+    //! Returns vector of all mobile phone numbers that use the Clickatell API in a notification group.
+    /*!
+     * \param init MySQL handle
+     * \param groupID ID of notification group.
+     * \param sevBorder Severity level of this alert. Used for selection of receivers because Receivers can have a minimum severity level.
+     * \return vector of phone numbers in international format.
+     */
+    static vector&lt;string&gt; getMobileCWarningReceivers(MYSQL* init, string groupID, string sevBorder);
+
+    //! Returns query to delete all health data of this node from database.
+    static string clearHealth(unsigned int nodeID);
+
+    //! Returns query to update health data of given PID in database.
+    /*!
      * \param nodeID The ID of this node
-		 * \param pid The PID. Used as primary key.
-		 * \param clienthandler Bool. Is this process a clientHandler?
-		 * \param vmem This process' size of virtual memory
-		 * \param threads This process' number of threads
-		 * \param packetsOK The number of packages this process successful received.
-		 * \param packetsERR The number of packages this process refused or failed to handle.
-		 * \param dbTotalSize Total size of database (Megabyte)
-		 * \param dbSensorSize Size of &quot;sensorvalues&quot; table (Megabyte)
-		 * \param dbServiceSize Size of &quot;servicerecords&quot; table (Megabyte)
-		 * \sa clearHealth()
-		 * \return Query
-		 */
-		static string updateHealth(unsigned int nodeID, string pid, bool clienthandler, string vmem, string threads,
-				int packetsOK, int packetsERR, double dbTotalSize, double dbSensorSize,
-				double dbServiceSize);
-
-		//! Returs information about emergency.
-		/*!
-		 * \param emergencyID ID of emergency
-		 * \param type  0: Description, 1: Timestamp of creation, 2: Severity (numeric)
-		 * \return Query
-		 */
-		static string getEmergencyInformation(int emergencyID, int type);
-
-		//! Set the status of an emergency notification receiver.
-		/*!
-		 * \param ID ID of receiver in queue table.
-		 * \param status Status to set (0: not yet sent, 1: sent, -1: error)
-		 * \return Query
-		 */
-		static string setReceiverMark(int ID, int status);
+     * \param pid The PID. Used as primary key.
+     * \param clienthandler Bool. Is this process a clientHandler?
+     * \param vmem This process' size of virtual memory
+     * \param threads This process' number of threads
+     * \param packetsOK The number of packages this process successful received.
+     * \param packetsERR The number of packages this process refused or failed to handle.
+     * \param dbTotalSize Total size of database (Megabyte)
+     * \param dbSensorSize Size of &quot;sensorvalues&quot; table (Megabyte)
+     * \param dbServiceSize Size of &quot;servicerecords&quot; table (Megabyte)
+     * \sa clearHealth()
+     * \return Query
+     */
+    static string updateHealth(unsigned int nodeID, string pid, bool clienthandler, string vmem, string threads,
+      int packetsOK, int packetsERR, double dbTotalSize, double dbSensorSize,
+      double dbServiceSize);
+
+    //! Returs information about emergency.
+    /*!
+     * \param emergencyID ID of emergency
+     * \param type  0: Description, 1: Timestamp of creation, 2: Severity (numeric)
+     * \return Query
+     */
+    static string getEmergencyInformation(int emergencyID, int type);
+
+    //! Set the status of an emergency notification receiver.
+    /*!
+     * \param ID ID of receiver in queue table.
+     * \param status Status to set (0: not yet sent, 1: sent, -1: error)
+     * \return Query
+     */
+    static string setReceiverMark(int ID, int status);
 };
-
-#endif /*INFORMATION_H_*/
+#endif                                            /*INFORMATION_H_*/</diff>
      <filename>src/database/Information.h</filename>
    </modified>
    <modified>
      <diff>@@ -19,140 +19,167 @@
 #include &quot;../database/Database.h&quot;
 #include &quot;../internal.h&quot;
 
-string Health::getPID(){
-	string returnage = &quot;0&quot;;
-
-	// Open the /proc/self/status file.
-	ifstream status(&quot;/proc/self/status&quot;);
-
-	if(!status.fail()){
-		// We opened the file.
-		string line;
-
-		// Go to the 4th line.
-		while(getline(status, line)){
-			if(line.find(&quot;Pid&quot;) != string::npos){
-				status.close();
-				return noSpaces(line.erase(0,4));
-			}
-		}
-	}
-
-	status.close();
-
-	return returnage;
+string Health::getPID()
+{
+  string returnage = &quot;0&quot;;
+
+  // Open the /proc/self/status file.
+  ifstream status(&quot;/proc/self/status&quot;);
+
+  if(!status.fail())
+  {
+    // We opened the file.
+    string line;
+
+    // Go to the 4th line.
+    while(getline(status, line))
+    {
+      if(line.find(&quot;Pid&quot;) != string::npos)
+      {
+        status.close();
+        return noSpaces(line.erase(0,4));
+      }
+    }
+  }
+
+  status.close();
+
+  return returnage;
 }
 
-string Health::getVMSize(){
-	string returnage = &quot;0&quot;;
 
-	// Open the /proc/self/status file.
-	ifstream status(&quot;/proc/self/status&quot;);
+string Health::getVMSize()
+{
+  string returnage = &quot;0&quot;;
+
+  // Open the /proc/self/status file.
+  ifstream status(&quot;/proc/self/status&quot;);
 
-	if(!status.fail()){
-		// We opened the file.
-		string line;
+  if(!status.fail())
+  {
+    // We opened the file.
+    string line;
 
-		// Go to the 12th line.
-		while(getline(status, line)){
-			if(line.find(&quot;VmSize&quot;) != string::npos){
-				status.close();
-				return noSpaces(line.erase(0,7));
-			}
-		}
-	}
+    // Go to the 12th line.
+    while(getline(status, line))
+    {
+      if(line.find(&quot;VmSize&quot;) != string::npos)
+      {
+        status.close();
+        return noSpaces(line.erase(0,7));
+      }
+    }
+  }
 
-	status.close();
+  status.close();
 
-	return returnage;
+  return returnage;
 }
 
-string Health::getThreads(){
-	string returnage = &quot;0&quot;;
 
-	// Open the /proc/self/status file.
-	ifstream status(&quot;/proc/self/status&quot;);
+string Health::getThreads()
+{
+  string returnage = &quot;0&quot;;
 
-	if(!status.fail()){
-		// We opened the file.
-		string line;
+  // Open the /proc/self/status file.
+  ifstream status(&quot;/proc/self/status&quot;);
 
-		// Go to the 21st line.
-		while(getline(status, line)){
-			if(line.find(&quot;Threads&quot;) != string::npos){
-				status.close();
-				return noSpaces(line.erase(0,8));
-			}
-		}
-	}
+  if(!status.fail())
+  {
+    // We opened the file.
+    string line;
 
-	status.close();
+    // Go to the 21st line.
+    while(getline(status, line))
+    {
+      if(line.find(&quot;Threads&quot;) != string::npos)
+      {
+        status.close();
+        return noSpaces(line.erase(0,8));
+      }
+    }
+  }
 
-	return returnage;
+  status.close();
+
+  return returnage;
 }
 
-double Health::getDBSize(mySQLData dbData, int type){
-	// Prepare database connection.
-	Database db(dbData);
-
-	if(db.initConnection()){
-		MYSQL* init = db.getHandle();
-		// Get tasks.
-		const char* taskQuery = &quot;SHOW TABLE STATUS&quot;;
-
-		if(mysql_real_query(init, taskQuery, strlen(taskQuery)) != 0){
-			// Query was not successful.
-			mysql_close(init);
-			return 0;
-		}else{
-			// Query successful.
-			MYSQL_RES* res = mysql_store_result(init);
-			MYSQL_ROW row;
-			if(mysql_num_rows(res) &gt; 0){
-				double totalSize = 0;
-				// Got notifications to send.
-				while((row = mysql_fetch_row(res))){
-					switch(type){
-						case 1:
-							// Sum up everything to get the total size.
-							totalSize = totalSize+stringToInteger(row[6])+stringToInteger(row[8]);
-							break;
-						case 2:
-							// Only return size of table sensorvalues.
-							if(strcmp(row[0], &quot;sensorvalues&quot;) == 0){
-								// Return data length + index length.
-								mysql_free_result(res);
-								mysql_close(init);
-								return (stringToInteger(row[6])+stringToInteger(row[8]))/1024;
-							}
-							break;
-						case 3:
-							// Only return size of table servicerecords.
-							if(strcmp(row[0], &quot;servicerecords&quot;) == 0){
-								// Return data length + index length.
-								mysql_free_result(res);
-								mysql_close(init);
-								return (stringToInteger(row[6])+stringToInteger(row[8]))/1024;
-							}
-							break;
-						default:
-							mysql_free_result(res);
-							mysql_close(init);
-							return 0;
-					}
-				}
-				mysql_free_result(res);
-				mysql_close(init);
-				// Convert byte to kilobyte and return total size.
-				return totalSize/1024;
-			}else{
-				// Nothing fetched.
-				mysql_free_result(res);
-				mysql_close(init);
-				return 0;
-			}
-		}
-	}
-
-	return 0;
+
+double Health::getDBSize(mySQLData dbData, int type)
+{
+  // Prepare database connection.
+  Database db(dbData);
+
+  if(db.initConnection())
+  {
+    MYSQL* init = db.getHandle();
+    // Get tasks.
+    const char* taskQuery = &quot;SHOW TABLE STATUS&quot;;
+
+    if(mysql_real_query(init, taskQuery, strlen(taskQuery)) != 0)
+    {
+      // Query was not successful.
+      mysql_close(init);
+      return 0;
+    }
+    else
+    {
+      // Query successful.
+      MYSQL_RES* res = mysql_store_result(init);
+      MYSQL_ROW row;
+      if(mysql_num_rows(res) &gt; 0)
+      {
+        double totalSize = 0;
+        // Got notifications to send.
+        while((row = mysql_fetch_row(res)))
+        {
+          switch(type)
+          {
+            case 1:
+              // Sum up everything to get the total size.
+              totalSize = totalSize+stringToInteger(row[6])+stringToInteger(row[8]);
+              break;
+            case 2:
+              // Only return size of table sensorvalues.
+              if(strcmp(row[0], &quot;sensorvalues&quot;) == 0)
+              {
+                // Return data length + index length.
+                mysql_free_result(res);
+                mysql_close(init);
+                return (stringToInteger(row[6])+stringToInteger(row[8]))/1024;
+              }
+              break;
+            case 3:
+              // Only return size of table servicerecords.
+              if(strcmp(row[0], &quot;servicerecords&quot;) == 0)
+              {
+                // Return data length + index length.
+                mysql_free_result(res);
+                mysql_close(init);
+                return (stringToInteger(row[6])+stringToInteger(row[8]))/1024;
+              }
+              break;
+            default:
+              mysql_free_result(res);
+              mysql_close(init);
+              return 0;
+          }
+        }
+        mysql_free_result(res);
+        mysql_close(init);
+        // Convert byte to kilobyte and return total size.
+        return totalSize/1024;
+      }
+      else
+      {
+        // Nothing fetched.
+        mysql_free_result(res);
+        mysql_close(init);
+        return 0;
+      }
+    }
+  }
+
+  return 0;
 }</diff>
      <filename>src/health/Health.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -25,24 +25,24 @@
 
 #include &quot;../internal.h&quot;
 
-class Health{
-	public:
-		//! Returns the PID of the calling process.
-		static	string	getPID();
-		
-		//! Returns the virtual memory size of the calling process.
-		static	string	getVMSize();
-		
-		//! Returns the number of threads of the calling process.  
-		static	string	getThreads();
-		
-		//! Returns the size of some database tables or the whole database.  
-		/*!
-		 * \param dbData Database login information. 
-		 * \param type What size to get. 1: Total database size, 2: Size of table &quot;sensorrecords&quot;, 3: Size of table &quot;servicerecords&quot;.
-		 * \return Size in Megabyte
-		 */ 
-		static	double	getDBSize(mySQLData dbData, int type);
-};
+class Health
+{
+  public:
+    //! Returns the PID of the calling process.
+    static  string  getPID();
+
+    //! Returns the virtual memory size of the calling process.
+    static  string  getVMSize();
 
-#endif /*HEALTH_H_*/
+    //! Returns the number of threads of the calling process.
+    static  string  getThreads();
+
+    //! Returns the size of some database tables or the whole database.
+    /*!
+     * \param dbData Database login information.
+     * \param type What size to get. 1: Total database size, 2: Size of table &quot;sensorrecords&quot;, 3: Size of table &quot;servicerecords&quot;.
+     * \return Size in Megabyte
+     */
+    static  double  getDBSize(mySQLData dbData, int type);
+};
+#endif                                            /*HEALTH_H_*/</diff>
      <filename>src/health/Health.h</filename>
    </modified>
    <modified>
      <diff>@@ -18,18 +18,22 @@
 #include &quot;../internal.h&quot;
 #include &quot;Host.h&quot;
 
-Host::Host(mySQLData myDBData, int mySocket, struct sockaddr_in mySocketAddress){
+Host::Host(mySQLData myDBData, int mySocket, struct sockaddr_in mySocketAddress)
+{
   socket = mySocket;
   socketAddress = mySocketAddress;
   dbData = myDBData;
 }
 
-bool Host::send(string message){
+
+bool Host::send(string message)
+{
   ssize_t len;
   len = write(socket, message.c_str(), strlen(message.c_str()));
-  
+
   // Check if the message has been sent.
-  if(len &lt;= 0){
+  if(len &lt;= 0)
+  {
     return 0;
   }
 
@@ -37,7 +41,9 @@ bool Host::send(string message){
   return 1;
 }
 
-string Host::receive(){
+
+string Host::receive()
+{
   char buffer[TALKBUFSIZE] = &quot;&quot;;
   ssize_t len;
 
@@ -45,14 +51,18 @@ string Host::receive(){
   len = read(socket, buffer, TALKBUFSIZE-1);
 
   // Check if something has been received.
-  if(len &lt;= 0){
+  if(len &lt;= 0)
+  {
     return &quot;err&quot;;
   }
 
   // Terminate buffer char array.
-  if(len &lt; TALKBUFSIZE){
+  if(len &lt; TALKBUFSIZE)
+  {
     buffer[len] = '\0';
-  }else{
+  }
+  else
+  {
     return &quot;err&quot;;
   }
 
@@ -62,28 +72,38 @@ string Host::receive(){
   return res.str();
 }
 
-string Host::getIPv4Address(){
+
+string Host::getIPv4Address()
+{
   stringstream res;
   res &lt;&lt; inet_ntoa(socketAddress.sin_addr);
   return res.str();
 }
 
-void Host::refuse(string reason){
+
+void Host::refuse(string reason)
+{
   send(&quot;Closing connection (Reason: &quot; + reason + &quot;)&quot;);
 }
 
-void Host::notify(string reason){
+
+void Host::notify(string reason)
+{
   send(reason);
 }
 
-hostMessage Host::parse(string message){
+
+hostMessage Host::parse(string message)
+{
   hostMessage result;
   string token;
   istringstream iss(message);
   unsigned int i = 0;
 
-  while(getline(iss, token, ',')){
-    switch(i){
+  while(getline(iss, token, ','))
+  {
+    switch(i)
+    {
       case 0:
         result.hostID = stringToInteger(token);
         break;
@@ -100,221 +120,278 @@ hostMessage Host::parse(string message){
   return result;
 }
 
-bool Host::isBlacklisted(Database db){
+
+bool Host::isBlacklisted(Database db)
+{
   string query = &quot;SELECT 1 FROM blacklisted_hosts WHERE host = '&quot; + getIPv4Address() + &quot;'&quot;;
-  if(db.getNumOfResults(query) &gt; 0){
+  if(db.getNumOfResults(query) &gt; 0)
+  {
     return 1;
-  }else{
+  }
+  else
+  {
     return 0;
   }
 }
 
-bool Host::addToBlacklist(Database db){
+
+bool Host::addToBlacklist(Database db)
+{
   string query = &quot;INSERT INTO blacklisted_hosts(host, created_at, updated_at) &quot;
-                 &quot;VALUES('&quot; + getIPv4Address() + &quot;', NOW(), NOW())&quot;;
+    &quot;VALUES('&quot; + getIPv4Address() + &quot;', NOW(), NOW())&quot;;
   return db.setQuery(db.getHandle(), query);
 }
 
-bool Host::checkLogin(Database db){
+
+bool Host::checkLogin(Database db)
+{
   // Get the login request message.
   string msg = receive();
   hostMessage request = parse(msg);
 
   // Check if the data is valid.
-  if(request.hostID == 0 || request.type != &quot;login&quot; || request.value.empty()){
+  if(request.hostID == 0 || request.type != &quot;login&quot; || request.value.empty())
+  {
     return 0;
   }
 
   // Check if the login is correct.
   stringstream query;
   query &lt;&lt; &quot;SELECT 1 FROM hosts WHERE id = &quot; &lt;&lt; request.hostID
-        &lt;&lt; &quot; AND password = '&quot; &lt;&lt; Database::escapeString(request.value) &lt;&lt; &quot;'&quot;;
+    &lt;&lt; &quot; AND password = '&quot; &lt;&lt; Database::escapeString(request.value) &lt;&lt; &quot;'&quot;;
 
-  if(db.getNumOfResults(query.str()) == 1){
+  if(db.getNumOfResults(query.str()) == 1)
+  {
     return 1;
-  }else{
+  }
+  else
+  {
     return 0;
   }
 
   return 0;
 }
 
-bool Host::receiveAndStoreData(Database db){
+
+bool Host::receiveAndStoreData(Database db)
+{
   // Receive the sensor data.
   string msg = receive();
 
   // Check if the messsage was received successfully.
-  if(msg == &quot;err&quot;){
+  if(msg == &quot;err&quot;)
+  {
     lastError = &quot;Could not receive message from client.&quot;;
     return 0;
   }
 
   hostMessage sensorData = parse(msg);
-  
+
   string query = generateQuery(sensorData, db);
 
-  if(query == &quot;err&quot;){
+  if(query == &quot;err&quot;)
+  {
     lastError = &quot;Could not generate query.&quot;;
     return 0;
   }
 
-  if(query == &quot;done&quot;){
+  if(query == &quot;done&quot;)
+  {
     // The data has been inserted by generateQuery()! (i know..)
     return 1;
   }
 
   // Recent sensor data.
-  if(getSensorType(sensorData) == SENSOR_TYPE_SENSORDATA){
+  if(getSensorType(sensorData) == SENSOR_TYPE_SENSORDATA)
+  {
     if(!db.setQuery(db.getHandle(), generateDeletionQueryForRecentData(sensorData))
-        || !db.setQuery(db.getHandle(), generateQueryForRecentData(sensorData))){
+      || !db.setQuery(db.getHandle(), generateQueryForRecentData(sensorData)))
+    {
       lastError = &quot;Could not store data in recent value table. Database error: &quot; + db.getError();
       return 0;
     }
   }
 
-  if(!db.setQuery(db.getHandle(), query)){
+  if(!db.setQuery(db.getHandle(), query))
+  {
     lastError = &quot;Could not store data. Database error: &quot; + db.getError();
     return 0;
-  }else{
+  }
+  else
+  {
     return 1;
   }
 }
 
-int Host::getSensorType(hostMessage sensorData){
-  if(sensorData.type.length() &gt;= 7){
-    if(sensorData.type.substr(0, 7) == &quot;profile&quot;){
+
+int Host::getSensorType(hostMessage sensorData)
+{
+  if(sensorData.type.length() &gt;= 7)
+  {
+    if(sensorData.type.substr(0, 7) == &quot;profile&quot;)
+    {
       return SENSOR_TYPE_PROFILEDATA;
     }
   }
   return SENSOR_TYPE_SENSORDATA;
 }
 
-vector&lt;string&gt; Host::buildNetworkInterfacesQuery(string data, unsigned int hostID){
-	vector&lt;string&gt; returnage;
-	
-	istringstream iss(data);
-	string nic;
-	
-	while(getline(iss, nic, ';')){
-		stringstream query;
-		istringstream parts(nic);
-		string part;
-		
-		query &lt;&lt; &quot;INSERT INTO networkinterfaces(host_id, name, received, sent, created_at) VALUES(&quot; &lt;&lt; hostID;
-		
-		while(getline(parts, part, '|')){
-			query &lt;&lt; &quot;,'&quot; &lt;&lt; Database::escapeString(part) &lt;&lt; &quot;'&quot;;
-		}
-		query &lt;&lt; &quot;, NOW())&quot;;
-
-		returnage.push_back(query.str());
-	}
-	return returnage;
+
+vector&lt;string&gt; Host::buildNetworkInterfacesQuery(string data, unsigned int hostID)
+{
+  vector&lt;string&gt; returnage;
+
+  istringstream iss(data);
+  string nic;
+
+  while(getline(iss, nic, ';'))
+  {
+    stringstream query;
+    istringstream parts(nic);
+    string part;
+
+    query &lt;&lt; &quot;INSERT INTO networkinterfaces(host_id, name, received, sent, created_at) VALUES(&quot; &lt;&lt; hostID;
+
+    while(getline(parts, part, '|'))
+    {
+      query &lt;&lt; &quot;,'&quot; &lt;&lt; Database::escapeString(part) &lt;&lt; &quot;'&quot;;
+    }
+    query &lt;&lt; &quot;, NOW())&quot;;
+
+    returnage.push_back(query.str());
+  }
+  return returnage;
 }
 
-vector&lt;string&gt; Host::buildCpusQuery(string data, unsigned int hostID){
-	vector&lt;string&gt; returnage;
-
-	istringstream iss(data);
-	string cpu;
-	
-	while(getline(iss, cpu, ';')){
-		stringstream query;
-		istringstream bigparts(cpu);
-		string bigpart;
-		
-		query &lt;&lt; &quot;INSERT INTO cpus(host_id, core_number, vendor, model, created_at) VALUES(&quot; &lt;&lt; hostID;
-		
-		while(getline(bigparts, bigpart, '|')){
-			istringstream parts(bigpart);
-			string part;
-			unsigned int i = 0;
-			while(getline(parts, part, ':')){
-				if(i == 1){
-					query &lt;&lt; &quot;,'&quot; &lt;&lt; Database::escapeString(part) &lt;&lt; &quot;'&quot;;
-				}
-				i++;
-			}
-		}
-		query &lt;&lt; &quot;, NOW())&quot;;
-
-		returnage.push_back(query.str());
-	}
-	return returnage;
+
+vector&lt;string&gt; Host::buildCpusQuery(string data, unsigned int hostID)
+{
+  vector&lt;string&gt; returnage;
+
+  istringstream iss(data);
+  string cpu;
+
+  while(getline(iss, cpu, ';'))
+  {
+    stringstream query;
+    istringstream bigparts(cpu);
+    string bigpart;
+
+    query &lt;&lt; &quot;INSERT INTO cpus(host_id, core_number, vendor, model, created_at) VALUES(&quot; &lt;&lt; hostID;
+
+    while(getline(bigparts, bigpart, '|'))
+    {
+      istringstream parts(bigpart);
+      string part;
+      unsigned int i = 0;
+      while(getline(parts, part, ':'))
+      {
+        if(i == 1)
+        {
+          query &lt;&lt; &quot;,'&quot; &lt;&lt; Database::escapeString(part) &lt;&lt; &quot;'&quot;;
+        }
+        i++;
+      }
+    }
+    query &lt;&lt; &quot;, NOW())&quot;;
+
+    returnage.push_back(query.str());
+  }
+  return returnage;
 }
 
-string Host::generateQueryForRecentData(hostMessage sensorData){
+
+string Host::generateQueryForRecentData(hostMessage sensorData)
+{
   stringstream query;
   query &lt;&lt; &quot;INSERT INTO recentsensorvalues(host_id, name, value, created_at) &quot;
-        &lt;&lt; &quot;VALUES(&quot;
-        &lt;&lt; sensorData.hostID
-        &lt;&lt; &quot;, '&quot;
-        &lt;&lt; Database::escapeString(sensorData.type)
-        &lt;&lt; &quot;', '&quot;
-        &lt;&lt; Database::escapeString(sensorData.value)
-        &lt;&lt; &quot;', NOW())&quot;;
+    &lt;&lt; &quot;VALUES(&quot;
+    &lt;&lt; sensorData.hostID
+    &lt;&lt; &quot;, '&quot;
+    &lt;&lt; Database::escapeString(sensorData.type)
+    &lt;&lt; &quot;', '&quot;
+    &lt;&lt; Database::escapeString(sensorData.value)
+    &lt;&lt; &quot;', NOW())&quot;;
   return query.str();
 }
 
-string Host::generateDeletionQueryForRecentData(hostMessage sensorData){
+
+string Host::generateDeletionQueryForRecentData(hostMessage sensorData)
+{
   stringstream query;
   query &lt;&lt; &quot;DELETE FROM recentsensorvalues WHERE host_id = &quot; &lt;&lt; sensorData.hostID
-        &lt;&lt; &quot; AND name = '&quot; &lt;&lt; Database::escapeString(sensorData.type) &lt;&lt; &quot;'&quot;;
+    &lt;&lt; &quot; AND name = '&quot; &lt;&lt; Database::escapeString(sensorData.type) &lt;&lt; &quot;'&quot;;
   return query.str();
 }
 
-string Host::generateQuery(hostMessage sensorData, Database db){
+
+string Host::generateQuery(hostMessage sensorData, Database db)
+{
   string table;
   stringstream values;
 
   int type = getSensorType(sensorData);
 
-  if(type == SENSOR_TYPE_SENSORDATA){
+  if(type == SENSOR_TYPE_SENSORDATA)
+  {
     table = &quot;sensorvalues(host_id, name, value, created_at)&quot;;
     values &lt;&lt; sensorData.hostID
-           &lt;&lt; &quot;, '&quot;
-           &lt;&lt; Database::escapeString(sensorData.type)
-           &lt;&lt; &quot;', '&quot;
-           &lt;&lt; Database::escapeString(sensorData.value)
-           &lt;&lt; &quot;', NOW()&quot;;
-  }else if(type == SENSOR_TYPE_PROFILEDATA){
+      &lt;&lt; &quot;, '&quot;
+      &lt;&lt; Database::escapeString(sensorData.type)
+      &lt;&lt; &quot;', '&quot;
+      &lt;&lt; Database::escapeString(sensorData.value)
+      &lt;&lt; &quot;', NOW()&quot;;
+  }
+  else if(type == SENSOR_TYPE_PROFILEDATA)
+  {
     if(sensorData.type == &quot;profile_hostname&quot;){ stringstream query; query &lt;&lt; &quot;UPDATE hosts SET hostname = '&quot; &lt;&lt; Database::escapeString(sensorData.value) &lt;&lt; &quot;' WHERE id = &quot; &lt;&lt; sensorData.hostID; return query.str(); }
     if(sensorData.type == &quot;profile_domainname&quot;){ stringstream query; query &lt;&lt; &quot;UPDATE hosts SET domainname = '&quot; &lt;&lt; Database::escapeString(sensorData.value) &lt;&lt; &quot;' WHERE id = &quot; &lt;&lt; sensorData.hostID; return query.str(); }
     if(sensorData.type == &quot;profile_kernel&quot;){ stringstream query; query &lt;&lt; &quot;UPDATE hosts SET linux_kernelversion = '&quot; &lt;&lt; Database::escapeString(sensorData.value) &lt;&lt; &quot;' WHERE id = &quot; &lt;&lt; sensorData.hostID; return query.str(); }
     if(sensorData.type == &quot;profile_total_memory&quot;){ stringstream query; query &lt;&lt; &quot;UPDATE hosts SET total_memory = '&quot; &lt;&lt; Database::escapeString(sensorData.value) &lt;&lt; &quot;' WHERE id = &quot; &lt;&lt; sensorData.hostID; return query.str(); }
     if(sensorData.type == &quot;profile_total_swap&quot;){ stringstream query; query &lt;&lt; &quot;UPDATE hosts SET total_swap = '&quot; &lt;&lt; Database::escapeString(sensorData.value) &lt;&lt; &quot;' WHERE id = &quot; &lt;&lt; sensorData.hostID; return query.str(); }
     if(sensorData.type == &quot;profile_sp_client_version&quot;){ stringstream query; query &lt;&lt; &quot;UPDATE hosts SET clientversion = '&quot; &lt;&lt; Database::escapeString(sensorData.value) &lt;&lt; &quot;' WHERE id = &quot; &lt;&lt; sensorData.hostID; return query.str(); }
-    if(sensorData.type == &quot;profile_network_interfaces&quot;){
-    	stringstream delquery; delquery &lt;&lt; &quot;DELETE FROM networkinterfaces WHERE host_id = &quot; &lt;&lt; sensorData.hostID;
-    	db.setQuery(db.getHandle(), delquery.str());
-    	vector&lt;string&gt; queries = buildNetworkInterfacesQuery(sensorData.value, sensorData.hostID);
-    	for(vector&lt;string&gt;::const_iterator iter = queries.begin(); iter != queries.end(); ++iter){
-    		db.setQuery(db.getHandle(), *iter);
-    	}
+    if(sensorData.type == &quot;profile_network_interfaces&quot;)
+    {
+      stringstream delquery; delquery &lt;&lt; &quot;DELETE FROM networkinterfaces WHERE host_id = &quot; &lt;&lt; sensorData.hostID;
+      db.setQuery(db.getHandle(), delquery.str());
+      vector&lt;string&gt; queries = buildNetworkInterfacesQuery(sensorData.value, sensorData.hostID);
+      for(vector&lt;string&gt;::const_iterator iter = queries.begin(); iter != queries.end(); ++iter)
+      {
+        db.setQuery(db.getHandle(), *iter);
+      }
       // Let the calling method know that we already inserted the values for this packet.
       return &quot;done&quot;;
     }
- 	if(sensorData.type == &quot;profile_cpus&quot;){
-    	stringstream delquery; delquery &lt;&lt; &quot;DELETE FROM cpus WHERE host_id = &quot; &lt;&lt; sensorData.hostID;
-    	db.setQuery(db.getHandle(), delquery.str());
-    	vector&lt;string&gt; queries = buildCpusQuery(sensorData.value, sensorData.hostID);
-    	for(vector&lt;string&gt;::const_iterator iter = queries.begin(); iter != queries.end(); ++iter){
-    		db.setQuery(db.getHandle(), *iter);
-    	}
+    if(sensorData.type == &quot;profile_cpus&quot;)
+    {
+      stringstream delquery; delquery &lt;&lt; &quot;DELETE FROM cpus WHERE host_id = &quot; &lt;&lt; sensorData.hostID;
+      db.setQuery(db.getHandle(), delquery.str());
+      vector&lt;string&gt; queries = buildCpusQuery(sensorData.value, sensorData.hostID);
+      for(vector&lt;string&gt;::const_iterator iter = queries.begin(); iter != queries.end(); ++iter)
+      {
+        db.setQuery(db.getHandle(), *iter);
+      }
       // Let the calling method know that we already inserted the values for this packet.
       return &quot;done&quot;;
     }
-  }else{
+  }
+  else
+  {
     return &quot;err&quot;;
   }
 
   return &quot;INSERT INTO &quot; + table + &quot; VALUES( &quot; + values.str() + &quot;)&quot;;
 }
 
-string Host::getLastError(){
-  if(lastError.empty()){
+
+string Host::getLastError()
+{
+  if(lastError.empty())
+  {
     return &quot;No error message given.&quot;;
-  }else{
+  }
+  else
+  {
     return lastError;
   }
-}
\ No newline at end of file
+}</diff>
      <filename>src/host/Host.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -23,13 +23,14 @@
 #include &quot;../internal.h&quot;
 #include &quot;../database/Database.h&quot;
 
-class Host {
+class Host
+{
   private:
     mySQLData dbData;
     int socket;
-  
+
     struct sockaddr_in socketAddress;
-  	
+
     bool send(string message);
     string receive();
     hostMessage parse(string message);
@@ -37,27 +38,26 @@ class Host {
     int getSensorType(hostMessage sensorData);
     string generateQueryForRecentData(hostMessage sensorData);
     string generateDeletionQueryForRecentData(hostMessage sensorData);
-  
+
     vector&lt;string&gt; buildNetworkInterfacesQuery(string data, unsigned int hostID);
     vector&lt;string&gt; buildCpusQuery(string data, unsigned int hostID);
-    
+
     string lastError;
 
   public:
     Host(mySQLData myDBData, int mySocket, struct sockaddr_in mySocketAddress);
-  
+
     string getIPv4Address();
     void refuse(string reason);
     void notify(string reason);
-  
+
     bool isBlacklisted(Database db);
     bool addToBlacklist(Database db);
-  
+
     bool checkLogin(Database db);
-  
+
     bool receiveAndStoreData(Database db);
-    
+
     string getLastError();
 };
-
-#endif /*HOST_H_*/
+#endif                                            /*HOST_H_*/</diff>
      <filename>src/host/Host.h</filename>
    </modified>
    <modified>
      <diff>@@ -54,87 +54,93 @@ using namespace std;
 // Configuration structs.
 
 //! Struct: Holds login and connection information of MySQL database.
-struct mySQLData {
-	//! The host the MySQL server is running on. (Hostname or IP)
-	const char*		host;
-	//! The user we want to connect with.
-	const char*		user;
-	//! The password of the chosen user.
-	const char*		pass;
-	//! The ScopePort database.
-	const char*		db;
-	//! The port of the MySQL server we want to connect to. (0 = Standard port)
-	unsigned int	port;
+struct mySQLData
+{
+  //! The host the MySQL server is running on. (Hostname or IP)
+  const char*   host;
+  //! The user we want to connect with.
+  const char*   user;
+  //! The password of the chosen user.
+  const char*   pass;
+  //! The ScopePort database.
+  const char*   db;
+  //! The port of the MySQL server we want to connect to. (0 = Standard port)
+  unsigned int  port;
 
 };
 
 //! Struct: Holds login, server and general SMTP information.
-struct mailingData {
-	//! Is mailing enabled?
-	bool			doMailing;
-	//! Do we need to authenticate on the SMTP server?
-	bool			mailUseAuth;
-	//! The SMTP server we want to connect to. (Hostname or IP)
-	string			mailServer;
-	//! The port we want to use.
-	unsigned int	mailPort;
-	//! The user we want to connect with.
-	string			mailUser;
-	//! The password of the user.
-	string			mailPass;
-	//! Our hostname. Specified in EHLO sequence.
-	string			mailHostname;
-	//! The &quot;mail-from&quot; field of sent messages.
-	string			mailFrom;
-	//! A receiver that is used if an error occures while fetching other addresses.
-	string			fallbackReceiver;
+struct mailingData
+{
+  //! Is mailing enabled?
+  bool      doMailing;
+  //! Do we need to authenticate on the SMTP server?
+  bool      mailUseAuth;
+  //! The SMTP server we want to connect to. (Hostname or IP)
+  string      mailServer;
+  //! The port we want to use.
+  unsigned int  mailPort;
+  //! The user we want to connect with.
+  string      mailUser;
+  //! The password of the user.
+  string      mailPass;
+  //! Our hostname. Specified in EHLO sequence.
+  string      mailHostname;
+  //! The &quot;mail-from&quot; field of sent messages.
+  string      mailFrom;
+  //! A receiver that is used if an error occures while fetching other addresses.
+  string      fallbackReceiver;
 };
 
 //! Struct: Holds information of login, server and general XMPP information
-struct XMPPData {
-	//! Is XMPP enabled?
-	bool			doXMPP;
-	//! The XMPP server we want to connect to.
-	string			xmppServer;
-	//! The port of the XMPP server.
-	unsigned int	xmppPort;
-	//! The user we want to connect with.
-	string			xmppUser;
-	//! The password of the user.
-	string			xmppPass;
-	//! A XMPP ressource (part of the JID like /home or /notebook).
-	string			xmppResource;
-	//! A receiver that is used if an error occures while fetching other addresses.
-	string			fallbackReceiver;
+struct XMPPData
+{
+  //! Is XMPP enabled?
+  bool      doXMPP;
+  //! The XMPP server we want to connect to.
+  string      xmppServer;
+  //! The port of the XMPP server.
+  unsigned int  xmppPort;
+  //! The user we want to connect with.
+  string      xmppUser;
+  //! The password of the user.
+  string      xmppPass;
+  //! A XMPP ressource (part of the JID like /home or /notebook).
+  string      xmppResource;
+  //! A receiver that is used if an error occures while fetching other addresses.
+  string      fallbackReceiver;
 };
 
 //! Struct: Holds information of Clickatell SMS Gateway API.
-struct mobilecData {
-	//! Is usage of the API enabled?
-	bool	doMobileC;
-	//! The API username.
-	string	username;
-	//! The API password.
-	string	password;
-	//! The API ID.
-	string	apiID;
-	//! A receiver that is used if an error occures while fetching other addresses.
-	string	fallbackNumber;
+struct mobilecData
+{
+  //! Is usage of the API enabled?
+  bool  doMobileC;
+  //! The API username.
+  string  username;
+  //! The API password.
+  string  password;
+  //! The API ID.
+  string  apiID;
+  //! A receiver that is used if an error occures while fetching other addresses.
+  string  fallbackNumber;
 };
 
 //! Struct: Holds information of emergeny notification receiver.
-struct enData {
-	//! The type of the receiver. (e.g. JID or email address)
-	string	type;
-	//! The address. (e.g. JID or email)
-	string	address;
-	//! The emergeny ID this notification belogs to.
-	int		emergencyID;
-	//! The notificationList ID of this receiver.
-	int		ID;
+struct enData
+{
+  //! The type of the receiver. (e.g. JID or email address)
+  string  type;
+  //! The address. (e.g. JID or email)
+  string  address;
+  //! The emergeny ID this notification belogs to.
+  int   emergencyID;
+  //! The notificationList ID of this receiver.
+  int   ID;
 };
 
-struct hostMessage {
+struct hostMessage
+{
   unsigned int hostID;
   string type;
   string value;
@@ -181,5 +187,4 @@ bool numOnly(string checkMe);
 #define CONV_DEBUG_DIRECTION_RECV 1
 #define CONV_DEBUG_ERROR_SENT &quot;Sending the message failed&quot;
 #define CONV_DEBUG_ERROR_RECV &quot;Nothing was received&quot;
-
-#endif /*INTERNAL_H_*/
+#endif                                            /*INTERNAL_H_*/</diff>
      <filename>src/internal.h</filename>
    </modified>
    <modified>
      <diff>@@ -20,7 +20,8 @@
 #include &quot;../database/Database.h&quot;
 
 ConversationDebug::ConversationDebug(mySQLData myDBData, string myMethod, string myRemoteHost)
-			: Database(myDBData) {
+: Database(myDBData)
+{
   method = myMethod;
   remoteHost = myRemoteHost;
 
@@ -28,21 +29,29 @@ ConversationDebug::ConversationDebug(mySQLData myDBData, string myMethod, string
   create();
 }
 
-bool ConversationDebug::checkIfDisabledForThisMethod(){
+
+bool ConversationDebug::checkIfDisabledForThisMethod()
+{
   stringstream query;
   query &lt;&lt; &quot;SELECT &quot;;
 
-  if(method == &quot;smtp&quot;){
+  if(method == &quot;smtp&quot;)
+  {
     query &lt;&lt; &quot;conversation_logging_smtp&quot;;
-  }else if(method == &quot;xmpp&quot;){
+  }
+  else if(method == &quot;xmpp&quot;)
+  {
     query &lt;&lt; &quot;conversation_logging_xmpp&quot;;
-  }else{
+  }
+  else
+  {
     return 1;
   }
 
   query &lt;&lt; &quot; FROM settings ORDER BY id DESC LIMIT 1&quot;;
 
-  if(initConnection()){
+  if(initConnection())
+  {
     string result = sGetQuery(query.str());
     mysql_close(getHandle());
     if(result == &quot;1&quot;) { return 0; }
@@ -51,8 +60,10 @@ bool ConversationDebug::checkIfDisabledForThisMethod(){
   return 1;
 }
 
-void ConversationDebug::create(){
-  if(disabled) { return; }  
+
+void ConversationDebug::create()
+{
+  if(disabled) { return; }
 
   static timeval tv;
   static timeval tv2;
@@ -63,34 +74,36 @@ void ConversationDebug::create(){
   stringstream query;
 
   query &lt;&lt; &quot;INSERT INTO conversations(conversation_id, method, remote_host, created_at) VALUES(&quot;
-        &lt;&lt; conversationID
-        &lt;&lt; &quot;, '&quot;
-        &lt;&lt; Database::escapeString(method)
-        &lt;&lt;  &quot;', '&quot;
-        &lt;&lt; Database::escapeString(remoteHost)
-        &lt;&lt; &quot;', NOW())&quot;;
-
-  if(initConnection()){
+    &lt;&lt; conversationID
+    &lt;&lt; &quot;, '&quot;
+    &lt;&lt; Database::escapeString(method)
+    &lt;&lt;  &quot;', '&quot;
+    &lt;&lt; Database::escapeString(remoteHost)
+    &lt;&lt; &quot;', NOW())&quot;;
+
+  if(initConnection())
+  {
     setQuery(getHandle(), query.str());
     mysql_close(getHandle());
   }
 }
 
 
-void ConversationDebug::log(unsigned int direction, string message){
-  if(disabled) { return; }  
+void ConversationDebug::log(unsigned int direction, string message)
+{
+  if(disabled) { return; }
 
   stringstream query;
   query &lt;&lt; &quot;INSERT INTO conversationmessages(conversation_id, direction, message, created_at) VALUES(&quot;
-        &lt;&lt; conversationID
-        &lt;&lt; &quot;, &quot;
-        &lt;&lt; direction
-        &lt;&lt;  &quot;, '&quot;
-        &lt;&lt; Database::escapeString(message)
-        &lt;&lt; &quot;', NOW())&quot;;
-  if(initConnection()){
+    &lt;&lt; conversationID
+    &lt;&lt; &quot;, &quot;
+    &lt;&lt; direction
+    &lt;&lt;  &quot;, '&quot;
+    &lt;&lt; Database::escapeString(message)
+    &lt;&lt; &quot;', NOW())&quot;;
+  if(initConnection())
+  {
     setQuery(getHandle(), query.str());
     mysql_close(getHandle());
   }
 }
-</diff>
      <filename>src/log/ConversationDebug.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -21,8 +21,9 @@
 #include &quot;../internal.h&quot;
 #include &quot;../database/Database.h&quot;
 
-class ConversationDebug : public Database {
-	private:
+class ConversationDebug : public Database
+{
+  private:
     unsigned int conversationID;
     string method;
     string remoteHost;
@@ -30,10 +31,9 @@ class ConversationDebug : public Database {
 
     void create();
     bool checkIfDisabledForThisMethod();
-	public:
+  public:
     ConversationDebug(mySQLData myDBData, string myMethod, string myRemoteHost);
 
     void log(unsigned int direction, string message);
 };
-
-#endif /*LOG_H_*/
+#endif                                            /*LOG_H_*/</diff>
      <filename>src/log/ConversationDebug.h</filename>
    </modified>
    <modified>
      <diff>@@ -21,48 +21,59 @@
 #include &quot;../notifications/GeneralNotifications.h&quot;
 
 Log::Log(const char* myLogfile, mySQLData myDBData)
-			: Database(myDBData) {
-	logfile = myLogfile;
+: Database(myDBData)
+{
+  logfile = myLogfile;
 }
 
-void Log::putLog(int severity, string errorcode, string logmsg){
-	time_t rawtime;
+
+void Log::putLog(int severity, string errorcode, string logmsg)
+{
+  time_t rawtime;
   time(&amp;rawtime);
   char* logtime = noNewLine(ctime(&amp;rawtime), strlen(ctime(&amp;rawtime)));
-	ofstream log(&quot;/var/log/scopeport-server.log&quot;, ios::app);
-	if(!log.fail()){
-		if(logmsg != &quot;.newrun&quot;){
-			log &lt;&lt; logtime &lt;&lt; &quot; - &quot; &lt;&lt; logmsg &lt;&lt; endl;
-			if(initConnection()){
-				MYSQL* init = getHandle();
-				char *safeMsg = new char[strlen(logmsg.c_str())*2 + 1];
-				mysql_real_escape_string(init, safeMsg,logmsg.c_str(),strlen(logmsg.c_str()));
-				stringstream query;
-				query 	&lt;&lt; &quot;INSERT INTO `logmessages` (logtime,severity,errorcode,logmsg) VALUES('&quot;
-						&lt;&lt; rawtime
-						&lt;&lt; &quot;',\'&quot;
-						&lt;&lt; severity
-						&lt;&lt; &quot;',\'&quot;
-						&lt;&lt; errorcode
-						&lt;&lt; &quot;',\'&quot;
-						&lt;&lt; safeMsg
-						&lt;&lt; &quot;\')&quot;;
-				mysql_real_query(init, query.str().c_str(), strlen(query.str().c_str()));
-				mysql_close(init);
-			}
-		}else{
-			log &lt;&lt; &quot;--------------&quot; &lt;&lt; endl;
-		}
-	}
-	log.close();
+  ofstream log(&quot;/var/log/scopeport-server.log&quot;, ios::app);
+  if(!log.fail())
+  {
+    if(logmsg != &quot;.newrun&quot;)
+    {
+      log &lt;&lt; logtime &lt;&lt; &quot; - &quot; &lt;&lt; logmsg &lt;&lt; endl;
+      if(initConnection())
+      {
+        MYSQL* init = getHandle();
+        char *safeMsg = new char[strlen(logmsg.c_str())*2 + 1];
+        mysql_real_escape_string(init, safeMsg,logmsg.c_str(),strlen(logmsg.c_str()));
+        stringstream query;
+        query   &lt;&lt; &quot;INSERT INTO `logmessages` (logtime,severity,errorcode,logmsg) VALUES('&quot;
+          &lt;&lt; rawtime
+          &lt;&lt; &quot;',\'&quot;
+          &lt;&lt; severity
+          &lt;&lt; &quot;',\'&quot;
+          &lt;&lt; errorcode
+          &lt;&lt; &quot;',\'&quot;
+          &lt;&lt; safeMsg
+          &lt;&lt; &quot;\')&quot;;
+        mysql_real_query(init, query.str().c_str(), strlen(query.str().c_str()));
+        mysql_close(init);
+      }
+    }
+    else
+    {
+      log &lt;&lt; &quot;--------------&quot; &lt;&lt; endl;
+    }
+  }
+  log.close();
 }
 
-void Log::debug(bool debug, string msg){
-  if(!debug){
+
+void Log::debug(bool debug, string msg)
+{
+  if(!debug)
+  {
     return;
   }
 
-	time_t rawtime;
+  time_t rawtime;
   time(&amp;rawtime);
   char* logtime = noNewLine(ctime(&amp;rawtime), strlen(ctime(&amp;rawtime)));
   cout &lt;&lt; logtime &lt;&lt; &quot; - &quot; &lt;&lt; msg &lt;&lt; endl;</diff>
      <filename>src/log/Log.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -18,7 +18,7 @@
 //!  Event logging
 /*!
  * Logs events to logfile and database based on loglevel and severity of event.
-*/
+ */
 
 #ifndef LOG_H_
 #define LOG_H_
@@ -26,22 +26,22 @@
 #include &quot;../internal.h&quot;
 #include &quot;../database/Database.h&quot;
 
-class Log : public Database {
-	private:
-		//! Path of logfile.  
-		const char* logfile;
-	public:
-		Log(const char* myLogfile, mySQLData myDBData);
-		
-		//! Writes message to database and logfile.  
-		/*!
-		 * \param severity The severity of this event.
-		 * \param errorcode The error code of this event.
-		 * \param logmsg The message that should be logged.
-		 */
-		void putLog(int severity, string errorcode, string logmsg);
+class Log : public Database
+{
+  private:
+    //! Path of logfile.
+    const char* logfile;
+  public:
+    Log(const char* myLogfile, mySQLData myDBData);
+
+    //! Writes message to database and logfile.
+    /*!
+     * \param severity The severity of this event.
+     * \param errorcode The error code of this event.
+     * \param logmsg The message that should be logged.
+     */
+    void putLog(int severity, string errorcode, string logmsg);
 
     static void debug(bool debug, string msg);
 };
-
-#endif /*LOG_H_*/
+#endif                                            /*LOG_H_*/</diff>
      <filename>src/log/Log.h</filename>
    </modified>
    <modified>
      <diff>@@ -17,24 +17,29 @@
 
 #include &quot;Timer.h&quot;
 
-void Timer::startTimer() {
-	m_timeval = get_tv ();
+void Timer::startTimer()
+{
+  m_timeval = get_tv ();
 }
 
-unsigned int Timer::stopTimer() const {
-	timeval timeval = get_tv ();
-	int returnage = ( timeval.tv_sec - m_timeval.tv_sec ) * 1000 + (( timeval.tv_usec - m_timeval.tv_usec ) / 1000);
 
-	// Round the time up to one millisecond if it is zero.
-	if(returnage == 0)
-		returnage = 1;
+unsigned int Timer::stopTimer() const
+{
+  timeval timeval = get_tv ();
+  int returnage = ( timeval.tv_sec - m_timeval.tv_sec ) * 1000 + (( timeval.tv_usec - m_timeval.tv_usec ) / 1000);
 
-	return returnage;
+  // Round the time up to one millisecond if it is zero.
+  if(returnage == 0)
+    returnage = 1;
+
+  return returnage;
 }
 
-const timeval&amp; Timer::get_tv() const {
-	static timeval tv;
-	static struct timezone tz;
-	gettimeofday ( &amp;tv, &amp;tz );
-	return tv;
+
+const timeval&amp; Timer::get_tv() const
+{
+  static timeval tv;
+  static struct timezone tz;
+  gettimeofday ( &amp;tv, &amp;tz );
+  return tv;
 }</diff>
      <filename>src/misc/Timer.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -22,13 +22,13 @@
 
 #include &quot;../internal.h&quot;
 
-class Timer {  
-	public:
-	    void startTimer();
-	    unsigned int stopTimer() const;
-	private:
-	    timeval m_timeval;
-	    const timeval&amp; get_tv() const;
+class Timer
+{
+  public:
+    void startTimer();
+    unsigned int stopTimer() const;
+  private:
+    timeval m_timeval;
+    const timeval&amp; get_tv() const;
 };
-
-#endif /*TIMER_H_*/
+#endif                                            /*TIMER_H_*/</diff>
      <filename>src/misc/Timer.h</filename>
    </modified>
    <modified>
      <diff>@@ -19,62 +19,82 @@
 #include &quot;../internal.h&quot;
 #include &quot;../database/Database.h&quot;
 
-mobilecData Clickatell::fetchSettings(mySQLData dbData){
+mobilecData Clickatell::fetchSettings(mySQLData dbData)
+{
   mobilecData clickatell;
 
   Database db(dbData);
-  if(db.initConnection()){
+  if(db.initConnection())
+  {
     const char* getSettingsSQL = &quot;SELECT doMobileClickatell, mobilecUsername, mobilecPassword,&quot;
-                                &quot;mobilecAPIID FROM settings&quot;;
-    if(mysql_real_query(db.getHandle(), getSettingsSQL, strlen(getSettingsSQL)) == 0){
+      &quot;mobilecAPIID FROM settings&quot;;
+    if(mysql_real_query(db.getHandle(), getSettingsSQL, strlen(getSettingsSQL)) == 0)
+    {
       MYSQL_RES* res;
-      if((res = mysql_store_result(db.getHandle())) != NULL){
+      if((res = mysql_store_result(db.getHandle())) != NULL)
+      {
         MYSQL_ROW row;
         row = mysql_fetch_row(res);
         stringstream result;
-        if(mysql_num_rows(res) &gt; 0){
+        if(mysql_num_rows(res) &gt; 0)
+        {
 
           // doMobileClickatell
-          if(row[0] != NULL){
-            if(strcmp(row[0], &quot;1&quot;) == 0){
+          if(row[0] != NULL)
+          {
+            if(strcmp(row[0], &quot;1&quot;) == 0)
+            {
               clickatell.doMobileC = 1;
-            }else{
+            }
+            else
+            {
               clickatell.doMobileC = 0;
             }
           }
 
           // mobilecUsername
-          if(row[1] != NULL){
+          if(row[1] != NULL)
+          {
             clickatell.username = row[1];
           }
 
           // mobilecPassword
-          if(row[2] != NULL){
+          if(row[2] != NULL)
+          {
             clickatell.password = row[2];
           }
 
           // mobilecPassword
-          if(row[3] != NULL){
+          if(row[3] != NULL)
+          {
             clickatell.apiID = row[3];
           }
 
-        }else{
+        }
+        else
+        {
           // Nothing fetched. Disable.
           clickatell.doMobileC = 0;
         }
-      }else{
+      }
+      else
+      {
         // Error. Disable.
-    	clickatell.doMobileC = 0;
+        clickatell.doMobileC = 0;
       }
       mysql_free_result(res);
-    }else{
+    }
+    else
+    {
       // Query failed. Disable.
       clickatell.doMobileC = 0;
     }
     mysql_close(db.getHandle());
-  }else{
+  }
+  else
+  {
     // Could not connect to DB. Disable.
-	  clickatell.doMobileC = 0;
+    clickatell.doMobileC = 0;
   }
 
   return clickatell;</diff>
      <filename>src/notifications/Clickatell.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -20,10 +20,10 @@
 
 #include &quot;../internal.h&quot;
 
-class Clickatell {
-	public:
-		//! Returns mobilecData struct with settings from database.
-		static mobilecData fetchSettings(mySQLData dbData);
+class Clickatell
+{
+  public:
+    //! Returns mobilecData struct with settings from database.
+    static mobilecData fetchSettings(mySQLData dbData);
 };
-
-#endif /* CLICKATELL_H_ */
+#endif                                            /* CLICKATELL_H_ */</diff>
      <filename>src/notifications/Clickatell.h</filename>
    </modified>
    <modified>
      <diff>@@ -23,14 +23,16 @@
 #include &quot;../internal.h&quot;
 
 EmergencyNotifications::EmergencyNotifications(mySQLData myDBData, mailingData myMailData,
-		XMPPData myXMPPData, mobilecData myMobilecData)
-			: Database(myDBData){
-	dbData = myDBData;
-	mailData = myMailData;
-	xmppData = myXMPPData;
-	clickatellData = myMobilecData;
+XMPPData myXMPPData, mobilecData myMobilecData)
+: Database(myDBData)
+{
+  dbData = myDBData;
+  mailData = myMailData;
+  xmppData = myXMPPData;
+  clickatellData = myMobilecData;
 }
 
+
 /*
  * Return values:
  * 	1: Emergency notifications to send fetched.
@@ -38,214 +40,253 @@ EmergencyNotifications::EmergencyNotifications(mySQLData myDBData, mailingData m
  * -1: Error
  */
 
-int EmergencyNotifications::fetchTasks(){
-	if(initConnection()){
-		MYSQL* init = getHandle();
-		// Get tasks.
-		const char* taskQuery = &quot;SELECT email, jid, emergencyid, ID, numberc&quot;
-							&quot; FROM emergencynotifications &quot;
-							&quot; WHERE notifiedon = 0&quot;
-							&quot; LIMIT 250&quot;;
-
-		if(mysql_real_query(init, taskQuery, strlen(taskQuery)) != 0){
-			// Query was not successful.
-			mysql_close(init);
-			return 0;
-		}else{
-			// Query successful.
-			MYSQL_RES* res = mysql_store_result(init);
-			MYSQL_ROW row;
-			if(mysql_num_rows(res) &gt; 0){
-				unsigned int i = 0;
-				// Got notifications to send.
-				while((row = mysql_fetch_row(res))){
-					stringstream address;
-					if(strlen(row[0]) &gt; 0){
-						// This is an email address.
-						address	&lt;&lt; &quot;mail|&quot;
-								&lt;&lt; row[0]
-								&lt;&lt; &quot;|&quot;
-								&lt;&lt; row[2]
-								&lt;&lt; &quot;|&quot;
-								&lt;&lt; row[3];
-					}else if(strlen(row[1]) &gt; 0){
-						// This is a jid.
-						address &lt;&lt; &quot;jid|&quot;
-								&lt;&lt; row[1]
-								&lt;&lt; &quot;|&quot;
-								&lt;&lt; row[2]
-								&lt;&lt; &quot;|&quot;
-								&lt;&lt; row[3];
-					}else if(strlen(row[4]) &gt; 0){
-						// This is a Clickatell mobile number.
-						address &lt;&lt; &quot;mobilec|&quot;
-								&lt;&lt; row[4]
-								&lt;&lt; &quot;|&quot;
-								&lt;&lt; row[2]
-								&lt;&lt; &quot;|&quot;
-								&lt;&lt; row[3];
-					}else{
-						// No email address or jid. Skip.
-						i++;
-						continue;
-					}
-					notificationList[i] = address.str();
-					i++;
-				}
-				mysql_free_result(res);
-				mysql_close(init);
-				return 1;
-			}else{
-				// Nothing fetched.
-				mysql_free_result(res);
-				mysql_close(init);
-				return 1;
-			}
-		}
-	}
-
-	return -1;
+int EmergencyNotifications::fetchTasks()
+{
+  if(initConnection())
+  {
+    MYSQL* init = getHandle();
+    // Get tasks.
+    const char* taskQuery = &quot;SELECT email, jid, emergencyid, ID, numberc&quot;
+      &quot; FROM emergencynotifications &quot;
+      &quot; WHERE notifiedon = 0&quot;
+      &quot; LIMIT 250&quot;;
+
+    if(mysql_real_query(init, taskQuery, strlen(taskQuery)) != 0)
+    {
+      // Query was not successful.
+      mysql_close(init);
+      return 0;
+    }
+    else
+    {
+      // Query successful.
+      MYSQL_RES* res = mysql_store_result(init);
+      MYSQL_ROW row;
+      if(mysql_num_rows(res) &gt; 0)
+      {
+        unsigned int i = 0;
+        // Got notifications to send.
+        while((row = mysql_fetch_row(res)))
+        {
+          stringstream address;
+          if(strlen(row[0]) &gt; 0)
+          {
+            // This is an email address.
+            address &lt;&lt; &quot;mail|&quot;
+              &lt;&lt; row[0]
+              &lt;&lt; &quot;|&quot;
+              &lt;&lt; row[2]
+              &lt;&lt; &quot;|&quot;
+              &lt;&lt; row[3];
+          }
+          else if(strlen(row[1]) &gt; 0)
+          {
+            // This is a jid.
+            address &lt;&lt; &quot;jid|&quot;
+              &lt;&lt; row[1]
+              &lt;&lt; &quot;|&quot;
+              &lt;&lt; row[2]
+              &lt;&lt; &quot;|&quot;
+              &lt;&lt; row[3];
+          }
+          else if(strlen(row[4]) &gt; 0)
+          {
+            // This is a Clickatell mobile number.
+            address &lt;&lt; &quot;mobilec|&quot;
+              &lt;&lt; row[4]
+              &lt;&lt; &quot;|&quot;
+              &lt;&lt; row[2]
+              &lt;&lt; &quot;|&quot;
+              &lt;&lt; row[3];
+          }
+          else
+          {
+            // No email address or jid. Skip.
+            i++;
+            continue;
+          }
+          notificationList[i] = address.str();
+          i++;
+        }
+        mysql_free_result(res);
+        mysql_close(init);
+        return 1;
+      }
+      else
+      {
+        // Nothing fetched.
+        mysql_free_result(res);
+        mysql_close(init);
+        return 1;
+      }
+    }
+  }
+
+  return -1;
 }
 
-int EmergencyNotifications::getListSize(){
-	return notificationList.size();
+
+int EmergencyNotifications::getListSize()
+{
+  return notificationList.size();
 }
 
-enData EmergencyNotifications::splitEmergencyInformation(int recvNum){
-	enData info;
-	// Split the receiver to get the information.
-	string token;
-	istringstream iss(notificationList[recvNum]);
-	int i = 0;
-	while(getline(iss, token, '|')){
-		switch(i){
-			case 0:
-				// The type.
-				info.type = token;
-				break;
-			case 1:
-				// The address.
-				info.address = token;
-				break;
-			case 2:
-				// The emergency ID.
-				info.emergencyID = stringToInteger(token.c_str());
-				break;
-			case 3:
-				info.ID = stringToInteger(token.c_str());
-				break;
-		}
-		i++;
-	}
-	return info;
+
+enData EmergencyNotifications::splitEmergencyInformation(int recvNum)
+{
+  enData info;
+  // Split the receiver to get the information.
+  string token;
+  istringstream iss(notificationList[recvNum]);
+  int i = 0;
+  while(getline(iss, token, '|'))
+  {
+    switch(i)
+    {
+      case 0:
+        // The type.
+        info.type = token;
+        break;
+      case 1:
+        // The address.
+        info.address = token;
+        break;
+      case 2:
+        // The emergency ID.
+        info.emergencyID = stringToInteger(token.c_str());
+        break;
+      case 3:
+        info.ID = stringToInteger(token.c_str());
+        break;
+    }
+    i++;
+  }
+  return info;
 }
 
-int EmergencyNotifications::sendMessage(int recvNum){
-	enData info = splitEmergencyInformation(recvNum);
-
-	// Check if we got all needed data.
-	if(info.type.length() &lt;= 0 || info.address.length() &lt;= 0 || info.emergencyID &lt;= 0)
-		return -1;
-
-	// These are used to generate a message.
-	string description;
-	string timestamp;
-	string severity;
-	string severityName;
-
-	// Connect to database.
-	if(initConnection()){
-		description = sGetQuery(Information::getEmergencyInformation(info.emergencyID, 0));
-		timestamp = sGetQuery(Information::getEmergencyInformation(info.emergencyID, 1));
-		severity = sGetQuery(Information::getEmergencyInformation(info.emergencyID, 2));
-
-		// Close database connection.
-		mysql_close(getHandle());
-	}else{
-		// Could not connect to database.
-		return 0;
-	}
-
-	// Check if needed information was fetched without errors.
-	if(description == &quot;NULL&quot; || timestamp == &quot;NULL&quot; || severity == &quot;NULL&quot;)
-		return -1;
-
-	// Convert severity types to names.
-	switch(stringToInteger(severity.c_str())){
-		case 1:
-			severityName = &quot;Medium&quot;;
-			break;
-		case 2:
-			severityName = &quot;High&quot;;
-			break;
-		case 3:
-			severityName = &quot;Disaster&quot;;
-			break;
-		default:
-			return -1;
-	}
-
-	// Build the message
-	stringstream message;
-	message	&lt;&lt; &quot;ALERT: An emergency has been declared!&quot;
-			&lt;&lt; endl &lt;&lt; endl
-			&lt;&lt; &quot;Description:&quot;
-			&lt;&lt; description
-			&lt;&lt; endl &lt;&lt; endl
-			&lt;&lt; &quot;Severity: &quot;
-			&lt;&lt; severityName;
-
-	// Everything seems to be okay. Send the message.
-	if(info.type == &quot;jid&quot;){
-		// We need to send an XMPP message.
-		XMPP xmpp(xmppData, dbData);
-		if(!xmpp.sendMessage(message.str(), info.address))
-			return -1;
-		return 1;
-	}else if(info.type == &quot;mail&quot;){
-		// We need to send an email.
-		Mail mailing(mailData, dbData);
-		if(!mailing.sendMail(info.address, &quot;An emergency has been declared&quot;, message.str()))
-			return -1;
-		return 1;
-	}else if(info.type == &quot;mobilec&quot;){
-		// We need to send an SMS via the Clickatell SMTP API.
-		Mail mailing(mailData, dbData);
-		// Build the message that fits to the API.
-		stringstream newMessage;
-		newMessage	&lt;&lt; &quot;user:&quot; &lt;&lt; clickatellData.username &lt;&lt; endl
-					&lt;&lt; &quot;password:&quot; &lt;&lt; clickatellData.password &lt;&lt; endl
-					&lt;&lt; &quot;api_id:&quot; &lt;&lt; clickatellData.apiID &lt;&lt; endl
-					&lt;&lt; &quot;to:&quot; &lt;&lt; info.address &lt;&lt; endl
-					&lt;&lt; &quot;text:&quot; &lt;&lt; &quot;[ScopePort] &quot; &lt;&lt; noNewLineS(message.str());
-		if(!mailing.sendMail(CLICKATELLMAIL, &quot;&quot;, newMessage.str()))
-			return -1;
-		return 1;
-	}
-
-	return -1;
+
+int EmergencyNotifications::sendMessage(int recvNum)
+{
+  enData info = splitEmergencyInformation(recvNum);
+
+  // Check if we got all needed data.
+  if(info.type.length() &lt;= 0 || info.address.length() &lt;= 0 || info.emergencyID &lt;= 0)
+    return -1;
+
+  // These are used to generate a message.
+  string description;
+  string timestamp;
+  string severity;
+  string severityName;
+
+  // Connect to database.
+  if(initConnection())
+  {
+    description = sGetQuery(Information::getEmergencyInformation(info.emergencyID, 0));
+    timestamp = sGetQuery(Information::getEmergencyInformation(info.emergencyID, 1));
+    severity = sGetQuery(Information::getEmergencyInformation(info.emergencyID, 2));
+
+    // Close database connection.
+    mysql_close(getHandle());
+  }
+  else
+  {
+    // Could not connect to database.
+    return 0;
+  }
+
+  // Check if needed information was fetched without errors.
+  if(description == &quot;NULL&quot; || timestamp == &quot;NULL&quot; || severity == &quot;NULL&quot;)
+    return -1;
+
+  // Convert severity types to names.
+  switch(stringToInteger(severity.c_str()))
+  {
+    case 1:
+      severityName = &quot;Medium&quot;;
+      break;
+    case 2:
+      severityName = &quot;High&quot;;
+      break;
+    case 3:
+      severityName = &quot;Disaster&quot;;
+      break;
+    default:
+      return -1;
+  }
+
+  // Build the message
+  stringstream message;
+  message &lt;&lt; &quot;ALERT: An emergency has been declared!&quot;
+    &lt;&lt; endl &lt;&lt; endl
+    &lt;&lt; &quot;Description:&quot;
+    &lt;&lt; description
+    &lt;&lt; endl &lt;&lt; endl
+    &lt;&lt; &quot;Severity: &quot;
+    &lt;&lt; severityName;
+
+  // Everything seems to be okay. Send the message.
+  if(info.type == &quot;jid&quot;)
+  {
+    // We need to send an XMPP message.
+    XMPP xmpp(xmppData, dbData);
+    if(!xmpp.sendMessage(message.str(), info.address))
+      return -1;
+    return 1;
+  }
+  else if(info.type == &quot;mail&quot;)
+  {
+    // We need to send an email.
+    Mail mailing(mailData, dbData);
+    if(!mailing.sendMail(info.address, &quot;An emergency has been declared&quot;, message.str()))
+      return -1;
+    return 1;
+  }
+  else if(info.type == &quot;mobilec&quot;)
+  {
+    // We need to send an SMS via the Clickatell SMTP API.
+    Mail mailing(mailData, dbData);
+    // Build the message that fits to the API.
+    stringstream newMessage;
+    newMessage  &lt;&lt; &quot;user:&quot; &lt;&lt; clickatellData.username &lt;&lt; endl
+      &lt;&lt; &quot;password:&quot; &lt;&lt; clickatellData.password &lt;&lt; endl
+      &lt;&lt; &quot;api_id:&quot; &lt;&lt; clickatellData.apiID &lt;&lt; endl
+      &lt;&lt; &quot;to:&quot; &lt;&lt; info.address &lt;&lt; endl
+      &lt;&lt; &quot;text:&quot; &lt;&lt; &quot;[ScopePort] &quot; &lt;&lt; noNewLineS(message.str());
+    if(!mailing.sendMail(CLICKATELLMAIL, &quot;&quot;, newMessage.str()))
+      return -1;
+    return 1;
+  }
+
+  return -1;
 }
 
-bool EmergencyNotifications::markReceiver(int recvNum, int status){
-	enData info = splitEmergencyInformation(recvNum);
-
-	// Check if we got all needed data.
-	if(info.ID &lt;= 0)
-		return 0;
-
-	// Connect to database.
-	if(initConnection()){
-		if(!setQuery(getHandle(), Information::setReceiverMark(info.ID, status))){
-			mysql_close(getHandle());
-			return 0;
-		}
-		// Close database connection.
-		mysql_close(getHandle());
-		return 1;
-	}else{
-		// Could not connect to database.
-		return 0;
-	}
-
-	return 0;
+
+bool EmergencyNotifications::markReceiver(int recvNum, int status)
+{
+  enData info = splitEmergencyInformation(recvNum);
+
+  // Check if we got all needed data.
+  if(info.ID &lt;= 0)
+    return 0;
+
+  // Connect to database.
+  if(initConnection())
+  {
+    if(!setQuery(getHandle(), Information::setReceiverMark(info.ID, status)))
+    {
+      mysql_close(getHandle());
+      return 0;
+    }
+    // Close database connection.
+    mysql_close(getHandle());
+    return 1;
+  }
+  else
+  {
+    // Could not connect to database.
+    return 0;
+  }
+
+  return 0;
 }</diff>
      <filename>src/notifications/EmergencyNotifications.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -26,66 +26,66 @@
 #include &quot;../internal.h&quot;
 #include &quot;../database/Database.h&quot;
 
-class EmergencyNotifications : public Database {
-	private:
-		//! Holds login and connection information of MySQL database.  
-		mySQLData dbData;
-		
-		//! Holds SMTP login information and settings.
-		mailingData		mailData;
-		
-		//! Holds XMPP login information and settings.
-		XMPPData		xmppData;
-		
-		//! Struct: Holds information of Clickatell SMS Gateway API.
-		mobilecData clickatellData;
-		
-		//! Holds information about every receiver that needs to be informed.  
-		map&lt;int,string&gt;	notificationList;
-	public:
-		//! Constructor
-		/*!
-		 * \sa dbData
-		 * \sa mailData
-		 * \sa xmppData
-		 */
-		EmergencyNotifications(mySQLData myDBData, mailingData myMailData,
-								XMPPData myXMPPData, mobilecData myMobilecData);
-		
-		//! Fetch e.g. email adresses or JIDs that need to be informed. Fills notificationList.
-		/*!
-		 * \sa notificationList
-		 * \return 1: Emergency notifications to send fetched, 0: Nothing to send, -1: Error
-		 */
-		int		fetchTasks();
-		
-		//! Return the number of receivers in notificationList.
-		/*!
-		 * \sa notificationList
-		 */
-		int		getListSize();
-		
-		//! Sends a message to the e.g. email address of JID with given notificatioList ID.
-		/*!
-		 * \param recvNum The index of receiver in notificationList
-		 * \return 1: Message was sent, 0: Message could not be send, -1: Syntax error of receiver. No attempt to send message was made.
-		 * \sa notificationList
-		 */
-		int		sendMessage(int recvNum);
-		
-		//! Splits an notificationList entry to its relevant parts.
-		/*!
-		 * \sa notificationList
-		 */
-		enData	splitEmergencyInformation(int recvNum);
-		
-		//! Marks an receiver as notified or not.  
-		/*!
-		 * \param recvNum The index of receiver in notificationList
-		 * \param status The status this receiver should be set to.
-		 * \sa notificationList
-		 */
-		bool	markReceiver(int recvNum, int status);	
-};
+class EmergencyNotifications : public Database
+{
+  private:
+    //! Holds login and connection information of MySQL database.
+    mySQLData dbData;
+
+    //! Holds SMTP login information and settings.
+    mailingData   mailData;
+
+    //! Holds XMPP login information and settings.
+    XMPPData    xmppData;
+
+    //! Struct: Holds information of Clickatell SMS Gateway API.
+    mobilecData clickatellData;
+
+    //! Holds information about every receiver that needs to be informed.
+    map&lt;int,string&gt; notificationList;
+  public:
+    //! Constructor
+    /*!
+     * \sa dbData
+     * \sa mailData
+     * \sa xmppData
+     */
+    EmergencyNotifications(mySQLData myDBData, mailingData myMailData,
+      XMPPData myXMPPData, mobilecData myMobilecData);
 
-#endif /*EMERGENCYNOTIFICATIONS_H_*/
+    //! Fetch e.g. email adresses or JIDs that need to be informed. Fills notificationList.
+    /*!
+     * \sa notificationList
+     * \return 1: Emergency notifications to send fetched, 0: Nothing to send, -1: Error
+     */
+    int   fetchTasks();
+
+    //! Return the number of receivers in notificationList.
+    /*!
+     * \sa notificationList
+     */
+    int   getListSize();
+
+    //! Sends a message to the e.g. email address of JID with given notificatioList ID.
+    /*!
+     * \param recvNum The index of receiver in notificationList
+     * \return 1: Message was sent, 0: Message could not be send, -1: Syntax error of receiver. No attempt to send message was made.
+     * \sa notificationList
+     */
+    int   sendMessage(int recvNum);
+
+    //! Splits an notificationList entry to its relevant parts.
+    /*!
+     * \sa notificationList
+     */
+    enData  splitEmergencyInformation(int recvNum);
+
+    //! Marks an receiver as notified or not.
+    /*!
+     * \param recvNum The index of receiver in notificationList
+     * \param status The status this receiver should be set to.
+     * \sa notificationList
+     */
+    bool  markReceiver(int recvNum, int status);
+};
+#endif                                            /*EMERGENCYNOTIFICATIONS_H_*/</diff>
      <filename>src/notifications/EmergencyNotifications.h</filename>
    </modified>
    <modified>
      <diff>@@ -23,147 +23,172 @@
 #include &quot;../notifications/XMPP.h&quot;
 
 GeneralNotifications::GeneralNotifications(mySQLData myDBData, mailingData myMailData,
-		XMPPData myXMPPData, mobilecData myClickatellData)
-				: Database(myDBData){
-	dbData = myDBData;
-	mailData = myMailData;
-	xmppData = myXMPPData;
-	clickatellData = myClickatellData;
+XMPPData myXMPPData, mobilecData myClickatellData)
+: Database(myDBData)
+{
+  dbData = myDBData;
+  mailData = myMailData;
+  xmppData = myXMPPData;
+  clickatellData = myClickatellData;
 }
 
-bool GeneralNotifications::getGNGroup(){
-	// Initialize database connection.  
-	if(initConnection()){
-		MYSQL* init = getHandle();
-		// Get receivers.  
-		const char* gnQuery = &quot;SELECT gnotigroup FROM settings LIMIT 1&quot;;
-		if(mysql_real_query(init, gnQuery, strlen(gnQuery)) != 0){
-			// Query was not successful.  
-			mysql_close(init);
-			return 0;
-		}else{
-			// Query successful.  
-			MYSQL_RES* res = mysql_store_result(init);
-			MYSQL_ROW row;
-			if(mysql_num_rows(res) &gt; 0){
-				// Got the general notification group.  
-				if((row = mysql_fetch_row(res)) == NULL)
-					return 0;
-				gnGroup = row[0];
-				mysql_free_result(res);
-				mysql_close(init);
-				return 1;
-			}else{
-				// Nothing fetched.  
-				mysql_free_result(res);
-				mysql_close(init);
-				return 0;
-			}
-		}
-	}
-	return 0;
+
+bool GeneralNotifications::getGNGroup()
+{
+  // Initialize database connection.
+  if(initConnection())
+  {
+    MYSQL* init = getHandle();
+    // Get receivers.
+    const char* gnQuery = &quot;SELECT gnotigroup FROM settings LIMIT 1&quot;;
+    if(mysql_real_query(init, gnQuery, strlen(gnQuery)) != 0)
+    {
+      // Query was not successful.
+      mysql_close(init);
+      return 0;
+    }
+    else
+    {
+      // Query successful.
+      MYSQL_RES* res = mysql_store_result(init);
+      MYSQL_ROW row;
+      if(mysql_num_rows(res) &gt; 0)
+      {
+        // Got the general notification group.
+        if((row = mysql_fetch_row(res)) == NULL)
+          return 0;
+        gnGroup = row[0];
+        mysql_free_result(res);
+        mysql_close(init);
+        return 1;
+      }
+      else
+      {
+        // Nothing fetched.
+        mysql_free_result(res);
+        mysql_close(init);
+        return 0;
+      }
+    }
+  }
+  return 0;
 }
 
-bool GeneralNotifications::sendMessages(string subject, string message){
-	
-	bool fallback = 0;
-	
-	// Get the defined notification group for general notifications.  
-	if(!getGNGroup()){
-		// Could not get receivers from DB.
-		fallback = 1;
-	}
-
-	// Initialize database connection.  
-	if(!fallback &amp;&amp; initConnection()){
-		MYSQL* init = getHandle();
-
-		Mail mailing(mailData, dbData);
-
-		XMPP xmpp(xmppData, dbData);
-
-		// Fetch mail receivers.  
-		vector&lt;string&gt; mailRecvList;
-		if(mailData.doMailing){
-			mailRecvList = Information::getMailWarningReceivers(init, gnGroup, &quot;3&quot;);
-		}
-
-		// Send a warning mail to every mail receiver.  
-		int mailRecvCount = 0;
-		int mailRecvListSize = mailRecvList.size();
-		while(mailRecvCount &lt; mailRecvListSize){
-			if(!mailRecvList[mailRecvCount].empty())
-				mailing.sendMail(mailRecvList[mailRecvCount], subject, message);
-			mailRecvCount++;
-		}
-		
-		// Get XMPP receivers.  
-		vector&lt;string&gt; xmppRecvList;
-		if(xmppData.doXMPP){
-			xmppRecvList = Information::getXMPPWarningReceivers(init, gnGroup, &quot;3&quot;);
-		}
-			
-		// Send a warning message to every XMPP receiver.  
-		int xmppRecvCount = 0;
-		int xmppRecvListSize = xmppRecvList.size();
-		while(xmppRecvCount &lt; xmppRecvListSize){
-			if(!xmppRecvList[xmppRecvCount].empty())
-					xmpp.sendMessage(message, xmppRecvList[xmppRecvCount]);
-			xmppRecvCount++;
-		}
-		
-		// Clickatell SMS notifications.  
-		if(clickatellData.doMobileC &amp;&amp; mailData.doMailing){
-			vector&lt;string&gt; mobilecRecvList = Information::getMobileCWarningReceivers(init,
-					gnGroup, &quot;3&quot;);
-		
-			int mobilecRecvCount = 0;
-			int mobilecRecvListSize = mobilecRecvList.size();
-			while(mobilecRecvCount &lt; mobilecRecvListSize){
-				if(!mobilecRecvList[mobilecRecvCount].empty()){
-					// Build the message that fits to the API.  
-					stringstream newWarningMsg;
-					newWarningMsg	&lt;&lt; &quot;user:&quot; &lt;&lt; clickatellData.username &lt;&lt; endl
-									&lt;&lt; &quot;password:&quot; &lt;&lt; clickatellData.password &lt;&lt; endl
-									&lt;&lt; &quot;api_id:&quot; &lt;&lt; clickatellData.apiID &lt;&lt; endl
-									&lt;&lt; &quot;to:&quot; &lt;&lt; mobilecRecvList[mobilecRecvCount] &lt;&lt; endl
-									&lt;&lt; &quot;text:&quot; &lt;&lt; &quot;[ScopePort] &quot; &lt;&lt; message;
-					mailing.sendMail(CLICKATELLMAIL, &quot;&quot;, newWarningMsg.str());
-				}
-				mobilecRecvCount++;
-			}
-		}
-		
-		mysql_close(init);
-		return 1;
-	}else{
-		// Send in fallback mode.  
-		
-		
-		message = message + &quot; (This message has been sent in fallback mode!)&quot;;
-		if(mailData.doMailing){
-			Mail mailing(mailData, dbData);
-			mailing.sendMail(mailData.fallbackReceiver, subject, message);
-		}
-		
-		if(xmppData.doXMPP){
-			XMPP xmpp(xmppData, dbData);
-			xmpp.sendMessage(message, xmppData.fallbackReceiver);
-		}
-		
-		if(clickatellData.doMobileC &amp;&amp; mailData.doMailing){
-			Mail mailing(mailData, dbData);
-			// Build the message that fits to the API.  
-			stringstream newWarningMsg;
-			newWarningMsg	&lt;&lt; &quot;user:&quot; &lt;&lt; clickatellData.username &lt;&lt; endl
-							&lt;&lt; &quot;password:&quot; &lt;&lt; clickatellData.password &lt;&lt; endl
-							&lt;&lt; &quot;api_id:&quot; &lt;&lt; clickatellData.apiID &lt;&lt; endl
-							&lt;&lt; &quot;to:&quot; &lt;&lt; clickatellData.fallbackNumber &lt;&lt; endl
-							&lt;&lt; &quot;text:&quot; &lt;&lt; &quot;[ScopePort] &quot; &lt;&lt; message;
-			mailing.sendMail(CLICKATELLMAIL, subject, newWarningMsg.str());
-		}
-		
-		return 1;
-	}
-	return 0;
+
+bool GeneralNotifications::sendMessages(string subject, string message)
+{
+
+  bool fallback = 0;
+
+  // Get the defined notification group for general notifications.
+  if(!getGNGroup())
+  {
+    // Could not get receivers from DB.
+    fallback = 1;
+  }
+
+  // Initialize database connection.
+  if(!fallback &amp;&amp; initConnection())
+  {
+    MYSQL* init = getHandle();
+
+    Mail mailing(mailData, dbData);
+
+    XMPP xmpp(xmppData, dbData);
+
+    // Fetch mail receivers.
+    vector&lt;string&gt; mailRecvList;
+    if(mailData.doMailing)
+    {
+      mailRecvList = Information::getMailWarningReceivers(init, gnGroup, &quot;3&quot;);
+    }
+
+    // Send a warning mail to every mail receiver.
+    int mailRecvCount = 0;
+    int mailRecvListSize = mailRecvList.size();
+    while(mailRecvCount &lt; mailRecvListSize)
+    {
+      if(!mailRecvList[mailRecvCount].empty())
+        mailing.sendMail(mailRecvList[mailRecvCount], subject, message);
+      mailRecvCount++;
+    }
+
+    // Get XMPP receivers.
+    vector&lt;string&gt; xmppRecvList;
+    if(xmppData.doXMPP)
+    {
+      xmppRecvList = Information::getXMPPWarningReceivers(init, gnGroup, &quot;3&quot;);
+    }
+
+    // Send a warning message to every XMPP receiver.
+    int xmppRecvCount = 0;
+    int xmppRecvListSize = xmppRecvList.size();
+    while(xmppRecvCount &lt; xmppRecvListSize)
+    {
+      if(!xmppRecvList[xmppRecvCount].empty())
+        xmpp.sendMessage(message, xmppRecvList[xmppRecvCount]);
+      xmppRecvCount++;
+    }
+
+    // Clickatell SMS notifications.
+    if(clickatellData.doMobileC &amp;&amp; mailData.doMailing)
+    {
+      vector&lt;string&gt; mobilecRecvList = Information::getMobileCWarningReceivers(init,
+        gnGroup, &quot;3&quot;);
+
+      int mobilecRecvCount = 0;
+      int mobilecRecvListSize = mobilecRecvList.size();
+      while(mobilecRecvCount &lt; mobilecRecvListSize)
+      {
+        if(!mobilecRecvList[mobilecRecvCount].empty())
+        {
+          // Build the message that fits to the API.
+          stringstream newWarningMsg;
+          newWarningMsg &lt;&lt; &quot;user:&quot; &lt;&lt; clickatellData.username &lt;&lt; endl
+            &lt;&lt; &quot;password:&quot; &lt;&lt; clickatellData.password &lt;&lt; endl
+            &lt;&lt; &quot;api_id:&quot; &lt;&lt; clickatellData.apiID &lt;&lt; endl
+            &lt;&lt; &quot;to:&quot; &lt;&lt; mobilecRecvList[mobilecRecvCount] &lt;&lt; endl
+            &lt;&lt; &quot;text:&quot; &lt;&lt; &quot;[ScopePort] &quot; &lt;&lt; message;
+          mailing.sendMail(CLICKATELLMAIL, &quot;&quot;, newWarningMsg.str());
+        }
+        mobilecRecvCount++;
+      }
+    }
+
+    mysql_close(init);
+    return 1;
+  }
+  else
+  {
+    // Send in fallback mode.
+
+    message = message + &quot; (This message has been sent in fallback mode!)&quot;;
+    if(mailData.doMailing)
+    {
+      Mail mailing(mailData, dbData);
+      mailing.sendMail(mailData.fallbackReceiver, subject, message);
+    }
+
+    if(xmppData.doXMPP)
+    {
+      XMPP xmpp(xmppData, dbData);
+      xmpp.sendMessage(message, xmppData.fallbackReceiver);
+    }
+
+    if(clickatellData.doMobileC &amp;&amp; mailData.doMailing)
+    {
+      Mail mailing(mailData, dbData);
+      // Build the message that fits to the API.
+      stringstream newWarningMsg;
+      newWarningMsg &lt;&lt; &quot;user:&quot; &lt;&lt; clickatellData.username &lt;&lt; endl
+        &lt;&lt; &quot;password:&quot; &lt;&lt; clickatellData.password &lt;&lt; endl
+        &lt;&lt; &quot;api_id:&quot; &lt;&lt; clickatellData.apiID &lt;&lt; endl
+        &lt;&lt; &quot;to:&quot; &lt;&lt; clickatellData.fallbackNumber &lt;&lt; endl
+        &lt;&lt; &quot;text:&quot; &lt;&lt; &quot;[ScopePort] &quot; &lt;&lt; message;
+      mailing.sendMail(CLICKATELLMAIL, subject, newWarningMsg.str());
+    }
+
+    return 1;
+  }
+  return 0;
 }</diff>
      <filename>src/notifications/GeneralNotifications.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -27,51 +27,51 @@
 #include &quot;../internal.h&quot;
 #include &quot;../database/Database.h&quot;
 
-class GeneralNotifications : public Database {
-	private:
-		//! Holds database login information.
-		mySQLData	dbData;
-		
-		//! Holds SMTP login information and settings.
-		mailingData		mailData;
-		
-		//! Holds XMPP login information and settings.
-		XMPPData		xmppData;
+class GeneralNotifications : public Database
+{
+  private:
+    //! Holds database login information.
+    mySQLData dbData;
 
-		//! Holds information of Clickatell SMS Gateway API.
-		mobilecData		clickatellData;
-		
-		//! The ID of the general notification group defined in the web interface.
-		string		gnGroup;
-		
-		//! The fallback mail receiver. Defined in the config file and used if no database connection can be established.
-		/*!
-		 * \sa fallbackXMPPReciver
-		 */
-		string		fallbackMailReceiver;
-		
-		//! The fallback XMPP receiver. Defined in the config file and used if no database connection can be established.
-		/*!
-		 * \sa fallbackMailReciver
-		 */
-		string		fallbackXMPPReceiver;
-		
-		//! Fetches the general notification group from the database.  
-		/*!
-		 * \sa gnGroup
-		 * \return True if the gnGroup variable was filled, false in case of error.
-		 */
-		bool getGNGroup();
-	public:
-		GeneralNotifications(mySQLData myDBData, mailingData myMailData, XMPPData myXMPPData,
-				mobilecData myClickatellData);
-		//! Sends defined text and subject to all notification receivers.  
-		/*! 
-		 * \param subject The subject of the message.
-		 * \param message The message itself.
-		 * \return True if message was deliverd, false if an error occured.
-		 */
-		bool sendMessages(string subject, string message);
-};
+    //! Holds SMTP login information and settings.
+    mailingData   mailData;
+
+    //! Holds XMPP login information and settings.
+    XMPPData    xmppData;
+
+    //! Holds information of Clickatell SMS Gateway API.
+    mobilecData   clickatellData;
+
+    //! The ID of the general notification group defined in the web interface.
+    string    gnGroup;
 
-#endif /*GENERALNOTIFICATIONS_H_*/
+    //! The fallback mail receiver. Defined in the config file and used if no database connection can be established.
+    /*!
+     * \sa fallbackXMPPReciver
+     */
+    string    fallbackMailReceiver;
+
+    //! The fallback XMPP receiver. Defined in the config file and used if no database connection can be established.
+    /*!
+     * \sa fallbackMailReciver
+     */
+    string    fallbackXMPPReceiver;
+
+    //! Fetches the general notification group from the database.
+    /*!
+     * \sa gnGroup
+     * \return True if the gnGroup variable was filled, false in case of error.
+     */
+    bool getGNGroup();
+  public:
+    GeneralNotifications(mySQLData myDBData, mailingData myMailData, XMPPData myXMPPData,
+      mobilecData myClickatellData);
+    //! Sends defined text and subject to all notification receivers.
+    /*!
+     * \param subject The subject of the message.
+     * \param message The message itself.
+     * \return True if message was deliverd, false if an error occured.
+     */
+    bool sendMessages(string subject, string message);
+};
+#endif                                            /*GENERALNOTIFICATIONS_H_*/</diff>
      <filename>src/notifications/GeneralNotifications.h</filename>
    </modified>
    <modified>
      <diff>@@ -19,38 +19,47 @@
 #include &quot;../internal.h&quot;
 #include &quot;../database/Database.h&quot;
 
-Mail::Mail(mailingData myMailData, mySQLData myDBData){
-	mailData = myMailData;
+Mail::Mail(mailingData myMailData, mySQLData myDBData)
+{
+  mailData = myMailData;
   dbData = myDBData;
 }
 
-void Mail::updateSettings(mailingData myMailData){
-	mailData = myMailData;
+
+void Mail::updateSettings(mailingData myMailData)
+{
+  mailData = myMailData;
 }
 
+
 int sock;
 
-bool Mail::sendSocket(string msg){
-	ssize_t len;
-	len = write(sock,msg.c_str(),strlen(msg.c_str()));
-	if(len &lt;= 0){
+bool Mail::sendSocket(string msg)
+{
+  ssize_t len;
+  len = write(sock,msg.c_str(),strlen(msg.c_str()));
+  if(len &lt;= 0)
+  {
     p_debug-&gt;log(CONV_DEBUG_DIRECTION_SENT, CONV_DEBUG_ERROR_SENT);
-		return 0;
+    return 0;
   }
   p_debug-&gt;log(CONV_DEBUG_DIRECTION_SENT, noNewLineS(msg));
-	return 1;
+  return 1;
 }
 
+
 #define MAILBUFSIZE 1024
 
-bool Mail::readSocket(){
-	ssize_t len;
-	char mailBuf[MAILBUFSIZE] = &quot;&quot;;
-	len = read(sock,mailBuf, MAILBUFSIZE-1);
-  
-	if(len &lt;= 0){
+bool Mail::readSocket()
+{
+  ssize_t len;
+  char mailBuf[MAILBUFSIZE] = &quot;&quot;;
+  len = read(sock,mailBuf, MAILBUFSIZE-1);
+
+  if(len &lt;= 0)
+  {
     p_debug-&gt;log(CONV_DEBUG_DIRECTION_RECV, CONV_DEBUG_ERROR_RECV);
-		return 0;
+    return 0;
   }
 
   // Terminate the buffer.
@@ -58,307 +67,348 @@ bool Mail::readSocket(){
 
   p_debug-&gt;log(CONV_DEBUG_DIRECTION_RECV, noNewLine(mailBuf, strlen(mailBuf)));
 
-	return 1;
+  return 1;
 }
 
+
 static const string base64_chars =
-	&quot;ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;
-	&quot;abcdefghijklmnopqrstuvwxyz&quot;
-	&quot;0123456789+/&quot;;
-
-string encodeBase64(string stringToEncode) {
-	unsigned char const * bytes_to_encode = reinterpret_cast&lt;const unsigned char*&gt;(stringToEncode.c_str());
-	unsigned int in_len = stringToEncode.length();
-	string ret;
-	int i = 0;
-	int j = 0;
-	unsigned char char_array_3[3];
-	unsigned char char_array_4[4];
-
-	while(in_len--){
-		char_array_3[i++] = * (bytes_to_encode++);
-		if (i == 3){
-			char_array_4[0] = (char_array_3[0] &amp; 0xfc) &gt;&gt; 2;
-			char_array_4[1] = ((char_array_3[0] &amp; 0x03) &lt;&lt; 4) + ((char_array_3[1] &amp; 0xf0) &gt;&gt; 4);
-			char_array_4[2] = ((char_array_3[1] &amp; 0x0f) &lt;&lt; 2) + ((char_array_3[2] &amp; 0xc0) &gt;&gt; 6);
-			char_array_4[3] = char_array_3[2] &amp; 0x3f;
-
-			for(i = 0; (i &lt; 4); i++)
-				ret += base64_chars[char_array_4[i]];
-			i = 0;
-		}
-	}
-
-	if(i){
-		for(j = i; j &lt; 3; j++)
-			char_array_3[j] = '\0';
-
-		char_array_4[0] = (char_array_3[0] &amp; 0xfc) &gt;&gt; 2;
-		char_array_4[1] = ((char_array_3[0] &amp; 0x03) &lt;&lt; 4) + ((char_array_3[1] &amp; 0xf0) &gt;&gt; 4);
-		char_array_4[2] = ((char_array_3[1] &amp; 0x0f) &lt;&lt; 2) + ((char_array_3[2] &amp; 0xc0) &gt;&gt; 6);
-		char_array_4[3] = char_array_3[2] &amp; 0x3f;
-
-		for(j = 0; (j &lt; i + 1); j++)
-			ret += base64_chars[char_array_4[j]];
-
-		while((i++ &lt; 3))
-			ret += '=';
-	}
-
-	return ret;
+&quot;ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;
+&quot;abcdefghijklmnopqrstuvwxyz&quot;
+&quot;0123456789+/&quot;;
+
+string encodeBase64(string stringToEncode)
+{
+  unsigned char const * bytes_to_encode = reinterpret_cast&lt;const unsigned char*&gt;(stringToEncode.c_str());
+  unsigned int in_len = stringToEncode.length();
+  string ret;
+  int i = 0;
+  int j = 0;
+  unsigned char char_array_3[3];
+  unsigned char char_array_4[4];
+
+  while(in_len--)
+  {
+    char_array_3[i++] = * (bytes_to_encode++);
+    if (i == 3)
+    {
+      char_array_4[0] = (char_array_3[0] &amp; 0xfc) &gt;&gt; 2;
+      char_array_4[1] = ((char_array_3[0] &amp; 0x03) &lt;&lt; 4) + ((char_array_3[1] &amp; 0xf0) &gt;&gt; 4);
+      char_array_4[2] = ((char_array_3[1] &amp; 0x0f) &lt;&lt; 2) + ((char_array_3[2] &amp; 0xc0) &gt;&gt; 6);
+      char_array_4[3] = char_array_3[2] &amp; 0x3f;
+
+      for(i = 0; (i &lt; 4); i++)
+        ret += base64_chars[char_array_4[i]];
+      i = 0;
+    }
+  }
+
+  if(i)
+  {
+    for(j = i; j &lt; 3; j++)
+      char_array_3[j] = '\0';
+
+    char_array_4[0] = (char_array_3[0] &amp; 0xfc) &gt;&gt; 2;
+    char_array_4[1] = ((char_array_3[0] &amp; 0x03) &lt;&lt; 4) + ((char_array_3[1] &amp; 0xf0) &gt;&gt; 4);
+    char_array_4[2] = ((char_array_3[1] &amp; 0x0f) &lt;&lt; 2) + ((char_array_3[2] &amp; 0xc0) &gt;&gt; 6);
+    char_array_4[3] = char_array_3[2] &amp; 0x3f;
+
+    for(j = 0; (j &lt; i + 1); j++)
+      ret += base64_chars[char_array_4[j]];
+
+    while((i++ &lt; 3))
+      ret += '=';
+  }
+
+  return ret;
 }
 
-bool Mail::sendMail(string toMail, string subject, string mailText){
-
-	// Prepared debug data.
-	//	cout	&lt;&lt; &quot;from: &quot;
-	//			&lt;&lt; mailData.mailFrom
-	//			&lt;&lt; endl
-	//			&lt;&lt; &quot;to: &quot;
-	//			&lt;&lt; toMail
-	//			&lt;&lt; endl
-	//			&lt;&lt; &quot;subject: &quot;
-	//			&lt;&lt; subject
-	//			&lt;&lt; endl
-	//			&lt;&lt; &quot;text: &quot;
-	//			&lt;&lt; mailText
-	//			&lt;&lt; endl &lt;&lt; endl
-	//			&lt;&lt; &quot;hostname: &quot; &lt;&lt; mailData.mailHostname &lt;&lt; endl
-	//			&lt;&lt; &quot;user: &quot; &lt;&lt; mailData.mailUser &lt;&lt; endl
-	//			&lt;&lt; &quot;password: &quot; &lt;&lt; mailData.mailPass
-	//			&lt;&lt; endl &lt;&lt; endl;
-
-	struct sockaddr_in server;
-	struct hostent *host;
-
-	// Create socket.
-	sock = socket(AF_INET, SOCK_STREAM, 0);
-	if(sock &lt; 0){
-		// Creating socket failed.
-		return 0;
-	}
-
-	// Verify host.
-	server.sin_family = AF_INET;
-	host = gethostbyname(mailData.mailServer.c_str());
-	if(host==(struct hostent *) 0){
-		// Host unknown.
-		return 0;
-	}
-
-	// Connect to defined SMTP port.
-	memcpy((char *) &amp;server.sin_addr, (char *) host-&gt;h_addr, host-&gt;h_length);
-	server.sin_port=htons(mailData.mailPort);
-
-	if(connect(sock, (struct sockaddr *) &amp;server, sizeof server) &lt; 0) {
-		// Could not connect.
-		return 0;
-	}
-
-	// A little bit conversation.
-  
+
+bool Mail::sendMail(string toMail, string subject, string mailText)
+{
+
+  // Prepared debug data.
+  //	cout	&lt;&lt; &quot;from: &quot;
+  //			&lt;&lt; mailData.mailFrom
+  //			&lt;&lt; endl
+  //			&lt;&lt; &quot;to: &quot;
+  //			&lt;&lt; toMail
+  //			&lt;&lt; endl
+  //			&lt;&lt; &quot;subject: &quot;
+  //			&lt;&lt; subject
+  //			&lt;&lt; endl
+  //			&lt;&lt; &quot;text: &quot;
+  //			&lt;&lt; mailText
+  //			&lt;&lt; endl &lt;&lt; endl
+  //			&lt;&lt; &quot;hostname: &quot; &lt;&lt; mailData.mailHostname &lt;&lt; endl
+  //			&lt;&lt; &quot;user: &quot; &lt;&lt; mailData.mailUser &lt;&lt; endl
+  //			&lt;&lt; &quot;password: &quot; &lt;&lt; mailData.mailPass
+  //			&lt;&lt; endl &lt;&lt; endl;
+
+  struct sockaddr_in server;
+  struct hostent *host;
+
+  // Create socket.
+  sock = socket(AF_INET, SOCK_STREAM, 0);
+  if(sock &lt; 0)
+  {
+    // Creating socket failed.
+    return 0;
+  }
+
+  // Verify host.
+  server.sin_family = AF_INET;
+  host = gethostbyname(mailData.mailServer.c_str());
+  if(host==(struct hostent *) 0)
+  {
+    // Host unknown.
+    return 0;
+  }
+
+  // Connect to defined SMTP port.
+  memcpy((char *) &amp;server.sin_addr, (char *) host-&gt;h_addr, host-&gt;h_length);
+  server.sin_port=htons(mailData.mailPort);
+
+  if(connect(sock, (struct sockaddr *) &amp;server, sizeof server) &lt; 0)
+  {
+    // Could not connect.
+    return 0;
+  }
+
+  // A little bit conversation.
+
   ConversationDebug debug(dbData, &quot;smtp&quot;, mailData.mailServer);
   p_debug = &amp;debug;
 
-	// Welcome string.
-	if(!readSocket())
-		return 0;
-
-	if(mailData.mailUseAuth){
-		// EHLO.
-		stringstream ehlo;
-		ehlo	&lt;&lt; &quot;EHLO &quot;
-				&lt;&lt; mailData.mailHostname
-        &lt;&lt; &quot;\r\n&quot;;
-
-		if(!sendSocket(ehlo.str()))
-			return 0;
-		// Get reply.
-		if(!readSocket())
-			return 0;
-		// Ask for AUTH LOGIN.
-		if(!sendSocket(&quot;AUTH LOGIN\r\n&quot;))
-			return 0;
-		if(!readSocket())
-			return 0;
-		// Send username.
-		if(!sendSocket(encodeBase64(mailData.mailUser)))
-			return 0;
-		if(!sendSocket(&quot;\r\n&quot;))
-			return 0;
-		if(!readSocket())
-			return 0;
-		// Send Password.
-		if(!sendSocket(encodeBase64(mailData.mailPass)))
-			return 0;
-		if(!sendSocket(&quot;\r\n&quot;))
-			return 0;
-		if(!readSocket())
-			return 0;
-	}else{
-		// HELO.
-		stringstream helo;
-		helo	&lt;&lt; &quot;HELO &quot;
-				&lt;&lt; mailData.mailHostname
-        &lt;&lt; &quot;\r\n&quot;;
-
-		if(!sendSocket(helo.str()))
-			return 0;
-		// Get reply.
-		if(!readSocket())
-			return 0;
-	}
-
-	// Sender.
-	stringstream mailFrom;
-	mailFrom	&lt;&lt; &quot;Mail from: &lt;&quot;
-				&lt;&lt; mailData.mailFrom
-				&lt;&lt; &quot;&gt;\r\n&quot;;
-
-	if(!sendSocket(mailFrom.str()))
-		return 0;
-	if(!readSocket())
-		return 0;
-
-	// Recipient.
-	stringstream mailTo;
-	mailTo	&lt;&lt; &quot;RCPT to: &lt;&quot;
-				&lt;&lt; toMail
-				&lt;&lt; &quot;&gt;\r\n&quot;;
-
-	if(!sendSocket(mailTo.str()))
-		return 0;
-	if(!readSocket())
-		return 0;
-
-	// Data.
-	if(!sendSocket(&quot;DATA\r\n&quot;))
-		return 0;
-	if(!readSocket())
-		return 0;
-
-	// Header.
-	stringstream headerTo;
-	headerTo	&lt;&lt; &quot;to: &quot;
-				&lt;&lt; toMail
-        &lt;&lt; &quot;\r\n&quot;;
-	if(!sendSocket(headerTo.str()))
-		return 0;
-
-	stringstream headerFrom;
-	headerFrom	&lt;&lt; &quot;from: &quot;
-				&lt;&lt; mailData.mailFrom
-        &lt;&lt; &quot;\r\n&quot;;
-	if(!sendSocket(headerFrom.str()))
-		return 0;
-
-	stringstream headerSubject;
-	headerSubject	&lt;&lt; &quot;subject: [ScopePort] &quot;
-					&lt;&lt; subject
-					&lt;&lt; &quot;\r\n\r\n&quot;;
-	if(!sendSocket(headerSubject.str()))
-		return 0;
-	if(!sendSocket(mailText))
-		return 0;
-	if(!sendSocket(&quot;\n\n.\n&quot;))
-		return 0;
-
-	// Quit.
-	if(!readSocket())
-		return 0;
-
-	if(!sendSocket(&quot;QUIT\r\n&quot;))
-		return 0;
-
-	if(!readSocket())
-		return 0;
-
-	// Close socket.
-	close(sock);
-
-	return 1;
+  // Welcome string.
+  if(!readSocket())
+    return 0;
+
+  if(mailData.mailUseAuth)
+  {
+    // EHLO.
+    stringstream ehlo;
+    ehlo  &lt;&lt; &quot;EHLO &quot;
+      &lt;&lt; mailData.mailHostname
+      &lt;&lt; &quot;\r\n&quot;;
+
+    if(!sendSocket(ehlo.str()))
+      return 0;
+    // Get reply.
+    if(!readSocket())
+      return 0;
+    // Ask for AUTH LOGIN.
+    if(!sendSocket(&quot;AUTH LOGIN\r\n&quot;))
+      return 0;
+    if(!readSocket())
+      return 0;
+    // Send username.
+    if(!sendSocket(encodeBase64(mailData.mailUser)))
+      return 0;
+    if(!sendSocket(&quot;\r\n&quot;))
+      return 0;
+    if(!readSocket())
+      return 0;
+    // Send Password.
+    if(!sendSocket(encodeBase64(mailData.mailPass)))
+      return 0;
+    if(!sendSocket(&quot;\r\n&quot;))
+      return 0;
+    if(!readSocket())
+      return 0;
+  }
+  else
+  {
+    // HELO.
+    stringstream helo;
+    helo  &lt;&lt; &quot;HELO &quot;
+      &lt;&lt; mailData.mailHostname
+      &lt;&lt; &quot;\r\n&quot;;
+
+    if(!sendSocket(helo.str()))
+      return 0;
+    // Get reply.
+    if(!readSocket())
+      return 0;
+  }
+
+  // Sender.
+  stringstream mailFrom;
+  mailFrom  &lt;&lt; &quot;Mail from: &lt;&quot;
+    &lt;&lt; mailData.mailFrom
+    &lt;&lt; &quot;&gt;\r\n&quot;;
+
+  if(!sendSocket(mailFrom.str()))
+    return 0;
+  if(!readSocket())
+    return 0;
+
+  // Recipient.
+  stringstream mailTo;
+  mailTo  &lt;&lt; &quot;RCPT to: &lt;&quot;
+    &lt;&lt; toMail
+    &lt;&lt; &quot;&gt;\r\n&quot;;
+
+  if(!sendSocket(mailTo.str()))
+    return 0;
+  if(!readSocket())
+    return 0;
+
+  // Data.
+  if(!sendSocket(&quot;DATA\r\n&quot;))
+    return 0;
+  if(!readSocket())
+    return 0;
+
+  // Header.
+  stringstream headerTo;
+  headerTo  &lt;&lt; &quot;to: &quot;
+    &lt;&lt; toMail
+    &lt;&lt; &quot;\r\n&quot;;
+  if(!sendSocket(headerTo.str()))
+    return 0;
+
+  stringstream headerFrom;
+  headerFrom  &lt;&lt; &quot;from: &quot;
+    &lt;&lt; mailData.mailFrom
+    &lt;&lt; &quot;\r\n&quot;;
+  if(!sendSocket(headerFrom.str()))
+    return 0;
+
+  stringstream headerSubject;
+  headerSubject &lt;&lt; &quot;subject: [ScopePort] &quot;
+    &lt;&lt; subject
+    &lt;&lt; &quot;\r\n\r\n&quot;;
+  if(!sendSocket(headerSubject.str()))
+    return 0;
+  if(!sendSocket(mailText))
+    return 0;
+  if(!sendSocket(&quot;\n\n.\n&quot;))
+    return 0;
+
+  // Quit.
+  if(!readSocket())
+    return 0;
+
+  if(!sendSocket(&quot;QUIT\r\n&quot;))
+    return 0;
+
+  if(!readSocket())
+    return 0;
+
+  // Close socket.
+  close(sock);
+
+  return 1;
 }
 
-mailingData Mail::fetchSettings(mySQLData dbData){
+
+mailingData Mail::fetchSettings(mySQLData dbData)
+{
   mailingData mailData;
 
   Database db(dbData);
-  if(db.initConnection()){
+  if(db.initConnection())
+  {
     const char* getSettingsSQL = &quot;SELECT mail_enabled, mail_useauth, mail_server,&quot;
-                                &quot;mail_port, mail_user, mail_pass, mail_hostname,&quot;
-                                &quot;mail_from FROM settings&quot;;
-    if(mysql_real_query(db.getHandle(), getSettingsSQL, strlen(getSettingsSQL)) == 0){
+      &quot;mail_port, mail_user, mail_pass, mail_hostname,&quot;
+      &quot;mail_from FROM settings&quot;;
+    if(mysql_real_query(db.getHandle(), getSettingsSQL, strlen(getSettingsSQL)) == 0)
+    {
       MYSQL_RES* res;
-      if((res = mysql_store_result(db.getHandle())) != NULL){
+      if((res = mysql_store_result(db.getHandle())) != NULL)
+      {
         MYSQL_ROW row;
         row = mysql_fetch_row(res);
         stringstream result;
-        if(mysql_num_rows(res) &gt; 0){
+        if(mysql_num_rows(res) &gt; 0)
+        {
 
           // mail_enabled
-          if(row[0] != NULL){
-            if(strcmp(row[0], &quot;1&quot;) == 0){
+          if(row[0] != NULL)
+          {
+            if(strcmp(row[0], &quot;1&quot;) == 0)
+            {
               mailData.doMailing = 1;
-            }else{
+            }
+            else
+            {
               mailData.doMailing = 0;
             }
           }
 
           // mail_useauth
-          if(row[1] != NULL){
-            if(strcmp(row[1], &quot;1&quot;) == 0){
+          if(row[1] != NULL)
+          {
+            if(strcmp(row[1], &quot;1&quot;) == 0)
+            {
               mailData.mailUseAuth = 1;
-            }else{
+            }
+            else
+            {
               mailData.mailUseAuth = 0;
             }
           }
 
           // mail_server
-          if(row[2] != NULL){
+          if(row[2] != NULL)
+          {
             mailData.mailServer = row[2];
           }
 
           // mail_port
-          if(row[3] != NULL){
+          if(row[3] != NULL)
+          {
             mailData.mailPort = stringToInteger(row[3]);
           }
 
           // mail_user
-          if(row[4] != NULL){
+          if(row[4] != NULL)
+          {
             mailData.mailUser = row[4];
           }
 
           // mail_pass
-          if(row[5] != NULL){
+          if(row[5] != NULL)
+          {
             mailData.mailPass = row[5];
           }
 
           // mail_hostname
-          if(row[6] != NULL){
+          if(row[6] != NULL)
+          {
             mailData.mailHostname = row[6];
           }
 
           // mail_from
-          if(row[7] != NULL){
+          if(row[7] != NULL)
+          {
             mailData.mailFrom = row[7];
           }
 
-        }else{
+        }
+        else
+        {
           // Nothing fetched. Disable mailing.
           mailData.doMailing = 0;
         }
-      }else{
+      }
+      else
+      {
         // Error. Disable mailing.
         mailData.doMailing = 0;
       }
       mysql_free_result(res);
-    }else{
+    }
+    else
+    {
       // Query failed. Disable mailing.
       mailData.doMailing = 0;
     }
 
     mysql_close(db.getHandle());
-  }else{
+  }
+  else
+  {
     // Could not connect to DB. Diable mailing.
     mailData.doMailing = 0;
   }</diff>
      <filename>src/notifications/Mail.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -27,37 +27,36 @@
 #include &quot;../internal.h&quot;
 #include &quot;../log/ConversationDebug.h&quot;
 
-class Mail{
-	private:
-		//! Holds login, server and general SMTP information.
-		mailingData mailData;
+class Mail
+{
+  private:
+    //! Holds login, server and general SMTP information.
+    mailingData mailData;
     mySQLData dbData;
 
     ConversationDebug* p_debug;
 
     bool readSocket();
     bool sendSocket(string msg);
-	public:
-		Mail(mailingData myMailData, mySQLData myDBData);
-		//! Updates mailData
-		/*!
-		 * \sa mailData
-		 */
-		void updateSettings(mailingData myMailData);
-
-		//! Sends email
-		/*!
-		 * \param toMail The receiver of this email
-		 * \param subject The subject of this email
-		 * \param mailText The text in this email
-		 * \return True on success, false in case of error.
-		 */
-		bool sendMail(string toMail, string subject, string mailText);
-
-
-		//! Returns mailingData struct with settings from database.
-		static mailingData fetchSettings(mySQLData dbData);
+  public:
+    Mail(mailingData myMailData, mySQLData myDBData);
+    //! Updates mailData
+    /*!
+     * \sa mailData
+     */
+    void updateSettings(mailingData myMailData);
+
+    //! Sends email
+    /*!
+     * \param toMail The receiver of this email
+     * \param subject The subject of this email
+     * \param mailText The text in this email
+     * \return True on success, false in case of error.
+     */
+    bool sendMail(string toMail, string subject, string mailText);
+
+    //! Returns mailingData struct with settings from database.
+    static mailingData fetchSettings(mySQLData dbData);
 
 };
-
-#endif /*MAIL_H_*/
+#endif                                            /*MAIL_H_*/</diff>
      <filename>src/notifications/Mail.h</filename>
    </modified>
    <modified>
      <diff>@@ -21,175 +21,207 @@
 #include &quot;../log/Log.h&quot;
 
 Warning::Warning(mySQLData myDBData)
-		: Database(myDBData){
-	dbData = myDBData;
+: Database(myDBData)
+{
+  dbData = myDBData;
 }
 
-bool Warning::getConditions(string hostid, string st){
-	// Clear the list of conditions - Needed if this is used as a refresh.
-	conditionList.clear();
-	// Initialize database connection.
-	if(initConnection()){
-		MYSQL* init = getHandle();
-		// Get all enabled hosts.
-		stringstream query;
-		query	&lt;&lt; &quot;SELECT type,value FROM sensor_conditions &quot;
-					&quot;WHERE disabled = 0 AND hostid = &quot;
-				&lt;&lt; hostid
-				&lt;&lt; &quot; AND st = &quot;
-				&lt;&lt; st;
-		if(mysql_real_query(init, query.str().c_str(), strlen(query.str().c_str())) != 0){
-			// Query was not successful.
-			error = mysql_error(init);
-			mysql_close(init);
-			return 0;
-		}else{
-			// Query successful.
-			MYSQL_RES* res = mysql_store_result(init);
-			MYSQL_ROW row;
-			int i = 0;
-			if(mysql_num_rows(res) &gt; 0){
-				while((row = mysql_fetch_row(res))){
-					stringstream thiscondition;
-					thiscondition &lt;&lt; hostid &lt;&lt; &quot;.&quot; &lt;&lt; st &lt;&lt; &quot;:&quot; &lt;&lt; row[0] &lt;&lt; &quot;.&quot; &lt;&lt; row[1];
-					conditionList[i] = thiscondition.str();
-					i++;
-				}
-			}else{
-				// Nothing defined in database.
-				mysql_free_result(res);
-				mysql_close(init);
-				return 1;
-			}
-			mysql_free_result(res);
-			mysql_close(init);
-			// Just to make sure...
-			if(conditionList.size() &lt; 0)
-				return 0;
-			return 1;
-		}
-	}
-	return 0;
+
+bool Warning::getConditions(string hostid, string st)
+{
+  // Clear the list of conditions - Needed if this is used as a refresh.
+  conditionList.clear();
+  // Initialize database connection.
+  if(initConnection())
+  {
+    MYSQL* init = getHandle();
+    // Get all enabled hosts.
+    stringstream query;
+    query &lt;&lt; &quot;SELECT type,value FROM sensor_conditions &quot;
+      &quot;WHERE disabled = 0 AND hostid = &quot;
+      &lt;&lt; hostid
+      &lt;&lt; &quot; AND st = &quot;
+      &lt;&lt; st;
+    if(mysql_real_query(init, query.str().c_str(), strlen(query.str().c_str())) != 0)
+    {
+      // Query was not successful.
+      error = mysql_error(init);
+      mysql_close(init);
+      return 0;
+    }
+    else
+    {
+      // Query successful.
+      MYSQL_RES* res = mysql_store_result(init);
+      MYSQL_ROW row;
+      int i = 0;
+      if(mysql_num_rows(res) &gt; 0)
+      {
+        while((row = mysql_fetch_row(res)))
+        {
+          stringstream thiscondition;
+          thiscondition &lt;&lt; hostid &lt;&lt; &quot;.&quot; &lt;&lt; st &lt;&lt; &quot;:&quot; &lt;&lt; row[0] &lt;&lt; &quot;.&quot; &lt;&lt; row[1];
+          conditionList[i] = thiscondition.str();
+          i++;
+        }
+      }
+      else
+      {
+        // Nothing defined in database.
+        mysql_free_result(res);
+        mysql_close(init);
+        return 1;
+      }
+      mysql_free_result(res);
+      mysql_close(init);
+      // Just to make sure...
+      if(conditionList.size() &lt; 0)
+        return 0;
+      return 1;
+    }
+  }
+  return 0;
 }
 
+
 /*
  * Returns	-1 if something failed
  * 			 0 if Sensor value is not in condition range.
  * 			 1 if Sensor is okay
  */
 
-int Warning::checkSensor(string checkHostID, string checkSt, string checkSv, string lastWarn){
-	// Just to make sure...
-	if(conditionList.size() &lt;= 0)
-		return -1;
-
-	int i = 0;
-	int conditionSize = conditionList.size();
-	while(i &lt; conditionSize){
-		string hostID;
-		string st;
-		string conditionType;
-		string conditionValue;
-
-		int j = 0;
-
-		string token;
-		istringstream iss(conditionList[i]);
-		while(getline(iss, token, ':')){
-			if(j == 0){
-				int k = 0;
-				// Split host ID and sensor ID.
-				string token2;
-				istringstream iss2(token);
-				while(getline(iss2, token2, '.')){
-					if(k == 0) hostID = token2;
-					if(k == 1) st = token2;
-					k++;
-				}
-			}
-			if(j == 1){
-				int k = 0;
-				// Split sensor type and value.
-				string token2;
-				istringstream iss2(token);
-				while(getline(iss2, token2, '.')){
-					if(k == 0) conditionType = token2;
-					if(k == 1) conditionValue = token2;
-					k++;
-				}
-			}
-			j++;
-		}
-
-		// Check if we got everything.
-		if(hostID.empty() || st.empty() || conditionType.empty() || conditionValue.empty())
-			continue;
-
-		// Looks good. Go on.
-
-		time_t rawtime;
-		time(&amp;rawtime);
-
-		// Only send warning all 6 hours.
-		if(rawtime-stringToInteger(lastWarn.c_str()) &gt; 21600){
-
-			// Find the sensor we want to compare.
-			if(hostID == checkHostID &amp;&amp; st == checkSt){
-				if(conditionType == &quot;below&quot;){
-					if(atof(checkSv.c_str()) &lt; atof(conditionValue.c_str())){
-							return 1;
-						}
-					updateAlarms(checkHostID, checkSt, checkSv);
-					return 0;
-				}
-
-				if(conditionType == &quot;equal&quot;){
-					if(atof(checkSv.c_str()) == atof(conditionValue.c_str())){
-							return 1;
-						}
-					updateAlarms(checkHostID, checkSt, checkSv);
-					return 0;
-				}
-
-				if(conditionType == &quot;above&quot;){
-					if(atof(checkSv.c_str()) &gt; atof(conditionValue.c_str())){
-							return 1;
-						}
-					updateAlarms(checkHostID, checkSt, checkSv);
-					return 0;
-				}
-			}
-		}
-		i++;
-	}
-	return -1;
+int Warning::checkSensor(string checkHostID, string checkSt, string checkSv, string lastWarn)
+{
+  // Just to make sure...
+  if(conditionList.size() &lt;= 0)
+    return -1;
+
+  int i = 0;
+  int conditionSize = conditionList.size();
+  while(i &lt; conditionSize)
+  {
+    string hostID;
+    string st;
+    string conditionType;
+    string conditionValue;
+
+    int j = 0;
+
+    string token;
+    istringstream iss(conditionList[i]);
+    while(getline(iss, token, ':'))
+    {
+      if(j == 0)
+      {
+        int k = 0;
+        // Split host ID and sensor ID.
+        string token2;
+        istringstream iss2(token);
+        while(getline(iss2, token2, '.'))
+        {
+          if(k == 0) hostID = token2;
+          if(k == 1) st = token2;
+          k++;
+        }
+      }
+      if(j == 1)
+      {
+        int k = 0;
+        // Split sensor type and value.
+        string token2;
+        istringstream iss2(token);
+        while(getline(iss2, token2, '.'))
+        {
+          if(k == 0) conditionType = token2;
+          if(k == 1) conditionValue = token2;
+          k++;
+        }
+      }
+      j++;
+    }
+
+    // Check if we got everything.
+    if(hostID.empty() || st.empty() || conditionType.empty() || conditionValue.empty())
+      continue;
+
+    // Looks good. Go on.
+
+    time_t rawtime;
+    time(&amp;rawtime);
+
+    // Only send warning all 6 hours.
+    if(rawtime-stringToInteger(lastWarn.c_str()) &gt; 21600)
+    {
+
+      // Find the sensor we want to compare.
+      if(hostID == checkHostID &amp;&amp; st == checkSt)
+      {
+        if(conditionType == &quot;below&quot;)
+        {
+          if(atof(checkSv.c_str()) &lt; atof(conditionValue.c_str()))
+          {
+            return 1;
+          }
+          updateAlarms(checkHostID, checkSt, checkSv);
+          return 0;
+        }
+
+        if(conditionType == &quot;equal&quot;)
+        {
+          if(atof(checkSv.c_str()) == atof(conditionValue.c_str()))
+          {
+            return 1;
+          }
+          updateAlarms(checkHostID, checkSt, checkSv);
+          return 0;
+        }
+
+        if(conditionType == &quot;above&quot;)
+        {
+          if(atof(checkSv.c_str()) &gt; atof(conditionValue.c_str()))
+          {
+            return 1;
+          }
+          updateAlarms(checkHostID, checkSt, checkSv);
+          return 0;
+        }
+      }
+    }
+    i++;
+  }
+  return -1;
 }
 
-void Warning::updateAlarms(string checkHostID, string checkSt, string checkSv){
-
-	time_t rawtime;
-	time(&amp;rawtime);
-
-	Log log(LOGFILE, dbData);
-
-	// Insert alarm into database.
-	stringstream alarmSQL;
-	alarmSQL	&lt;&lt; &quot;INSERT INTO alarms (type, timestamp, hostid, st, sv) VALUES ('1','&quot;
-				&lt;&lt; rawtime
-				&lt;&lt; &quot;','&quot;
-				&lt;&lt; checkHostID
-				&lt;&lt; &quot;','&quot;
-				&lt;&lt; checkSt
-				&lt;&lt; &quot;','&quot;
-				&lt;&lt; checkSv
-				&lt;&lt; &quot;')&quot;;
-
-	if(initConnection()){
-		if(!setQuery(getHandle(), alarmSQL.str()))
-			log.putLog(1, &quot;009&quot;, &quot;Could not update alarms table.&quot;);
-	}else{
-		log.putLog(1, &quot;010&quot;, &quot;Could not update alarms table.&quot;);
-	}
-
-	mysql_close(getHandle());
+
+void Warning::updateAlarms(string checkHostID, string checkSt, string checkSv)
+{
+
+  time_t rawtime;
+  time(&amp;rawtime);
+
+  Log log(LOGFILE, dbData);
+
+  // Insert alarm into database.
+  stringstream alarmSQL;
+  alarmSQL  &lt;&lt; &quot;INSERT INTO alarms (type, timestamp, hostid, st, sv) VALUES ('1','&quot;
+    &lt;&lt; rawtime
+    &lt;&lt; &quot;','&quot;
+    &lt;&lt; checkHostID
+    &lt;&lt; &quot;','&quot;
+    &lt;&lt; checkSt
+    &lt;&lt; &quot;','&quot;
+    &lt;&lt; checkSv
+    &lt;&lt; &quot;')&quot;;
+
+  if(initConnection())
+  {
+    if(!setQuery(getHandle(), alarmSQL.str()))
+      log.putLog(1, &quot;009&quot;, &quot;Could not update alarms table.&quot;);
+  }
+  else
+  {
+    log.putLog(1, &quot;010&quot;, &quot;Could not update alarms table.&quot;);
+  }
+
+  mysql_close(getHandle());
 }</diff>
      <filename>src/notifications/Warning.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -23,58 +23,58 @@
 #include &quot;../internal.h&quot;
 #include &quot;../database/Database.h&quot;
 
-class Warning : public Database{
-	private:
-		//! This map holds all sensor conditions.
-		/*!
-		 * \sa getConditions()
-		 */
-		map&lt;int,string&gt; conditionList;
-		
-		//! Holds the last error message.
-		/*!
-		 * \sa getError()
-		 */
-		string error;
-		
-		//! Holds login and connection information of MySQL database.
-		mySQLData dbData;
-		
-	public:
-		Warning(mySQLData myDBData);
-		
-		//!  Fetches sensor conditions and fills conditionList.
-		/*!
-		 * \return False in case of error, true if everything went fine.
-		 * \param hostid1
-		 * \param st1
-		 * \sa conditionList
-		 */
-		bool getConditions(string hostid, string st);
-		
-		//! Checks if a sensor is in range and if a notification needs to be sent.
-		/*!
-		 * \param hostid Host ID
-		 * \param st Sensor type ID
-		 * \param checkSv Sensor value
-		 * \param lastWarn Timestamp of last warning
-		 * \return  -1: something failed, 0: sensor value is not in condition range, 1: Sensor is okay
-		 */
-		int checkSensor(string hostid, string st, string checkSv, string lastWarn);
-		
-		//! Inserts alarm into alarms table.
-		/*!
-		 * \param checkHostID Host ID
-		 * \param checkSt Sensor type ID
-		 * \param checkSv Sensor value
-		 */
-		void updateAlarms(string checkHostID, string checkSt, string checkSv);
-		
-		//! Returns last error.
-		/*!
-		 * \sa error
-		 */
-		string getError(){ return error; }
-};
+class Warning : public Database
+{
+  private:
+    //! This map holds all sensor conditions.
+    /*!
+     * \sa getConditions()
+     */
+    map&lt;int,string&gt; conditionList;
+
+    //! Holds the last error message.
+    /*!
+     * \sa getError()
+     */
+    string error;
+
+    //! Holds login and connection information of MySQL database.
+    mySQLData dbData;
+
+  public:
+    Warning(mySQLData myDBData);
 
-#endif /*WARNING_H_*/
+    //!  Fetches sensor conditions and fills conditionList.
+    /*!
+     * \return False in case of error, true if everything went fine.
+     * \param hostid1
+     * \param st1
+     * \sa conditionList
+     */
+    bool getConditions(string hostid, string st);
+
+    //! Checks if a sensor is in range and if a notification needs to be sent.
+    /*!
+     * \param hostid Host ID
+     * \param st Sensor type ID
+     * \param checkSv Sensor value
+     * \param lastWarn Timestamp of last warning
+     * \return  -1: something failed, 0: sensor value is not in condition range, 1: Sensor is okay
+     */
+    int checkSensor(string hostid, string st, string checkSv, string lastWarn);
+
+    //! Inserts alarm into alarms table.
+    /*!
+     * \param checkHostID Host ID
+     * \param checkSt Sensor type ID
+     * \param checkSv Sensor value
+     */
+    void updateAlarms(string checkHostID, string checkSt, string checkSv);
+
+    //! Returns last error.
+    /*!
+     * \sa error
+     */
+    string getError(){ return error; }
+};
+#endif                                            /*WARNING_H_*/</diff>
      <filename>src/notifications/Warning.h</filename>
    </modified>
    <modified>
      <diff>@@ -19,38 +19,47 @@
 #include &quot;XMPP.h&quot;
 #include &quot;../log/Log.h&quot;
 
-XMPP::XMPP(XMPPData myXMPPData, mySQLData myDBData){
-	xmppData = myXMPPData;
-	dbData = myDBData;
+XMPP::XMPP(XMPPData myXMPPData, mySQLData myDBData)
+{
+  xmppData = myXMPPData;
+  dbData = myDBData;
 }
 
-void XMPP::updateSettings(XMPPData myXMPPData){
-	xmppData = myXMPPData;
+
+void XMPP::updateSettings(XMPPData myXMPPData)
+{
+  xmppData = myXMPPData;
 }
 
+
 int xmppSock;
 
-bool XMPP::sendSocket(string msg){
-	ssize_t len;
-	len = write(xmppSock,msg.c_str(),strlen(msg.c_str()));
-	if(len &lt;= 0){
+bool XMPP::sendSocket(string msg)
+{
+  ssize_t len;
+  len = write(xmppSock,msg.c_str(),strlen(msg.c_str()));
+  if(len &lt;= 0)
+  {
     p_debug-&gt;log(CONV_DEBUG_DIRECTION_SENT, CONV_DEBUG_ERROR_SENT);
-		return 0;
+    return 0;
   }
   p_debug-&gt;log(CONV_DEBUG_DIRECTION_SENT, noNewLineS(msg));
-	return 1;
+  return 1;
 }
 
+
 #define XMPPBUFSIZE 1024
 char buffer[XMPPBUFSIZE] = &quot;&quot;;
 
-bool XMPP::readSocket(){
-	ssize_t len;
-	len = read(xmppSock,buffer, XMPPBUFSIZE-1);
-  
-	if(len &lt;= 0){
+bool XMPP::readSocket()
+{
+  ssize_t len;
+  len = read(xmppSock,buffer, XMPPBUFSIZE-1);
+
+  if(len &lt;= 0)
+  {
     p_debug-&gt;log(CONV_DEBUG_DIRECTION_RECV, CONV_DEBUG_ERROR_RECV);
-		return 0;
+    return 0;
   }
 
   // Terminate the buffer.
@@ -58,275 +67,317 @@ bool XMPP::readSocket(){
 
   p_debug-&gt;log(CONV_DEBUG_DIRECTION_RECV, noNewLine(buffer, strlen(buffer)));
 
-	return 1;
+  return 1;
 }
 
-string XMPP::getErrorReplyMessage(string message, int errortype){
-	if(errortype == XMPP_STREAM_ERROR){
-		return &quot;Stream error.&quot;;
-	}
-
-	if(errortype == XMPP_GENERAL_ERROR){
-		// Cut out the error information (&lt;error&gt;&lt;/error&gt;).
-		unsigned int start = message.find(&quot;&lt;error&quot;);
-		unsigned int stop = message.find(&quot;&lt;/error&gt;&quot;);
-		unsigned int length = stop-start;
-		string error = message.substr(start, length);
-
-		// We now have the error information in &quot;string error&quot;.
-
-		// Get the name of the error.
-		start = error.find(&quot;&gt;&quot;)+2;
-		string temp = error.substr(start);
-		stop = temp.find(&quot;xmlns&quot;)-1;
-		string result = error.substr(start, stop);
-		if(result.length() &lt;= 0)
-			return &quot;Unknown&quot;;
-		return result;
-	}
-
-	return &quot;Unknown&quot;;
+
+string XMPP::getErrorReplyMessage(string message, int errortype)
+{
+  if(errortype == XMPP_STREAM_ERROR)
+  {
+    return &quot;Stream error.&quot;;
+  }
+
+  if(errortype == XMPP_GENERAL_ERROR)
+  {
+    // Cut out the error information (&lt;error&gt;&lt;/error&gt;).
+    unsigned int start = message.find(&quot;&lt;error&quot;);
+    unsigned int stop = message.find(&quot;&lt;/error&gt;&quot;);
+    unsigned int length = stop-start;
+    string error = message.substr(start, length);
+
+    // We now have the error information in &quot;string error&quot;.
+
+    // Get the name of the error.
+    start = error.find(&quot;&gt;&quot;)+2;
+    string temp = error.substr(start);
+    stop = temp.find(&quot;xmlns&quot;)-1;
+    string result = error.substr(start, stop);
+    if(result.length() &lt;= 0)
+      return &quot;Unknown&quot;;
+    return result;
+  }
+
+  return &quot;Unknown&quot;;
 }
 
-bool XMPP::sendMessage(string myMessage, string receiver){
 
-	Log log(LOGFILE, dbData);
+bool XMPP::sendMessage(string myMessage, string receiver)
+{
 
-	struct sockaddr_in address;
-	if((xmppSock = socket(AF_INET, SOCK_STREAM,0)) &gt; 0){
+  Log log(LOGFILE, dbData);
 
-		// Socket created.
-		address.sin_family = AF_INET;
-		address.sin_port = htons(xmppData.xmppPort);
-		address.sin_addr.s_addr = resolveName((char*) xmppData.xmppServer.c_str());
-		if(connect(xmppSock,(struct sockaddr *) &amp;address, sizeof(address)) == 0){
-			// Connected to server.
+  struct sockaddr_in address;
+  if((xmppSock = socket(AF_INET, SOCK_STREAM,0)) &gt; 0)
+  {
+
+    // Socket created.
+    address.sin_family = AF_INET;
+    address.sin_port = htons(xmppData.xmppPort);
+    address.sin_addr.s_addr = resolveName((char*) xmppData.xmppServer.c_str());
+    if(connect(xmppSock,(struct sockaddr *) &amp;address, sizeof(address)) == 0)
+    {
+      // Connected to server.
 
       ConversationDebug debug(dbData, &quot;xmpp&quot;, xmppData.xmppServer);
       p_debug = &amp;debug;
 
-			stringstream message;
-			stringstream reply;
-
-			// Build message for stream initialization.
-			message	&lt;&lt; &quot;&lt;stream:stream to='&quot;
-					&lt;&lt; xmppData.xmppServer
-					&lt;&lt; &quot;' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'&gt;&quot; &lt;&lt; endl;
-
-			// Send stream initialization.
-			if(!sendSocket(message.str())){
-				close(xmppSock);
-				return 0;
-			}
-
-			// Clear message.
-			message.str(&quot;&quot;);
-
-			// Build message for iq request.
-			message &lt;&lt; &quot;&lt;iq type='get' to='&quot;
-					&lt;&lt; xmppData.xmppServer
-					&lt;&lt; &quot;' id='auth1'&gt;&lt;query xmlns='jabber:iq:auth'/&gt;&lt;/iq&gt;&quot; &lt;&lt; endl;
-
-			// Send iq request.
-			if(!sendSocket(message.str())){
-				close(xmppSock);
-				return 0;
-			}
-
-			// Read reply.
-			if(!readSocket()){
-				close(xmppSock);
-				return 0;
-			}
-
-			// See if an error occured.
-			reply &lt;&lt; buffer;
-			if(reply.str().find(&quot;&lt;stream:error&gt;&quot;, 0) != string::npos){
-
-				// There was an error. Abort.
-				stringstream error;
-				error	&lt;&lt; &quot;Could not send XMPP message to \&quot;&quot;
-						&lt;&lt; receiver
-						&lt;&lt; &quot;\&quot; - Server reply: \&quot;&quot;
-						&lt;&lt; getErrorReplyMessage(reply.str(), XMPP_STREAM_ERROR) &lt;&lt; &quot;\&quot;&quot;;
-				log.putLog(1, &quot;011&quot;, error.str());
-				close(xmppSock);
-				return 0;
-			}
-
-			// Clear reply.
-			reply.str(&quot;&quot;);
-
-			// Clear message.
-			message.str(&quot;&quot;);
-
-			// Build login message.
-			message	&lt;&lt; &quot;&lt;iq type='set' id='auth2'&gt;&lt;query xmlns='jabber:iq:auth'&gt;&lt;username&gt;&quot;
-					&lt;&lt; xmppData.xmppUser
-					&lt;&lt; &quot;&lt;/username&gt;&lt;password&gt;&quot;
-					&lt;&lt; xmppData.xmppPass
-					&lt;&lt; &quot;&lt;/password&gt;&lt;resource&gt;&quot;
-					&lt;&lt; xmppData.xmppResource
-					&lt;&lt; &quot;&lt;/resource&gt;&lt;/query&gt;&lt;/iq&gt;&quot;
-					&lt;&lt; endl;
-
-			// Send login message.
-			if(!sendSocket(message.str())){
-				close(xmppSock);
-				return 0;
-			}
-
-			// Read reply.
-			if(!readSocket()){
-				close(xmppSock);
-				return 0;
-			}
-
-			// See if an error occured.
-			reply &lt;&lt; buffer;
-
-			if(reply.str().find(&quot;&lt;error&quot;, 0) != string::npos){
-				// There was an error. Abort.
-				stringstream error;
-				error	&lt;&lt; &quot;Could not send XMPP message to \&quot;&quot;
-						&lt;&lt; receiver
-						&lt;&lt; &quot;\&quot; - Server reply: \&quot;&quot;
-						&lt;&lt; getErrorReplyMessage(reply.str(), XMPP_GENERAL_ERROR) &lt;&lt; &quot;\&quot;&quot;;
-				log.putLog(1, &quot;012&quot;, error.str());
-				close(xmppSock);
-				return 0;
-			}
-			// Clear reply.
-			reply.str(&quot;&quot;);
-
-			// Clear message.
-			message.str(&quot;&quot;);
-
-			// Build the message to send alarm message to user.
-			message	&lt;&lt; &quot;&lt;message to='&quot;
-					&lt;&lt; receiver
-					&lt;&lt; &quot;' from='&quot;
-					&lt;&lt; xmppData.xmppUser
-					&lt;&lt; &quot;@&quot;
-					&lt;&lt; xmppData.xmppServer
-					&lt;&lt; &quot;' type='chat' xml:lang='en'&gt;&lt;body&gt;&quot;
-					&lt;&lt; myMessage
-					&lt;&lt; &quot;&lt;/body&gt;&lt;/message&gt;&quot;
-					&lt;&lt; endl;
-
-			if(!sendSocket(message.str())){
-				close(xmppSock);
-				return 0;
-			}
-
-			if(!readSocket()){
-				close(xmppSock);
-				return 0;
-			}
-
-			// See if an error occurred.
-			reply &lt;&lt; buffer;
-
-			if(reply.str().find(&quot;&lt;error&quot;, 0) != string::npos){
-				// There was an error. Abort.
-				stringstream error;
-				error	&lt;&lt; &quot;Could not send XMPP message to \&quot;&quot;
-						&lt;&lt; receiver
-						&lt;&lt; &quot;\&quot; - Server reply: \&quot;&quot;
-						&lt;&lt; getErrorReplyMessage(reply.str(), XMPP_GENERAL_ERROR) &lt;&lt; &quot;\&quot;&quot;;
-				log.putLog(1, &quot;013&quot;, error.str());
-				close(xmppSock);
-				return 0;
-			}
-
-			// Close this session.
-			sendSocket(&quot;&lt;/stream&gt;&quot;);
-
-			close(xmppSock);
-			return 1;
-		}else{
-			// Could not connect to server.
-			close(xmppSock);
-			stringstream error;
-			error	&lt;&lt; &quot;Could not XMPP connect to \&quot;&quot;
-					&lt;&lt; xmppData.xmppServer
-					&lt;&lt; &quot;\&quot;&quot;;
-			log.putLog(1, &quot;014&quot;, error.str());
-			return 0;
-		}
-		log.putLog(1, &quot;015&quot;, &quot;Could not bind to socket for XMPP messaging.&quot;);
-		close(xmppSock);
-	}
-	close(xmppSock);
-
-	return 1;
+      stringstream message;
+      stringstream reply;
+
+      // Build message for stream initialization.
+      message &lt;&lt; &quot;&lt;stream:stream to='&quot;
+        &lt;&lt; xmppData.xmppServer
+        &lt;&lt; &quot;' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'&gt;&quot; &lt;&lt; endl;
+
+      // Send stream initialization.
+      if(!sendSocket(message.str()))
+      {
+        close(xmppSock);
+        return 0;
+      }
+
+      // Clear message.
+      message.str(&quot;&quot;);
+
+      // Build message for iq request.
+      message &lt;&lt; &quot;&lt;iq type='get' to='&quot;
+        &lt;&lt; xmppData.xmppServer
+        &lt;&lt; &quot;' id='auth1'&gt;&lt;query xmlns='jabber:iq:auth'/&gt;&lt;/iq&gt;&quot; &lt;&lt; endl;
+
+      // Send iq request.
+      if(!sendSocket(message.str()))
+      {
+        close(xmppSock);
+        return 0;
+      }
+
+      // Read reply.
+      if(!readSocket())
+      {
+        close(xmppSock);
+        return 0;
+      }
+
+      // See if an error occured.
+      reply &lt;&lt; buffer;
+      if(reply.str().find(&quot;&lt;stream:error&gt;&quot;, 0) != string::npos)
+      {
+
+        // There was an error. Abort.
+        stringstream error;
+        error &lt;&lt; &quot;Could not send XMPP message to \&quot;&quot;
+          &lt;&lt; receiver
+          &lt;&lt; &quot;\&quot; - Server reply: \&quot;&quot;
+          &lt;&lt; getErrorReplyMessage(reply.str(), XMPP_STREAM_ERROR) &lt;&lt; &quot;\&quot;&quot;;
+        log.putLog(1, &quot;011&quot;, error.str());
+        close(xmppSock);
+        return 0;
+      }
+
+      // Clear reply.
+      reply.str(&quot;&quot;);
+
+      // Clear message.
+      message.str(&quot;&quot;);
+
+      // Build login message.
+      message &lt;&lt; &quot;&lt;iq type='set' id='auth2'&gt;&lt;query xmlns='jabber:iq:auth'&gt;&lt;username&gt;&quot;
+        &lt;&lt; xmppData.xmppUser
+        &lt;&lt; &quot;&lt;/username&gt;&lt;password&gt;&quot;
+        &lt;&lt; xmppData.xmppPass
+        &lt;&lt; &quot;&lt;/password&gt;&lt;resource&gt;&quot;
+        &lt;&lt; xmppData.xmppResource
+        &lt;&lt; &quot;&lt;/resource&gt;&lt;/query&gt;&lt;/iq&gt;&quot;
+        &lt;&lt; endl;
+
+      // Send login message.
+      if(!sendSocket(message.str()))
+      {
+        close(xmppSock);
+        return 0;
+      }
+
+      // Read reply.
+      if(!readSocket())
+      {
+        close(xmppSock);
+        return 0;
+      }
+
+      // See if an error occured.
+      reply &lt;&lt; buffer;
+
+      if(reply.str().find(&quot;&lt;error&quot;, 0) != string::npos)
+      {
+        // There was an error. Abort.
+        stringstream error;
+        error &lt;&lt; &quot;Could not send XMPP message to \&quot;&quot;
+          &lt;&lt; receiver
+          &lt;&lt; &quot;\&quot; - Server reply: \&quot;&quot;
+          &lt;&lt; getErrorReplyMessage(reply.str(), XMPP_GENERAL_ERROR) &lt;&lt; &quot;\&quot;&quot;;
+        log.putLog(1, &quot;012&quot;, error.str());
+        close(xmppSock);
+        return 0;
+      }
+      // Clear reply.
+      reply.str(&quot;&quot;);
+
+      // Clear message.
+      message.str(&quot;&quot;);
+
+      // Build the message to send alarm message to user.
+      message &lt;&lt; &quot;&lt;message to='&quot;
+        &lt;&lt; receiver
+        &lt;&lt; &quot;' from='&quot;
+        &lt;&lt; xmppData.xmppUser
+        &lt;&lt; &quot;@&quot;
+        &lt;&lt; xmppData.xmppServer
+        &lt;&lt; &quot;' type='chat' xml:lang='en'&gt;&lt;body&gt;&quot;
+        &lt;&lt; myMessage
+        &lt;&lt; &quot;&lt;/body&gt;&lt;/message&gt;&quot;
+        &lt;&lt; endl;
+
+      if(!sendSocket(message.str()))
+      {
+        close(xmppSock);
+        return 0;
+      }
+
+      if(!readSocket())
+      {
+        close(xmppSock);
+        return 0;
+      }
+
+      // See if an error occurred.
+      reply &lt;&lt; buffer;
+
+      if(reply.str().find(&quot;&lt;error&quot;, 0) != string::npos)
+      {
+        // There was an error. Abort.
+        stringstream error;
+        error &lt;&lt; &quot;Could not send XMPP message to \&quot;&quot;
+          &lt;&lt; receiver
+          &lt;&lt; &quot;\&quot; - Server reply: \&quot;&quot;
+          &lt;&lt; getErrorReplyMessage(reply.str(), XMPP_GENERAL_ERROR) &lt;&lt; &quot;\&quot;&quot;;
+        log.putLog(1, &quot;013&quot;, error.str());
+        close(xmppSock);
+        return 0;
+      }
+
+      // Close this session.
+      sendSocket(&quot;&lt;/stream&gt;&quot;);
+
+      close(xmppSock);
+      return 1;
+    }
+    else
+    {
+      // Could not connect to server.
+      close(xmppSock);
+      stringstream error;
+      error &lt;&lt; &quot;Could not XMPP connect to \&quot;&quot;
+        &lt;&lt; xmppData.xmppServer
+        &lt;&lt; &quot;\&quot;&quot;;
+      log.putLog(1, &quot;014&quot;, error.str());
+      return 0;
+    }
+    log.putLog(1, &quot;015&quot;, &quot;Could not bind to socket for XMPP messaging.&quot;);
+    close(xmppSock);
+  }
+  close(xmppSock);
+
+  return 1;
 }
 
 
-XMPPData XMPP::fetchSettings(mySQLData dbData){
+XMPPData XMPP::fetchSettings(mySQLData dbData)
+{
   XMPPData xmpp;
 
   Database db(dbData);
-  if(db.initConnection()){
+  if(db.initConnection())
+  {
     const char* getSettingsSQL = &quot;SELECT xmpp_enabled, xmpp_server, xmpp_port,&quot;
-                                &quot;xmpp_user, xmpp_pass, xmpp_resource FROM settings&quot;;
-    if(mysql_real_query(db.getHandle(), getSettingsSQL, strlen(getSettingsSQL)) == 0){
+      &quot;xmpp_user, xmpp_pass, xmpp_resource FROM settings&quot;;
+    if(mysql_real_query(db.getHandle(), getSettingsSQL, strlen(getSettingsSQL)) == 0)
+    {
       MYSQL_RES* res;
-      if((res = mysql_store_result(db.getHandle())) != NULL){
+      if((res = mysql_store_result(db.getHandle())) != NULL)
+      {
         MYSQL_ROW row;
         row = mysql_fetch_row(res);
         stringstream result;
-        if(mysql_num_rows(res) &gt; 0){
+        if(mysql_num_rows(res) &gt; 0)
+        {
 
           // xmpp_enabled
-          if(row[0] != NULL){
-            if(strcmp(row[0], &quot;1&quot;) == 0){
+          if(row[0] != NULL)
+          {
+            if(strcmp(row[0], &quot;1&quot;) == 0)
+            {
               xmpp.doXMPP = 1;
-            }else{
+            }
+            else
+            {
               xmpp.doXMPP = 0;
             }
           }
 
           // xmpp_server
-          if(row[1] != NULL){
+          if(row[1] != NULL)
+          {
             xmpp.xmppServer = row[1];
           }
 
           // xmpp_port
-          if(row[2] != NULL){
+          if(row[2] != NULL)
+          {
             xmpp.xmppPort = stringToInteger(row[2]);
           }
 
           // xmpp_user
-          if(row[3] != NULL){
+          if(row[3] != NULL)
+          {
             xmpp.xmppUser = row[3];
           }
 
           // xmpp_pass
-          if(row[4] != NULL){
+          if(row[4] != NULL)
+          {
             xmpp.xmppPass = row[4];
           }
 
           // xmpp_resource
-          if(row[5] != NULL){
+          if(row[5] != NULL)
+          {
             xmpp.xmppResource = row[5];
           }
 
-        }else{
+        }
+        else
+        {
           // Nothing fetched. Disable mailing.
           xmpp.doXMPP = 0;
         }
-      }else{
+      }
+      else
+      {
         // Error. Disable mailing.
         xmpp.doXMPP = 0;
       }
       mysql_free_result(res);
-    }else{
+    }
+    else
+    {
       // Query failed. Disable mailing.
       xmpp.doXMPP = 0;
     }
     mysql_close(db.getHandle());
-  }else{
+  }
+  else
+  {
     // Could not connect to DB. Diable mailing.
     xmpp.doXMPP = 0;
   }</diff>
      <filename>src/notifications/XMPP.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -27,46 +27,46 @@
 #include &quot;../internal.h&quot;
 #include &quot;../log/ConversationDebug.h&quot;
 
-class XMPP{
-	private:
-		//! Holds information of login, server and general XMPP information
-		XMPPData xmppData;
+class XMPP
+{
+  private:
+    //! Holds information of login, server and general XMPP information
+    XMPPData xmppData;
 
-		//! Holds login and connection information of MySQL database.
-		mySQLData dbData;
+    //! Holds login and connection information of MySQL database.
+    mySQLData dbData;
 
     ConversationDebug* p_debug;
-    
+
     bool sendSocket(string msg);
     bool readSocket();
 
-	public:
-		XMPP(XMPPData xmppData, mySQLData myDBData);
+  public:
+    XMPP(XMPPData xmppData, mySQLData myDBData);
 
-		//! Updates xmppData
-		/*!
-		 * \sa xmppData
-		 */
-		void updateSettings(XMPPData xmppData);
+    //! Updates xmppData
+    /*!
+     * \sa xmppData
+     */
+    void updateSettings(XMPPData xmppData);
 
-		//! Extracts the error message out of an XML/XMPP error reply.
-		/*!
-		 * \param message The error reply to extract the error message from
-		 * \param errortype Type of error (e.g. stream error)
-		 * \return The extracted error message
-		 */
-		string getErrorReplyMessage(string message, int errortype);
+    //! Extracts the error message out of an XML/XMPP error reply.
+    /*!
+     * \param message The error reply to extract the error message from
+     * \param errortype Type of error (e.g. stream error)
+     * \return The extracted error message
+     */
+    string getErrorReplyMessage(string message, int errortype);
 
-		//! Sends XMPP message
-		/*!
-		 * \param message The text to send
-		 * \param receiver JID of receiver
-		 * \return True on success, false in case of error.
-		 */
-		bool sendMessage(string message, string receiver);
+    //! Sends XMPP message
+    /*!
+     * \param message The text to send
+     * \param receiver JID of receiver
+     * \return True on success, false in case of error.
+     */
+    bool sendMessage(string message, string receiver);
 
-		//! Returns XMPPData struct with settings from database.
-		static XMPPData fetchSettings(mySQLData dbData);
+    //! Returns XMPPData struct with settings from database.
+    static XMPPData fetchSettings(mySQLData dbData);
 };
-
-#endif /*XMPP_H_*/
+#endif                                            /*XMPP_H_*/</diff>
      <filename>src/notifications/XMPP.h</filename>
    </modified>
    <modified>
      <diff>@@ -26,112 +26,151 @@
 #include &quot;../misc/Timer.h&quot;
 
 Services::Services(mySQLData myDBData, unsigned int myHandlerID)
-			: Database(myDBData){
-	dbData = myDBData;
- 	serviceID = 0;
-	handlerID = myHandlerID;
-	responseTime = 0;
-	m_responseTime1 = 0;
-	m_responseTime2 = 0;
-	timeout = 0;
+: Database(myDBData)
+{
+  dbData = myDBData;
+  serviceID = 0;
+  handlerID = myHandlerID;
+  responseTime = 0;
+  m_responseTime1 = 0;
+  m_responseTime2 = 0;
+  timeout = 0;
 }
 
-int Services::getFirstResponseTime(){
-	return m_responseTime1;
+
+int Services::getFirstResponseTime()
+{
+  return m_responseTime1;
 }
 
-int Services::getSecondResponseTime(){
-	return m_responseTime2;
+
+int Services::getSecondResponseTime()
+{
+  return m_responseTime2;
 }
 
-void Services::setServiceID(unsigned int x){
-	serviceID = x;
+
+void Services::setServiceID(unsigned int x)
+{
+  serviceID = x;
 }
 
-void Services::setAllowedFails(unsigned int x){
-	allowedFails = x;
+
+void Services::setAllowedFails(unsigned int x)
+{
+  allowedFails = x;
 }
 
-void Services::setPort(unsigned int x){
-	port = x;
+
+void Services::setPort(unsigned int x)
+{
+  port = x;
 }
 
-void Services::setMaximumResponse(unsigned int x){
-	maximumResponse = x;
+
+void Services::setMaximumResponse(unsigned int x)
+{
+  maximumResponse = x;
 }
 
-void Services::setHost(string x){
-	host = x;
+
+void Services::setHost(string x)
+{
+  host = x;
 }
 
-void Services::setServiceType(string x){
-	serviceType = x;
+
+void Services::setServiceType(string x)
+{
+  serviceType = x;
 }
 
-void Services::setNotiGroup(string x){
-	notiGroup = x;
+
+void Services::setNotiGroup(string x)
+{
+  notiGroup = x;
 }
 
-void Services::setHostname(string x){
-	hostname = x;
+
+void Services::setHostname(string x)
+{
+  hostname = x;
 }
 
-unsigned int Services::getServiceID(){
-	return serviceID;
+
+unsigned int Services::getServiceID()
+{
+  return serviceID;
 }
 
-unsigned int Services::getHandlerID(){
-	return handlerID;
+
+unsigned int Services::getHandlerID()
+{
+  return handlerID;
 }
 
-int Services::getMaximumResponse(){
-	return maximumResponse;
+
+int Services::getMaximumResponse()
+{
+  return maximumResponse;
 }
 
-unsigned int Services::getTimeout(){
+
+unsigned int Services::getTimeout()
+{
   return timeout;
 }
 
-void Services::setTimeout(unsigned int myTimeout){
+
+void Services::setTimeout(unsigned int myTimeout)
+{
   timeout = myTimeout;
 }
 
-bool Services::updateSettings(){
+
+bool Services::updateSettings()
+{
   // Return false if the service id has not been set yet.
-  if(serviceID == 0){
+  if(serviceID == 0)
+  {
     return 0;
   }
 
-	if(initConnection()){
-		stringstream query;
+  if(initConnection())
+  {
+    stringstream query;
     query &lt;&lt; &quot;SELECT host, port, service_type, allowed_fails, maxres, host, timeout FROM services &quot;
-				     &quot;WHERE id = &quot;
-          &lt;&lt; getServiceID();
-		if(mysql_real_query(getHandle(), query.str().c_str(), strlen(query.str().c_str())) == 0){
-			// Query successful.
-			MYSQL_ROW serviceResult;
-			MYSQL_RES* res = mysql_store_result(getHandle());
-			serviceResult = mysql_fetch_row(res);
-			if(mysql_num_rows(res) &gt; 0){
-        		// We fetched the service to update. Update!
-				setHost(serviceResult[0]);
-				setPort(stringToInteger(serviceResult[1]));
-				setServiceType(serviceResult[2]);
-				setAllowedFails(stringToInteger(serviceResult[3]));
-				setMaximumResponse(stringToInteger(serviceResult[4]));
-				setHostname(serviceResult[5]);
-        		setTimeout(stringToInteger(serviceResult[6]));
-
-        		// Clean up.
-				mysql_free_result(res);
-				mysql_close(getHandle());
+      &quot;WHERE id = &quot;
+      &lt;&lt; getServiceID();
+    if(mysql_real_query(getHandle(), query.str().c_str(), strlen(query.str().c_str())) == 0)
+    {
+      // Query successful.
+      MYSQL_ROW serviceResult;
+      MYSQL_RES* res = mysql_store_result(getHandle());
+      serviceResult = mysql_fetch_row(res);
+      if(mysql_num_rows(res) &gt; 0)
+      {
+        // We fetched the service to update. Update!
+        setHost(serviceResult[0]);
+        setPort(stringToInteger(serviceResult[1]));
+        setServiceType(serviceResult[2]);
+        setAllowedFails(stringToInteger(serviceResult[3]));
+        setMaximumResponse(stringToInteger(serviceResult[4]));
+        setHostname(serviceResult[5]);
+        setTimeout(stringToInteger(serviceResult[6]));
+
+        // Clean up.
+        mysql_free_result(res);
+        mysql_close(getHandle());
 
         // Great success. &lt;/borat&gt;
         return 1;
-      }else{
+      }
+      else
+      {
         // Could not find service with specified ID.
-				mysql_free_result(res);
-				mysql_close(getHandle());
+        mysql_free_result(res);
+        mysql_close(getHandle());
       }
     }
   }
@@ -140,480 +179,561 @@ bool Services::updateSettings(){
   return 0;
 }
 
-int Services::checkService(int run){
-	Log log(LOGFILE, dbData);
-	int sock;
-	struct sockaddr_in server;
-	struct hostent *host;
+
+int Services::checkService(int run)
+{
+  Log log(LOGFILE, dbData);
+  int sock;
+  struct sockaddr_in server;
+  struct hostent *host;
 
   /* 
    * Store the response time of the first run in responseTime1
    * and the second run in responseTime2.
    */
   int *p_responseTime;
-  if(run == 1){
+  if(run == 1)
+  {
     p_responseTime = &amp;m_responseTime1;
-  }else{
+  }
+  else
+  {
     p_responseTime = &amp;m_responseTime2;
   }
 
-	// Create socket.
-	sock = socket(AF_INET, SOCK_STREAM, 0);
-	if(sock &lt; 0){
-		// Creating socket failed.
-		close(sock);
-		return SERVICE_STATE_INTERR;
-	}
+  // Create socket.
+  sock = socket(AF_INET, SOCK_STREAM, 0);
+  if(sock &lt; 0)
+  {
+    // Creating socket failed.
+    close(sock);
+    return SERVICE_STATE_INTERR;
+  }
 
-	// Verify host.
-	server.sin_family = AF_INET;
-	host = gethostbyname(hostname.c_str());
-	if(host==(struct hostent *) 0){
-		// Host unknown.
-		close(sock);
-		return SERVICE_STATE_CONFAIL;
-	}
+  // Verify host.
+  server.sin_family = AF_INET;
+  host = gethostbyname(hostname.c_str());
+  if(host==(struct hostent *) 0)
+  {
+    // Host unknown.
+    close(sock);
+    return SERVICE_STATE_CONFAIL;
+  }
 
-	// Connect to defined port.
-	memcpy((char *) &amp;server.sin_addr, (char *) host-&gt;h_addr, host-&gt;h_length);
-	server.sin_port=htons(port);
+  // Connect to defined port.
+  memcpy((char *) &amp;server.sin_addr, (char *) host-&gt;h_addr, host-&gt;h_length);
+  server.sin_port=htons(port);
 
   // Set socket to non-blocking.
   long arg;
-  arg = fcntl(sock, F_GETFL, NULL); 
-  arg |= O_NONBLOCK; 
+  arg = fcntl(sock, F_GETFL, NULL);
+  arg |= O_NONBLOCK;
   fcntl(sock, F_SETFL, arg);
 
-	// Connect and measure time it takes to connect.
-	Timer t;
-	t.startTimer();
-	int res = connect(sock, (struct sockaddr *) &amp;server, sizeof server);
-
-  int valopt; 
-  fd_set myset; 
-  struct timeval tv; 
-  socklen_t lon; 
-
-	if(res &lt; 0){
-    if(errno == EINPROGRESS){
-      tv.tv_sec = getTimeout(); 
-      tv.tv_usec = 0; 
-      FD_ZERO(&amp;myset); 
-      FD_SET(sock, &amp;myset); 
-      if(select(sock+1, NULL, &amp;myset, NULL, &amp;tv) &gt; 0){
-        lon = sizeof(int); 
-        getsockopt(sock, SOL_SOCKET, SO_ERROR, (void*)(&amp;valopt), &amp;lon); 
-        if(valopt != 0){
+  // Connect and measure time it takes to connect.
+  Timer t;
+  t.startTimer();
+  int res = connect(sock, (struct sockaddr *) &amp;server, sizeof server);
+
+  int valopt;
+  fd_set myset;
+  struct timeval tv;
+  socklen_t lon;
+
+  if(res &lt; 0)
+  {
+    if(errno == EINPROGRESS)
+    {
+      tv.tv_sec = getTimeout();
+      tv.tv_usec = 0;
+      FD_ZERO(&amp;myset);
+      FD_SET(sock, &amp;myset);
+      if(select(sock+1, NULL, &amp;myset, NULL, &amp;tv) &gt; 0)
+      {
+        lon = sizeof(int);
+        getsockopt(sock, SOL_SOCKET, SO_ERROR, (void*)(&amp;valopt), &amp;lon);
+        if(valopt != 0)
+        {
           // Error.
-			    close(sock);
+          close(sock);
           return SERVICE_STATE_CONFAIL;
         }
-      }else{
+      }
+      else
+      {
         // Timeout.
-			  close(sock);
+        close(sock);
         return SERVICE_STATE_TIMEOUT;
       }
-    }else{
+    }
+    else
+    {
       // Error on connect.
-			close(sock);
+      close(sock);
       return SERVICE_STATE_CONFAIL;
     }
   }
 
-	*p_responseTime = t.stopTimer();
+  *p_responseTime = t.stopTimer();
 
   // We are connected! Set socket back to blocking mode.
-  arg = fcntl(sock, F_GETFL, NULL); 
-  arg &amp;= (~O_NONBLOCK); 
-  fcntl(sock, F_SETFL, arg); 
+  arg = fcntl(sock, F_GETFL, NULL);
+  arg &amp;= (~O_NONBLOCK);
+  fcntl(sock, F_SETFL, arg);
 
-  if(serviceType == &quot;none&quot;){
-		// This service needs no protocol check.
-  	// Service is running if we arrived here.
+  if(serviceType == &quot;none&quot;)
+  {
+    // This service needs no protocol check.
+    // Service is running if we arrived here.
+    close(sock);
+    return SERVICE_STATE_OKAY;
+  }
+  else if(serviceType == &quot;smtp&quot;)
+  {
+    *p_responseTime = checkSMTP(sock);
+  }
+  else if(serviceType == &quot;http&quot;)
+  {
+    *p_responseTime = checkHTTP(sock);
+  }
+  else if(serviceType == &quot;imap&quot;)
+  {
+    *p_responseTime = checkIMAP(sock);
+  }
+  else if(serviceType == &quot;pop3&quot;)
+  {
+    *p_responseTime = checkPOP3(sock);
+  }
+  else if(serviceType == &quot;ssh&quot;)
+  {
+    *p_responseTime = checkSSH(sock);
+  }
+  else if(serviceType == &quot;ftp&quot;)
+  {
+    *p_responseTime = checkFTP(sock);
+  }
+  else
+  {
+    // Unknown service type.
     close(sock);
-	  return SERVICE_STATE_OKAY;
-	}else if(serviceType == &quot;smtp&quot;){
-		*p_responseTime = checkSMTP(sock);
-	}else if(serviceType == &quot;http&quot;){
-		*p_responseTime = checkHTTP(sock);
-	}else if(serviceType == &quot;imap&quot;){
-		*p_responseTime = checkIMAP(sock);
-	}else if(serviceType == &quot;pop3&quot;){
-		*p_responseTime = checkPOP3(sock);
-	}else if(serviceType == &quot;ssh&quot;){
-		*p_responseTime = checkSSH(sock);
-	}else if(serviceType == &quot;ftp&quot;){
-		*p_responseTime = checkFTP(sock);
-	}else{
-		// Unknown service type.
-		close(sock);
-		return SERVICE_STATE_INTERR;
-	}
+    return SERVICE_STATE_INTERR;
+  }
 
   close(sock);
 
   // Check if there was an error in the protocol check.
-  switch(*p_responseTime){
-      case -1:
-        return SERVICE_STATE_CONFAIL;
-        break;
-      case -2:
-        return SERVICE_STATE_TIMEOUT;
-        break;
-      case -3:
-        return SERVICE_STATE_INTERR;
-        break;
+  switch(*p_responseTime)
+  {
+    case -1:
+      return SERVICE_STATE_CONFAIL;
+      break;
+    case -2:
+      return SERVICE_STATE_TIMEOUT;
+      break;
+    case -3:
+      return SERVICE_STATE_INTERR;
+      break;
   }
 
   // The service is running if we arrived here.
-	return SERVICE_STATE_OKAY;
+  return SERVICE_STATE_OKAY;
 }
 
-bool Services::buildAverageResponseTime(){
+
+bool Services::buildAverageResponseTime()
+{
   // Return false if the difference is too high.
-  
+
   // Build the average response time.
   responseTime = (m_responseTime1 + m_responseTime2)/2;
   return 1;
 }
 
-void Services::updateStatus(int status){
+
+void Services::updateStatus(int status)
+{
   m_status = status;
-	Database db(dbData);
-	Log log(LOGFILE, dbData);
-	if(initConnection()){
-		time_t rawtime;
-		stringstream query;
-		query	&lt;&lt; &quot;UPDATE services SET state = &quot;
-				&lt;&lt; status
-				&lt;&lt; &quot; , lastcheck = &quot;
-				&lt;&lt; time(&amp;rawtime)
-				&lt;&lt; &quot; WHERE id = &quot;
-				&lt;&lt; serviceID;
-		setQuery(getHandle(), query.str());
-		mysql_close(getHandle());
-	}else{
-		log.putLog(2, &quot;4000&quot;, &quot;Could not update status of service&quot;);
-		mysql_close(getHandle());
-	}
+  Database db(dbData);
+  Log log(LOGFILE, dbData);
+  if(initConnection())
+  {
+    time_t rawtime;
+    stringstream query;
+    query &lt;&lt; &quot;UPDATE services SET state = &quot;
+      &lt;&lt; status
+      &lt;&lt; &quot; , lastcheck = &quot;
+      &lt;&lt; time(&amp;rawtime)
+      &lt;&lt; &quot; WHERE id = &quot;
+      &lt;&lt; serviceID;
+    setQuery(getHandle(), query.str());
+    mysql_close(getHandle());
+  }
+  else
+  {
+    log.putLog(2, &quot;4000&quot;, &quot;Could not update status of service&quot;);
+    mysql_close(getHandle());
+  }
 }
 
-bool Services::checkResponseTime(){
+
+bool Services::checkResponseTime()
+{
 
   // Build the average response time.
   buildAverageResponseTime();
 
-	// Initialize database connection.
-	if(initConnection()){
+  // Initialize database connection.
+  if(initConnection())
+  {
 
-		string table;
+    string table;
 
-		stringstream query;
-		query	&lt;&lt; &quot;SELECT maxres FROM services WHERE id = &quot;
-		      &lt;&lt; serviceID;
+    stringstream query;
+    query &lt;&lt; &quot;SELECT maxres FROM services WHERE id = &quot;
+      &lt;&lt; serviceID;
 
-		setMaximumResponse(stringToInteger(sGetQuery(query.str()).c_str()));
+    setMaximumResponse(stringToInteger(sGetQuery(query.str()).c_str()));
 
-		if(responseTime &gt; getMaximumResponse()){
-			// Higher than defined maximum!
-			mysql_close(getHandle());
-			return 0;
-		}
+    if(responseTime &gt; getMaximumResponse())
+    {
+      // Higher than defined maximum!
+      mysql_close(getHandle());
+      return 0;
+    }
 
-		mysql_close(getHandle());
-	}
+    mysql_close(getHandle());
+  }
 
-	// All went fine. The response was not higher than defined maximum.
-	return 1;
+  // All went fine. The response was not higher than defined maximum.
+  return 1;
 }
 
-void Services::sendWarning(){
-	Log log(LOGFILE, dbData);
-
-	// Initialize database connection.
-	if(initConnection()){
-
-		mailingData mailData;
-		XMPPData xmppData;
-		mobilecData mobilecData;
-
-		mailData = Mail::fetchSettings(dbData);
-		xmppData = XMPP::fetchSettings(dbData);
-		mobilecData = Clickatell::fetchSettings(dbData);
-
-		// Create mailing object.
-		Mail mailing(mailData, dbData);
-
-		// Check for mailing parameters.
-		if(mailData.doMailing &amp;&amp; !mailData.mailServer.empty() &gt; 0 &amp;&amp; mailData.mailPort &gt; 0
-				&amp;&amp; !mailData.mailHostname.empty() &amp;&amp; !mailData.mailFrom.empty()){
-			// All mailing parameters set correctly.
-			mailData.doMailing = 1;
-		}else{
-			// Parameters missing - Disable mailing.
-			mailData.doMailing = 0;
-		}
-
-		// Create XMPP object.
-		XMPP xmpp(xmppData, dbData);
-
-		// Check for XMPP parameters.
-		if(xmppData.doXMPP &amp;&amp; !xmppData.xmppServer.empty() &amp;&amp; xmppData.xmppPort &gt; 0
-				&amp;&amp; !xmppData.xmppUser.empty() &amp;&amp; !xmppData.xmppPass.empty()
-				&amp;&amp; !xmppData.xmppResource.empty()){
-			// All XMPP parameters set correctly.
-			xmppData.doXMPP = 1;
-		}else{
-			// Parameters missing - Disable XMPP.
-			xmppData.doXMPP = 0;
-		}
-
-		// Check for Clickatell SMS parameters.
-		if(mobilecData.doMobileC &amp;&amp; !mobilecData.username.empty()
-				&amp;&amp; !mobilecData.password.empty()
-				&amp;&amp; !mobilecData.apiID.empty()){
-			mobilecData.doMobileC = 1;
-		}else{
-			// Parameters missing - Disable Clickatell SMS.
-			mobilecData.doMobileC = 0;
-		}
-
-		stringstream warningSubj;
-		stringstream warningMsg;
-
-		string serviceName;
-
-		serviceName = sGetQuery(Information::getServiceName(serviceID));
-
-		int qms = 0;
-
-    if(m_status == 2){
-			// It is a warning for a too high response time.
-			warningSubj &lt;&lt; &quot;Warning! Service \&quot;&quot;
-						&lt;&lt; serviceName
-						&lt;&lt; &quot;\&quot; has a too high response time!&quot;;
-
-			warningMsg	&lt;&lt; &quot;Warning! Service \&quot;&quot;
-						&lt;&lt; serviceName
-						&lt;&lt; &quot;\&quot; (&quot;
-						&lt;&lt; hostname
-						&lt;&lt; &quot; on Port &quot;
-						&lt;&lt; port
-						&lt;&lt; &quot;) has response time \&quot;&quot;
-						&lt;&lt; responseTime
-						&lt;&lt; &quot;ms\&quot;!&quot;;
-			qms = responseTime;
-		}else if(m_status == 4){
+
+void Services::sendWarning()
+{
+  Log log(LOGFILE, dbData);
+
+  // Initialize database connection.
+  if(initConnection())
+  {
+
+    mailingData mailData;
+    XMPPData xmppData;
+    mobilecData mobilecData;
+
+    mailData = Mail::fetchSettings(dbData);
+    xmppData = XMPP::fetchSettings(dbData);
+    mobilecData = Clickatell::fetchSettings(dbData);
+
+    // Create mailing object.
+    Mail mailing(mailData, dbData);
+
+    // Check for mailing parameters.
+    if(mailData.doMailing &amp;&amp; !mailData.mailServer.empty() &gt; 0 &amp;&amp; mailData.mailPort &gt; 0
+      &amp;&amp; !mailData.mailHostname.empty() &amp;&amp; !mailData.mailFrom.empty())
+    {
+      // All mailing parameters set correctly.
+      mailData.doMailing = 1;
+    }
+    else
+    {
+      // Parameters missing - Disable mailing.
+      mailData.doMailing = 0;
+    }
+
+    // Create XMPP object.
+    XMPP xmpp(xmppData, dbData);
+
+    // Check for XMPP parameters.
+    if(xmppData.doXMPP &amp;&amp; !xmppData.xmppServer.empty() &amp;&amp; xmppData.xmppPort &gt; 0
+      &amp;&amp; !xmppData.xmppUser.empty() &amp;&amp; !xmppData.xmppPass.empty()
+      &amp;&amp; !xmppData.xmppResource.empty())
+    {
+      // All XMPP parameters set correctly.
+      xmppData.doXMPP = 1;
+    }
+    else
+    {
+      // Parameters missing - Disable XMPP.
+      xmppData.doXMPP = 0;
+    }
+
+    // Check for Clickatell SMS parameters.
+    if(mobilecData.doMobileC &amp;&amp; !mobilecData.username.empty()
+      &amp;&amp; !mobilecData.password.empty()
+      &amp;&amp; !mobilecData.apiID.empty())
+    {
+      mobilecData.doMobileC = 1;
+    }
+    else
+    {
+      // Parameters missing - Disable Clickatell SMS.
+      mobilecData.doMobileC = 0;
+    }
+
+    stringstream warningSubj;
+    stringstream warningMsg;
+
+    string serviceName;
+
+    serviceName = sGetQuery(Information::getServiceName(serviceID));
+
+    int qms = 0;
+
+    if(m_status == 2)
+    {
+      // It is a warning for a too high response time.
+      warningSubj &lt;&lt; &quot;Warning! Service \&quot;&quot;
+        &lt;&lt; serviceName
+        &lt;&lt; &quot;\&quot; has a too high response time!&quot;;
+
+      warningMsg  &lt;&lt; &quot;Warning! Service \&quot;&quot;
+        &lt;&lt; serviceName
+        &lt;&lt; &quot;\&quot; (&quot;
+        &lt;&lt; hostname
+        &lt;&lt; &quot; on Port &quot;
+        &lt;&lt; port
+        &lt;&lt; &quot;) has response time \&quot;&quot;
+        &lt;&lt; responseTime
+        &lt;&lt; &quot;ms\&quot;!&quot;;
+      qms = responseTime;
+    }
+    else if(m_status == 4)
+    {
       // It is a warning for a timed out service.
-			warningSubj &lt;&lt; &quot;Warning! Service \&quot;&quot;
-						&lt;&lt; serviceName
-						&lt;&lt; &quot;\&quot; timed out!&quot;;
-
-			warningMsg	&lt;&lt; &quot;Warning! Service \&quot;&quot;
-						&lt;&lt; serviceName
-						&lt;&lt; &quot;\&quot; (&quot;
-						&lt;&lt; hostname
-						&lt;&lt; &quot; on Port &quot;
-						&lt;&lt; port
-						&lt;&lt; &quot;) timed out.&quot;;
-    }else{
-			// It is a &quot;normal&quot; failed service.
-			warningSubj &lt;&lt; &quot;Warning! Service \&quot;&quot;
-						&lt;&lt; serviceName
-						&lt;&lt; &quot;\&quot; seems to have failed!&quot;;
-
-			warningMsg	&lt;&lt; &quot;Warning! Service \&quot;&quot;
-						&lt;&lt; serviceName
-						&lt;&lt; &quot;\&quot; (&quot;
-						&lt;&lt; hostname
-						&lt;&lt; &quot; on Port &quot;
-						&lt;&lt; port
-						&lt;&lt; &quot;) seems to have failed!&quot;;
-    }
-
-		string lastWarn;
-		lastWarn = sGetQuery(Information::getLastServiceWarn(serviceID));
-
-		time_t rawtime;
-		time(&amp;rawtime);
-
-		// Only send warning all 6 hours.
-		if(rawtime-stringToInteger(lastWarn.c_str()) &gt; 21600){
-
-			// Build query for scheduled downtime check.
-			stringstream checkDowntimeQuery;
-			checkDowntimeQuery	&lt;&lt; &quot;SELECT id FROM downtimes&quot;
-									&quot; WHERE serviceid = &quot; &lt;&lt; serviceID &lt;&lt;
-								   &quot; AND type = 2 AND `from` &lt; &quot; &lt;&lt; rawtime &lt;&lt;
-								   &quot; AND `to` &gt; &quot; &lt;&lt; rawtime;
-
-
-			if(mysql_real_query(getHandle(), checkDowntimeQuery.str().c_str(),
-					strlen(checkDowntimeQuery.str().c_str())) != 0){
-				// Query was not successful.
-				log.putLog(1, &quot;5678&quot;, &quot;Could not fetch downtimes for service alarm.&quot;);
-				mysql_close(getHandle());
-				return;
-			}else{
-				// Query successful.
-
-				time_t alarmtime;
-				time(&amp;alarmtime);
-
-				// Check if a downtime was scheduled for this service.
-				MYSQL_RES* sdres = mysql_store_result(getHandle());
-				if(mysql_num_rows(sdres) &gt; 0){
-					// A downtime was scheduled. Don't warn.
-					mysql_free_result(sdres);
-					mysql_close(getHandle());
-					return;
-				}
-				mysql_free_result(sdres);
-
-				// We need to send warnings.
-
-				// Set last warning time.
-				time_t warntime;
-				time(&amp;warntime);
-				setQuery(getHandle(), Information::setLastServiceWarn(warntime, serviceID));
-
-				// Insert warning into database.
-				stringstream alarmSQL;
-				alarmSQL	&lt;&lt; &quot;INSERT INTO alarms (alarm_type, timestamp, service_id, ms, service_state) VALUES ('2','&quot;
-							&lt;&lt; alarmtime
-							&lt;&lt; &quot;','&quot;
-							&lt;&lt; serviceID
-							&lt;&lt; &quot;','&quot;
-							&lt;&lt; qms
-							&lt;&lt; &quot;','&quot;
-							&lt;&lt; m_status
-							&lt;&lt; &quot;')&quot;;
-
-				if(!setQuery(getHandle(), alarmSQL.str()))
-					log.putLog(2, &quot;002&quot;, &quot;Could not update alarms table.&quot;);
-
-
-				if(mailData.doMailing){
-					vector&lt;string&gt; mailRecvList = Information::getMailWarningReceivers(getHandle(),
-							sGetQuery(Information::getServiceReceiverGroup(serviceID)), &quot;4&quot;);
-
-					int mailRecvCount = 0;
-					int mailRecvListSize = mailRecvList.size();
-					while(mailRecvCount &lt; mailRecvListSize){
-						if(!mailRecvList[mailRecvCount].empty())
-							mailing.sendMail(mailRecvList[mailRecvCount], warningSubj.str(), warningMsg.str());
-						mailRecvCount++;
-					}
-				}
-
-				// Get XMPP receivers.
-				if(xmppData.doXMPP){
-					vector&lt;string&gt; xmppRecvList = Information::getXMPPWarningReceivers(getHandle(),
-												sGetQuery(Information::getServiceReceiverGroup(
-														serviceID)),&quot;3&quot;);
-
-					// Send a warning message to every XMPP receiver.
-					int xmppRecvCount = 0;
-					int xmppRecvListSize = xmppRecvList.size();
-					while(xmppRecvCount &lt; xmppRecvListSize){
-							if(!xmppRecvList[xmppRecvCount].empty())
-									xmpp.sendMessage(warningMsg.str(), xmppRecvList[xmppRecvCount]);
-							xmppRecvCount++;
-					}
-				}
-
-
-				if(mobilecData.doMobileC &amp;&amp; mailData.doMailing){
-					vector&lt;string&gt; mobilecRecvList = Information::getMobileCWarningReceivers(getHandle(),
-							sGetQuery(Information::getServiceReceiverGroup(serviceID)), &quot;4&quot;);
-					int mobilecRecvCount = 0;
-					int mobilecRecvListSize = mobilecRecvList.size();
-					while(mobilecRecvCount &lt; mobilecRecvListSize){
-						if(!mobilecRecvList[mobilecRecvCount].empty()){
-							// Build the message that fits to the API.
-							stringstream newWarningMsg;
-							newWarningMsg	&lt;&lt; &quot;user:&quot; &lt;&lt; mobilecData.username &lt;&lt; endl
-											&lt;&lt; &quot;password:&quot; &lt;&lt; mobilecData.password &lt;&lt; endl
-											&lt;&lt; &quot;api_id:&quot; &lt;&lt; mobilecData.apiID &lt;&lt; endl
-											&lt;&lt; &quot;to:&quot; &lt;&lt; mobilecRecvList[mobilecRecvCount] &lt;&lt; endl
-											&lt;&lt; &quot;text:&quot; &lt;&lt; warningMsg.str();
-							mailing.sendMail(CLICKATELLMAIL, warningSubj.str(), newWarningMsg.str());
-						}
-						mobilecRecvCount++;
-					}
-				}
-
-			}
-		}
-		mysql_close(getHandle());
-	}else{
-		log.putLog(2, &quot;1234&quot;, &quot;Could not connect to database for service warning/alarm.&quot;);
-	}
+      warningSubj &lt;&lt; &quot;Warning! Service \&quot;&quot;
+        &lt;&lt; serviceName
+        &lt;&lt; &quot;\&quot; timed out!&quot;;
+
+      warningMsg  &lt;&lt; &quot;Warning! Service \&quot;&quot;
+        &lt;&lt; serviceName
+        &lt;&lt; &quot;\&quot; (&quot;
+        &lt;&lt; hostname
+        &lt;&lt; &quot; on Port &quot;
+        &lt;&lt; port
+        &lt;&lt; &quot;) timed out.&quot;;
+    }
+    else
+    {
+      // It is a &quot;normal&quot; failed service.
+      warningSubj &lt;&lt; &quot;Warning! Service \&quot;&quot;
+        &lt;&lt; serviceName
+        &lt;&lt; &quot;\&quot; seems to have failed!&quot;;
+
+      warningMsg  &lt;&lt; &quot;Warning! Service \&quot;&quot;
+        &lt;&lt; serviceName
+        &lt;&lt; &quot;\&quot; (&quot;
+        &lt;&lt; hostname
+        &lt;&lt; &quot; on Port &quot;
+        &lt;&lt; port
+        &lt;&lt; &quot;) seems to have failed!&quot;;
+    }
+
+    string lastWarn;
+    lastWarn = sGetQuery(Information::getLastServiceWarn(serviceID));
+
+    time_t rawtime;
+    time(&amp;rawtime);
+
+    // Only send warning all 6 hours.
+    if(rawtime-stringToInteger(lastWarn.c_str()) &gt; 21600)
+    {
+
+      // Build query for scheduled downtime check.
+      stringstream checkDowntimeQuery;
+      checkDowntimeQuery  &lt;&lt; &quot;SELECT id FROM downtimes&quot;
+        &quot; WHERE serviceid = &quot; &lt;&lt; serviceID &lt;&lt;
+        &quot; AND type = 2 AND `from` &lt; &quot; &lt;&lt; rawtime &lt;&lt;
+        &quot; AND `to` &gt; &quot; &lt;&lt; rawtime;
+
+      if(mysql_real_query(getHandle(), checkDowntimeQuery.str().c_str(),
+        strlen(checkDowntimeQuery.str().c_str())) != 0)
+      {
+        // Query was not successful.
+        log.putLog(1, &quot;5678&quot;, &quot;Could not fetch downtimes for service alarm.&quot;);
+        mysql_close(getHandle());
+        return;
+      }
+      else
+      {
+        // Query successful.
+
+        time_t alarmtime;
+        time(&amp;alarmtime);
+
+        // Check if a downtime was scheduled for this service.
+        MYSQL_RES* sdres = mysql_store_result(getHandle());
+        if(mysql_num_rows(sdres) &gt; 0)
+        {
+          // A downtime was scheduled. Don't warn.
+          mysql_free_result(sdres);
+          mysql_close(getHandle());
+          return;
+        }
+        mysql_free_result(sdres);
+
+        // We need to send warnings.
+
+        // Set last warning time.
+        time_t warntime;
+        time(&amp;warntime);
+        setQuery(getHandle(), Information::setLastServiceWarn(warntime, serviceID));
+
+        // Insert warning into database.
+        stringstream alarmSQL;
+        alarmSQL  &lt;&lt; &quot;INSERT INTO alarms (alarm_type, timestamp, service_id, ms, service_state) VALUES ('2','&quot;
+          &lt;&lt; alarmtime
+          &lt;&lt; &quot;','&quot;
+          &lt;&lt; serviceID
+          &lt;&lt; &quot;','&quot;
+          &lt;&lt; qms
+          &lt;&lt; &quot;','&quot;
+          &lt;&lt; m_status
+          &lt;&lt; &quot;')&quot;;
+
+        if(!setQuery(getHandle(), alarmSQL.str()))
+          log.putLog(2, &quot;002&quot;, &quot;Could not update alarms table.&quot;);
+
+        if(mailData.doMailing)
+        {
+          vector&lt;string&gt; mailRecvList = Information::getMailWarningReceivers(getHandle(),
+            sGetQuery(Information::getServiceReceiverGroup(serviceID)), &quot;4&quot;);
+
+          int mailRecvCount = 0;
+          int mailRecvListSize = mailRecvList.size();
+          while(mailRecvCount &lt; mailRecvListSize)
+          {
+            if(!mailRecvList[mailRecvCount].empty())
+              mailing.sendMail(mailRecvList[mailRecvCount], warningSubj.str(), warningMsg.str());
+            mailRecvCount++;
+          }
+        }
+
+        // Get XMPP receivers.
+        if(xmppData.doXMPP)
+        {
+          vector&lt;string&gt; xmppRecvList = Information::getXMPPWarningReceivers(getHandle(),
+            sGetQuery(Information::getServiceReceiverGroup(
+            serviceID)),&quot;3&quot;);
+
+          // Send a warning message to every XMPP receiver.
+          int xmppRecvCount = 0;
+          int xmppRecvListSize = xmppRecvList.size();
+          while(xmppRecvCount &lt; xmppRecvListSize)
+          {
+            if(!xmppRecvList[xmppRecvCount].empty())
+              xmpp.sendMessage(warningMsg.str(), xmppRecvList[xmppRecvCount]);
+            xmppRecvCount++;
+          }
+        }
+
+        if(mobilecData.doMobileC &amp;&amp; mailData.doMailing)
+        {
+          vector&lt;string&gt; mobilecRecvList = Information::getMobileCWarningReceivers(getHandle(),
+            sGetQuery(Information::getServiceReceiverGroup(serviceID)), &quot;4&quot;);
+          int mobilecRecvCount = 0;
+          int mobilecRecvListSize = mobilecRecvList.size();
+          while(mobilecRecvCount &lt; mobilecRecvListSize)
+          {
+            if(!mobilecRecvList[mobilecRecvCount].empty())
+            {
+              // Build the message that fits to the API.
+              stringstream newWarningMsg;
+              newWarningMsg &lt;&lt; &quot;user:&quot; &lt;&lt; mobilecData.username &lt;&lt; endl
+                &lt;&lt; &quot;password:&quot; &lt;&lt; mobilecData.password &lt;&lt; endl
+                &lt;&lt; &quot;api_id:&quot; &lt;&lt; mobilecData.apiID &lt;&lt; endl
+                &lt;&lt; &quot;to:&quot; &lt;&lt; mobilecRecvList[mobilecRecvCount] &lt;&lt; endl
+                &lt;&lt; &quot;text:&quot; &lt;&lt; warningMsg.str();
+              mailing.sendMail(CLICKATELLMAIL, warningSubj.str(), newWarningMsg.str());
+            }
+            mobilecRecvCount++;
+          }
+        }
+
+      }
+    }
+    mysql_close(getHandle());
+  }
+  else
+  {
+    log.putLog(2, &quot;1234&quot;, &quot;Could not connect to database for service warning/alarm.&quot;);
+  }
 }
 
-bool Services::storeResponseTime(){
+
+bool Services::storeResponseTime()
+{
 
   // Build the average response time.
   buildAverageResponseTime();
-	
+
   // Initialize database connection.
-	if(initConnection()){
-		stringstream queryLastData;
-		stringstream queryAllData;
-
-		time_t thistime;
-		time(&amp;thistime);
-
-		queryAllData &lt;&lt; &quot;INSERT INTO servicerecords(timestamp, serviceid, ms) VALUES('&quot;
-						&lt;&lt; thistime
-						&lt;&lt; &quot;', '&quot;
-						&lt;&lt; serviceID
-						&lt;&lt; &quot;', '&quot;
-						&lt;&lt; responseTime
-						&lt;&lt; &quot;')&quot;;
-
-		queryLastData	&lt;&lt; &quot;UPDATE services SET responsetime = &quot;
-						&lt;&lt; responseTime
-						&lt;&lt; &quot; WHERE id = &quot;
-						&lt;&lt; serviceID;
-
-		if(!setQuery(getHandle(), queryLastData.str())){
-			mysql_close(getHandle());
-			return 0;
-		}
-
-		if(!setQuery(getHandle(), queryAllData.str())){
-			mysql_close(getHandle());
-			return 0;
-		}
-
-		mysql_close(getHandle());
-		return 1;
-	}
-
-	return 0;
+  if(initConnection())
+  {
+    stringstream queryLastData;
+    stringstream queryAllData;
+
+    time_t thistime;
+    time(&amp;thistime);
+
+    queryAllData &lt;&lt; &quot;INSERT INTO servicerecords(timestamp, serviceid, ms) VALUES('&quot;
+      &lt;&lt; thistime
+      &lt;&lt; &quot;', '&quot;
+      &lt;&lt; serviceID
+      &lt;&lt; &quot;', '&quot;
+      &lt;&lt; responseTime
+      &lt;&lt; &quot;')&quot;;
+
+    queryLastData &lt;&lt; &quot;UPDATE services SET responsetime = &quot;
+      &lt;&lt; responseTime
+      &lt;&lt; &quot; WHERE id = &quot;
+      &lt;&lt; serviceID;
+
+    if(!setQuery(getHandle(), queryLastData.str()))
+    {
+      mysql_close(getHandle());
+      return 0;
+    }
+
+    if(!setQuery(getHandle(), queryAllData.str()))
+    {
+      mysql_close(getHandle());
+      return 0;
+    }
+
+    mysql_close(getHandle());
+    return 1;
+  }
+
+  return 0;
 }
 
+
 #define CHECKBUFSIZE 1024
 
-string Services::readWithTimeout(int socket){
-	// Our buffer.
-	char checkBuffer[CHECKBUFSIZE];
+string Services::readWithTimeout(int socket)
+{
+  // Our buffer.
+  char checkBuffer[CHECKBUFSIZE];
 
-	// Will hold the length of the reply.
-	int len;
+  // Will hold the length of the reply.
+  int len;
   len = read(socket, checkBuffer, CHECKBUFSIZE-1);
-  
-  if(len &lt;= 0){
+
+  if(len &lt;= 0)
+  {
     return &quot;err-con&quot;;
   }
 
   // Terminate the string if the reply was not too long.
-	if(len &lt; CHECKBUFSIZE){
-		checkBuffer[len] = '\0';
-	}else{
-		return &quot;err-int&quot;;
-	}
+  if(len &lt; CHECKBUFSIZE)
+  {
+    checkBuffer[len] = '\0';
+  }
+  else
+  {
+    return &quot;err-int&quot;;
+  }
 
   stringstream res;
   res &lt;&lt; checkBuffer;
@@ -621,264 +741,317 @@ string Services::readWithTimeout(int socket){
   return res.str();
 }
 
-int Services::checkSMTP(int sock){
 
-	int ms = 1;
+int Services::checkSMTP(int sock)
+{
 
-	// The message to send to the server.
-	const char* message = &quot;EHLO example.org\n\r\n\r&quot;;
+  int ms = 1;
+
+  // The message to send to the server.
+  const char* message = &quot;EHLO example.org\n\r\n\r&quot;;
 
   int len = 0;
 
-	// Send the message.
-	if((len = send(sock,message,strlen(message),0)) &lt;= 0)
-		return -1;
+  // Send the message.
+  if((len = send(sock,message,strlen(message),0)) &lt;= 0)
+    return -1;
 
-	Timer t;
+  Timer t;
 
-	t.startTimer();
+  t.startTimer();
 
   string reply;
 
-	// Read the answer.
-  if((reply = readWithTimeout(sock)) == &quot;err&quot;){
-    if(reply == &quot;err-con&quot;){
+  // Read the answer.
+  if((reply = readWithTimeout(sock)) == &quot;err&quot;)
+  {
+    if(reply == &quot;err-con&quot;)
+    {
       return -1;
-    }else if(reply == &quot;err-time&quot;){
+    }
+    else if(reply == &quot;err-time&quot;)
+    {
       return -2;
-    }else{
-		  return -3;
+    }
+    else
+    {
+      return -3;
     }
   }
 
-	ms = t.stopTimer();
-  
-	// Quit message to close the connection.
-	const char* quitMessage = &quot;QUIT&quot;;
+  ms = t.stopTimer();
 
-	// Send the quit message.
-	if((len = send(sock,quitMessage,strlen(quitMessage),0)) &lt;= 0)
-		return -1;
+  // Quit message to close the connection.
+  const char* quitMessage = &quot;QUIT&quot;;
 
-	// If the first three chars are &quot;220&quot;, there is a SMTP server running.
-	if(reply.substr(0,3) == &quot;220&quot;)
-		return ms;
+  // Send the quit message.
+  if((len = send(sock,quitMessage,strlen(quitMessage),0)) &lt;= 0)
+    return -1;
 
-	// The first three chars of the reply were not &quot;220&quot;. No SMTP server running.
-	return -1;
+  // If the first three chars are &quot;220&quot;, there is a SMTP server running.
+  if(reply.substr(0,3) == &quot;220&quot;)
+    return ms;
+
+  // The first three chars of the reply were not &quot;220&quot;. No SMTP server running.
+  return -1;
 }
 
-int Services::checkHTTP(int sock){
 
-	int ms = 1;
+int Services::checkHTTP(int sock)
+{
+
+  int ms = 1;
 
-	// Will hold the length of the reply.
-	int len;
+  // Will hold the length of the reply.
+  int len;
 
-	const char* message = &quot;HEAD / HTTP/1.0\n\r\n\r&quot;;
+  const char* message = &quot;HEAD / HTTP/1.0\n\r\n\r&quot;;
 
-	// Send the message.
-	if((len = send(sock,message,strlen(message),0)) &lt;= 0)
-		return -1;
+  // Send the message.
+  if((len = send(sock,message,strlen(message),0)) &lt;= 0)
+    return -1;
 
-	Timer t;
+  Timer t;
 
-	t.startTimer();
+  t.startTimer();
 
   string reply;
 
-	// Read the answer.
-  if((reply = readWithTimeout(sock)) == &quot;err&quot;){
-    if(reply == &quot;err-con&quot;){
+  // Read the answer.
+  if((reply = readWithTimeout(sock)) == &quot;err&quot;)
+  {
+    if(reply == &quot;err-con&quot;)
+    {
       return -1;
-    }else if(reply == &quot;err-time&quot;){
+    }
+    else if(reply == &quot;err-time&quot;)
+    {
       return -2;
-    }else{
-		  return -3;
+    }
+    else
+    {
+      return -3;
     }
   }
 
-	ms = t.stopTimer();
+  ms = t.stopTimer();
 
-	// If the first five chars are &quot;HTTP/&quot;, there is a HTTP server running.
-	if(reply.substr(0,5) == &quot;HTTP/&quot;)
-		return ms;
+  // If the first five chars are &quot;HTTP/&quot;, there is a HTTP server running.
+  if(reply.substr(0,5) == &quot;HTTP/&quot;)
+    return ms;
 
-	// The first five chars of the reply were not &quot;HTTP/&quot;. No HTTP server running.
-	return -1;
+  // The first five chars of the reply were not &quot;HTTP/&quot;. No HTTP server running.
+  return -1;
 }
 
-int Services::checkIMAP(int sock){
 
-	int ms = 1;
+int Services::checkIMAP(int sock)
+{
+
+  int ms = 1;
 
-	Timer t;
+  Timer t;
 
-	t.startTimer();
+  t.startTimer();
 
   string reply;
 
-	// Read the answer.
-  if((reply = readWithTimeout(sock)) == &quot;err&quot;){
-    if(reply == &quot;err-con&quot;){
+  // Read the answer.
+  if((reply = readWithTimeout(sock)) == &quot;err&quot;)
+  {
+    if(reply == &quot;err-con&quot;)
+    {
       return -1;
-    }else if(reply == &quot;err-time&quot;){
+    }
+    else if(reply == &quot;err-time&quot;)
+    {
       return -2;
-    }else{
-		  return -3;
+    }
+    else
+    {
+      return -3;
     }
   }
 
-	ms = t.stopTimer();
+  ms = t.stopTimer();
 
-	// If the first four chars are &quot;* OK&quot;, there is an IMAP server running.
-	if(reply.substr(0,4) == &quot;* OK&quot;)
-		return ms;
+  // If the first four chars are &quot;* OK&quot;, there is an IMAP server running.
+  if(reply.substr(0,4) == &quot;* OK&quot;)
+    return ms;
 
-	// The first four chars of the reply were not &quot;* OK&quot;. No IMAP server running.
-	return -1;
+  // The first four chars of the reply were not &quot;* OK&quot;. No IMAP server running.
+  return -1;
 }
 
-int Services::checkPOP3(int sock){
 
-	int ms = 1;
+int Services::checkPOP3(int sock)
+{
 
-	// Will hold the length of the reply.
-	int len;
+  int ms = 1;
 
-	Timer t;
+  // Will hold the length of the reply.
+  int len;
 
-	t.startTimer();
+  Timer t;
+
+  t.startTimer();
 
   string reply;
 
-	// Read the answer.
-  if((reply = readWithTimeout(sock)) == &quot;err&quot;){
-    if(reply == &quot;err-con&quot;){
+  // Read the answer.
+  if((reply = readWithTimeout(sock)) == &quot;err&quot;)
+  {
+    if(reply == &quot;err-con&quot;)
+    {
       return -1;
-    }else if(reply == &quot;err-time&quot;){
+    }
+    else if(reply == &quot;err-time&quot;)
+    {
       return -2;
-    }else{
-		  return -3;
+    }
+    else
+    {
+      return -3;
     }
   }
 
-	ms = t.stopTimer();
+  ms = t.stopTimer();
 
-	// Quit message to close the connection.
-	const char* message = &quot;QUIT\n&quot;;
+  // Quit message to close the connection.
+  const char* message = &quot;QUIT\n&quot;;
 
-	// Send the quit message.
-	if((len = send(sock,message,strlen(message),0)) &lt;= 0)
-		return -1;
+  // Send the quit message.
+  if((len = send(sock,message,strlen(message),0)) &lt;= 0)
+    return -1;
 
-	// If the first three chars are &quot;* OK&quot;, there is an POP3 server running.
-	if(reply.substr(0,3) == &quot;+OK&quot;)
-		return ms;
+  // If the first three chars are &quot;* OK&quot;, there is an POP3 server running.
+  if(reply.substr(0,3) == &quot;+OK&quot;)
+    return ms;
 
-	// The first three chars of the reply were not &quot;+OK&quot;. No POP3 server running.
-	return -1;
+  // The first three chars of the reply were not &quot;+OK&quot;. No POP3 server running.
+  return -1;
 }
 
-int Services::checkSSH(int sock){
 
-	int ms = 1;
-	
+int Services::checkSSH(int sock)
+{
+
+  int ms = 1;
+
   Timer t;
 
-	t.startTimer();
+  t.startTimer();
 
   string reply;
 
-	// Read the answer.
-  if((reply = readWithTimeout(sock)) == &quot;err&quot;){
-    if(reply == &quot;err-con&quot;){
+  // Read the answer.
+  if((reply = readWithTimeout(sock)) == &quot;err&quot;)
+  {
+    if(reply == &quot;err-con&quot;)
+    {
       return -1;
-    }else if(reply == &quot;err-time&quot;){
+    }
+    else if(reply == &quot;err-time&quot;)
+    {
       return -2;
-    }else{
-		  return -3;
+    }
+    else
+    {
+      return -3;
     }
   }
 
-	ms = t.stopTimer();
+  ms = t.stopTimer();
 
-	// If the first three chars are &quot;SSH&quot;, there is an SSH server running.
-	if(reply.substr(0,3) == &quot;SSH&quot;)
-		return ms;
+  // If the first three chars are &quot;SSH&quot;, there is an SSH server running.
+  if(reply.substr(0,3) == &quot;SSH&quot;)
+    return ms;
 
-	// The first three chars of the reply were not &quot;SSH&quot;. No SSH server running.
-	return -1;
+  // The first three chars of the reply were not &quot;SSH&quot;. No SSH server running.
+  return -1;
 }
 
-int Services::checkFTP(int sock){
 
-	/*
-	 * Because the FTP protocol is very similar to the SMTP
-	 * protocol, we need to do some more checks.
-	 * We will check the first reply - If it begins with 220
-	 * there might be a FTP server running. Then we try to login.
-	 * If the next reply begins with 331, there is a very good
-	 * chance to have a FTP server.
-	 *
-	 */
+int Services::checkFTP(int sock)
+{
 
-	int ms = 1;
-	int len;
+  /*
+   * Because the FTP protocol is very similar to the SMTP
+   * protocol, we need to do some more checks.
+   * We will check the first reply - If it begins with 220
+   * there might be a FTP server running. Then we try to login.
+   * If the next reply begins with 331, there is a very good
+   * chance to have a FTP server.
+   *
+   */
 
-	Timer t;
-	t.startTimer();
+  int ms = 1;
+  int len;
+
+  Timer t;
+  t.startTimer();
 
   string reply;
 
-	// Read the answer.
-  if((reply = readWithTimeout(sock)) == &quot;err&quot;){
-    if(reply == &quot;err-con&quot;){
+  // Read the answer.
+  if((reply = readWithTimeout(sock)) == &quot;err&quot;)
+  {
+    if(reply == &quot;err-con&quot;)
+    {
       return -1;
-    }else if(reply == &quot;err-time&quot;){
+    }
+    else if(reply == &quot;err-time&quot;)
+    {
       return -2;
-    }else{
-		  return -3;
+    }
+    else
+    {
+      return -3;
     }
   }
 
-	ms = t.stopTimer();
+  ms = t.stopTimer();
 
-	// If the first three chars are &quot;220&quot;, there could be a FTP server running.
-	if(reply.substr(0,3) != &quot;220&quot;)
-		return -1;
+  // If the first three chars are &quot;220&quot;, there could be a FTP server running.
+  if(reply.substr(0,3) != &quot;220&quot;)
+    return -1;
 
-	len = 0;
+  len = 0;
   reply = &quot;&quot;;
 
-	// Try to login to make sure there is a FTP server running.
-	const char* testLoginMessage = &quot;USER scopeport-service-check\n&quot;;
+  // Try to login to make sure there is a FTP server running.
+  const char* testLoginMessage = &quot;USER scopeport-service-check\n&quot;;
 
-	// Send the quit message.
-	if((len = send(sock,testLoginMessage,strlen(testLoginMessage),0)) &lt;= 0)
-		return -1;
+  // Send the quit message.
+  if((len = send(sock,testLoginMessage,strlen(testLoginMessage),0)) &lt;= 0)
+    return -1;
 
-	// Read the answer.
-  if((reply = readWithTimeout(sock)) == &quot;err&quot;){
-    if(reply == &quot;err-con&quot;){
+  // Read the answer.
+  if((reply = readWithTimeout(sock)) == &quot;err&quot;)
+  {
+    if(reply == &quot;err-con&quot;)
+    {
       return -1;
-    }else if(reply == &quot;err-time&quot;){
+    }
+    else if(reply == &quot;err-time&quot;)
+    {
       return -2;
-    }else{
-		  return -3;
+    }
+    else
+    {
+      return -3;
     }
   }
 
-	// If the first three chars are &quot;331&quot;, there is a FTP server running.
-	if(reply.substr(0,3) != &quot;331&quot;)
-		return -1;
+  // If the first three chars are &quot;331&quot;, there is a FTP server running.
+  if(reply.substr(0,3) != &quot;331&quot;)
+    return -1;
 
-	const char* quitMessage = &quot;QUIT\n&quot;;
+  const char* quitMessage = &quot;QUIT\n&quot;;
 
-	// Send the quit message.
-	len = send(sock,quitMessage,strlen(quitMessage),0);
+  // Send the quit message.
+  len = send(sock,quitMessage,strlen(quitMessage),0);
 
-	// All tests performed. There is a FTP server running.
-	return ms;
+  // All tests performed. There is a FTP server running.
+  return ms;
 }
-</diff>
      <filename>src/services/Services.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -23,115 +23,115 @@
 #include &quot;../internal.h&quot;
 #include &quot;../database/Database.h&quot;
 
-class Services : public Database {
-	protected:
-		//! Holds login and connection information of MySQL database.
-		mySQLData dbData;
-
-	private:
-		unsigned int	handlerID;
-		unsigned int	serviceID;
-		unsigned int	port;
-		unsigned int	allowedFails;
-		int	m_responseTime1;
-		int	m_responseTime2;
-		int	responseTime;
-		int	maximumResponse;
-    	unsigned int  timeout;
-    	unsigned int  m_status;
-
-    	string 			host;
-		string 			serviceType;
-		string			notiGroup;
-		string			hostname;
-
-    	string readWithTimeout(int socket);
-
-	public:
-		Services(mySQLData myDBData, unsigned int myHandlerID);
-
-		void setServiceID(unsigned int serviceID);
-		void setAllowedFails(unsigned int allowedFails);
-		void setPort(unsigned int port);
-		void setMaximumResponse(unsigned int maxres);
-		void setHost(string host);
-		void setServiceType(string serviceType);
-		void setNotiGroup(string notiGroup);
-		void setHostname(string hostname);
-    	void setTimeout(unsigned int timeout);
-
-		unsigned int getServiceID();
-		unsigned int getHandlerID();
-		int getMaximumResponse();
-    	unsigned int getTimeout();
-    	int getFirstResponseTime();
-    	int getSecondResponseTime();
-
-    	bool updateSettings();
-
-		int checkService(int run);
-
-		void updateStatus(int status);
-
-		//! Checks if the response time of a service is in range.
-		/*!
-		 * \returns True if the response time is in range, false if not.
-		 */
-		bool checkResponseTime();
-
-    	bool buildAverageResponseTime();
-
-		//! Sends warning if service has failed
-		void sendWarning();
-
-		//! Stores response time in database.
-		/*!
-		 * \param checkid The ID of the soft- or rudecheck
-		 * \param ms The response time to store
-		 */
-		bool storeResponseTime();
-
-		//! Check if there is an SMTP server behind given socket connection.
-		/*!
-		 * \param sock The socket to test on
-		 * \return 0 in case of error/wrong protocol or the response time in milliseconds if everything went fine
-		 */
-		int checkSMTP(int sock);
-
-		//! Check if there is an HTTP server behind given socket connection.
-		/*!
-		 * \param sock The socket to test on
-		 * \return 0 in case of error/wrong protocol or the response time in milliseconds if everything went fine
-		 */
-		int checkHTTP(int sock);
-
-		//! Check if there is an IMAP server behind given socket connection.
-		/*!
-		 * \param sock The socket to test on
-		 * \return 0 in case of error/wrong protocol or the response time in milliseconds if everything went fine
-		 */
-		int checkIMAP(int sock);
-
-		//! Check if there is an POP3 server behind given socket connection.
-		/*!
-		 * \param sock The socket to test on
-		 * \return 0 in case of error/wrong protocol or the response time in milliseconds if everything went fine
-		 */
-		int checkPOP3(int sock);
-
-		//! Check if there is an SSH server behind given socket connection.
-		/*!
-		 * \param sock The socket to test on
-		 * \return 0 in case of error/wrong protocol or the response time in milliseconds if everything went fine
-		 */
-		int checkSSH(int sock);
-
-		//! Check if there is an FTP server behind given socket connection.
-		/*!
-		 * \param sock The socket to test on
-		 * \return 0 in case of error/wrong protocol or the response time in milliseconds if everything went fine
-		 */
-		int checkFTP(int sock);
+class Services : public Database
+{
+  protected:
+    //! Holds login and connection information of MySQL database.
+    mySQLData dbData;
+
+  private:
+    unsigned int  handlerID;
+    unsigned int  serviceID;
+    unsigned int  port;
+    unsigned int  allowedFails;
+    int m_responseTime1;
+    int m_responseTime2;
+    int responseTime;
+    int maximumResponse;
+    unsigned int  timeout;
+    unsigned int  m_status;
+
+    string      host;
+    string      serviceType;
+    string      notiGroup;
+    string      hostname;
+
+    string readWithTimeout(int socket);
+
+  public:
+    Services(mySQLData myDBData, unsigned int myHandlerID);
+
+    void setServiceID(unsigned int serviceID);
+    void setAllowedFails(unsigned int allowedFails);
+    void setPort(unsigned int port);
+    void setMaximumResponse(unsigned int maxres);
+    void setHost(string host);
+    void setServiceType(string serviceType);
+    void setNotiGroup(string notiGroup);
+    void setHostname(string hostname);
+    void setTimeout(unsigned int timeout);
+
+    unsigned int getServiceID();
+    unsigned int getHandlerID();
+    int getMaximumResponse();
+    unsigned int getTimeout();
+    int getFirstResponseTime();
+    int getSecondResponseTime();
+
+    bool updateSettings();
+
+    int checkService(int run);
+
+    void updateStatus(int status);
+
+    //! Checks if the response time of a service is in range.
+    /*!
+     * \returns True if the response time is in range, false if not.
+     */
+    bool checkResponseTime();
+
+    bool buildAverageResponseTime();
+
+    //! Sends warning if service has failed
+    void sendWarning();
+
+    //! Stores response time in database.
+    /*!
+     * \param checkid The ID of the soft- or rudecheck
+     * \param ms The response time to store
+     */
+    bool storeResponseTime();
+
+    //! Check if there is an SMTP server behind given socket connection.
+    /*!
+     * \param sock The socket to test on
+     * \return 0 in case of error/wrong protocol or the response time in milliseconds if everything went fine
+     */
+    int checkSMTP(int sock);
+
+    //! Check if there is an HTTP server behind given socket connection.
+    /*!
+     * \param sock The socket to test on
+     * \return 0 in case of error/wrong protocol or the response time in milliseconds if everything went fine
+     */
+    int checkHTTP(int sock);
+
+    //! Check if there is an IMAP server behind given socket connection.
+    /*!
+     * \param sock The socket to test on
+     * \return 0 in case of error/wrong protocol or the response time in milliseconds if everything went fine
+     */
+    int checkIMAP(int sock);
+
+    //! Check if there is an POP3 server behind given socket connection.
+    /*!
+     * \param sock The socket to test on
+     * \return 0 in case of error/wrong protocol or the response time in milliseconds if everything went fine
+     */
+    int checkPOP3(int sock);
+
+    //! Check if there is an SSH server behind given socket connection.
+    /*!
+     * \param sock The socket to test on
+     * \return 0 in case of error/wrong protocol or the response time in milliseconds if everything went fine
+     */
+    int checkSSH(int sock);
+
+    //! Check if there is an FTP server behind given socket connection.
+    /*!
+     * \param sock The socket to test on
+     * \return 0 in case of error/wrong protocol or the response time in milliseconds if everything went fine
+     */
+    int checkFTP(int sock);
 };
-
-#endif /*SERVICES_H_*/
+#endif                                            /*SERVICES_H_*/</diff>
      <filename>src/services/Services.h</filename>
    </modified>
    <modified>
      <diff>@@ -17,10 +17,13 @@
 
 #include &quot;fetchSNMP.h&quot;
 
-fetchSNMP::fetchSNMP(int mySocket){
-	socket = mySocket;
+fetchSNMP::fetchSNMP(int mySocket)
+{
+  socket = mySocket;
 }
 
-bool fetchSNMP::openSocket(){
-	return 0;
+
+bool fetchSNMP::openSocket()
+{
+  return 0;
 }</diff>
      <filename>src/snmp/fetchSNMP.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -18,13 +18,13 @@
 #ifndef FETCHSNMP_H_
 #define FETCHSNMP_H_
 
-class fetchSNMP{
-	private:
-		int	port;
-		int	socket;
-	public:
-		fetchSNMP(int mySocket);
-		bool openSocket();
+class fetchSNMP
+{
+  private:
+    int port;
+    int socket;
+  public:
+    fetchSNMP(int mySocket);
+    bool openSocket();
 };
-
-#endif /*FETCHSNMP_H_*/
+#endif                                            /*FETCHSNMP_H_*/</diff>
      <filename>src/snmp/fetchSNMP.h</filename>
    </modified>
    <modified>
      <diff>@@ -28,22 +28,22 @@
 //
 //bool spreadSNMP::openSocket(){
 //	if((servSock = socket(AF_INET, SOCK_STREAM, 0)) == -1){
-//		// Socket could not be created.  
+//		// Socket could not be created.
 //		return 0;
 //	}else{
-//		// Socket created.  
+//		// Socket created.
 //		setsockopt(servSock, SOL_SOCKET, SO_REUSEADDR, 0, sizeof(int));
 //		address.sin_family = AF_INET;
-//		// On which IPs to listen (INADDR_ANY -&gt; any IP).  
+//		// On which IPs to listen (INADDR_ANY -&gt; any IP).
 //		address.sin_addr.s_addr = INADDR_ANY;
-//		// On which port to listen.  
+//		// On which port to listen.
 //		int port = 12201;
 //		address.sin_port = htons(port);
 //		if(bind(servSock,(struct sockaddr *) &amp;address,sizeof (address)) != 0) {
-//			// Could not bind to socket.  
+//			// Could not bind to socket.
 //			return 0;
 //		}else{
-//			// Bound to socket! Listen.  
+//			// Bound to socket! Listen.
 //			listen(servSock, 50);
 //			return 1;
 //		}
@@ -63,12 +63,12 @@
 //}
 //
 //const char* spreadSNMP::fetchMessage(int snmpid){
-//	// Prepare database connection.  
+//	// Prepare database connection.
 //	Database db(dbData);
-//	// Initialize database connection.  
+//	// Initialize database connection.
 //	if(db.initConnection()){
 //		MYSQL* init = db.getHandle();
-//		// Get all enabled rudechecks.  
+//		// Get all enabled rudechecks.
 //		stringstream query;
 //		query &lt;&lt; &quot;SELECT snmpdevices.address, snmpitems.ID, snmpitems.item &quot;
 //				&quot;FROM snmpitems &quot;
@@ -77,11 +77,11 @@
 //				&quot;WHERE snmpclients.ID = &quot; &lt;&lt; snmpid;
 //
 //		if(mysql_real_query(init, query.str().c_str(), strlen(query.str().c_str())) != 0){
-//			// Query was not successful.  
+//			// Query was not successful.
 //			mysql_close(init);
 //			return &quot;err&quot;;
 //		}else{
-//			// Query successful.  
+//			// Query successful.
 //			MYSQL_RES* res = mysql_store_result(init);
 //			MYSQL_ROW row;
 //			stringstream message;
@@ -95,14 +95,14 @@
 //					        	&lt;&lt; &quot;|&quot;;
 //				}
 //			}else{
-//				// There are no services in the database.  
+//				// There are no services in the database.
 //				mysql_free_result(res);
 //				mysql_close(init);
 //				return &quot;err&quot;;
 //			}
 //			mysql_free_result(res);
 //			mysql_close(init);
-//			// Return result.  
+//			// Return result.
 //			return message.str().c_str();
 //		}
 //	}
@@ -110,25 +110,25 @@
 //}
 //
 //bool spreadSNMP::serveSNMP(int clntSock){
-//	
+//
 //	Log log(LOGFILE, dbData);
 //
 //	char buffer[1024] = &quot;&quot;;
-//	
-//	// Init TLS session.  
+//
+//	// Init TLS session.
 //	gnutls_session_t session;
 //	gnutls_init(&amp;session, GNUTLS_SERVER);
 //	gnutls_priority_set_direct(session, &quot;NORMAL:+ANON-DH&quot;, NULL);
 //	gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred);
 //	gnutls_dh_set_prime_bits(session, DH_BITS);
 //	gnutls_transport_set_ptr(session, (gnutls_transport_ptr_t) clntSock);
-//	
-//	// Do TLS handshake.  
+//
+//	// Do TLS handshake.
 //	int ret = gnutls_handshake(session);
-//			
-//	// Did the handshake succeed?  
+//
+//	// Did the handshake succeed?
 //	if(ret &lt; 0){
-//		// No.  
+//		// No.
 //		gnutls_deinit(session);
 //		stringstream shakeError;
 //		shakeError	&lt;&lt; &quot;SNMP: TLS handshake with host &quot;
@@ -138,28 +138,28 @@
 //		close(clntSock);
 //		return 0;
 //	}
-//			
-//	// TLS handshake completed.  
-//	
-//	// Get request.  
-//	
+//
+//	// TLS handshake completed.
+//
+//	// Get request.
+//
 //	ret = gnutls_record_recv(session, buffer, 1024);
-//	
+//
 //	istringstream iss;
 //	int snmpid = 0;
 //	iss.str(buffer);
 //	iss &gt;&gt; snmpid;
-//	
+//
 //	const char* message = fetchMessage(snmpid);
-//	
+//
 //	if(strcmp(message,&quot;err&quot; ) == 0){
 //		close(clntSock);
 //		return 0;
 //	}
-//	
-//	// Send reply.  
+//
+//	// Send reply.
 //	gnutls_record_send(session, message, strlen(message));
-//		
+//
 //	gnutls_bye (session, GNUTLS_SHUT_RDWR);
 //	gnutls_deinit(session);
 //	gnutls_anon_free_server_credentials(anoncred);</diff>
      <filename>src/snmp/spreadSNMP.cpp</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>71f9a211547917e757085ac24d5b918aa3b00f0e</id>
    </parent>
  </parents>
  <author>
    <name>Lennart Koopmann</name>
    <email>lennart@sundaysister.(none)</email>
  </author>
  <url>http://github.com/lennartkoopmann/scopeport-server/commit/05024a6eb8f34edf8289804b512b87d6b6405042</url>
  <id>05024a6eb8f34edf8289804b512b87d6b6405042</id>
  <committed-date>2009-10-22T16:44:29-07:00</committed-date>
  <authored-date>2009-10-22T16:44:29-07:00</authored-date>
  <message>Fixed indention and code style of all files</message>
  <tree>0897b4256a660d2fa1896517d3cc20f97b5f92db</tree>
  <committer>
    <name>Lennart Koopmann</name>
    <email>lennart@sundaysister.(none)</email>
  </committer>
</commit>
