Skip to content
Snippets Groups Projects
Commit b8cb297d authored by Rafaël Carré's avatar Rafaël Carré
Browse files

macroify SIPAccount::unserialize()

parent 16274a0d
No related branches found
No related tags found
No related merge requests found
...@@ -293,211 +293,105 @@ void SIPAccount::unserialize (Conf::MappingNode *map) ...@@ -293,211 +293,105 @@ void SIPAccount::unserialize (Conf::MappingNode *map)
assert(map); assert(map);
val = (Conf::ScalarNode *) (map->getValue (aliasKey)); #define GETKEY(map, var, key) do { \
if (val) val = (Conf::ScalarNode *) (map->getValue (key)); \
_alias = val->getValue(); if (val) \
var = val->getValue(); \
val = (Conf::ScalarNode *) (map->getValue (typeKey)); } while(0)
if (val) #define GETBOOL(map, var, key) do { \
_type = val->getValue(); val = (Conf::ScalarNode *) (map->getValue (key)); \
if (val) \
val = (Conf::ScalarNode *) (map->getValue (idKey)); var = !val->getValue().compare("true"); \
if (val) } while(0)
_accountID = val->getValue(); #define GETINT(map, var, key) do { \
val = (Conf::ScalarNode *) (map->getValue (key)); \
val = (Conf::ScalarNode *) (map->getValue (usernameKey)); if (val) \
if (val) var = atoi(val->getValue().data()); \
_username = val->getValue(); } while(0)
val = (Conf::ScalarNode *) (map->getValue (passwordKey)); GETKEY(map, _alias, aliasKey);
if (val) GETKEY(map, _type, typeKey);
_password = val->getValue(); GETKEY(map, _accountID, idKey);
GETKEY(map, _username, usernameKey);
val = (Conf::ScalarNode *) (map->getValue (hostnameKey)); GETKEY(map, _password, passwordKey);
if (val) GETKEY(map, _hostname, hostnameKey);
_hostname = val->getValue(); GETBOOL(map, _enabled, accountEnableKey);
GETKEY(map, _mailBox, mailboxKey);
val = (Conf::ScalarNode *) (map->getValue (accountEnableKey)); GETKEY(map, _codecStr, codecsKey);
if (val)
_enabled = (val->getValue() != "false");
val = (Conf::ScalarNode *) (map->getValue (mailboxKey));
if (val)
_mailBox = val->getValue();
val = (Conf::ScalarNode *) (map->getValue (codecsKey));
if (val)
_codecStr = val->getValue();
// Update codec list which one is used for SDP offer // Update codec list which one is used for SDP offer
setActiveCodecs (Manager::instance ().unserialize (_codecStr)); setActiveCodecs (Manager::instance ().unserialize (_codecStr));
val = (Conf::ScalarNode *) (map->getValue (ringtonePathKey)); GETKEY(map, _ringtonePath, ringtonePathKey);
if (val) GETBOOL(map, _ringtoneEnabled, ringtoneEnabledKey);
_ringtonePath = val->getValue(); GETKEY(map, _registrationExpire, expireKey);
GETKEY(map, _interface, interfaceKey);
val = (Conf::ScalarNode *) (map->getValue (ringtoneEnabledKey)); GETINT(map, _localPort, portKey);
if (val) GETKEY(map, _publishedIpAddress, publishAddrKey);
_ringtoneEnabled = (val->getValue() == "true"); GETINT(map, _publishedPort, publishPortKey);
GETBOOL(map, _publishedSameasLocal, sameasLocalKey);
val = (Conf::ScalarNode *) (map->getValue (expireKey)); GETBOOL(map, _resolveOnce, resolveOnceKey);
if (val)
_registrationExpire = val->getValue();
val = (Conf::ScalarNode *) (map->getValue (interfaceKey));
if (val)
_interface = val->getValue();
val = (Conf::ScalarNode *) (map->getValue (portKey));
if (val)
_localPort = atoi (val->getValue().data());
val = (Conf::ScalarNode *) (map->getValue (publishAddrKey));
if (val)
_publishedIpAddress = val->getValue();
val = (Conf::ScalarNode *) (map->getValue (publishPortKey));
if (val)
_publishedPort = atoi (val->getValue().data());
val = (Conf::ScalarNode *) (map->getValue (sameasLocalKey));
if (val)
_publishedSameasLocal = (val->getValue().compare ("true") == 0);
val = (Conf::ScalarNode *) (map->getValue (resolveOnceKey));
if (val)
_resolveOnce = (val->getValue().compare ("true") == 0);
val = (Conf::ScalarNode *) (map->getValue (dtmfTypeKey)); val = (Conf::ScalarNode *) (map->getValue (dtmfTypeKey));
if (val) if (val)
_dtmfType = (val->getValue() == "overrtp") ? OVERRTP : SIPINFO; _dtmfType = (val->getValue() == "overrtp") ? OVERRTP : SIPINFO;
// _dtmfType = atoi(val->getValue(); // _dtmfType = atoi(val->getValue();
val = (Conf::ScalarNode *) (map->getValue (serviceRouteKey)); GETKEY(map, _serviceRoute, serviceRouteKey);
if (val)
_serviceRoute = val->getValue();
// stun enabled // stun enabled
val = (Conf::ScalarNode *) (map->getValue (stunEnabledKey)); GETBOOL(map, _stunEnabled, stunEnabledKey);
if (val) GETKEY(map, _stunServer, stunServerKey);
_stunEnabled = (val->getValue().compare ("true") == 0);
val = (Conf::ScalarNode *) (map->getValue (stunServerKey));
if (val)
_stunServer = val->getValue();
// Init stun server name with default server name // Init stun server name with default server name
_stunServerName = pj_str ( (char*) _stunServer.data()); _stunServerName = pj_str ( (char*) _stunServer.data());
credMap = (Conf::MappingNode *) (map->getValue (credKey)); GETKEY(map, _displayName, displayNameKey);
credMap = (Conf::MappingNode *) (map->getValue (credKey));
if (credMap) if (credMap)
credentials.unserialize (credMap); credentials.unserialize (credMap);
val = (Conf::ScalarNode *) (map->getValue (displayNameKey));
if (val)
_displayName = val->getValue();
// get srtp submap // get srtp submap
srtpMap = (Conf::MappingNode *) (map->getValue (srtpKey)); srtpMap = (Conf::MappingNode *) (map->getValue (srtpKey));
if (!srtpMap) if (!srtpMap)
throw SipAccountException (" did not found srtp map"); throw SipAccountException (" did not found srtp map");
val = (Conf::ScalarNode *) (srtpMap->getValue (srtpEnableKey)); GETBOOL(srtpMap, _srtpEnabled, srtpEnableKey);
if (val) GETKEY(srtpMap, _srtpKeyExchange, keyExchangeKey);
_srtpEnabled = (val->getValue().compare ("true") == 0); GETBOOL(srtpMap, _srtpFallback, rtpFallbackKey);
val = (Conf::ScalarNode *) (srtpMap->getValue (keyExchangeKey));
if (val)
_srtpKeyExchange = val->getValue();
val = (Conf::ScalarNode *) (srtpMap->getValue (rtpFallbackKey));
if (val)
_srtpFallback = (val->getValue().compare ("true") == 0);
// get zrtp submap // get zrtp submap
zrtpMap = (Conf::MappingNode *) (map->getValue (zrtpKey)); zrtpMap = (Conf::MappingNode *) (map->getValue (zrtpKey));
if (!zrtpMap) if (!zrtpMap)
throw SipAccountException (" did not found zrtp map"); throw SipAccountException (" did not found zrtp map");
val = (Conf::ScalarNode *) (zrtpMap->getValue (displaySasKey)); GETBOOL(zrtpMap, _zrtpDisplaySas, displaySasKey);
if (val) GETBOOL(zrtpMap, _zrtpDisplaySasOnce, displaySasOnceKey);
_zrtpDisplaySas = (val->getValue().compare ("true") == 0); GETBOOL(zrtpMap, _zrtpHelloHash, helloHashEnabledKey);
GETBOOL(zrtpMap, _zrtpNotSuppWarning, notSuppWarningKey);
val = (Conf::ScalarNode *) (zrtpMap->getValue (displaySasOnceKey));
if (val)
_zrtpDisplaySasOnce = (val->getValue().compare ("true") == 0);
val = (Conf::ScalarNode *) (zrtpMap->getValue (helloHashEnabledKey));
if (val)
_zrtpHelloHash = (val->getValue().compare ("true") == 0);
val = (Conf::ScalarNode *) (zrtpMap->getValue (notSuppWarningKey));
if (val)
_zrtpNotSuppWarning = (val->getValue().compare ("true") == 0);
// get tls submap // get tls submap
tlsMap = (Conf::MappingNode *) (map->getValue (tlsKey)); tlsMap = (Conf::MappingNode *) (map->getValue (tlsKey));
if (!tlsMap) if (!tlsMap)
throw SipAccountException (" did not found tls map"); throw SipAccountException (" did not found tls map");
val = (Conf::ScalarNode *) (tlsMap->getValue (tlsEnableKey)); GETKEY(tlsMap, _tlsEnable, tlsEnableKey);
if (val) GETKEY(tlsMap, _tlsPortStr, tlsPortKey);
_tlsEnable = val->getValue(); GETKEY(tlsMap, _tlsCertificateFile, certificateKey);
GETKEY(tlsMap, _tlsCaListFile, calistKey);
val = (Conf::ScalarNode *) (tlsMap->getValue (tlsPortKey)); GETKEY(tlsMap, _tlsCiphers, ciphersKey);
if (val) GETKEY(tlsMap, _tlsMethod, methodKey);
_tlsPortStr = val->getValue(); GETKEY(tlsMap, _tlsPassword, tlsPasswordKey);
GETKEY(tlsMap, _tlsPrivateKeyFile, privateKeyKey);
val = (Conf::ScalarNode *) (tlsMap->getValue (certificateKey)); GETBOOL(tlsMap, _tlsRequireClientCertificate, requireCertifKey);
if (val) GETKEY(tlsMap, _tlsServerName, serverKey);
_tlsCertificateFile = val->getValue(); GETBOOL(tlsMap, _tlsVerifyServer, verifyClientKey);
GETBOOL(tlsMap, _tlsVerifyClient, verifyServerKey);
val = (Conf::ScalarNode *) (tlsMap->getValue (calistKey));
if (val)
_tlsCaListFile = val->getValue();
val = (Conf::ScalarNode *) (tlsMap->getValue (ciphersKey));
if (val)
_tlsCiphers = val->getValue();
val = (Conf::ScalarNode *) (tlsMap->getValue (methodKey));
if (val)
_tlsMethod = val->getValue();
val = (Conf::ScalarNode *) (tlsMap->getValue (timeoutKey));
if (val) {
// FIXME // FIXME
_tlsNegotiationTimeoutSec = val->getValue(); GETKEY(tlsMap, _tlsNegotiationTimeoutSec, timeoutKey);
_tlsNegotiationTimeoutMsec = val->getValue(); GETKEY(tlsMap, _tlsNegotiationTimeoutMsec, timeoutKey);
}
val = (Conf::ScalarNode *) (tlsMap->getValue (tlsPasswordKey));
if (val)
_tlsPassword = val->getValue();
val = (Conf::ScalarNode *) (tlsMap->getValue (privateKeyKey));
if (val)
_tlsPrivateKeyFile = val->getValue();
val = (Conf::ScalarNode *) (tlsMap->getValue (requireCertifKey));
if (val)
_tlsRequireClientCertificate = (val->getValue().compare ("true") == 0);
val = (Conf::ScalarNode *) (tlsMap->getValue (serverKey));
if (val)
_tlsServerName = val->getValue();
val = (Conf::ScalarNode *) (tlsMap->getValue (verifyClientKey));
if (val)
_tlsVerifyServer = (val->getValue().compare ("true") == 0);
val = (Conf::ScalarNode *) (tlsMap->getValue (verifyServerKey));
if (val)
_tlsVerifyClient = (val->getValue().compare ("true") == 0);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment