diff options
author | Vadim Dashevskiy <watcherhd@gmail.com> | 2013-03-17 13:41:49 +0000 |
---|---|---|
committer | Vadim Dashevskiy <watcherhd@gmail.com> | 2013-03-17 13:41:49 +0000 |
commit | 5e6e1e8838fe7637ef588e0fb080ad07fc5700aa (patch) | |
tree | 2cc32c95da0cf49f8361879eec1fa5a4a4b557d8 /plugins/!NotAdopted/WinterSpeak/speak/user | |
parent | 561f00a7d38c61ec30c5898b90766314011d32d8 (diff) |
Winter Speak plugin added (not adopted)
git-svn-id: http://svn.miranda-ng.org/main/trunk@4076 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/!NotAdopted/WinterSpeak/speak/user')
-rw-r--r-- | plugins/!NotAdopted/WinterSpeak/speak/user/user_information.cpp | 116 | ||||
-rw-r--r-- | plugins/!NotAdopted/WinterSpeak/speak/user/user_information.h | 69 |
2 files changed, 185 insertions, 0 deletions
diff --git a/plugins/!NotAdopted/WinterSpeak/speak/user/user_information.cpp b/plugins/!NotAdopted/WinterSpeak/speak/user/user_information.cpp new file mode 100644 index 0000000000..0a2317f78c --- /dev/null +++ b/plugins/!NotAdopted/WinterSpeak/speak/user/user_information.cpp @@ -0,0 +1,116 @@ +//==============================================================================
+// Miranda Speak Plugin, © 2002 Ryan Winter
+//==============================================================================
+
+#pragma warning(disable:4786)
+
+#include "user_information.h"
+
+#include "speak.h"
+
+#include <general/debug/debug.h>
+
+//------------------------------------------------------------------------------
+// public:
+//------------------------------------------------------------------------------
+UserInformation::UserInformation()
+ :
+ m_status_info(),
+ m_status_strings()
+{
+ CLASSCERR("UserInformation::UserInformation");
+
+ // insert the status strings into a map for easy access
+ m_status_strings[ID_STATUS_OFFLINE] = "%u is now offline";
+ m_status_strings[ID_STATUS_ONLINE] = "%u is now online";
+ m_status_strings[ID_STATUS_AWAY] = "%u is away";
+ m_status_strings[ID_STATUS_INVISIBLE] = "%u is invisible";
+ m_status_strings[ID_STATUS_NA] = "%u is not available";
+ m_status_strings[ID_STATUS_DND] = "%u does not want to be disturbed";
+ m_status_strings[ID_STATUS_OCCUPIED] = "%u is occupied";
+ m_status_strings[ID_STATUS_FREECHAT] = "%u is free for chat";
+}
+
+//------------------------------------------------------------------------------
+UserInformation::~UserInformation()
+{
+ CLASSCERR("UserInformation::~UserInformation");
+}
+
+//------------------------------------------------------------------------------
+bool
+UserInformation::updateStatus(HANDLE user, int status)
+{
+ CLASSCERR("UserInformation::updateStatus(," << 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::string
+UserInformation::statusString(HANDLE user)
+{
+ CLASSCERR("UserInformation::statusString()");
+
+ return m_status_strings[m_status_info[user]];
+}
+
+//------------------------------------------------------------------------------
+std::string
+UserInformation::statusModeString(HANDLE user)
+{
+ CLASSCERR("UserInformation::statusModeString()");
+
+ int status = CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,
+ m_status_info[user], 0);
+
+ if (NULL == status)
+ {
+ return "";
+ }
+
+ return reinterpret_cast<char *>(status);
+}
+
+//------------------------------------------------------------------------------
+void
+UserInformation::insertName(std::string &str, HANDLE user) const
+{
+ CLASSCERR("UserInformation::insertName(" << str << ",)");
+
+ // insert the user's name into the string
+ str.replace(str.find("%u"), 2, nameString(user));
+}
+
+//------------------------------------------------------------------------------
+std::string
+UserInformation::nameString(HANDLE user) const
+{
+ CLASSCERR("UserInformation::nameString()");
+
+ char *ret = reinterpret_cast<char *>(
+ CallService(MS_CLIST_GETCONTACTDISPLAYNAME,
+ reinterpret_cast<unsigned int>(user),
+ 0));
+
+ if (0 == ret)
+ {
+ return "";
+ }
+
+ return Translate(ret);
+}
+
+//==============================================================================
diff --git a/plugins/!NotAdopted/WinterSpeak/speak/user/user_information.h b/plugins/!NotAdopted/WinterSpeak/speak/user/user_information.h new file mode 100644 index 0000000000..5e6ec80d46 --- /dev/null +++ b/plugins/!NotAdopted/WinterSpeak/speak/user/user_information.h @@ -0,0 +1,69 @@ +#ifndef guard_speak_user_user_information_h
+#define guard_speak_user_user_information_h
+//==============================================================================
+// Miranda Speak Plugin, © 2002 Ryan Winter
+//==============================================================================
+
+#include <windows.h>
+
+#include <map>
+#include <string>
+
+class UserInformation
+{
+ public:
+ UserInformation();
+ ~UserInformation();
+
+ //--------------------------------------------------------------------------
+ // Description : update the users status
+ // Parameters : user - the current user
+ // status - the users status
+ // Returns : true - the status changed
+ // false - the status stayed the same
+ //--------------------------------------------------------------------------
+ bool updateStatus(HANDLE 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::string statusString(HANDLE user);
+
+ //--------------------------------------------------------------------------
+ // Description : return the status mode of the user
+ // Parameters : user - the current user
+ // Returns : the string containing the users status mode
+ //--------------------------------------------------------------------------
+ std::string statusModeString(HANDLE 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::string &str, HANDLE user) const;
+
+ //--------------------------------------------------------------------------
+ // Description : get the name string for the user
+ // Parameters : user - the current user
+ // Returns : a string containing the user's name
+ //--------------------------------------------------------------------------
+ std::string nameString(HANDLE user) const;
+
+ private:
+ std::map<HANDLE, int> m_status_info;
+ std::map<int, std::string> m_status_strings;
+};
+
+//==============================================================================
+//
+// Summary : Contain information about the current users
+//
+// Description : Provides an interface to get various information about the
+// user. Also holds the users current status.
+//
+//==============================================================================
+
+#endif
\ No newline at end of file |