summaryrefslogtreecommitdiff
path: root/plugins/WinterSpeak/src/UserInformation.cpp
diff options
context:
space:
mode:
authorPhilip Schell <github.com@blubbfish.net>2013-10-19 13:05:02 +0000
committerPhilip Schell <github.com@blubbfish.net>2013-10-19 13:05:02 +0000
commit397e25f2b71347c7c83495fe5b25496ff3b02b75 (patch)
tree71f6ad2ef525218541a7a35cc659b4fb7bf047d6 /plugins/WinterSpeak/src/UserInformation.cpp
parent9e786b686fae94e71279a797047a91ffdc4b0443 (diff)
WinterSpeak: ticket:269 WinterSpeak now rewritten
git-svn-id: http://svn.miranda-ng.org/main/trunk@6532 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/WinterSpeak/src/UserInformation.cpp')
-rw-r--r--plugins/WinterSpeak/src/UserInformation.cpp78
1 files changed, 78 insertions, 0 deletions
diff --git a/plugins/WinterSpeak/src/UserInformation.cpp b/plugins/WinterSpeak/src/UserInformation.cpp
new file mode 100644
index 0000000000..fa5db0b0e5
--- /dev/null
+++ b/plugins/WinterSpeak/src/UserInformation.cpp
@@ -0,0 +1,78 @@
+#include "Common.h"
+#include "UserInformation.h"
+
+
+UserInformation::UserInformation() : m_status_info(), m_status_strings() {
+ // insert the status strings into a map for easy access
+ m_status_strings[ID_STATUS_OFFLINE] = L"%u is now offline";
+ m_status_strings[ID_STATUS_ONLINE] = L"%u is now online";
+ m_status_strings[ID_STATUS_AWAY] = L"%u is away";
+ m_status_strings[ID_STATUS_INVISIBLE] = L"%u is invisible";
+ m_status_strings[ID_STATUS_NA] = L"%u is not available";
+ m_status_strings[ID_STATUS_DND] = L"%u does not want to be disturbed";
+ m_status_strings[ID_STATUS_OCCUPIED] = L"%u is occupied";
+ m_status_strings[ID_STATUS_FREECHAT] = L"%u is free for chat";
+}
+
+//------------------------------------------------------------------------------
+UserInformation::~UserInformation()
+{
+}
+
+//------------------------------------------------------------------------------
+bool UserInformation::updateStatus(HANDLE user, int status)
+{
+ bool ret = false;
+
+ // if the user exists and their status hasn't changed, then return false
+ if ((m_status_info.find(user) != m_status_info.end())
+ && (m_status_info[user] != status))
+ {
+ ret = true;
+ }
+
+ // update the status
+ m_status_info[user] = status;
+
+ return ret;
+}
+
+//------------------------------------------------------------------------------
+std::wstring UserInformation::statusString(HANDLE user)
+{
+ return m_status_strings[m_status_info[user]];
+}
+
+//------------------------------------------------------------------------------
+std::wstring UserInformation::statusModeString(HANDLE user)
+{
+ int status = CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, m_status_info[user], 0);
+
+ if (NULL == status)
+ {
+ return L"";
+ }
+
+ return reinterpret_cast<WCHAR *>(status);
+}
+
+//------------------------------------------------------------------------------
+void UserInformation::insertName(std::wstring &str, HANDLE 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
+{
+ //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);
+ if (0 == ret)
+ {
+ return L"";
+ }
+ return TranslateW(mir_a2t(ret));
+}
+
+//==============================================================================