summaryrefslogtreecommitdiff
path: root/plugins/WinterSpeak/src
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/WinterSpeak/src')
-rw-r--r--plugins/WinterSpeak/src/SpeakAnnounce.cpp130
-rw-r--r--plugins/WinterSpeak/src/SpeakAnnounce.h25
-rw-r--r--plugins/WinterSpeak/src/UserInformation.cpp10
-rw-r--r--plugins/WinterSpeak/src/UserInformation.h16
-rw-r--r--plugins/WinterSpeak/src/main.cpp11
5 files changed, 80 insertions, 112 deletions
diff --git a/plugins/WinterSpeak/src/SpeakAnnounce.cpp b/plugins/WinterSpeak/src/SpeakAnnounce.cpp
index e9120f20eb..1d95b743f6 100644
--- a/plugins/WinterSpeak/src/SpeakAnnounce.cpp
+++ b/plugins/WinterSpeak/src/SpeakAnnounce.cpp
@@ -12,7 +12,7 @@ SpeakAnnounce::~SpeakAnnounce()
}
//------------------------------------------------------------------------------
-void SpeakAnnounce::statusChange(DBCONTACTWRITESETTING *write_setting, HANDLE user)
+void SpeakAnnounce::statusChange(DBCONTACTWRITESETTING *write_setting, HCONTACT user)
{
const std::string STATUS = "Status";
@@ -20,15 +20,11 @@ void SpeakAnnounce::statusChange(DBCONTACTWRITESETTING *write_setting, HANDLE us
// if it's not a status change then return
// check and update the user's status, if status didn't change the return
if ((NULL == user) || (STATUS != write_setting->szSetting) || (!m_user_info.updateStatus(user, write_setting->value.wVal)))
- {
return;
- }
// check if we just connected, and want to suppress status changes
if (!m_db.getStatusFlag(AnnounceDatabase::StatusFlag_SuppressConnect) && m_protocol_info.isDisabled((char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)user, 0)))
- {
return;
- }
bool speak = false;
@@ -61,9 +57,7 @@ void SpeakAnnounce::statusChange(DBCONTACTWRITESETTING *write_setting, HANDLE us
}
if (!speak)
- {
return;
- }
// translate, insert name then speak
std::wstring status_str = TranslateW(m_user_info.statusString(user).c_str());
@@ -74,61 +68,50 @@ void SpeakAnnounce::statusChange(DBCONTACTWRITESETTING *write_setting, HANDLE us
//------------------------------------------------------------------------------
void SpeakAnnounce::incomingEvent(HCONTACT user, HANDLE event)
{
- if (m_event_info.isValidEvent(event))
- {
- bool speak = false;
- switch (m_event_info.getLastEvent())
- {
- case EVENTTYPE_MESSAGE:
- speak = m_db.getEventFlag(AnnounceDatabase::EventFlag_Message);
- break;
-
- case EVENTTYPE_URL:
- speak = m_db.getEventFlag(AnnounceDatabase::EventFlag_Url);
- break;
-
- case EVENTTYPE_ADDED:
- speak = m_db.getEventFlag(AnnounceDatabase::EventFlag_Added);
- break;
-
- case EVENTTYPE_AUTHREQUEST:
- speak = m_db.getEventFlag(AnnounceDatabase::EventFlag_AuthRequest);
- break;
-
- case EVENTTYPE_FILE:
- speak = m_db.getEventFlag(AnnounceDatabase::EventFlag_File);
- break;
-
- }
-
- if (!speak)
- {
- return;
- }
- std::wstring event_str = L"";
-
- if (EVENTTYPE_MESSAGE == m_event_info.getLastEvent())
- {
- if (!readMessage(user))
- {
- return; // message dialog is open so just leave without saying anything
- }
- if ((m_db.getEventFlag(AnnounceDatabase::EventFlag_ReadMsgLength)) && (m_event_info.getMessageSize() <= m_db.getMaxMsgSize()))
- {
- event_str = m_event_info.getMessage(); // conditions met to read the message
- }
- else
- {
- event_str = m_event_info.eventString();
- }
- }
+ if (!m_event_info.isValidEvent(event))
+ return;
+
+ bool speak = false;
+ switch (m_event_info.getLastEvent()) {
+ case EVENTTYPE_MESSAGE:
+ speak = m_db.getEventFlag(AnnounceDatabase::EventFlag_Message);
+ break;
+
+ case EVENTTYPE_URL:
+ speak = m_db.getEventFlag(AnnounceDatabase::EventFlag_Url);
+ break;
+
+ case EVENTTYPE_ADDED:
+ speak = m_db.getEventFlag(AnnounceDatabase::EventFlag_Added);
+ break;
+
+ case EVENTTYPE_AUTHREQUEST:
+ speak = m_db.getEventFlag(AnnounceDatabase::EventFlag_AuthRequest);
+ break;
+
+ case EVENTTYPE_FILE:
+ speak = m_db.getEventFlag(AnnounceDatabase::EventFlag_File);
+ break;
+ }
+
+ if (!speak)
+ return;
+
+ std::wstring event_str = L"";
+
+ if (EVENTTYPE_MESSAGE == m_event_info.getLastEvent()) {
+ if (!readMessage(user))
+ return; // message dialog is open so just leave without saying anything
+
+ if ((m_db.getEventFlag(AnnounceDatabase::EventFlag_ReadMsgLength)) && (m_event_info.getMessageSize() <= m_db.getMaxMsgSize()))
+ event_str = m_event_info.getMessage(); // conditions met to read the message
else
- {
event_str = m_event_info.eventString();
- }
- m_user_info.insertName(event_str, user); // translate the string, insert the name, then speak it
- message(event_str, user);
}
+ else event_str = m_event_info.eventString();
+
+ m_user_info.insertName(event_str, user); // translate the string, insert the name, then speak it
+ message(event_str, user);
}
//------------------------------------------------------------------------------
@@ -148,52 +131,41 @@ void SpeakAnnounce::protocolAck(ACKDATA *ack)
}
//------------------------------------------------------------------------------
-void SpeakAnnounce::message(const std::wstring &sentence, HANDLE user)
+void SpeakAnnounce::message(const std::wstring &sentence, HCONTACT user)
{
- CallService(MS_SPEAK_MESSAGE, reinterpret_cast<LPARAM>(user), reinterpret_cast<WPARAM>(sentence.c_str()));
+ CallService(MS_SPEAK_MESSAGE, LPARAM(user), reinterpret_cast<WPARAM>(sentence.c_str()));
}
-void SpeakAnnounce::status(const std::wstring &sentence, HANDLE user)
+
+void SpeakAnnounce::status(const std::wstring &sentence, HCONTACT user)
{
- CallService(MS_SPEAK_STATUS, reinterpret_cast<LPARAM>(user), reinterpret_cast<WPARAM>(sentence.c_str()));
+ CallService(MS_SPEAK_STATUS, LPARAM(user), reinterpret_cast<WPARAM>(sentence.c_str()));
}
//------------------------------------------------------------------------------
-bool SpeakAnnounce::readMessage(HANDLE contact)
+bool SpeakAnnounce::readMessage(HCONTACT contact)
{
std::wstring title = m_user_info.nameString(contact) + L" (" + m_user_info.statusModeString(contact) + L"): ";
- HWND window = NULL;
-
- window = FindWindow(L"#32770", (title + TranslateW(L"Message Session")).c_str());
- if (window)
- {
+ HWND window = FindWindow(L"#32770", (title + TranslateW(L"Message Session")).c_str());
+ if (window) {
// check if we dont want to read message if dialog is open
if (m_db.getEventFlag(AnnounceDatabase::EventFlag_DialogOpen))
- {
return false;
- }
// check if we dont want to read message if dialog if focused
if ((window == GetForegroundWindow()) && m_db.getEventFlag(AnnounceDatabase::EventFlag_DialogFocused))
- {
return false;
- }
}
window = FindWindow(L"#32770", (title + TranslateW(L"Message Received")).c_str());
- if (window)
- {
+ if (window) {
// check if we dont want to read message if dialog is open
if (m_db.getEventFlag(AnnounceDatabase::EventFlag_DialogOpen))
- {
return false;
- }
// check if we dont want to read message if dialog if focused
if ((window == GetForegroundWindow()) && m_db.getEventFlag(AnnounceDatabase::EventFlag_DialogFocused))
- {
return false;
- }
}
return true;
diff --git a/plugins/WinterSpeak/src/SpeakAnnounce.h b/plugins/WinterSpeak/src/SpeakAnnounce.h
index e4980a292a..cb1a53f8bf 100644
--- a/plugins/WinterSpeak/src/SpeakAnnounce.h
+++ b/plugins/WinterSpeak/src/SpeakAnnounce.h
@@ -5,14 +5,14 @@
class SpeakAnnounce
{
- public:
+public:
SpeakAnnounce(HINSTANCE instance);
~SpeakAnnounce();
//--------------------------------------------------------------------------
// Description : handle a status change
//--------------------------------------------------------------------------
- void statusChange(DBCONTACTWRITESETTING *write_setting, HANDLE user);
+ void statusChange(DBCONTACTWRITESETTING *write_setting, HCONTACT user);
//--------------------------------------------------------------------------
// Description : handle an event
@@ -22,33 +22,32 @@ class SpeakAnnounce
//--------------------------------------------------------------------------
// Description : handle a protocol state change
//--------------------------------------------------------------------------
- void protocolAck(ACKDATA *ack);
+ void protocolAck(ACKDATA *ack);
//--------------------------------------------------------------------------
// Description : speak a sentence
// Parameters : sentence - the sentence to speak
- // user - the user who is speaking, or NULL for no user
+ // user - the user who is speaking, or NULL for no user
// Returns : true - speak successful
// false - speak failed
//--------------------------------------------------------------------------
- void message(const std::wstring &sentence, HANDLE user);
- void status(const std::wstring &sentence, HANDLE user);
+ void message(const std::wstring &sentence, HCONTACT user);
+ void status(const std::wstring &sentence, HCONTACT user);
- private:
+private:
//--------------------------------------------------------------------------
// Description : check if the users message window is open and focused
// Parameters : contact - the user to check for
// Returns : true = message window is open
// false = message window not open
//--------------------------------------------------------------------------
- bool readMessage(HANDLE contact);
+ bool readMessage(HCONTACT contact);
- HINSTANCE m_instance;
+ HINSTANCE m_instance;
AnnounceDatabase m_db;
- AnnounceDialog m_dialog;
- UserInformation m_user_info;
+ AnnounceDialog m_dialog;
+ UserInformation m_user_info;
EventInformation m_event_info;
- ProtocolInformation m_protocol_info;
+ ProtocolInformation m_protocol_info;
};
-
diff --git a/plugins/WinterSpeak/src/UserInformation.cpp b/plugins/WinterSpeak/src/UserInformation.cpp
index 046c148542..ba081d2b95 100644
--- a/plugins/WinterSpeak/src/UserInformation.cpp
+++ b/plugins/WinterSpeak/src/UserInformation.cpp
@@ -20,7 +20,7 @@ UserInformation::~UserInformation()
}
//------------------------------------------------------------------------------
-bool UserInformation::updateStatus(HANDLE user, int status)
+bool UserInformation::updateStatus(HCONTACT user, int status)
{
bool ret = false;
@@ -38,13 +38,13 @@ bool UserInformation::updateStatus(HANDLE user, int status)
}
//------------------------------------------------------------------------------
-std::wstring UserInformation::statusString(HANDLE user)
+std::wstring UserInformation::statusString(HCONTACT user)
{
return m_status_strings[m_status_info[user]];
}
//------------------------------------------------------------------------------
-std::wstring UserInformation::statusModeString(HANDLE user)
+std::wstring UserInformation::statusModeString(HCONTACT user)
{
int status = CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, m_status_info[user], 0);
@@ -57,14 +57,14 @@ std::wstring UserInformation::statusModeString(HANDLE user)
}
//------------------------------------------------------------------------------
-void UserInformation::insertName(std::wstring &str, HANDLE user) const
+void UserInformation::insertName(std::wstring &str, HCONTACT user) const
{
// insert the user's name into the string
str.replace(str.find(L"%u"), 2, nameString(user));
}
//------------------------------------------------------------------------------
-std::wstring UserInformation::nameString(HANDLE user) const
+std::wstring UserInformation::nameString(HCONTACT user) const
{
//WCHAR *ret = reinterpret_cast<WCHAR *>(CallService(MS_CLIST_GETCONTACTDISPLAYNAME, reinterpret_cast<unsigned int>(user), 0));
char* ret = (char *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, WPARAM(user), 0);
diff --git a/plugins/WinterSpeak/src/UserInformation.h b/plugins/WinterSpeak/src/UserInformation.h
index a9d972d96d..7ab11ecddc 100644
--- a/plugins/WinterSpeak/src/UserInformation.h
+++ b/plugins/WinterSpeak/src/UserInformation.h
@@ -5,7 +5,7 @@
class UserInformation
{
- public:
+public:
UserInformation();
~UserInformation();
@@ -16,38 +16,38 @@ class UserInformation
// Returns : true - the status changed
// false - the status stayed the same
//--------------------------------------------------------------------------
- bool updateStatus(HANDLE user, int status);
+ bool updateStatus(HCONTACT user, int status);
//--------------------------------------------------------------------------
// Description : get a string containing the users current status string
// Parameters : user - the current user
// Returns : the string containing the users status
//--------------------------------------------------------------------------
- std::wstring statusString(HANDLE user);
+ std::wstring statusString(HCONTACT user);
//--------------------------------------------------------------------------
// Description : return the status mode of the user
// Parameters : user - the current user
// Returns : the string containing the users status mode
//--------------------------------------------------------------------------
- std::wstring statusModeString(HANDLE user);
+ std::wstring statusModeString(HCONTACT user);
//--------------------------------------------------------------------------
// Description : insert the name into the string at the %u location
// Parameters : str - the string to have the username inserted into
// user - the current user
//--------------------------------------------------------------------------
- void insertName(std::wstring &str, HANDLE user) const;
+ void insertName(std::wstring &str, HCONTACT user) const;
//--------------------------------------------------------------------------
// Description : get the name string for the user
// Parameters : user - the current user
// Returns : a string containing the user's name
//--------------------------------------------------------------------------
- std::wstring nameString(HANDLE user) const;
+ std::wstring nameString(HCONTACT user) const;
- private:
- std::map<HANDLE, int> m_status_info;
+private:
+ std::map<HCONTACT, int> m_status_info;
std::map<int, std::wstring> m_status_strings;
};
diff --git a/plugins/WinterSpeak/src/main.cpp b/plugins/WinterSpeak/src/main.cpp
index e20c0fa113..f218b87f43 100644
--- a/plugins/WinterSpeak/src/main.cpp
+++ b/plugins/WinterSpeak/src/main.cpp
@@ -31,12 +31,12 @@ PLUGININFOEX pluginInfo={
//-----------------------------------------------------------------------------
INT_PTR status(WPARAM wParam, LPARAM lParam)
{
- return g_speak_config->status(reinterpret_cast<WCHAR *>(lParam), reinterpret_cast<HCONTACT>(wParam));
+ return g_speak_config->status(reinterpret_cast<WCHAR *>(lParam), HCONTACT(wParam));
}
INT_PTR message(WPARAM wParam, LPARAM lParam)
{
- return g_speak_config->message(reinterpret_cast<WCHAR *>(lParam), reinterpret_cast<HCONTACT>(wParam));
+ return g_speak_config->message(reinterpret_cast<WCHAR *>(lParam), HCONTACT(wParam));
}
//-----------------------------------------------------------------------------
@@ -44,10 +44,7 @@ INT_PTR message(WPARAM wParam, LPARAM lParam)
//-----------------------------------------------------------------------------
int eventStatusChange(WPARAM wParam, LPARAM lParam)
{
- g_speak_announce->statusChange(
- reinterpret_cast<DBCONTACTWRITESETTING *>(lParam),
- reinterpret_cast<HANDLE>(wParam));
-
+ g_speak_announce->statusChange(reinterpret_cast<DBCONTACTWRITESETTING *>(lParam), HCONTACT(wParam));
return 0;
}
@@ -56,7 +53,7 @@ int eventStatusChange(WPARAM wParam, LPARAM lParam)
//-----------------------------------------------------------------------------
int eventMessageAdded(WPARAM wParam, LPARAM lParam)
{
- g_speak_announce->incomingEvent(reinterpret_cast<HCONTACT>(wParam), reinterpret_cast<HANDLE>(lParam));
+ g_speak_announce->incomingEvent(HCONTACT(wParam), reinterpret_cast<HANDLE>(lParam));
return 0;
}