From d79709659222f91c68df514ffeab6052827fa543 Mon Sep 17 00:00:00 2001 From: pierre-luc <pierre-luc.bacon@savoirfairelinux.com> Date: Fri, 14 Aug 2009 18:22:59 -0400 Subject: [PATCH] [#811][#812] Small gtk-ui fix. --- .../src/config/accountwindow.c | 2 +- sflphone-client-gnome/src/contacts/calltree.c | 2 - .../src/audio/audiortp/AudioRtpFactory.cpp | 15 +++--- .../audio/audiortp/ZrtpSessionCallback.cpp | 6 +-- sflphone-common/src/config/config.cpp | 11 +++++ sflphone-common/src/config/config.h | 1 + sflphone-common/src/global.h | 17 ++++--- sflphone-common/src/managerimpl.cpp | 48 ++++++++++++------- sflphone-common/src/managerimpl.h | 12 ++++- sflphone-common/src/sip/sipaccount.cpp | 4 +- sflphone-common/src/sip/sipvoiplink.cpp | 4 +- 11 files changed, 76 insertions(+), 46 deletions(-) diff --git a/sflphone-client-gnome/src/config/accountwindow.c b/sflphone-client-gnome/src/config/accountwindow.c index 6d105ed769..67126a979b 100644 --- a/sflphone-client-gnome/src/config/accountwindow.c +++ b/sflphone-client-gnome/src/config/accountwindow.c @@ -772,7 +772,7 @@ show_account_window (account_t * a) } gchar* keyExchange = (gchar *)gtk_combo_box_get_active_text(GTK_COMBO_BOX(keyExchangeCombo)); - if (g_strcasecmp(keyExchange, ZRTP) == 0) { + if (g_strcasecmp(keyExchange, "ZRTP") == 0) { g_hash_table_replace(currentAccount->properties, g_strdup(ACCOUNT_SRTP_ENABLED), g_strdup("true")); g_hash_table_replace(currentAccount->properties, g_strdup(ACCOUNT_KEY_EXCHANGE), g_strdup(ZRTP)); } else { diff --git a/sflphone-client-gnome/src/contacts/calltree.c b/sflphone-client-gnome/src/contacts/calltree.c index d61ea7f2a5..37dbbda7b1 100644 --- a/sflphone-client-gnome/src/contacts/calltree.c +++ b/sflphone-client-gnome/src/contacts/calltree.c @@ -294,8 +294,6 @@ calltree_create (calltab_t* tab, gboolean searchbar_type) rend, "markup", COLUMN_ACCOUNT_DESC, NULL); - g_object_set(rend, "xalign", (gfloat) 1.0, NULL); - g_object_set(rend, "yalign", (gfloat) 0.0, NULL); g_object_set(rend, "wrap-mode", (PangoWrapMode) PANGO_WRAP_WORD_CHAR, NULL); g_object_set(rend, "wrap-width", (gint) CALLTREE_TEXT_WIDTH, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW(tab->view), col); diff --git a/sflphone-common/src/audio/audiortp/AudioRtpFactory.cpp b/sflphone-common/src/audio/audiortp/AudioRtpFactory.cpp index 9dbec99bc0..e0dd37fef3 100644 --- a/sflphone-common/src/audio/audiortp/AudioRtpFactory.cpp +++ b/sflphone-common/src/audio/audiortp/AudioRtpFactory.cpp @@ -65,22 +65,21 @@ namespace sfl { AccountID accountId = Manager::instance().getAccountFromCall (ca->getCallId()); - int srtpEnabled = 0; - int keyExchangeProtocol = 0; - int helloHashEnabled = 0; + bool srtpEnabled = false; + int keyExchangeProtocol = 1; + bool helloHashEnabled = true; // Check if it is an IP-to-IP call if(accountId == AccountNULL) { - srtpEnabled = Manager::instance().getConfigInt(IP2IP_PROFILE, SRTP_ENABLE); + srtpEnabled = Manager::instance().getConfigBool(IP2IP_PROFILE, SRTP_ENABLE); keyExchangeProtocol = Manager::instance().getConfigInt(IP2IP_PROFILE, SRTP_KEY_EXCHANGE); _debug("Ip-to-ip profile selected with key exchange protocol number %d\n", keyExchangeProtocol); - helloHashEnabled = Manager::instance().getConfigInt(IP2IP_PROFILE, ZRTP_HELLO_HASH); + helloHashEnabled = Manager::instance().getConfigBool(IP2IP_PROFILE, ZRTP_HELLO_HASH); } else { - srtpEnabled = Manager::instance().getConfigInt(accountId, SRTP_ENABLE); + srtpEnabled = Manager::instance().getConfigBool(accountId, SRTP_ENABLE); keyExchangeProtocol = Manager::instance().getConfigInt(accountId, SRTP_KEY_EXCHANGE); _debug("Registered account %s profile selected with key exchange protocol number %d\n", accountId.c_str(), keyExchangeProtocol); - helloHashEnabled = Manager::instance().getConfigInt(accountId, ZRTP_HELLO_HASH); - + helloHashEnabled = Manager::instance().getConfigBool(accountId, ZRTP_HELLO_HASH); } _debug("Srtp enable: %d \n", srtpEnabled); diff --git a/sflphone-common/src/audio/audiortp/ZrtpSessionCallback.cpp b/sflphone-common/src/audio/audiortp/ZrtpSessionCallback.cpp index a553e38f83..3b3a7e7c76 100644 --- a/sflphone-common/src/audio/audiortp/ZrtpSessionCallback.cpp +++ b/sflphone-common/src/audio/audiortp/ZrtpSessionCallback.cpp @@ -143,19 +143,19 @@ namespace sfl { if (sev == Info) { msg = _infoMap[subCode]; if (msg != NULL) { - _debug("ZRTP Debug:\n", msg->c_str()); + _debug("ZRTP Debug:\n"); } } if (sev == Warning) { msg = _warningMap[subCode]; if (msg != NULL) { - _debug("ZRTP Debug:\n", msg->c_str()); + _debug("ZRTP Debug:\n"); } } if (sev == Severe) { msg = _severeMap[subCode]; if (msg != NULL) { - _debug("ZRTP Debug:\n", msg->c_str()); + _debug("ZRTP Debug:\n"); } } if (sev == ZrtpError) { diff --git a/sflphone-common/src/config/config.cpp b/sflphone-common/src/config/config.cpp index 30d54ba176..4d91cdee2c 100644 --- a/sflphone-common/src/config/config.cpp +++ b/sflphone-common/src/config/config.cpp @@ -159,6 +159,17 @@ ConfigTree::getConfigTreeItemIntValue (const std::string& section, const std::st return retval; } +bool +ConfigTree::getConfigTreeItemBoolValue(const std::string& section, const std::string& itemName) +{ + std::string configItem = getConfigTreeItemValue (section, itemName); + if (configItem == "true") { + return true; + } + + return false; +} + bool ConfigTree::getConfigTreeItemToken (const std::string& section, const std::string& itemName, TokenList& arg) { diff --git a/sflphone-common/src/config/config.h b/sflphone-common/src/config/config.h index 2e1de5e540..9e6309d58b 100644 --- a/sflphone-common/src/config/config.h +++ b/sflphone-common/src/config/config.h @@ -149,6 +149,7 @@ class ConfigTree */ std::string getConfigTreeItemValue (const std::string& section, const std::string& itemName); int getConfigTreeItemIntValue (const std::string& section, const std::string& itemName); + bool getConfigTreeItemBoolValue(const std::string& section, const std::string& itemName); /** * Flush data to .ini file diff --git a/sflphone-common/src/global.h b/sflphone-common/src/global.h index 72b6451c28..08677aed95 100644 --- a/sflphone-common/src/global.h +++ b/sflphone-common/src/global.h @@ -114,15 +114,14 @@ static const SOUND_FORMAT INT32 = 0x8; #define GSM_STRING_DESCRIPTION "gsm" /** GSM codec string description */ #define SPEEX_STRING_DESCRIPTION "speex" /** SPEEX codec string description */ -#define ILBC_STRING_DESCRIPTION "ilbc" /** Ilbc codec string description */ -#define RINGTONE_ENABLED 1 /** Custom ringtone enable or not */ -#define DISPLAY_DIALPAD 1 /** Display dialpad or not */ -#define DISPLAY_VOLUME_CONTROLS 1 /** Display the volume controls or not */ -#define START_HIDDEN 1 /** SFlphone starts hidden at start-up or not */ -#define WINDOW_POPUP 1 /** Popup mode */ -#define NOTIFY_ALL 1 /** Desktop notification level 0: never notify */ -#define NOTIFY_MAILS 1 /** Desktop mail notification level 0: never notify */ -#define STUN_ENABLED 1 +#define ILBC_STRING_DESCRIPTION "ilbc" /** Ilbc codec string description */ +#define RINGTONE_ENABLED TRUE_STR /** Custom ringtone enable or not */ +#define DISPLAY_DIALPAD TRUE_STR /** Display dialpad or not */ +#define DISPLAY_VOLUME_CONTROLS TRUE_STR /** Display the volume controls or not */ +#define START_HIDDEN TRUE_STR /** SFlphone starts hidden at start-up or not */ +#define WINDOW_POPUP TRUE_STR /** Popup mode */ +#define NOTIFY_ALL TRUE_STR /** Desktop notification level 0: never notify */ +#define STUN_ENABLED TRUE_STR // Error codes for error handling #define NO_ERROR 0x0000 /** No error - Everything alright */ diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp index 5405f1fb5d..8a38c332de 100644 --- a/sflphone-common/src/managerimpl.cpp +++ b/sflphone-common/src/managerimpl.cpp @@ -716,14 +716,14 @@ ManagerImpl::sendDtmf (const CallID& id, char code) bool ManagerImpl::playDtmf (char code, bool isTalking) { - int hasToPlayTone, pulselen, layer, size; + int pulselen, layer, size; bool ret = false; AudioLayer *audiolayer; SFLDataFormat *buf; stopTone (false); - hasToPlayTone = getConfigInt (SIGNALISATION, PLAY_DTMF); + bool hasToPlayTone = getConfigBool (SIGNALISATION, PLAY_DTMF); if (!hasToPlayTone) return false; @@ -1023,12 +1023,12 @@ void ManagerImpl::connectionStatusNotification() */ bool ManagerImpl::playATone (Tone::TONEID toneId) { - int hasToPlayTone; + bool hasToPlayTone; AudioLoop *audioloop; AudioLayer *audiolayer; unsigned int nbSamples; - hasToPlayTone = getConfigInt (SIGNALISATION, PLAY_TONES); + hasToPlayTone = getConfigBool (SIGNALISATION, PLAY_TONES); if (!hasToPlayTone) return false; @@ -1058,9 +1058,9 @@ bool ManagerImpl::playATone (Tone::TONEID toneId) */ void ManagerImpl::stopTone (bool stopAudio=true) { - int hasToPlayTone; + bool hasToPlayTone; - hasToPlayTone = getConfigInt (SIGNALISATION, PLAY_TONES); + hasToPlayTone = getConfigBool(SIGNALISATION, PLAY_TONES); if (!hasToPlayTone) return; @@ -1778,13 +1778,13 @@ ManagerImpl::isIax2Enabled (void) int ManagerImpl::isRingtoneEnabled (void) { - return getConfigInt (PREFERENCES , CONFIG_RINGTONE); + return (getConfigString (PREFERENCES, CONFIG_RINGTONE) == "true") ? 1:0; } void ManagerImpl::ringtoneEnabled (void) { - (getConfigInt (PREFERENCES , CONFIG_RINGTONE) == RINGTONE_ENABLED) ? setConfig (PREFERENCES , CONFIG_RINGTONE , FALSE_STR) : setConfig (PREFERENCES , CONFIG_RINGTONE , TRUE_STR); + (getConfigString (PREFERENCES , CONFIG_RINGTONE) == RINGTONE_ENABLED) ? setConfig (PREFERENCES , CONFIG_RINGTONE , FALSE_STR) : setConfig (PREFERENCES , CONFIG_RINGTONE , TRUE_STR); } std::string @@ -1830,7 +1830,7 @@ ManagerImpl::setRecordPath (const std::string& recPath) bool ManagerImpl::getMd5CredentialHashing(void) { - return getConfigInt(PREFERENCES, CONFIG_MD5HASH); + return getConfigBool(PREFERENCES, CONFIG_MD5HASH); } void @@ -1871,7 +1871,7 @@ void ManagerImpl::setStunServer (const std::string &server) int ManagerImpl::isStunEnabled (void) { - return getConfigInt (SIGNALISATION , STUN_ENABLE); + return getConfigString(SIGNALISATION, STUN_ENABLE) == TRUE_STR ? 1:0; } void ManagerImpl::enableStun (void) @@ -1921,19 +1921,19 @@ ManagerImpl::isRecording (const CallID& id) void ManagerImpl::startHidden (void) { - (getConfigInt (PREFERENCES , CONFIG_START) == START_HIDDEN) ? setConfig (PREFERENCES , CONFIG_START , FALSE_STR) : setConfig (PREFERENCES , CONFIG_START , TRUE_STR); + (getConfigString(PREFERENCES, CONFIG_START) == START_HIDDEN) ? setConfig(PREFERENCES , CONFIG_START , FALSE_STR) : setConfig (PREFERENCES , CONFIG_START , TRUE_STR); } int ManagerImpl::isStartHidden (void) { - return getConfigInt (PREFERENCES , CONFIG_START); + return (getConfigBool(PREFERENCES, CONFIG_START) == true) ? 1:0; } void ManagerImpl::switchPopupMode (void) { - (getConfigInt (PREFERENCES , CONFIG_POPUP) == WINDOW_POPUP) ? setConfig (PREFERENCES , CONFIG_POPUP , FALSE_STR) : setConfig (PREFERENCES , CONFIG_POPUP , TRUE_STR); + (getConfigString (PREFERENCES, CONFIG_POPUP) == WINDOW_POPUP) ? setConfig (PREFERENCES, CONFIG_POPUP, FALSE_STR) : setConfig (PREFERENCES, CONFIG_POPUP, TRUE_STR); } void ManagerImpl::setHistoryLimit (const int& days) @@ -1971,25 +1971,25 @@ ManagerImpl::setSearchbar (void) int ManagerImpl::popupMode (void) { - return getConfigInt (PREFERENCES , CONFIG_POPUP); + return (getConfigBool(PREFERENCES, CONFIG_POPUP) == true) ? 1:0 ; } int32_t ManagerImpl::getNotify (void) { - return getConfigInt (PREFERENCES , CONFIG_NOTIFY); + return (getConfigBool(PREFERENCES , CONFIG_NOTIFY) == true) ? 1:0; } void ManagerImpl::setNotify (void) { - (getConfigInt (PREFERENCES , CONFIG_NOTIFY) == NOTIFY_ALL) ? setConfig (PREFERENCES , CONFIG_NOTIFY , FALSE_STR) : setConfig (PREFERENCES , CONFIG_NOTIFY , TRUE_STR); + (getConfigString(PREFERENCES, CONFIG_NOTIFY) == NOTIFY_ALL) ? setConfig (PREFERENCES, CONFIG_NOTIFY , FALSE_STR) : setConfig (PREFERENCES, CONFIG_NOTIFY , TRUE_STR); } int32_t ManagerImpl::getMailNotify (void) { - return getConfigInt (PREFERENCES , CONFIG_MAIL_NOTIFY); + return getConfigInt(PREFERENCES, CONFIG_MAIL_NOTIFY); } int32_t @@ -2038,7 +2038,7 @@ ManagerImpl::getAudioManager (void) void ManagerImpl::setMailNotify (void) { - (getConfigInt (PREFERENCES , CONFIG_MAIL_NOTIFY) == NOTIFY_ALL) ? setConfig (PREFERENCES , CONFIG_MAIL_NOTIFY , FALSE_STR) : setConfig (PREFERENCES , CONFIG_MAIL_NOTIFY , TRUE_STR); + (getConfigString (PREFERENCES , CONFIG_MAIL_NOTIFY) == NOTIFY_ALL) ? setConfig (PREFERENCES , CONFIG_MAIL_NOTIFY , FALSE_STR) : setConfig (PREFERENCES , CONFIG_MAIL_NOTIFY , TRUE_STR); } void @@ -2426,6 +2426,18 @@ ManagerImpl::getConfigInt (const std::string& section, const std::string& name) return 0; } + +bool +ManagerImpl::getConfigBool (const std::string& section, const std::string& name) +{ + try { + return (_config.getConfigTreeItemValue (section, name) == TRUE_STR) ? true:false; + } catch (Conf::ConfigTreeItemException& e) { + throw e; + } + + return false; +} //THREAD=Main std::string diff --git a/sflphone-common/src/managerimpl.h b/sflphone-common/src/managerimpl.h index a9fdc6dae3..a6daacba79 100644 --- a/sflphone-common/src/managerimpl.h +++ b/sflphone-common/src/managerimpl.h @@ -758,7 +758,17 @@ class ManagerImpl { */ int getConfigInt(const std::string& section, const std::string& name); - + + /** + * Get a bool from the configuration tree + * Throw an Conf::ConfigTreeItemException if not found + * @param section The section name to look in + * @param name The parameter name + * @return bool The bool value + */ + + bool getConfigBool(const std::string& section, const std::string& name); + /** * Get a string from the configuration tree * Throw an Conf::ConfigTreeItemException if not found diff --git a/sflphone-common/src/sip/sipaccount.cpp b/sflphone-common/src/sip/sipaccount.cpp index 5722d83279..f26d7b1e3f 100644 --- a/sflphone-common/src/sip/sipaccount.cpp +++ b/sflphone-common/src/sip/sipaccount.cpp @@ -72,9 +72,9 @@ int SIPAccount::registerVoIPLink() credentialCount = Manager::instance().getConfigInt (_accountID, CONFIG_CREDENTIAL_NUMBER); credentialCount += 1; - int md5HashingEnabled = 0; + bool md5HashingEnabled = false; int dataType = 0; - md5HashingEnabled = Manager::instance().getConfigInt(PREFERENCES, CONFIG_MD5HASH); + md5HashingEnabled = Manager::instance().getConfigBool(PREFERENCES, CONFIG_MD5HASH); std::string digest; if (md5HashingEnabled) { dataType = PJSIP_CRED_DATA_DIGEST; diff --git a/sflphone-common/src/sip/sipvoiplink.cpp b/sflphone-common/src/sip/sipvoiplink.cpp index d04c13a9fc..05617b3a71 100644 --- a/sflphone-common/src/sip/sipvoiplink.cpp +++ b/sflphone-common/src/sip/sipvoiplink.cpp @@ -1591,9 +1591,9 @@ bool SIPVoIPLink::pjsip_init() port = _regPort; /* Retrieve the STUN configuration */ - useStun = Manager::instance().getConfigInt (SIGNALISATION, SIP_USE_STUN); + useStun = Manager::instance().getConfigBool(SIGNALISATION, SIP_USE_STUN); this->setStunServer (Manager::instance().getConfigString (SIGNALISATION, SIP_STUN_SERVER)); - this->useStun (useStun!=0 ? true : false); + this->useStun(useStun); if (useStun && !Manager::instance().behindNat (getStunServer(), port)) { port = RANDOM_SIP_PORT; -- GitLab