From 7601339de57fd8a827815ad9264719a08280b7fe Mon Sep 17 00:00:00 2001 From: Alexandre Savard <alexandre.savard@savoirfairelinux.com> Date: Fri, 9 Jul 2010 09:26:02 -0400 Subject: [PATCH] [#3649] Migrate to new config system --- .../dbus/configurationmanager-introspec.xml | 11 +++-- .../src/dbus/configurationmanager.cpp | 4 ++ .../src/dbus/configurationmanager.h | 29 ++++++------ sflphone-common/src/managerimpl.cpp | 45 ++++++++++++------- sflphone-common/src/managerimpl.h | 24 +++++----- 5 files changed, 68 insertions(+), 45 deletions(-) diff --git a/sflphone-common/src/dbus/configurationmanager-introspec.xml b/sflphone-common/src/dbus/configurationmanager-introspec.xml index f75d22c662..19e0590b34 100644 --- a/sflphone-common/src/dbus/configurationmanager-introspec.xml +++ b/sflphone-common/src/dbus/configurationmanager-introspec.xml @@ -633,6 +633,7 @@ </arg> </method> + <!-- <method name="setNotify" tp:name-for-bindings="setNotify"> <tp:docstring> </tp:docstring> @@ -646,7 +647,7 @@ </tp:docstring> </arg> </method> - + --> <method name="setMailNotify" tp:name-for-bindings="setMailNotify"> <tp:docstring> </tp:docstring> @@ -660,7 +661,7 @@ </tp:docstring> </arg> </method> - + <!-- <method name="getDialpad" tp:name-for-bindings="getDialpad"> <tp:docstring> </tp:docstring> @@ -724,6 +725,7 @@ </tp:docstring> </arg> </method> + --> <method name="getHistoryLimit" tp:name-for-bindings="getHistoryLimit"> <tp:docstring> @@ -742,7 +744,7 @@ </tp:docstring> </arg> </method> - + <!-- <method name="startHidden" tp:name-for-bindings="startHidden"> <tp:docstring> </tp:docstring> @@ -756,7 +758,7 @@ </tp:docstring> </arg> </method> - + <method name="popupMode" tp:name-for-bindings="popupMode"> <tp:docstring> </tp:docstring> @@ -770,6 +772,7 @@ <tp:docstring> </tp:docstring> </method> + --> <method name="getWindowWidth" tp:name-for-bindings="getWindowWidth"> <tp:docstring> diff --git a/sflphone-common/src/dbus/configurationmanager.cpp b/sflphone-common/src/dbus/configurationmanager.cpp index 608d91622a..0984c2299f 100644 --- a/sflphone-common/src/dbus/configurationmanager.cpp +++ b/sflphone-common/src/dbus/configurationmanager.cpp @@ -642,6 +642,7 @@ void ConfigurationManager::setRecordPath(const std::string& recPath) { Manager::instance().setRecordPath(recPath); } +/* int32_t ConfigurationManager::getDialpad(void) { return Manager::instance().getDialpad(); } @@ -665,6 +666,7 @@ int32_t ConfigurationManager::getVolumeControls(void) { void ConfigurationManager::setVolumeControls(const bool& display) { Manager::instance().setVolumeControls(display); } +*/ int32_t ConfigurationManager::getHistoryLimit(void) { return Manager::instance().getHistoryLimit(); @@ -674,6 +676,7 @@ void ConfigurationManager::setHistoryLimit(const int32_t& days) { Manager::instance().setHistoryLimit(days); } +/* void ConfigurationManager::setHistoryEnabled(void) { Manager::instance().setHistoryEnabled(); } @@ -705,6 +708,7 @@ void ConfigurationManager::setNotify(void) { int32_t ConfigurationManager::getNotify(void) { return Manager::instance().getNotify(); } +*/ void ConfigurationManager::setAudioManager(const int32_t& api) { Manager::instance().setAudioManager(api); diff --git a/sflphone-common/src/dbus/configurationmanager.h b/sflphone-common/src/dbus/configurationmanager.h index 7c351af08e..c33ae08296 100644 --- a/sflphone-common/src/dbus/configurationmanager.h +++ b/sflphone-common/src/dbus/configurationmanager.h @@ -109,17 +109,19 @@ public: void setRingtoneChoice( const std::string& tone ); std::string getRecordPath( void ); void setRecordPath(const std::string& recPath ); + /* int32_t getDialpad( void ); void setDialpad (const bool& display); int32_t getSearchbar( void ); - void setSearchbar( void ); + */ void setHistoryLimit( const int32_t& days); int32_t getHistoryLimit (void); + /* void setHistoryEnabled (void); - std::string getHistoryEnabled (void); + std::string getHistoryEnabled (void); int32_t getVolumeControls( void ); void setVolumeControls (const bool& display); @@ -129,20 +131,21 @@ public: void switchPopupMode( void ); int32_t getNotify( void ); void setNotify( void ); + */ int32_t getMailNotify( void ); void setMailNotify( void ); - int32_t getWindowWidth (void); - int32_t getWindowHeight (void); - void setWindowWidth (const int32_t& width); - void setWindowHeight (const int32_t& height); - int32_t getWindowPositionX (void); - int32_t getWindowPositionY (void); - void setWindowPositionX (const int32_t& posX); - void setWindowPositionY (const int32_t& posY); - - void enableStatusIcon (const std::string&); - std::string isStatusIconEnabled (void); + int32_t getWindowWidth (void); + int32_t getWindowHeight (void); + void setWindowWidth (const int32_t& width); + void setWindowHeight (const int32_t& height); + int32_t getWindowPositionX (void); + int32_t getWindowPositionY (void); + void setWindowPositionX (const int32_t& posX); + void setWindowPositionY (const int32_t& posY); + + void enableStatusIcon (const std::string&); + std::string isStatusIconEnabled (void); std::map<std::string, int32_t> getAddressbookSettings (void); void setAddressbookSettings (const std::map<std::string, int32_t>& settings); diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp index 21ef3dc038..90a76cd0e8 100644 --- a/sflphone-common/src/managerimpl.cpp +++ b/sflphone-common/src/managerimpl.cpp @@ -1410,9 +1410,8 @@ void ManagerImpl::removeStream (const CallID& call_id) { //THREAD=Main bool ManagerImpl::saveConfig (void) { _debug ("Saving Configuration to XDG directory %s ... ", _path.c_str()); - setConfig(AUDIO, VOLUME_SPKR, getSpkrVolume()); - setConfig(AUDIO, VOLUME_MICRO, getMicVolume()); - + audioPreference.setVolumemic(getMicVolume()); // setConfig(AUDIO, VOLUME_SPKR, getSpkrVolume()); + audioPreference.setVolumespkr(getSpkrVolume()); // setConfig(AUDIO, VOLUME_MICRO, getMicVolume()); AccountMap::iterator iter = _accountMap.begin(); @@ -2557,6 +2556,7 @@ bool ManagerImpl::getMd5CredentialHashing (void) { } +/* int ManagerImpl::getDialpad (void) { if (getConfigString(PREFERENCES, CONFIG_DIALPAD) == TRUE_STR) { return 1; @@ -2600,7 +2600,7 @@ void ManagerImpl::setVolumeControls (bool display) { != FALSE_STR))) setConfig(PREFERENCES, CONFIG_VOLUME, set); } - +*/ void ManagerImpl::setRecordingCall (const CallID& id) { /* @@ -2632,6 +2632,7 @@ bool ManagerImpl::isRecording (const CallID& id) { return rec->isRecording(); } +/* void ManagerImpl::startHidden (void) { (getConfigString(PREFERENCES, CONFIG_START) == START_HIDDEN) ? setConfig( PREFERENCES, CONFIG_START, FALSE_STR) : setConfig(PREFERENCES, @@ -2647,15 +2648,18 @@ void ManagerImpl::switchPopupMode (void) { PREFERENCES, CONFIG_POPUP, FALSE_STR) : setConfig(PREFERENCES, CONFIG_POPUP, TRUE_STR); } +*/ void ManagerImpl::setHistoryLimit (const int& days) { - setConfig(PREFERENCES, CONFIG_HISTORY_LIMIT, days); + // setConfig(PREFERENCES, CONFIG_HISTORY_LIMIT, days); + preferences.setHistoryLimit(days); } int ManagerImpl::getHistoryLimit (void) { - return getConfigInt(PREFERENCES, CONFIG_HISTORY_LIMIT); + return preferences.getHistoryLimit(); // getConfigInt(PREFERENCES, CONFIG_HISTORY_LIMIT); } +/* std::string ManagerImpl::getHistoryEnabled (void) { return getConfigString(PREFERENCES, CONFIG_HISTORY_ENABLED); } @@ -2689,9 +2693,18 @@ void ManagerImpl::setNotify (void) { 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); + return preferences.getNotifyMails(); +} + +void ManagerImpl::setMailNotify (void) { + // (getConfigString(PREFERENCES, CONFIG_MAIL_NOTIFY) == NOTIFY_ALL) ? setConfig( + // PREFERENCES, CONFIG_MAIL_NOTIFY, FALSE_STR) + // : setConfig(PREFERENCES, CONFIG_MAIL_NOTIFY, TRUE_STR); + preferences.getNotifyMails() ? preferences.setNotifyMails(true) : preferences.setNotifyMails(false); } void ManagerImpl::setAudioManager (const int32_t& api) { @@ -2711,7 +2724,8 @@ void ManagerImpl::setAudioManager (const int32_t& api) { return; } - setConfig(PREFERENCES, CONFIG_AUDIO, api); + // setConfig(PREFERENCES, CONFIG_AUDIO, api); + preferences.setAudioApi(api); switchAudioManager(); return; @@ -2719,14 +2733,10 @@ void ManagerImpl::setAudioManager (const int32_t& api) { } int32_t ManagerImpl::getAudioManager (void) { - return getConfigInt(PREFERENCES, CONFIG_AUDIO); + //return getConfigInt(PREFERENCES, CONFIG_AUDIO); + return preferences.getAudioApi(); } -void ManagerImpl::setMailNotify (void) { - (getConfigString(PREFERENCES, CONFIG_MAIL_NOTIFY) == NOTIFY_ALL) ? setConfig( - PREFERENCES, CONFIG_MAIL_NOTIFY, FALSE_STR) - : setConfig(PREFERENCES, CONFIG_MAIL_NOTIFY, TRUE_STR); -} void ManagerImpl::notifyErrClient (const int32_t& errCode) { if (_dbus) { @@ -2845,10 +2855,13 @@ bool ManagerImpl::initAudioDriver (void) { _debugInit ("AudioLayer Creation"); - if (getConfigInt(PREFERENCES, CONFIG_AUDIO) == ALSA) { + // if (getConfigInt(PREFERENCES, CONFIG_AUDIO) == ALSA) { + if (preferences.getAudioApi() == ALSA) { _audiodriver = new AlsaLayer(this); _audiodriver->setMainBuffer(&_mainBuffer); - } else if (getConfigInt(PREFERENCES, CONFIG_AUDIO) == PULSEAUDIO) { + } + // } else if (getConfigInt(PREFERENCES, CONFIG_AUDIO) == PULSEAUDIO) { + else if(preferences.getAudioApi() == PULSEAUDIO) { if (app_is_running("pulseaudio") == 0) { _audiodriver = new PulseLayer(this); _audiodriver->setMainBuffer(&_mainBuffer); diff --git a/sflphone-common/src/managerimpl.h b/sflphone-common/src/managerimpl.h index efe1077c06..e6d07bbb75 100755 --- a/sflphone-common/src/managerimpl.h +++ b/sflphone-common/src/managerimpl.h @@ -662,24 +662,24 @@ class ManagerImpl { * @return int 1 if dialpad has to be displayed * 0 otherwise */ - int getDialpad( void ); + // int getDialpad( void ); /** * Set the dialpad visible or not */ - void setDialpad (bool display); + // void setDialpad (bool display); /** * Tells if the user wants to display the volume controls or not * @return int 1 if the controls have to be displayed * 0 otherwise */ - int getVolumeControls( void ); + // int getVolumeControls( void ); /** * Set the volume controls ( mic and speaker ) visible or not */ - void setVolumeControls (bool display); + // void setVolumeControls (bool display); /** * Set recording on / off @@ -705,9 +705,9 @@ class ManagerImpl { */ int getHistoryLimit (void); - void setHistoryEnabled (void); + // void setHistoryEnabled (void); - std::string getHistoryEnabled (void); + // std::string getHistoryEnabled (void); /** @@ -728,35 +728,35 @@ class ManagerImpl { * @return int 1 if it should popup on incoming calls * 0 if it should never popups */ - int popupMode( void ); + // int popupMode( void ); /** * Configure the popup behaviour * When SFLphone is in the system tray, you can configure when it popups * Never or only on incoming calls */ - void switchPopupMode( void ); + // void switchPopupMode( void ); /** * Determine whether or not the search bar (history) should be displayed */ - int getSearchbar( void ); + // int getSearchbar( void ); /** * Configure the search bar behaviour */ - void setSearchbar( void ); + // void setSearchbar( void ); /** * Set the desktop notification level */ - void setNotify( void ); + // void setNotify( void ); /** * Get the desktop notification level * @return int The notification level */ - int32_t getNotify( void ); + // int32_t getNotify( void ); /** * Set the desktop mail notification level -- GitLab