From 974b92f7589380ae232644e2dcbcc9e3e32db167 Mon Sep 17 00:00:00 2001
From: Tristan Matthews <tristan.matthews@savoirfairelinux.com>
Date: Thu, 2 Jun 2011 12:06:10 -0400
Subject: [PATCH] * #5998: removed "using namespace std" from
 ZrtpSessionCallback

---
 .../audio/audiortp/ZrtpSessionCallback.cpp    | 105 +++++++++---------
 .../src/audio/audiortp/ZrtpSessionCallback.h  |   4 +-
 2 files changed, 54 insertions(+), 55 deletions(-)

diff --git a/sflphone-common/src/audio/audiortp/ZrtpSessionCallback.cpp b/sflphone-common/src/audio/audiortp/ZrtpSessionCallback.cpp
index 870eb42e80..7849c8a11d 100644
--- a/sflphone-common/src/audio/audiortp/ZrtpSessionCallback.cpp
+++ b/sflphone-common/src/audio/audiortp/ZrtpSessionCallback.cpp
@@ -37,19 +37,20 @@
 #include <cstdlib>
 #include <string>
 #include <map>
+#include <utility> // for std::pair
 
 using namespace GnuZrtpCodes;
 
 using namespace ost;
 
-using namespace std;
-
 namespace sfl
 {
 
 ZrtpSessionCallback::ZrtpSessionCallback (SIPCall *sipcall) :
     _sipcall (sipcall)
 {
+    using std::pair;
+    using std::string;
 
     if (_mapInitialized) {
         return;
@@ -61,63 +62,63 @@ ZrtpSessionCallback::ZrtpSessionCallback (SIPCall *sipcall) :
      * Information Map
      */
 
-    _infoMap.insert (pair<int32, std::string*> (InfoHelloReceived, new string ("Hello received, preparing a Commit")));
-    _infoMap.insert (pair<int32, std::string*> (InfoCommitDHGenerated, new string ("Commit: Generated a public DH key")));
-    _infoMap.insert (pair<int32, std::string*> (InfoRespCommitReceived, new string ("Responder: Commit received, preparing DHPart1")));
-    _infoMap.insert (pair<int32, std::string*> (InfoDH1DHGenerated, new string ("DH1Part: Generated a public DH key")));
-    _infoMap.insert (pair<int32, std::string*> (InfoInitDH1Received, new string ("Initiator: DHPart1 received, preparing DHPart2")));
-    _infoMap.insert (pair<int32, std::string*> (InfoRespDH2Received, new string ("Responder: DHPart2 received, preparing Confirm1")));
-    _infoMap.insert (pair<int32, std::string*> (InfoInitConf1Received, new string ("Initiator: Confirm1 received, preparing Confirm2")));
-    _infoMap.insert (pair<int32, std::string*> (InfoRespConf2Received, new string ("Responder: Confirm2 received, preparing Conf2Ack")));
-    _infoMap.insert (pair<int32, std::string*> (InfoRSMatchFound, new string ("At least one retained secrets matches - security OK")));
-    _infoMap.insert (pair<int32, std::string*> (InfoSecureStateOn, new string ("Entered secure state")));
-    _infoMap.insert (pair<int32, std::string*> (InfoSecureStateOff, new string ("No more security for this session")));
+    _infoMap.insert (pair<int32, string*> (InfoHelloReceived, new string ("Hello received, preparing a Commit")));
+    _infoMap.insert (pair<int32, string*> (InfoCommitDHGenerated, new string ("Commit: Generated a public DH key")));
+    _infoMap.insert (pair<int32, string*> (InfoRespCommitReceived, new string ("Responder: Commit received, preparing DHPart1")));
+    _infoMap.insert (pair<int32, string*> (InfoDH1DHGenerated, new string ("DH1Part: Generated a public DH key")));
+    _infoMap.insert (pair<int32, string*> (InfoInitDH1Received, new string ("Initiator: DHPart1 received, preparing DHPart2")));
+    _infoMap.insert (pair<int32, string*> (InfoRespDH2Received, new string ("Responder: DHPart2 received, preparing Confirm1")));
+    _infoMap.insert (pair<int32, string*> (InfoInitConf1Received, new string ("Initiator: Confirm1 received, preparing Confirm2")));
+    _infoMap.insert (pair<int32, string*> (InfoRespConf2Received, new string ("Responder: Confirm2 received, preparing Conf2Ack")));
+    _infoMap.insert (pair<int32, string*> (InfoRSMatchFound, new string ("At least one retained secrets matches - security OK")));
+    _infoMap.insert (pair<int32, string*> (InfoSecureStateOn, new string ("Entered secure state")));
+    _infoMap.insert (pair<int32, string*> (InfoSecureStateOff, new string ("No more security for this session")));
 
     /**
      * Warning Map
      */
 
-    _warningMap.insert (pair<int32, std::string*> (WarningDHAESmismatch,
+    _warningMap.insert (pair<int32, string*> (WarningDHAESmismatch,
                         new string ("Commit contains an AES256 cipher but does not offer a Diffie-Helman 4096")));
-    _warningMap.insert (pair<int32, std::string*> (WarningGoClearReceived, new string ("Received a GoClear message")));
-    _warningMap.insert (pair<int32, std::string*> (WarningDHShort,
+    _warningMap.insert (pair<int32, string*> (WarningGoClearReceived, new string ("Received a GoClear message")));
+    _warningMap.insert (pair<int32, string*> (WarningDHShort,
                         new string ("Hello offers an AES256 cipher but does not offer a Diffie-Helman 4096")));
-    _warningMap.insert (pair<int32, std::string*> (WarningNoRSMatch, new string ("No retained secret matches - verify SAS")));
-    _warningMap.insert (pair<int32, std::string*> (WarningCRCmismatch, new string ("Internal ZRTP packet checksum mismatch - packet dropped")));
-    _warningMap.insert (pair<int32, std::string*> (WarningSRTPauthError, new string ("Dropping packet because SRTP authentication failed!")));
-    _warningMap.insert (pair<int32, std::string*> (WarningSRTPreplayError, new string ("Dropping packet because SRTP replay check failed!")));
-
-    _severeMap.insert (pair<int32, std::string*> (SevereHelloHMACFailed, new string ("Hash HMAC check of Hello failed!")));
-    _severeMap.insert (pair<int32, std::string*> (SevereCommitHMACFailed, new string ("Hash HMAC check of Commit failed!")));
-    _severeMap.insert (pair<int32, std::string*> (SevereDH1HMACFailed, new string ("Hash HMAC check of DHPart1 failed!")));
-    _severeMap.insert (pair<int32, std::string*> (SevereDH2HMACFailed, new string ("Hash HMAC check of DHPart2 failed!")));
-    _severeMap.insert (pair<int32, std::string*> (SevereCannotSend, new string ("Cannot send data - connection or peer down?")));
-    _severeMap.insert (pair<int32, std::string*> (SevereProtocolError, new string ("Internal protocol error occured!")));
-    _severeMap.insert (pair<int32, std::string*> (SevereNoTimer, new string ("Cannot start a timer - internal resources exhausted?")));
-    _severeMap.insert (pair<int32, std::string*> (SevereTooMuchRetries,
+    _warningMap.insert (pair<int32, string*> (WarningNoRSMatch, new string ("No retained secret matches - verify SAS")));
+    _warningMap.insert (pair<int32, string*> (WarningCRCmismatch, new string ("Internal ZRTP packet checksum mismatch - packet dropped")));
+    _warningMap.insert (pair<int32, string*> (WarningSRTPauthError, new string ("Dropping packet because SRTP authentication failed!")));
+    _warningMap.insert (pair<int32, string*> (WarningSRTPreplayError, new string ("Dropping packet because SRTP replay check failed!")));
+
+    _severeMap.insert (pair<int32, string*> (SevereHelloHMACFailed, new string ("Hash HMAC check of Hello failed!")));
+    _severeMap.insert (pair<int32, string*> (SevereCommitHMACFailed, new string ("Hash HMAC check of Commit failed!")));
+    _severeMap.insert (pair<int32, string*> (SevereDH1HMACFailed, new string ("Hash HMAC check of DHPart1 failed!")));
+    _severeMap.insert (pair<int32, string*> (SevereDH2HMACFailed, new string ("Hash HMAC check of DHPart2 failed!")));
+    _severeMap.insert (pair<int32, string*> (SevereCannotSend, new string ("Cannot send data - connection or peer down?")));
+    _severeMap.insert (pair<int32, string*> (SevereProtocolError, new string ("Internal protocol error occured!")));
+    _severeMap.insert (pair<int32, string*> (SevereNoTimer, new string ("Cannot start a timer - internal resources exhausted?")));
+    _severeMap.insert (pair<int32, string*> (SevereTooMuchRetries,
                        new string ("Too much retries during ZRTP negotiation - connection or peer down?")));
 
     /**
      * Zrtp protocol related messages map
      */
 
-    _zrtpMap.insert (pair<int32, std::string*> (MalformedPacket, new string ("Malformed packet (CRC OK, but wrong structure)")));
-    _zrtpMap.insert (pair<int32, std::string*> (CriticalSWError, new string ("Critical software error")));
-    _zrtpMap.insert (pair<int32, std::string*> (UnsuppZRTPVersion, new string ("Unsupported ZRTP version")));
-    _zrtpMap.insert (pair<int32, std::string*> (HelloCompMismatch, new string ("Hello components mismatch")));
-    _zrtpMap.insert (pair<int32, std::string*> (UnsuppHashType, new string ("Hash type not supported")));
-    _zrtpMap.insert (pair<int32, std::string*> (UnsuppCiphertype, new string ("Cipher type not supported")));
-    _zrtpMap.insert (pair<int32, std::string*> (UnsuppPKExchange, new string ("Public key exchange not supported")));
-    _zrtpMap.insert (pair<int32, std::string*> (UnsuppSRTPAuthTag, new string ("SRTP auth. tag not supported")));
-    _zrtpMap.insert (pair<int32, std::string*> (UnsuppSASScheme, new string ("SAS scheme not supported")));
-    _zrtpMap.insert (pair<int32, std::string*> (NoSharedSecret, new string ("No shared secret available, DH mode required")));
-    _zrtpMap.insert (pair<int32, std::string*> (DHErrorWrongPV, new string ("DH Error: bad pvi or pvr ( == 1, 0, or p-1)")));
-    _zrtpMap.insert (pair<int32, std::string*> (DHErrorWrongHVI, new string ("DH Error: hvi != hashed data")));
-    _zrtpMap.insert (pair<int32, std::string*> (SASuntrustedMiTM, new string ("Received relayed SAS from untrusted MiTM")));
-    _zrtpMap.insert (pair<int32, std::string*> (ConfirmHMACWrong, new string ("Auth. Error: Bad Confirm pkt HMAC")));
-    _zrtpMap.insert (pair<int32, std::string*> (NonceReused, new string ("Nonce reuse")));
-    _zrtpMap.insert (pair<int32, std::string*> (EqualZIDHello, new string ("Equal ZIDs in Hello")));
-    _zrtpMap.insert (pair<int32, std::string*> (GoCleatNotAllowed, new string ("GoClear packet received, but not allowed")));
+    _zrtpMap.insert (pair<int32, string*> (MalformedPacket, new string ("Malformed packet (CRC OK, but wrong structure)")));
+    _zrtpMap.insert (pair<int32, string*> (CriticalSWError, new string ("Critical software error")));
+    _zrtpMap.insert (pair<int32, string*> (UnsuppZRTPVersion, new string ("Unsupported ZRTP version")));
+    _zrtpMap.insert (pair<int32, string*> (HelloCompMismatch, new string ("Hello components mismatch")));
+    _zrtpMap.insert (pair<int32, string*> (UnsuppHashType, new string ("Hash type not supported")));
+    _zrtpMap.insert (pair<int32, string*> (UnsuppCiphertype, new string ("Cipher type not supported")));
+    _zrtpMap.insert (pair<int32, string*> (UnsuppPKExchange, new string ("Public key exchange not supported")));
+    _zrtpMap.insert (pair<int32, string*> (UnsuppSRTPAuthTag, new string ("SRTP auth. tag not supported")));
+    _zrtpMap.insert (pair<int32, string*> (UnsuppSASScheme, new string ("SAS scheme not supported")));
+    _zrtpMap.insert (pair<int32, string*> (NoSharedSecret, new string ("No shared secret available, DH mode required")));
+    _zrtpMap.insert (pair<int32, string*> (DHErrorWrongPV, new string ("DH Error: bad pvi or pvr ( == 1, 0, or p-1)")));
+    _zrtpMap.insert (pair<int32, string*> (DHErrorWrongHVI, new string ("DH Error: hvi != hashed data")));
+    _zrtpMap.insert (pair<int32, string*> (SASuntrustedMiTM, new string ("Received relayed SAS from untrusted MiTM")));
+    _zrtpMap.insert (pair<int32, string*> (ConfirmHMACWrong, new string ("Auth. Error: Bad Confirm pkt HMAC")));
+    _zrtpMap.insert (pair<int32, string*> (NonceReused, new string ("Nonce reuse")));
+    _zrtpMap.insert (pair<int32, string*> (EqualZIDHello, new string ("Equal ZIDs in Hello")));
+    _zrtpMap.insert (pair<int32, string*> (GoCleatNotAllowed, new string ("GoClear packet received, but not allowed")));
 
     _mapInitialized = true;
 }
@@ -155,7 +156,7 @@ ZrtpSessionCallback::zrtpNotSuppOther()
 void
 ZrtpSessionCallback::showMessage (GnuZrtpCodes::MessageSeverity sev, int32_t subCode)
 {
-    string* msg;
+    std::string* msg;
 
     if (sev == Info) {
         msg = _infoMap[subCode];
@@ -199,7 +200,7 @@ ZrtpSessionCallback::showMessage (GnuZrtpCodes::MessageSeverity sev, int32_t sub
 void
 ZrtpSessionCallback::zrtpNegotiationFailed (MessageSeverity severity, int subCode)
 {
-    string* msg;
+    std::string* msg;
 
     if (severity == ZrtpError) {
         if (subCode < 0) {  // received an error packet from peer
@@ -229,10 +230,10 @@ ZrtpSessionCallback::confirmGoClear()
     DBusManager::instance().getCallManager()->zrtpNotSuppOther (_sipcall->getCallId());
 }
 
-map<int32, std::string*>ZrtpSessionCallback::_infoMap;
-map<int32, std::string*>ZrtpSessionCallback::_warningMap;
-map<int32, std::string*>ZrtpSessionCallback::_severeMap;
-map<int32, std::string*>ZrtpSessionCallback::_zrtpMap;
+std::map<int32, std::string*>ZrtpSessionCallback::_infoMap;
+std::map<int32, std::string*>ZrtpSessionCallback::_warningMap;
+std::map<int32, std::string*>ZrtpSessionCallback::_severeMap;
+std::map<int32, std::string*>ZrtpSessionCallback::_zrtpMap;
 
 bool ZrtpSessionCallback::_mapInitialized = false;
 }
diff --git a/sflphone-common/src/audio/audiortp/ZrtpSessionCallback.h b/sflphone-common/src/audio/audiortp/ZrtpSessionCallback.h
index 24d6194d35..2fad01eed4 100644
--- a/sflphone-common/src/audio/audiortp/ZrtpSessionCallback.h
+++ b/sflphone-common/src/audio/audiortp/ZrtpSessionCallback.h
@@ -31,8 +31,6 @@
 #ifndef __SFL_ZRTP_CALLBACK_H__
 #define __SFL_ZRTP_CALLBACK_H__
 
-using namespace std;
-
 #include <libzrtpcpp/zrtpccrtp.h>
 #include <libzrtpcpp/ZrtpQueue.h>
 #include <libzrtpcpp/ZrtpUserCallback.h>
@@ -67,7 +65,7 @@ class ZrtpSessionCallback: public ZrtpUserCallback
 
     private:
         SIPCall* _sipcall;
-
+        /* FIXME: why are these strings dynamically allocated? */
         static std::map<int32, std::string*> _infoMap;
         static std::map<int32, std::string*> _warningMap;
         static std::map<int32, std::string*> _severeMap;
-- 
GitLab