diff options
author | George Hazan <george.hazan@gmail.com> | 2015-05-21 16:11:58 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-05-21 16:11:58 +0000 |
commit | 48266e479d1fcf5153b29c612866845990fccad8 (patch) | |
tree | c8cbc908cd3c5f08731e5e8d7eaac6b568007d09 /plugins/Spamotron | |
parent | ebdb556f152734035846f120eb8112f88ef91281 (diff) |
war against atavisms continues
- everything that goes to PSS_MESSAGE should be sent as utf8 string;
- thus PREF_UNICODE & PREF_UTF support discontinued, these constants are removed;
- support for PREF_UNICODE & PREF_UTF in protocols also removed;
- PREF_UNICODE used in file transfers (PROTOFILERECVT) replaced with PRFF_UNICODE / PRFF_TCHAR
git-svn-id: http://svn.miranda-ng.org/main/trunk@13734 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Spamotron')
-rw-r--r-- | plugins/Spamotron/src/spamotron.cpp | 135 |
1 files changed, 55 insertions, 80 deletions
diff --git a/plugins/Spamotron/src/spamotron.cpp b/plugins/Spamotron/src/spamotron.cpp index dc7fe34e84..4ce453a710 100644 --- a/plugins/Spamotron/src/spamotron.cpp +++ b/plugins/Spamotron/src/spamotron.cpp @@ -56,7 +56,6 @@ int OnDBEventFilterAdd(WPARAM wParam, LPARAM lParam) POPUPDATAT ppdp = {0};
DBTIMETOSTRING tts = {0};
char protoOption[256] = {0};
- char *response, *tmp, *challenge;
int buflen = MAX_BUFFER_LENGTH;
TCHAR buf[MAX_BUFFER_LENGTH];
TCHAR *message = NULL, *challengeW = NULL, *tmpW = NULL;
@@ -174,11 +173,8 @@ int OnDBEventFilterAdd(WPARAM wParam, LPARAM lParam) db_unset(hContact, "CList", "NotOnList");
db_unset(hContact, "CList", "Delete");
if (_getOptB("ReplyOnSuccess", defaultReplyOnSuccess) && (_getCOptB(hContact, "MsgSent", 0))) {
- tmp = mir_u2a(_getOptS(buf, buflen, "SuccessResponse", defaultSuccessResponse));
- response = mir_utf8encode(tmp);
- mir_free(tmp);
- CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)response);
- mir_free(response);
+ ptrA response(mir_utf8encodeT(_getOptS(buf, buflen, "SuccessResponse", defaultSuccessResponse)));
+ CallContactService(hContact, PSS_MESSAGE, 0, response);
}
return 0;
}
@@ -243,11 +239,8 @@ int OnDBEventFilterAdd(WPARAM wParam, LPARAM lParam) db_unset(hContact, "CList", "Delete");
db_unset(hContact, "CList", "ResponseNum");
if (_getOptB("ReplyOnSuccess", defaultReplyOnSuccess)) {
- tmp = mir_u2a(_getOptS(buf, buflen, "SuccessResponse", defaultSuccessResponse));
- response = mir_utf8encode(tmp);
- mir_free(tmp);
- CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)response);
- mir_free(response);
+ ptrA response(mir_utf8encodeT(_getOptS(buf, buflen, "SuccessResponse", defaultSuccessResponse)));
+ CallContactService(hContact, PSS_MESSAGE, 0, response);
}
_notify(hContact, POPUP_APPROVED, TranslateT("Contact %s approved."), NULL);
@@ -368,76 +361,58 @@ int OnDBEventFilterAdd(WPARAM wParam, LPARAM lParam) challengeW = (TCHAR *)malloc(maxmsglen*sizeof(TCHAR));
tmpW = (TCHAR *)malloc(maxmsglen*sizeof(TCHAR));
- switch (_getOptB("Mode", defaultMode))
- {
- case SPAMOTRON_MODE_PLAIN:
- if (dbei->eventType == EVENTTYPE_AUTHREQUEST)
- _getOptS(challengeW, maxmsglen, "AuthChallenge", defaultAuthChallenge);
- else
- _getOptS(challengeW, maxmsglen, "Challenge", defaultChallenge);
- ReplaceVars(challengeW, maxmsglen);
- tmp = mir_u2a(challengeW);
- challenge = mir_utf8encode(tmp);
- mir_free(tmp);
- CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)challenge);
- mir_free(challenge);
- _notify(hContact, POPUP_CHALLENGE, TranslateT("Sending plain challenge to %s."), message);
- break;
+ switch (_getOptB("Mode", defaultMode)) {
+ case SPAMOTRON_MODE_PLAIN:
+ if (dbei->eventType == EVENTTYPE_AUTHREQUEST)
+ _getOptS(challengeW, maxmsglen, "AuthChallenge", defaultAuthChallenge);
+ else
+ _getOptS(challengeW, maxmsglen, "Challenge", defaultChallenge);
+ ReplaceVars(challengeW, maxmsglen);
+ CallContactService(hContact, PSS_MESSAGE, 0, ptrA(mir_utf8encodeT(challengeW)));
+ _notify(hContact, POPUP_CHALLENGE, TranslateT("Sending plain challenge to %s."), message);
+ break;
- case SPAMOTRON_MODE_ROTATE:
- if (dbei->eventType == EVENTTYPE_AUTHREQUEST)
- _getOptS(challengeW, maxmsglen, "AuthChallenge", defaultAuthChallenge);
- else
- _getOptS(challengeW, maxmsglen, "Challenge", defaultChallenge);
- _getOptS(buf, buflen, "Response", defaultResponse);
- if (_getCOptD(hContact, "ResponseNum", 0) >= (unsigned int)(get_response_num(buf)-1)) {
- _setCOptD(hContact, "ResponseNum", -1);
- }
- _setCOptD(hContact, "ResponseNum", _getCOptD(hContact, "ResponseNum", -1) + 1);
- ReplaceVarsNum(challengeW, maxmsglen, _getCOptD(hContact, "ResponseNum", 0));
-
- tmp = mir_u2a(challengeW);
- challenge = mir_utf8encode(tmp);
- mir_free(tmp);
- CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)challenge);
- mir_free(challenge);
- _notify(hContact, POPUP_CHALLENGE, TranslateT("Sending round-robin challenge to %s."), message);
- break;
-
- case SPAMOTRON_MODE_RANDOM:
- if (dbei->eventType == EVENTTYPE_AUTHREQUEST)
- _getOptS(challengeW, maxmsglen, "AuthChallenge", defaultAuthChallenge);
- else
- _getOptS(challengeW, maxmsglen, "Challenge", defaultChallenge);
- _getOptS(buf, buflen, "Response", defaultResponse);
- srand(time(NULL));
- _setCOptD(hContact, "ResponseNum", rand() % get_response_num(buf));
- ReplaceVarsNum(challengeW, maxmsglen, _getCOptD(hContact, "ResponseNum", 0));
- tmp = mir_u2a(challengeW);
- challenge = mir_utf8encode(tmp);
- mir_free(tmp);
- CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)challenge);
- mir_free(challenge);
- _notify(hContact, POPUP_CHALLENGE, TranslateT("Sending random challenge to %s."), message);
- break;
-
- case SPAMOTRON_MODE_MATH:
- a = (rand() % 10) + 1;
- b = (rand() % 10) + 1;
- mir_sntprintf(mexpr, SIZEOF(mexpr), _T("%d + %d"), a, b);
- if (dbei->eventType == EVENTTYPE_AUTHREQUEST)
- _getOptS(challengeW, maxmsglen, "AuthChallengeMath", defaultAuthChallengeMath);
- else
- _getOptS(challengeW, maxmsglen, "ChallengeMath", defaultChallengeMath);
- ReplaceVar(challengeW, maxmsglen, _T("%mathexpr%"), mexpr);
- _setCOptD(hContact, "ResponseMath", a + b);
- tmp = mir_u2a(challengeW);
- challenge = mir_utf8encode(tmp);
- mir_free(tmp);
- CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)challenge);
- mir_free(challenge);
- _notify(hContact, POPUP_CHALLENGE, TranslateT("Sending math expression challenge to %s."), message);
- break;
+ case SPAMOTRON_MODE_ROTATE:
+ if (dbei->eventType == EVENTTYPE_AUTHREQUEST)
+ _getOptS(challengeW, maxmsglen, "AuthChallenge", defaultAuthChallenge);
+ else
+ _getOptS(challengeW, maxmsglen, "Challenge", defaultChallenge);
+ _getOptS(buf, buflen, "Response", defaultResponse);
+ if (_getCOptD(hContact, "ResponseNum", 0) >= (unsigned int)(get_response_num(buf)-1))
+ _setCOptD(hContact, "ResponseNum", -1);
+
+ _setCOptD(hContact, "ResponseNum", _getCOptD(hContact, "ResponseNum", -1) + 1);
+ ReplaceVarsNum(challengeW, maxmsglen, _getCOptD(hContact, "ResponseNum", 0));
+ CallContactService(hContact, PSS_MESSAGE, 0, ptrA(mir_utf8encodeT(challengeW)));
+ _notify(hContact, POPUP_CHALLENGE, TranslateT("Sending round-robin challenge to %s."), message);
+ break;
+
+ case SPAMOTRON_MODE_RANDOM:
+ if (dbei->eventType == EVENTTYPE_AUTHREQUEST)
+ _getOptS(challengeW, maxmsglen, "AuthChallenge", defaultAuthChallenge);
+ else
+ _getOptS(challengeW, maxmsglen, "Challenge", defaultChallenge);
+ _getOptS(buf, buflen, "Response", defaultResponse);
+ srand(time(NULL));
+ _setCOptD(hContact, "ResponseNum", rand() % get_response_num(buf));
+ ReplaceVarsNum(challengeW, maxmsglen, _getCOptD(hContact, "ResponseNum", 0));
+ CallContactService(hContact, PSS_MESSAGE, 0, ptrA(mir_utf8encodeT(challengeW)));
+ _notify(hContact, POPUP_CHALLENGE, TranslateT("Sending random challenge to %s."), message);
+ break;
+
+ case SPAMOTRON_MODE_MATH:
+ a = (rand() % 10) + 1;
+ b = (rand() % 10) + 1;
+ mir_sntprintf(mexpr, SIZEOF(mexpr), _T("%d + %d"), a, b);
+ if (dbei->eventType == EVENTTYPE_AUTHREQUEST)
+ _getOptS(challengeW, maxmsglen, "AuthChallengeMath", defaultAuthChallengeMath);
+ else
+ _getOptS(challengeW, maxmsglen, "ChallengeMath", defaultChallengeMath);
+ ReplaceVar(challengeW, maxmsglen, _T("%mathexpr%"), mexpr);
+ _setCOptD(hContact, "ResponseMath", a + b);
+ CallContactService(hContact, PSS_MESSAGE, 0, ptrA(mir_utf8encodeT(challengeW)));
+ _notify(hContact, POPUP_CHALLENGE, TranslateT("Sending math expression challenge to %s."), message);
+ break;
}
free(challengeW);
free(tmpW);
|