From 07ebfdca6d9347efdad25892b5d674837ac2325b Mon Sep 17 00:00:00 2001
From: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
Date: Fri, 14 Mar 2008 11:00:19 -0400
Subject: [PATCH] Enable/disable "custom" ringtone on incoming call

---
 src/global.h        |  2 +-
 src/managerimpl.cpp | 15 ++++++++++-----
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/global.h b/src/global.h
index d6d485943e..e78ed7e1f1 100644
--- a/src/global.h
+++ b/src/global.h
@@ -102,6 +102,6 @@ typedef short int16;
 
 #define GSM_STRING_DESCRIPTION	  "gsm"
 #define SPEEX_STRING_DESCRIPTION  "speex"
-#define RINGTONE_ENABLED	  "1"
+#define RINGTONE_ENABLED	  1
 
 #endif	// __GLOBAL_H__
diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp
index 1697d14293..31d80a390a 100644
--- a/src/managerimpl.cpp
+++ b/src/managerimpl.cpp
@@ -894,9 +894,9 @@ ManagerImpl::ringback () {
   void
 ManagerImpl::ringtone() 
 {
-  int hasToPlayTone = getConfigInt(SIGNALISATION, PLAY_TONES);
-  if (!hasToPlayTone) { return; }
-
+ // int hasToPlayTone = getConfigInt(SIGNALISATION, PLAY_TONES);
+  if( isRingtoneEnabled() )
+  {
   std::string ringchoice = getConfigString(AUDIO, RING_CHOICE);
   //if there is no / inside the path
   if ( ringchoice.find(DIR_SEPARATOR_CH) == std::string::npos ) {
@@ -923,6 +923,11 @@ ManagerImpl::ringtone()
   } else {
     ringback();
   }
+}
+else
+{
+  ringback();
+}
 }
 
   AudioLoop*
@@ -1364,13 +1369,13 @@ ManagerImpl::isIax2Enabled( void )
 int
 ManagerImpl::isRingtoneEnabled( void )
 {
-  return std::atoi( getConfigString( PREFERENCES , CONFIG_RINGTONE ).c_str());
+  return getConfigInt( PREFERENCES , CONFIG_RINGTONE );
 }
 
 void
 ManagerImpl::ringtoneEnabled( void )
 {
-  ( getConfigString( PREFERENCES , CONFIG_RINGTONE ) == RINGTONE_ENABLED )? setConfig(PREFERENCES , CONFIG_RINGTONE , "0") : setConfig( PREFERENCES , CONFIG_RINGTONE , "1");
+  ( getConfigInt( PREFERENCES , CONFIG_RINGTONE ) == RINGTONE_ENABLED )? setConfig(PREFERENCES , CONFIG_RINGTONE , 0) : setConfig( PREFERENCES , CONFIG_RINGTONE , 1);
 }
 
   int
-- 
GitLab