diff options
author | (no author) <(no author)@63852ff1-2cfd-40b9-8011-e561a9d89b1c> | 2008-11-28 09:54:30 +0000 |
---|---|---|
committer | (no author) <(no author)@63852ff1-2cfd-40b9-8011-e561a9d89b1c> | 2008-11-28 09:54:30 +0000 |
commit | 62a74c235e863104364994183bdc20ef6d5dda5d (patch) | |
tree | 7823d80b27fe761bcf026c711e6bf5d43da0c7d4 /stopspam_mod/trunk/utilities.cpp | |
parent | 6ab8c4ff109bfeec0df3f840a85cb28ec5d38259 (diff) |
recovering repository ....
git-svn-id: http://172.18.13.13/svn/mim_plugs@2 63852ff1-2cfd-40b9-8011-e561a9d89b1c
Diffstat (limited to 'stopspam_mod/trunk/utilities.cpp')
-rw-r--r-- | stopspam_mod/trunk/utilities.cpp | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/stopspam_mod/trunk/utilities.cpp b/stopspam_mod/trunk/utilities.cpp new file mode 100644 index 0000000..f2b35b3 --- /dev/null +++ b/stopspam_mod/trunk/utilities.cpp @@ -0,0 +1,94 @@ +#include "headers.h"
+
+tstring DBGetContactSettingStringPAN(HANDLE hContact, char const * szModule, char const * szSetting, tstring errorValue)
+{
+ DBVARIANT dbv;
+ //if(DBGetContactSetting(hContact, szModule, szSetting, &dbv))
+ if(DBGetContactSettingTString(hContact, szModule, szSetting, &dbv))
+ return errorValue;
+// if(DBVT_TCHAR == dbv.type )
+ errorValue = dbv.ptszVal;
+ DBFreeVariant(&dbv);
+ return errorValue;
+}
+
+std::string DBGetContactSettingStringPAN_A(HANDLE hContact, char const * szModule, char const * szSetting, std::string errorValue)
+{
+ DBVARIANT dbv;
+ //if(DBGetContactSetting(hContact, szModule, szSetting, &dbv))
+ if(DBGetContactSettingString(hContact, szModule, szSetting, &dbv))
+ return errorValue;
+// if(DBVT_ASCIIZ == dbv.type )
+ errorValue = dbv.pszVal;
+ DBFreeVariant(&dbv);
+ return errorValue;
+}
+
+tstring &GetDlgItemString(HWND hwnd, int id)
+{
+ HWND h = GetDlgItem(hwnd, id);
+ int len = GetWindowTextLength(h);
+ TCHAR * buf = new TCHAR[len + 1];
+ GetWindowText(h, buf, len + 1);
+ static tstring s;
+ s = buf;
+ delete []buf;
+ return s;
+}
+
+std::string &GetProtoList()
+{
+ static std::string s;
+ return s = DBGetContactSettingStringPAN_A(NULL, pluginName, "protoList", "ICQ\r\n");
+}
+
+
+bool ProtoInList(std::string proto)
+{
+ return std::string::npos != GetProtoList().find(proto + "\r\n");
+}
+
+int CreateCListGroup(TCHAR* szGroupName)
+{
+ int hGroup;
+ CLIST_INTERFACE *clint = NULL;
+
+ if (ServiceExists(MS_CLIST_RETRIEVE_INTERFACE))
+ clint = (CLIST_INTERFACE*)CallService(MS_CLIST_RETRIEVE_INTERFACE, 0, 0);
+
+ hGroup = CallService(MS_CLIST_GROUPCREATE, 0, 0);
+
+ TCHAR* usTmp = szGroupName;
+
+ clint->pfnRenameGroup(hGroup, usTmp);
+
+ return hGroup;
+}
+
+
+void RemoveExcludedUsers()
+{
+ HANDLE hContact;
+ HANDLE ToRemove[4096];
+ int i = 0;
+ int a = 0;
+ hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
+ if(hContact)
+ {
+ do
+ {
+ if(DBGetContactSettingByte(hContact, "CList", "NotOnList", 0) && DBGetContactSettingByte(hContact, pluginName, "Excluded", 0))
+ {
+ ToRemove[i] = hContact;
+ i++;
+ }
+ }
+ while(hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact, 0));
+ ToRemove[i] = INVALID_HANDLE_VALUE;
+ while(ToRemove[a] != INVALID_HANDLE_VALUE)
+ {
+ CallService(MS_DB_CONTACT_DELETE, (WPARAM)ToRemove[a], 0);
+ a++;
+ }
+ }
+}
|