diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2012-06-29 05:38:03 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2012-06-29 05:38:03 +0000 |
commit | af7e438cfe8ce85e1da234318ed1584e89d952cc (patch) | |
tree | 4cdb1379ef8d6c00389aa89cfb27a404ae2aba56 /plugins/XSoundNotify/xsn_utils.cpp | |
parent | 230623d50baff4e8bf13a8572e0b895bad7b7ed4 (diff) |
only add some plugins and protocols, not adapted
See please maybe not all need us
git-svn-id: http://svn.miranda-ng.org/main/trunk@678 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/XSoundNotify/xsn_utils.cpp')
-rw-r--r-- | plugins/XSoundNotify/xsn_utils.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/plugins/XSoundNotify/xsn_utils.cpp b/plugins/XSoundNotify/xsn_utils.cpp new file mode 100644 index 0000000000..d597776e8d --- /dev/null +++ b/plugins/XSoundNotify/xsn_utils.cpp @@ -0,0 +1,60 @@ +#include "xsn_utils.h"
+#include <m_protocols.h>
+#include <boost/lexical_cast.hpp>
+
+void initModuleConvertTable(ModuleConvertTable & table)
+{
+ int number = 0;
+ // may be need to free PROTOACCOUNT, but did't found information about it
+ PROTOACCOUNT ** accounts;
+ ProtoEnumAccounts(&number, &accounts);
+ for (int i = 0; i < number; ++i)
+ table[ModuleString(accounts[i]->szModuleName)] = ProtocolString(accounts[i]->szProtoName);
+}
+
+bool isReceiveMessage(LPARAM event)
+{
+ DBEVENTINFO info = { sizeof(info) };
+ CallService(MS_DB_EVENT_GET, event, (LPARAM)&info);
+ // i don't understand why it works and how it works, but it works correctly - practice way (методом тыка)
+ // so, i think correct condition would be : eventType == EVENTTYPE_MESSAGE && info.flags & DBEF_READ, but it really isn't
+ return !(((info.eventType != EVENTTYPE_MESSAGE) && !(info.flags & DBEF_READ)) || (info.flags & DBEF_SENT));
+}
+
+xsn_string getContactSound(HANDLE contact)
+{
+ XSN_Variant sound;
+ DBGetContactSettingTString(contact, XSN_ModuleInfo::name(), XSN_ModuleInfo::soundSetting(), &sound);
+ return sound.toString();
+}
+
+ModuleString getContactModule(HANDLE contact)
+{
+ char * proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)contact, 0);
+ if (proto == nullptr)
+ throw std::runtime_error("MS_PROTO_GETCONTACTBASEPROTO failed");
+ return ModuleString(proto);
+}
+
+xsn_string getIcqContactId(HANDLE contact, const ModuleString & module)
+{
+ XSN_Variant nick;
+ DBGetContactSettingTString(contact, module.c_str(), "CustomNick", &nick);
+ if (nick.empty())
+ DBGetContactSettingTString(contact, module.c_str(), "Nick", &nick);
+ DWORD uin = DBGetContactSettingDword(contact, module.c_str(), "UIN", 0);
+ xsn_string uinStr = boost::lexical_cast<xsn_string>(uin);
+ if (nick.empty())
+ return uinStr;
+ return nick.toString() + TEXT(" (") + uinStr + TEXT(")");
+}
+
+xsn_string getJabberContactId(HANDLE contact, const ModuleString & module)
+{
+ XSN_Variant jid, nick;
+ DBGetContactSettingTString(contact, module.c_str(), "jid", &jid);
+ DBGetContactSettingTString(contact, "CList", "MyHandle", &nick);
+ if (nick.empty())
+ return jid.toString();
+ return nick.toString() + TEXT(" (") + jid.toString() + TEXT(")");
+}
|