From ce83b46d4548feb14cc4fb521a22de135c5c6dfa Mon Sep 17 00:00:00 2001 From: Tobias Weimer Date: Sat, 19 Oct 2013 21:33:25 +0000 Subject: Winter Speak has been adopted. git-svn-id: http://svn.miranda-ng.org/main/trunk@6544 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- .../WinterSpeak/speak/config/config_database.cpp | 174 ------------- .../WinterSpeak/speak/config/config_database.h | 91 ------- .../speak/config/dialog_config_active.cpp | 234 ----------------- .../speak/config/dialog_config_active.h | 56 ---- .../speak/config/dialog_config_engine.cpp | 289 --------------------- .../speak/config/dialog_config_engine.h | 59 ----- .../WinterSpeak/speak/config/speak_config.cpp | 170 ------------ .../WinterSpeak/speak/config/speak_config.h | 59 ----- .../WinterSpeak/speak/config/speech_interface.cpp | 91 ------- .../WinterSpeak/speak/config/speech_interface.h | 48 ---- 10 files changed, 1271 deletions(-) delete mode 100644 plugins/!NotAdopted/WinterSpeak/speak/config/config_database.cpp delete mode 100644 plugins/!NotAdopted/WinterSpeak/speak/config/config_database.h delete mode 100644 plugins/!NotAdopted/WinterSpeak/speak/config/dialog_config_active.cpp delete mode 100644 plugins/!NotAdopted/WinterSpeak/speak/config/dialog_config_active.h delete mode 100644 plugins/!NotAdopted/WinterSpeak/speak/config/dialog_config_engine.cpp delete mode 100644 plugins/!NotAdopted/WinterSpeak/speak/config/dialog_config_engine.h delete mode 100644 plugins/!NotAdopted/WinterSpeak/speak/config/speak_config.cpp delete mode 100644 plugins/!NotAdopted/WinterSpeak/speak/config/speak_config.h delete mode 100644 plugins/!NotAdopted/WinterSpeak/speak/config/speech_interface.cpp delete mode 100644 plugins/!NotAdopted/WinterSpeak/speak/config/speech_interface.h (limited to 'plugins/!NotAdopted/WinterSpeak/speak/config') diff --git a/plugins/!NotAdopted/WinterSpeak/speak/config/config_database.cpp b/plugins/!NotAdopted/WinterSpeak/speak/config/config_database.cpp deleted file mode 100644 index d634e44824..0000000000 --- a/plugins/!NotAdopted/WinterSpeak/speak/config/config_database.cpp +++ /dev/null @@ -1,174 +0,0 @@ -//============================================================================== -// Miranda Speak Plugin, © 2002 Ryan Winter -//============================================================================== - -#pragma warning(disable:4786) - -#include "config_database.h" - -#include "speak.h" - -#include - -//------------------------------------------------------------------------------ -namespace -{ - const char *SPEAK = "speak_config"; - const char *ACTIVE_FLAGS = "active_flags"; - const char *ACTIVE_STATE = "active_state"; - const char *WELCOME_MSG = "welcome_msg"; - const char *ENGINE = "engine"; - const char *VOICE = "voice"; - const char *VOLUME = "volume"; - const char *RATE = "rate"; - const char *PITCH = "pitch"; -} - -//------------------------------------------------------------------------------ -// public: -//------------------------------------------------------------------------------ -ConfigDatabase::ConfigDatabase() - : - m_voice_desc(), - m_active_flags(0), - m_welcome_msg(""), - m_active_users() -{ - CLASSCERR("ConfigDatabase::ConfigDatabase"); - - // load the database from miranda - load(); -} - -//------------------------------------------------------------------------------ -ConfigDatabase::~ConfigDatabase() -{ - CLASSCERR("ConfigDatabase::~ConfigDatabase"); -} - -//------------------------------------------------------------------------------ -bool -ConfigDatabase::getActiveFlag(ActiveFlag flag) const -{ - return ((m_active_flags & (1 << flag)) != 0); -} - -//------------------------------------------------------------------------------ -void -ConfigDatabase::setActiveFlag(ActiveFlag flag, bool state) -{ - if (state) - { - m_active_flags |= (1 << flag); - } - else - { - m_active_flags &= ~(1 << flag); - } -} - -//------------------------------------------------------------------------------ -bool -ConfigDatabase::getActiveUser(HANDLE user) const -{ - ActiveUsersMap::const_iterator iter = m_active_users.find(user); - - if (iter == m_active_users.end()) - { - // get the unknown user status - iter = m_active_users.find(0); - - if (iter == m_active_users.end()) - { - CLASSCERR("ConfigDatabase::getActiveUser user error"); - return false; - } - } - - return iter->second; -} - -//------------------------------------------------------------------------------ -void -ConfigDatabase::setActiveUser(HANDLE user, bool state) -{ - m_active_users[user] = state; -} - -//------------------------------------------------------------------------------ -void -ConfigDatabase::load() -{ - CLASSCERR("ConfigDatabase::load"); - - m_voice_desc.engine = DBGetContactSettingString(SPEAK, ENGINE, ""); - m_voice_desc.voice = DBGetContactSettingString(SPEAK, VOICE, ""); - m_voice_desc.volume = DBGetContactSettingDword(NULL, SPEAK, VOLUME, 50); - m_voice_desc.pitch = DBGetContactSettingDword(NULL, SPEAK, PITCH, 50); - m_voice_desc.rate = DBGetContactSettingDword(NULL, SPEAK, RATE, 50); - - m_active_flags = DBGetContactSettingDword(NULL, SPEAK, ACTIVE_FLAGS, 0xffff); - - m_welcome_msg = DBGetContactSettingString(SPEAK, WELCOME_MSG, - "welcome to i c q"); - - // iterate through all the users and add them to the list if active - HANDLE contact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); - - while (NULL != contact) - { - m_active_users[contact] - = DBGetContactSettingByte(contact, SPEAK, ACTIVE_STATE, true); - - contact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)contact, 0); - } - - // load unknown users setting - m_active_users[0] = DBGetContactSettingByte(NULL, SPEAK, ACTIVE_STATE, true); -} - -//------------------------------------------------------------------------------ -void -ConfigDatabase::save() -{ - CLASSCERR("ConfigDatabase::save"); - - DBWriteContactSettingString(NULL, SPEAK, ENGINE, m_voice_desc.engine.c_str()); - DBWriteContactSettingString(NULL, SPEAK, VOICE, m_voice_desc.voice.c_str()); - DBWriteContactSettingDword(NULL, SPEAK, VOLUME, m_voice_desc.volume); - DBWriteContactSettingDword(NULL, SPEAK, PITCH, m_voice_desc.pitch); - DBWriteContactSettingDword(NULL, SPEAK, RATE, m_voice_desc.rate); - - DBWriteContactSettingDword(NULL, SPEAK, ACTIVE_FLAGS, m_active_flags); - - DBWriteContactSettingString(NULL, SPEAK, WELCOME_MSG, m_welcome_msg.c_str()); - - for (ActiveUsersMap::iterator i = m_active_users.begin(); - i != m_active_users.end(); ++i) - { - DBWriteContactSettingByte(i->first, SPEAK, ACTIVE_STATE, i->second); - } - - // notify the subjects that things have changed - notify(); -} - -//------------------------------------------------------------------------------ -// private: -//------------------------------------------------------------------------------ -std::string -ConfigDatabase::DBGetContactSettingString(const char *szModule, - const char *szSetting, const char *def) -{ - std::string ret = def; - DBVARIANT dbv; - - if (!DBGetContactSetting(NULL, szModule, szSetting, &dbv)) - { - ret = dbv.pszVal; - } - - return ret; -} - -//============================================================================== diff --git a/plugins/!NotAdopted/WinterSpeak/speak/config/config_database.h b/plugins/!NotAdopted/WinterSpeak/speak/config/config_database.h deleted file mode 100644 index 716745a3ce..0000000000 --- a/plugins/!NotAdopted/WinterSpeak/speak/config/config_database.h +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef guard_speak_config_config_database_h -#define guard_speak_config_config_database_h -//============================================================================== -// Miranda Speak Plugin, © 2002 Ryan Winter -//============================================================================== - -#include "defs/voice_desc.h" - -#include - -#include -#include -#include - -class ConfigDatabase : public Subject -{ - public: - ConfigDatabase(); - ~ConfigDatabase(); - - enum ActiveFlag - { - ActiveFlag_Online = 1, - ActiveFlag_Away, - ActiveFlag_Dnd, - ActiveFlag_Na, - ActiveFlag_Occupied, - ActiveFlag_FreeForChat, - ActiveFlag_Invisible - }; - - typedef std::map ActiveUsersMap; - - //-------------------------------------------------------------------------- - // Description : get/set the voice description - //-------------------------------------------------------------------------- - VoiceDesc getVoiceDesc() const { return m_voice_desc; } - void setVoiceDesc(const VoiceDesc &desc) { m_voice_desc = desc; } - - //-------------------------------------------------------------------------- - // Description : get/set the welcome message - //-------------------------------------------------------------------------- - const std::string & getWelcomeMessage() const { return m_welcome_msg; } - void setWelcomeMessage(const std::string &msg) { m_welcome_msg = msg; } - - //-------------------------------------------------------------------------- - // Description : get/set an status flags - //-------------------------------------------------------------------------- - bool getActiveFlag(ActiveFlag flag) const; - void setActiveFlag(ActiveFlag flag, bool state); - - //-------------------------------------------------------------------------- - // Description : get/set the user active flag - //-------------------------------------------------------------------------- - bool getActiveUser(HANDLE user) const; - void setActiveUser(HANDLE user, bool state); - ActiveUsersMap getActiveUsers() const { return m_active_users; } - - //-------------------------------------------------------------------------- - // Description : load/save the settings from the miranda database - //-------------------------------------------------------------------------- - void load(); - void save(); - - private: - //-------------------------------------------------------------------------- - // Description : For some reason this isn't implemented in miranda yet - // Just get a string from the db - // Parameters : szModule - the entrys' module - // szSetting - the entrys' setting - // def - default string if entry doesn't exist - //-------------------------------------------------------------------------- - static std::string DBGetContactSettingString(const char *szModule, - const char *szSetting, const char *def); - - VoiceDesc m_voice_desc; - unsigned int m_active_flags; - std::string m_welcome_msg; - ActiveUsersMap m_active_users; -}; - -//============================================================================== -// -// Summary : encapsulate the access to the miranda database -// -// Description : Provide a subject that allows clients to know when changes -// are made to the miranda database. -// -//============================================================================== - -#endif \ No newline at end of file diff --git a/plugins/!NotAdopted/WinterSpeak/speak/config/dialog_config_active.cpp b/plugins/!NotAdopted/WinterSpeak/speak/config/dialog_config_active.cpp deleted file mode 100644 index 9d261adc24..0000000000 --- a/plugins/!NotAdopted/WinterSpeak/speak/config/dialog_config_active.cpp +++ /dev/null @@ -1,234 +0,0 @@ -//============================================================================== -// Miranda Speak Plugin, © 2002 Ryan Winter -//============================================================================== - -#pragma warning(disable:4786) - -#include "dialog_config_active.h" - -#include "speak.h" -#include "resource.h" - -#include - -#include -#include - -//------------------------------------------------------------------------------ -DialogConfigActive *DialogConfigActive::m_instance = 0; - -//------------------------------------------------------------------------------ -// public: -//------------------------------------------------------------------------------ -DialogConfigActive::DialogConfigActive(ConfigDatabase &db) - : - m_db(db) -{ - CLASSCERR("DialogConfigActive::DialogConfigActive"); - - m_instance = this; -} - -//------------------------------------------------------------------------------ -DialogConfigActive::~DialogConfigActive() -{ - CLASSCERR("DialogConfigActive::~DialogConfigActive"); - - m_instance = 0; -} - -//------------------------------------------------------------------------------ -int CALLBACK -DialogConfigActive::process(HWND window, UINT message, WPARAM wparam, - LPARAM lparam) -{ - if (!m_instance) - { - return 1; - } - - switch (message) - { - case WM_INITDIALOG: - m_instance->load(window); - break; - - case WM_NOTIFY: - switch (reinterpret_cast(lparam)->code) - { - case PSN_APPLY: - m_instance->save(window); - break; - - case LVN_ITEMCHANGED: - m_instance->changed(window); - break; - } - break; - - case WM_COMMAND: - switch (LOWORD(wparam)) - { - case IDC_ACTIVE_OFFLINE: - case IDC_ACTIVE_ONLINE: - case IDC_ACTIVE_AWAY: - case IDC_ACTIVE_DND: - case IDC_ACTIVE_NA: - case IDC_ACTIVE_OCCUPIED: - case IDC_ACTIVE_FREEFORCHAT: - case IDC_ACTIVE_INVISIBLE: - m_instance->changed(window); - break; - - case IDC_ACTIVE_ALL: - m_instance->selectAllUsers(window, true); - break; - - case IDC_ACTIVE_NONE: - m_instance->selectAllUsers(window, false); - break; - - case IDC_ACTIVE_USERS: - m_instance->changed(window); - break; - } - break; - } - - return 0; -} - -//------------------------------------------------------------------------------ -// private: -//------------------------------------------------------------------------------ -void -DialogConfigActive::load(HWND window) -{ - CLASSCERR("DialogConfigActive::load"); - - TranslateDialogDefault(window); - - // initialise the checkboxes - CheckDlgButton(window, IDC_ACTIVE_ONLINE, - m_db.getActiveFlag(ConfigDatabase::ActiveFlag_Online)); - CheckDlgButton(window, IDC_ACTIVE_AWAY, - m_db.getActiveFlag(ConfigDatabase::ActiveFlag_Away)); - CheckDlgButton(window, IDC_ACTIVE_DND, - m_db.getActiveFlag(ConfigDatabase::ActiveFlag_Dnd)); - CheckDlgButton(window, IDC_ACTIVE_NA, - m_db.getActiveFlag(ConfigDatabase::ActiveFlag_Na)); - CheckDlgButton(window, IDC_ACTIVE_OCCUPIED, - m_db.getActiveFlag(ConfigDatabase::ActiveFlag_Occupied)); - CheckDlgButton(window, IDC_ACTIVE_FREEFORCHAT, - m_db.getActiveFlag(ConfigDatabase::ActiveFlag_FreeForChat)); - CheckDlgButton(window, IDC_ACTIVE_INVISIBLE, - m_db.getActiveFlag(ConfigDatabase::ActiveFlag_Invisible)); - - // add all the users active states - ConfigDatabase::ActiveUsersMap active_users = m_db.getActiveUsers(); - - HWND listview = GetDlgItem(window, IDC_ACTIVE_USERS); - - // add checkboxes - ListView_SetExtendedListViewStyle(listview, LVS_EX_CHECKBOXES); - - LV_ITEM lv_item; - lv_item.mask = LVIF_TEXT | LVIF_PARAM; - lv_item.iSubItem = 0; - - int index = 0; - ConfigDatabase::ActiveUsersMap::const_iterator iter; - for (iter = active_users.begin(); iter != active_users.end(); ++iter) - { - lv_item.lParam = (LPARAM)iter->first; - std::string str = ""; - - // if its index 0, the use its the unknown user - if (0 == lv_item.lParam) - { - lv_item.pszText = "Unknown"; - } - else - { - char *protocol = reinterpret_cast( - CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)iter->first,0)); - - if (protocol) - { - str += protocol; - str += ": "; - } - - str += reinterpret_cast( - CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)iter->first, 0)); - - lv_item.pszText = const_cast(str.c_str()); - } - lv_item.iItem = index++; - - int it = ListView_InsertItem(listview, &lv_item); - ListView_SetCheckState(listview, it, iter->second); - } -} - -//------------------------------------------------------------------------------ -void -DialogConfigActive::save(HWND window) -{ - CLASSCERR("DialogConfigActive::save"); - - // store the checkboxes - m_db.setActiveFlag(ConfigDatabase::ActiveFlag_Online, - (IsDlgButtonChecked(window, IDC_ACTIVE_ONLINE) != 0)); - m_db.setActiveFlag(ConfigDatabase::ActiveFlag_Away, - (IsDlgButtonChecked(window, IDC_ACTIVE_AWAY) != 0)); - m_db.setActiveFlag(ConfigDatabase::ActiveFlag_Dnd, - (IsDlgButtonChecked(window, IDC_ACTIVE_DND) != 0)); - m_db.setActiveFlag(ConfigDatabase::ActiveFlag_Na, - (IsDlgButtonChecked(window, IDC_ACTIVE_NA) != 0)); - m_db.setActiveFlag(ConfigDatabase::ActiveFlag_Occupied, - (IsDlgButtonChecked(window, IDC_ACTIVE_OCCUPIED) != 0)); - m_db.setActiveFlag(ConfigDatabase::ActiveFlag_FreeForChat, - (IsDlgButtonChecked(window, IDC_ACTIVE_FREEFORCHAT) != 0)); - m_db.setActiveFlag(ConfigDatabase::ActiveFlag_Invisible, - (IsDlgButtonChecked(window, IDC_ACTIVE_INVISIBLE) != 0)); - - // look through the listview an extract the active users - HWND listview = GetDlgItem(window, IDC_ACTIVE_USERS); - - LV_ITEM lv_item; - lv_item.mask = LVIF_PARAM; - lv_item.iSubItem = 0; - - for (int i = 0; i < ListView_GetItemCount(listview); ++i) - { - lv_item.iItem = i; - - if (TRUE == ListView_GetItem(listview, &lv_item)) - { - m_db.setActiveUser((HANDLE)lv_item.lParam, - ListView_GetCheckState(listview, i)); - } - } - - m_db.save(); -} - -//------------------------------------------------------------------------------ -void -DialogConfigActive::selectAllUsers(HWND window, bool state) -{ - CLASSCERR("DialogConfigActive::selectAllUsers"); - // look through the listview an extract the active users - - HWND listview = GetDlgItem(window, IDC_ACTIVE_USERS); - - for (int i = 0; i < ListView_GetItemCount(listview); ++i) - { - ListView_SetCheckState(listview, i, state); - } - - changed(window); -} - -//============================================================================== diff --git a/plugins/!NotAdopted/WinterSpeak/speak/config/dialog_config_active.h b/plugins/!NotAdopted/WinterSpeak/speak/config/dialog_config_active.h deleted file mode 100644 index 5e0c0e2403..0000000000 --- a/plugins/!NotAdopted/WinterSpeak/speak/config/dialog_config_active.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef guard_speak_config_dialog_config_active_h -#define guard_speak_config_dialog_config_active_h -//============================================================================== -// Miranda Speak Plugin, © 2002 Ryan Winter -//============================================================================== - -#include "dialog/miranda_dialog.h" -#include "config/config_database.h" - -#include - -class DialogConfigActive : public MirandaDialog -{ - public: - //-------------------------------------------------------------------------- - // Description : Initialise - // Parameters : db - reference to the database to initalise and save - // control to and from - //-------------------------------------------------------------------------- - DialogConfigActive(ConfigDatabase &db); - virtual ~DialogConfigActive(); - - //-------------------------------------------------------------------------- - // Description : process a dialog message - // Return : 0 - process ok - // 1 - error - //-------------------------------------------------------------------------- - static int CALLBACK process(HWND window, UINT message, WPARAM wparam, - LPARAM lparam); - - private: - //-------------------------------------------------------------------------- - // Description : load/save setting to the miranda database - //-------------------------------------------------------------------------- - void load(HWND window); - void save(HWND window); - - //-------------------------------------------------------------------------- - // Description : select/unselect all the active status checkboxes - // Parameters : state - the state to apply to the checkboxes - //-------------------------------------------------------------------------- - void selectAllUsers(HWND window, bool state); - - static DialogConfigActive *m_instance; - ConfigDatabase &m_db; -}; - -//============================================================================== -// -// Summary : Configuration Engine Dialog box -// -// Description : Set up the configuration dialog box and process its input -// -//============================================================================== - -#endif \ No newline at end of file diff --git a/plugins/!NotAdopted/WinterSpeak/speak/config/dialog_config_engine.cpp b/plugins/!NotAdopted/WinterSpeak/speak/config/dialog_config_engine.cpp deleted file mode 100644 index d95e610916..0000000000 --- a/plugins/!NotAdopted/WinterSpeak/speak/config/dialog_config_engine.cpp +++ /dev/null @@ -1,289 +0,0 @@ -//============================================================================== -// Miranda Speak Plugin, © 2002 Ryan Winter -//============================================================================== - -#pragma warning(disable:4786) - -#include "dialog_config_engine.h" - -#include "speak.h" -#include "resource.h" -#include "config/speech_interface.h" - -#include -#include - -#include -#include - -//------------------------------------------------------------------------------ -DialogConfigEngine *DialogConfigEngine::m_instance = 0; - -//------------------------------------------------------------------------------ -// public: -//------------------------------------------------------------------------------ -DialogConfigEngine::DialogConfigEngine(ConfigDatabase &db) - : - m_db(db), - m_test_tts(0) -{ - CLASSCERR("DialogConfigEngine::DialogConfigEngine"); - - m_instance = this; -} - -//------------------------------------------------------------------------------ -DialogConfigEngine::~DialogConfigEngine() -{ - CLASSCERR("DialogConfigEngine::~DialogConfigEngine"); - - m_instance = 0; -} - -//------------------------------------------------------------------------------ -int CALLBACK -DialogConfigEngine::process(HWND window, UINT message, WPARAM wparam, - LPARAM lparam) -{ - if (!m_instance) - { - return 1; - } - - switch (message) - { - case WM_INITDIALOG: - m_instance->load(window); - break; - - case WM_NOTIFY: - if (PSN_APPLY == reinterpret_cast(lparam)->code) - { - m_instance->save(window); - m_instance->m_db.save(); - } - break; - - case WM_HSCROLL: - m_instance->changed(window); - break; - - case WM_COMMAND: - m_instance->command(window, wparam); - break; - } - - return 0; -} - -//------------------------------------------------------------------------------ -// private: -//------------------------------------------------------------------------------ -void -DialogConfigEngine::command(HWND window, int control) -{ - switch (LOWORD(control)) - { - case IDC_WELCOME_MSG: - if (EN_CHANGE == HIWORD(control)) - { - changed(window); - } - break; - - case IDC_SELECT_VOICE: - if (CBN_SELCHANGE == HIWORD(control)) - { - changed(window); - } - break; - - case IDC_SELECT_ENGINE: - if (CBN_SELCHANGE == HIWORD(control)) - { - updateVoices(window); - changed(window); - } - break; - - case IDC_CONFIG_LEXICON: - if (createTts(window)) - { - if (!m_test_tts->lexiconDialog(window)) - { - MessageBox(window, "Lexicon for this engine is not supported", - "Speak", MB_OK | MB_ICONEXCLAMATION); - } - } - break; - - case IDC_BUTTON_TEST: - if (createTts(window)) - { - m_test_tts->say(Translate("testing testing 1 2 3")); - } - break; - } -} - -//------------------------------------------------------------------------------ -void -DialogConfigEngine::load(HWND window) -{ - CLASSCERR("DialogConfigEngine::load()"); - - TranslateDialogDefault(window); - - // add the available engines to the combo box - SpeechInterface si; - std::vector engines = si.getAvailableEngines(); - for (unsigned int i = 0; i < engines.size(); ++i) - { - CLASSCERR("DialogConfigEngine::load adding " << engines[i].c_str()); - - SendDlgItemMessage(window, IDC_SELECT_ENGINE, CB_ADDSTRING, 0, - (long)engines[i].c_str()); - } - - VoiceDesc desc = m_db.getVoiceDesc(); - - // initialise the sliders - SendDlgItemMessage(window, IDC_SLIDER_VOLUME, TBM_SETPOS, TRUE, - desc.volume); - SendDlgItemMessage(window, IDC_SLIDER_PITCH, TBM_SETPOS, TRUE, - desc.pitch); - SendDlgItemMessage(window, IDC_SLIDER_RATE, TBM_SETPOS, TRUE, - desc.rate); - - // select the speech engine - SendDlgItemMessage(window, IDC_SELECT_ENGINE, CB_SELECTSTRING, 0, - reinterpret_cast(desc.engine.c_str())); - - // initialise the welcome message box - SetDlgItemText(window, IDC_WELCOME_MSG, m_db.getWelcomeMessage().c_str()); - - updateVoices(window); -} - -//------------------------------------------------------------------------------ -void -DialogConfigEngine::save(HWND window) -{ - CLASSCERR("DialogConfigEngine::save()"); - - VoiceDesc desc; - getVoiceDesc(window, desc); - m_db.setVoiceDesc(desc); - - // store the welcome message - char text[512]; - GetDlgItemText(window, IDC_WELCOME_MSG, text, sizeof(text)); - m_db.setWelcomeMessage(std::string(text)); -} - -//------------------------------------------------------------------------------ -void -DialogConfigEngine::updateVoices(HWND window) -{ - CLASSCERR("DialogConfigEngine::updateVoices()"); - - SpeechInterface si; - m_test_tts = std::auto_ptr(si.createTts(getEngine(window))); - - if (!m_test_tts.get()) - { - // we couldnt open the text to speech engine - CLASSCERR("DialogConfigEngine::updateVoices invalid tts"); - return; - } - - // add the voices onto the list - std::vector voices = m_test_tts->getVoices(); - - SendDlgItemMessage(window, IDC_SELECT_VOICE, CB_RESETCONTENT, 0, 0); - for (unsigned int i = 0; i < voices.size(); ++i) - { - SendDlgItemMessage(window, IDC_SELECT_VOICE, CB_ADDSTRING, 0, - (long)voices[i].c_str()); - } - - // get the voice saved in the database - std::string voice = m_db.getVoiceDesc().voice; - - if (FAILED(SendDlgItemMessage(window, IDC_SELECT_VOICE, - CB_FINDSTRINGEXACT, 0, (long)voice.c_str()))) - { - // select the first one - SendDlgItemMessage(window, IDC_SELECT_VOICE, CB_SETCURSEL , 0, 0); - } - else - { - // select the saved voice - SendDlgItemMessage(window, IDC_SELECT_VOICE, CB_SELECTSTRING, 0, - (long)voice.c_str()); - } -} - -//------------------------------------------------------------------------------ -void -DialogConfigEngine::getVoiceDesc(HWND window, VoiceDesc &desc) -{ - CLASSCERR("DialogConfigEngine::getVoiceDesc(,)"); - - // get the engine - char text[100]; - GetDlgItemText(window, IDC_SELECT_ENGINE, text, sizeof(text)); - desc.engine = std::string(text); - - // get the voice - std::auto_ptr voice(new char[50]); - SendDlgItemMessage(window, IDC_SELECT_VOICE, CB_GETLBTEXT, - SendDlgItemMessage(window, IDC_SELECT_VOICE, CB_GETCURSEL, 0, 0), - reinterpret_cast(voice.get())); - desc.voice = voice.get(); - - // get the voice setting sliders - desc.volume - = SendDlgItemMessage(window, IDC_SLIDER_VOLUME, TBM_GETPOS, 0, 0); - desc.pitch - = SendDlgItemMessage(window, IDC_SLIDER_PITCH, TBM_GETPOS, 0, 0); - desc.rate - = SendDlgItemMessage(window, IDC_SLIDER_RATE, TBM_GETPOS, 0, 0); -} - -//------------------------------------------------------------------------------ -std::string -DialogConfigEngine::getEngine(HWND window) -{ - CLASSCERR("DialogConfigEngine::getEngine()"); - - // store the engine - char text[100]; - GetDlgItemText(window, IDC_SELECT_ENGINE, text, sizeof(text)); - - CLASSCERR("DialogConfigEngine::getEngine() return " << text); - return text; -} - -//------------------------------------------------------------------------------ -bool -DialogConfigEngine::createTts(HWND window) -{ - CLASSCERR("DialogConfigEngine::createTts()"); - - VoiceDesc desc; - getVoiceDesc(window, desc); - - SpeechInterface si; - m_test_tts = std::auto_ptr(si.createTts(desc.engine)); - - if (!m_test_tts.get()) - { - return false; - } - - si.configureTts(m_test_tts.get(), desc); - return true; -} - -//============================================================================== diff --git a/plugins/!NotAdopted/WinterSpeak/speak/config/dialog_config_engine.h b/plugins/!NotAdopted/WinterSpeak/speak/config/dialog_config_engine.h deleted file mode 100644 index 9aed91aa9b..0000000000 --- a/plugins/!NotAdopted/WinterSpeak/speak/config/dialog_config_engine.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef guard_speak_config_dialog_config_engine_h -#define guard_speak_config_dialog_config_engine_h -//============================================================================== -// Miranda Speak Plugin, © 2002 Ryan Winter -//============================================================================== - -#include "dialog/miranda_dialog.h" -#include "config/config_database.h" - -#include -#include - -class TextToSpeech; - -class DialogConfigEngine : public MirandaDialog -{ - public: - DialogConfigEngine(ConfigDatabase &db); - virtual ~DialogConfigEngine(); - - //-------------------------------------------------------------------------- - // Description : process a dialog message - // Return : 0 - process ok - // 1 - error - //-------------------------------------------------------------------------- - static int CALLBACK process(HWND window, UINT message, WPARAM wparam, - LPARAM lparam); - - private: - void command(HWND window, int control); - - //-------------------------------------------------------------------------- - // Description : load/save setting to the miranda database - //-------------------------------------------------------------------------- - void load(HWND window); - void save(HWND window); - - //-------------------------------------------------------------------------- - // Description : update the voices combo box - //-------------------------------------------------------------------------- - void updateVoices(HWND window); - void getVoiceDesc(HWND window, VoiceDesc &desc); - std::string getEngine(HWND window); - bool createTts(HWND window); - - static DialogConfigEngine *m_instance; - ConfigDatabase &m_db; - std::auto_ptr m_test_tts; -}; - -//============================================================================== -// -// Summary : Configuration Engine Dialog box -// -// Description : Set up the configuration dialog box and process its input -// -//============================================================================== - -#endif \ No newline at end of file diff --git a/plugins/!NotAdopted/WinterSpeak/speak/config/speak_config.cpp b/plugins/!NotAdopted/WinterSpeak/speak/config/speak_config.cpp deleted file mode 100644 index c9f6bfdbde..0000000000 --- a/plugins/!NotAdopted/WinterSpeak/speak/config/speak_config.cpp +++ /dev/null @@ -1,170 +0,0 @@ -//============================================================================== -// Miranda Speak Plugin, © 2002 Ryan Winter -//============================================================================== - -#pragma warning(disable:4786) - -#include "speak_config.h" - -#include "defs/voice_desc.h" -#include "config/speech_interface.h" -#include "config/dialog_config_engine.h" -#include "config/dialog_config_active.h" - -#include -#include -//#include - -#include - -//------------------------------------------------------------------------------ -// public: -//------------------------------------------------------------------------------ -SpeakConfig::SpeakConfig(HINSTANCE instance) - : - m_instance(instance), - m_db(), - m_tts(0), - m_dialog_engine(m_db), - m_dialog_active(m_db) -{ - CLASSCERR("SpeakConfig::SpeakConfig"); - - // create and configure the tts - SpeechInterface si; - VoiceDesc desc = m_db.getVoiceDesc(); - m_tts = std::auto_ptr(si.createTts(desc.engine)); - si.configureTts(m_tts.get(), desc); - - // observer the database for changes - m_db.attach(*this); - - say(m_db.getWelcomeMessage()); -} - -//------------------------------------------------------------------------------ -SpeakConfig::~SpeakConfig() -{ - CLASSCERR("SpeakConfig::~SpeakConfig"); -} - -//------------------------------------------------------------------------------ -void -SpeakConfig::update(Subject &subject) -{ - CLASSCERR("SpeakConfig::update(" << &subject << ")"); - - ConfigDatabase &db = static_cast(subject); - - SpeechInterface si; - VoiceDesc desc = db.getVoiceDesc(); - m_tts = std::auto_ptr(si.createTts(desc.engine)); - si.configureTts(m_tts.get(), desc); -} - -//------------------------------------------------------------------------------ -bool -SpeakConfig::say(const std::string &sentence, HANDLE user) -{ - CLASSCERR("SpeakConfig::say(" << sentence << ")"); - - if (!m_tts.get()) - { - return false; - } - - bool active = true; - - if (NULL != user) - { - // get the status of the protocol of this user - const char *protocol = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, - (WPARAM)user, 0); - - if (ID_STATUS_OFFLINE == CallProtoService(protocol, PS_GETSTATUS, 0, 0)) - { - // if we are offline for this protocol, then don't speak the - // sentence this is so we don't announce users offline status if - // we are disconnected. - active = false; - } - else - { - switch (CallService(MS_CLIST_GETSTATUSMODE, 0, 0)) - { - case ID_STATUS_ONLINE: - active = m_db.getActiveFlag(ConfigDatabase::ActiveFlag_Online); - break; - case ID_STATUS_AWAY: - active = m_db.getActiveFlag(ConfigDatabase::ActiveFlag_Away); - break; - case ID_STATUS_DND: - active = m_db.getActiveFlag(ConfigDatabase::ActiveFlag_Dnd); - break; - case ID_STATUS_NA: - active = m_db.getActiveFlag(ConfigDatabase::ActiveFlag_Na); - break; - case ID_STATUS_OCCUPIED: - active = m_db.getActiveFlag(ConfigDatabase::ActiveFlag_Occupied); - break; - case ID_STATUS_FREECHAT: - active = m_db.getActiveFlag(ConfigDatabase::ActiveFlag_FreeForChat); - break; - case ID_STATUS_INVISIBLE: - active = m_db.getActiveFlag(ConfigDatabase::ActiveFlag_Invisible); - break; - default: - active = false; - break; - } - } - - // if its a user say, then check the users status - if (active && (NULL != user)) - { - active = m_db.getActiveUser(user); - } - } - - if (!active) - { - return false; - } - - bool ret = m_tts->say(sentence); - - return ret; -} - -//------------------------------------------------------------------------------ -/*int -SpeakConfig::dialogEngine(HWND window, unsigned int message, WPARAM wparam, - LPARAM lparam) -{ - if (WM_INITDIALOG == message) - { - m_dialog_engine = std::auto_ptr - (new DialogConfigEngine(window, m_db)); - } - else if (WM_DESTROY == message) - { - m_dialog_engine = std::auto_ptr(0); - } - - if (!m_dialog_engine.get()) - { - return 1; - } - - // process the message and if settings are changed, reload the tts - if (m_dialog_engine->process(message, wparam, lparam)) - { - m_db.load(); - SpeechInterface si; - m_tts = std::auto_ptr(si.createTts(m_db.getVoiceDesc())); - } - - return 0; -}*/ - -//============================================================================== diff --git a/plugins/!NotAdopted/WinterSpeak/speak/config/speak_config.h b/plugins/!NotAdopted/WinterSpeak/speak/config/speak_config.h deleted file mode 100644 index c664c9d9d8..0000000000 --- a/plugins/!NotAdopted/WinterSpeak/speak/config/speak_config.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef guard_speak_config_speak_config_h -#define guard_speak_config_speak_config_h -//============================================================================== -// Miranda Speak Plugin, © 2002 Ryan Winter -//============================================================================== - -#include "speak.h" -#include "config/config_database.h" -#include "config/dialog_config_active.h" -#include "config/dialog_config_engine.h" - -#include - -#include -#include - -class TextToSpeech; - -class SpeakConfig : public Observer -{ - public: - SpeakConfig(HINSTANCE instance); - virtual ~SpeakConfig(); - - //-------------------------------------------------------------------------- - // Description : Called by a subject that this observer is observing - // to signify a change in state - // Parameters : subject - the subject that changed - //-------------------------------------------------------------------------- - virtual void update(Subject &subject); - - //-------------------------------------------------------------------------- - // Description : speak a sentence - // Parameters : sentence - the sentence to speak - // user - the user to associate the say with - // NULL = ignore user - // Returns : true - speak successful - // false - speak failed - //-------------------------------------------------------------------------- - bool say(const std::string &sentence, HANDLE user = NULL); - - private: - HINSTANCE m_instance; - - ConfigDatabase m_db; - std::auto_ptr m_tts; - DialogConfigEngine m_dialog_engine; - DialogConfigActive m_dialog_active; -}; - -//============================================================================== -// -// Summary : The main object for the speak plugins -// -// Description : see summary -// -//============================================================================== - -#endif \ No newline at end of file diff --git a/plugins/!NotAdopted/WinterSpeak/speak/config/speech_interface.cpp b/plugins/!NotAdopted/WinterSpeak/speak/config/speech_interface.cpp deleted file mode 100644 index c80a219165..0000000000 --- a/plugins/!NotAdopted/WinterSpeak/speak/config/speech_interface.cpp +++ /dev/null @@ -1,91 +0,0 @@ -//============================================================================== -// Miranda Speak Plugin, © 2002 Ryan Winter -//============================================================================== - -#pragma warning(disable:4786) - -#include "speech_interface.h" - -#include "config/config_database.h" - -#include -#include -#include - -//------------------------------------------------------------------------------ -// public: -//------------------------------------------------------------------------------ -SpeechInterface::SpeechInterface() -{ - CLASSCERR("SpeechInterface::SpeechInterface"); -} - -//------------------------------------------------------------------------------ -SpeechInterface::~SpeechInterface() -{ - CLASSCERR("SpeechInterface::~SpeechInterface"); -} - -//------------------------------------------------------------------------------ -TextToSpeech * -SpeechInterface::createTts(std::string &engine) const -{ - CLASSCERR("SpeechInterface::createTts()"); - - TextToSpeech *tts = 0; - - if (SpeechApi40a::getDescription() == engine) - { - tts = new SpeechApi40a(); - } - else if (SpeechApi51::getDescription() == engine) - { - tts = new SpeechApi51(); - } - - CLASSCERR("SpeechInterface::createTts() return " << tts); - return tts; -} - -//------------------------------------------------------------------------------ -void -SpeechInterface::configureTts(TextToSpeech *tts, const VoiceDesc &desc) const -{ - CLASSCERR("SpeechInterface::configureTts(" << tts << ",)"); - - if (!tts) - { - return; - } - - tts->setVoice(desc.voice); - tts->setVolume(desc.volume); - tts->setRate(desc.rate); - tts->setPitch(desc.pitch); - tts->load(); -} - -//------------------------------------------------------------------------------ -std::vector -SpeechInterface::getAvailableEngines() -{ - CLASSCERR("SpeechInterface::getAvailableEngines"); - - std::vector engines; - - SpeechApi40a sapi40a; - if (sapi40a.isAvailable()) - { - engines.push_back(SpeechApi40a::getDescription()); - } - - SpeechApi51 sapi51; - if (sapi51.isAvailable()) - { - engines.push_back(SpeechApi51::getDescription()); - } - - return engines; -} - -//============================================================================== diff --git a/plugins/!NotAdopted/WinterSpeak/speak/config/speech_interface.h b/plugins/!NotAdopted/WinterSpeak/speak/config/speech_interface.h deleted file mode 100644 index 69d2d44e14..0000000000 --- a/plugins/!NotAdopted/WinterSpeak/speak/config/speech_interface.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef guard_speak_config_speech_interface_h -#define guard_speak_config_speech_interface_h -//============================================================================== -// Miranda Speak Plugin, © 2002 Ryan Winter -//============================================================================== - -#include "defs/voice_desc.h" - -#include -#include - -class TextToSpeech; - -class SpeechInterface -{ - public: - SpeechInterface(); - ~SpeechInterface(); - - //-------------------------------------------------------------------------- - // Description : create the text to speech object - // Parameters : engine - the name of the engine to create - // Returns : an instance of the text to speech engine - //-------------------------------------------------------------------------- - TextToSpeech * createTts(std::string &engine) const; - - //-------------------------------------------------------------------------- - // Description : configure the tts object - // Parameters : tts - the tts object to configure - // desc - the description of the voice - //-------------------------------------------------------------------------- - void configureTts(TextToSpeech *tts, const VoiceDesc &desc) const; - - //-------------------------------------------------------------------------- - // Description : create a vector of available engines - //-------------------------------------------------------------------------- - std::vector getAvailableEngines(); -}; - -//============================================================================== -// -// Summary : Configure a text to speech object -// -// Description : Encapsulate the different speech engines available -// -//============================================================================== - -#endif \ No newline at end of file -- cgit v1.2.3