Index: code/branches/tutoriallevel2/src/orxonox/interfaces/NotificationListener.cc
===================================================================
--- code/branches/tutoriallevel2/src/orxonox/interfaces/NotificationListener.cc	(revision 8378)
+++ code/branches/tutoriallevel2/src/orxonox/interfaces/NotificationListener.cc	(revision 8445)
@@ -35,4 +35,5 @@
 #include "network/Host.h"
 #include "network/NetworkFunction.h"
+#include "util/SubString.h"
 
 #include "interfaces/NotificationListener.h"
@@ -41,9 +42,11 @@
 {
     
-    const std::string NotificationListener::ALL("all");
-    const std::string NotificationListener::NONE("none");
+    /*static*/ const std::string NotificationListener::ALL("all");
+    /*static*/ const std::string NotificationListener::NONE("none");
     
-    registerStaticNetworkFunction(NotificationListener::sendNotificationHelper);
+    // Commands
+    /*static*/ const std::string NotificationListener::COMMAND_CLEAR("clear");
     
+    registerStaticNetworkFunction(NotificationListener::sendHelper);
     
     NotificationListener::NotificationListener()
@@ -54,46 +57,84 @@
     /**
     @brief
-        Sends a Notification with the specified message to the specified client from the specified sender.
+        Helper method to send both notifications and commands over the network.
     @param message
-        The message that should be sent.
+        The message/command that should be sent.
     @param sender
-        The sender that sent the notification.
-    @param messageMode
-        The mode of the message, can be either 'message' or 'command'.
+        The sender that sent the notification/command.
     @param sendMode
-        The mode in which the notification is sent, can be 'local' to send the notification to the client where this function is executed, 'network' if the notification is to be sent to the client with the specified clientID, or 'broadcast' if the notification should be sent to all hosts.
+        The mode in which the notification/command is sent, can be 'local' to send the notification to the client where this function is executed, 'network' if the notification is to be sent to the client with the specified clientID, or 'broadcast' if the notification should be sent to all hosts.
     @param clientId
-        The id of the client the notification should be sent to.
+        The id of the client the notification/command should be sent to.
+    @param isCommand
+        Whether the message is a notification or a command.
+    @param messageType
+        The type of the notification, can be either 'info' or 'important'.
     */
-    /*static*/ void NotificationListener::sendNotification(const std::string& message, const std::string& sender, notificationMessageMode::Value messageMode, notificationSendMode::Value sendMode, unsigned int clientId)
+    /*static*/ void NotificationListener::sendNetworkHelper(const std::string& message, const std::string& sender, notificationSendMode::Value sendMode, unsigned int clientId, bool isCommand, notificationMessageType::Value messageType)
     {
-        // If we're in standalone mode or we're already no the right client we create and send the Notification.
+        // If we're in standalone mode or we're already no the right client we create and send the notification/command.
         if(GameMode::isStandalone() || sendMode == notificationSendMode::local || (sendMode ==  notificationSendMode::network && Host::getPlayerID() == clientId))
         {
-            sendNotificationHelper(message, sender, messageMode);
+            sendHelper(message, sender, isCommand, messageType);
         }
-        // If we're on the server (and the server is not the intended recipient of the Notification) we send it over the network.
+        // If we're on the server (and the server is not the intended recipient of the notification/command) we send it over the network.
         else if(GameMode::isServer() && sendMode == notificationSendMode::network && Host::getPlayerID() != clientId)
         {
-            callStaticNetworkFunction(NotificationListener::sendNotificationHelper, clientId, message, sender, (unsigned int)messageMode);
+            callStaticNetworkFunction(NotificationListener::sendHelper, clientId, message, sender, (unsigned int)messageType);
         }
         else if(GameMode::isServer() && sendMode == notificationSendMode::broadcast)
         {
             // TODO: Works as intended?
-            callStaticNetworkFunction(NotificationListener::sendNotificationHelper, NETWORK_PEER_ID_BROADCAST, message, sender, (unsigned int)messageMode);
+            callStaticNetworkFunction(NotificationListener::sendHelper, NETWORK_PEER_ID_BROADCAST, message, sender, (unsigned int)messageType);
         }
     }
-    
-    /*static*/ void NotificationListener::sendNotificationHelper(const std::string& message, const std::string& sender, unsigned int messageMode)
+
+    /**
+    @brief
+        Helper method to register a notification/execute a command with all NotificationListeners after it has been sent over the network.
+    @param message
+        The notification/command to be sent/executed.
+    @param sender
+        The sender that sent the notification/command.
+    @param isCommand
+        Whether the message is a command or a notification.
+    @param messageType
+        The type of the notification.
+    */
+    /*static*/ void NotificationListener::sendHelper(const std::string& message, const std::string& sender, bool isCommand, unsigned int messageType)
     {
         // Iterate through all NotificationListeners and notify them by calling the method they overloaded.
         for(ObjectList<NotificationListener>::iterator it = ObjectList<NotificationListener>::begin(); it != ObjectList<NotificationListener>::end(); ++it)
         {
-            if(messageMode == 0 && it->registerNotification(message, sender))
+            // If the notification is a message.
+            if(!isCommand && it->registerNotification(message, sender, notificationMessageType::Value(messageType)))
                 COUT(3) << "Notification \"" << message << "\" sent." << std::endl;
-            
-            if(messageMode == 1)
-                it->executeCommand(message, sender);
+
+            // If the notification is a command.
+            if(isCommand)
+            {
+                notificationCommand::Value command = str2Command(message);
+                if(command != notificationCommand::none && it->executeCommand(command, sender))
+                    COUT(3) << "Command \"" << message << "\" executed." << std::endl;
+            }
         }
+    }
+
+    /**
+    @brief
+        Helper method. Converts a string into the enum for a command.
+    @param string
+        The string to be converted.
+    @return
+        Returns the corresponding enum, notificationCommand::none if the command doesn't exist.
+    */
+    /*static*/ notificationCommand::Value NotificationListener::str2Command(const std::string& string)
+    {
+        notificationCommand::Value command = notificationCommand::none;
+
+        if(string == NotificationListener::COMMAND_CLEAR)
+            command = notificationCommand::clear;
+
+        return command;
     }
     
Index: code/branches/tutoriallevel2/src/orxonox/interfaces/NotificationListener.h
===================================================================
--- code/branches/tutoriallevel2/src/orxonox/interfaces/NotificationListener.h	(revision 8378)
+++ code/branches/tutoriallevel2/src/orxonox/interfaces/NotificationListener.h	(revision 8445)
@@ -48,10 +48,10 @@
 namespace orxonox
 {
-    
-    namespace notificationMessageMode
+    // TODO: Document.
+    namespace notificationMessageType
     {
         enum Value {
-            message,
-            command
+            info,
+            important
         };
     }
@@ -65,4 +65,12 @@
         };
     }
+    
+    namespace notificationCommand
+    {
+        enum Value {
+            none,
+            clear
+        };
+    }
 
     // TODO: Update doc.
@@ -71,6 +79,8 @@
         NotificationListener interface.
 
-        The NotificationListener interface presents a means to being informed when @ref orxonox::Notification "Notifications" in the target set of this NotificationListener change. (e.g. @ref orxonox::Notification "Notifications" were added or removed)
-        When inheriting from a NotificationListener it is important to register (in the constructor) and unregister (in the destructor) it to and from the @ref orxonox::NotificationManager "NotificationManager".
+        The NotificationListener interface (or more precisely abstract class) presents a means of being informed when a new @ref orxonox::Notification "Notification" is sent.
+        The NotificationListener can be used to send a new notification message (with NotificationListener::sendNotification() ) or a new notification command (with NotificationListener::sendCommand() ). Each NotificationListener is then informed about the new @ref orxonox::Notification "Notification" and can take appropriate action. Currently the only NotificationListener ist the @ref orxonox::NotificationManager "NotificationManager" singleton.
+
+        When inheriting from a NotificationListener it is important to provide an appropriate implementation of registerNotification() and executeCommand().
 
     @author
@@ -78,4 +88,5 @@
         
     @ingroup Notifications
+    @todo Consistent terminology between message, notification and command.
     */
     class _OrxonoxExport NotificationListener : virtual public OrxonoxClass
@@ -84,13 +95,58 @@
             NotificationListener();
             virtual ~NotificationListener() {}
+
+            /**
+            @brief Sends a Notification with the specified message to the specified client from the specified sender.
+            @param message The message that should be sent.
+            @param sender The sender that sent the notification. Default is 'none'.
+            @param messageType The type of the message, can be either 'info' or 'important'. Default is 'info'.
+            @param sendMode The mode in which the notification is sent, can be 'local' to send the notification to the client where this function is executed, 'network' if the notification is to be sent to the client with the specified clientID, or 'broadcast' if the notification should be sent to all hosts. Default is notificationSendMode::local.
+            @param clientId The id of the client the notification should be sent to. Default is 0.
+            */
+            static void sendNotification(const std::string& message, const std::string& sender = NotificationListener::NONE, notificationMessageType::Value messageType = notificationMessageType::info, notificationSendMode::Value sendMode = notificationSendMode::local, unsigned int clientId = 0)
+                { NotificationListener::sendNetworkHelper(message, sender, sendMode, clientId, false, messageType); }
+            /**
+            @brief Sends a specified command to the specified client from the specified sender.
+            @param message The command that should be sent (and later executed).
+            @param sender The sender that sent the notification. Default is 'none'.
+            @param sendMode The mode in which the command is sent, can be 'local' to send the command to the client where this function is executed, 'network' if the command is to be sent to the client with the specified clientID, or 'broadcast' if the command should be sent to all hosts. Default is notificationSendMode::local.
+            @param clientId The id of the client the command should be sent to. Default is 0.
+            */
+            static void sendCommand(const std::string& command, const std::string& sender = NotificationListener::NONE, notificationSendMode::Value sendMode = notificationSendMode::local, unsigned int clientId = 0)
+                { NotificationListener::sendNetworkHelper(command, sender, sendMode, clientId, true); }
+
+            static void sendHelper(const std::string& message, const std::string& sender, bool isCommand = false, unsigned int messageMode = 0); // Helper method to register a notification/execute a command with all NotificationListeners after it has been sent over the network.
+
+            //TODO: Make protected?
             
-            static const std::string ALL; //!< Static string to indicate a sender that sends to all NotificationListeners.
-            static const std::string NONE; //!< Static string to indicare a sender that sends to no specific NotificationListener.
+            /**
+            @brief Registers a notification with the NotificationListener.
+                   This needs to be overloaded by each class inheriting from NotificationListener.
+            @param message The notification's message.
+            @param sender The sender of the notification.
+            @param type The type of the notification.
+            @return Returns true if the notification was successfully registered, false if not.
+            */
+            virtual bool registerNotification(const std::string& message, const std::string& sender, notificationMessageType::Value type)
+                { return false; }
+            /**
+            @brief Executes a command with the NotificationListener
+                   This needs to be overloaded by each class inheriting from NotificationListener.
+            @param command The command to be executed.
+            @param sender The sender of the command.
+            @return Returns true if the command was successfully executed, false if not.
+            */
+            virtual bool executeCommand(notificationCommand::Value command, const std::string& sender) { return false; }
             
-            static void sendNotification(const std::string& message, const std::string& sender = NotificationListener::NONE, notificationMessageMode::Value messageMode = notificationMessageMode::message, notificationSendMode::Value sendMode = notificationSendMode::local, unsigned int clientId = 0);
-            static void sendNotificationHelper(const std::string& message, const std::string& sender, unsigned int messageMode);
+            static const std::string ALL; //!< Static string to indicate a sender that sends to all NotificationQueues.
+            static const std::string NONE; //!< Static string to indicate a sender that sends to no specific NotificationQueues.
             
-            virtual bool registerNotification(const std::string& message, const std::string& sender) { return false; }
-            virtual void executeCommand(const std::string& command, const std::string& sender) {}
+            //! Commands
+            static const std::string COMMAND_CLEAR;
+            
+        protected:
+            static void sendNetworkHelper(const std::string& message, const std::string& sender, notificationSendMode::Value sendMode, unsigned int clientId, bool isCommand = false, notificationMessageType::Value messageType = notificationMessageType::info); // Helper method to send both notifications and commands over the network.
+            
+            static notificationCommand::Value str2Command(const std::string& string); // Helper method. Converts a string into the enum for a command.
     };
 }
