summaryrefslogtreecommitdiff
path: root/protocols/VKontakte/src/misc.cpp
diff options
context:
space:
mode:
authorSergey Bolhovskoy <elzorfox@ya.ru>2015-10-23 09:18:49 +0000
committerSergey Bolhovskoy <elzorfox@ya.ru>2015-10-23 09:18:49 +0000
commit676c1d3d4bc2d6a52cc71ec14ef7e7b8b9817564 (patch)
tree894bc4f4b5f4d3de1e4bc8e13dd1de07fecbe5f4 /protocols/VKontakte/src/misc.cpp
parent169df25f12faff23b8fd8c20e057af715a2777ca (diff)
VKontakte:
popup & sound support for newsfeed add hidden option for return chat message version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@15600 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte/src/misc.cpp')
-rw-r--r--protocols/VKontakte/src/misc.cpp79
1 files changed, 79 insertions, 0 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp
index 28b44fcd01..48eec5377a 100644
--- a/protocols/VKontakte/src/misc.cpp
+++ b/protocols/VKontakte/src/misc.cpp
@@ -1147,4 +1147,83 @@ void CVkProto::SetInvisible(MCONTACT hContact)
debugLogA("CVkProto::SetInvisible %d set ID_STATUS_INVISIBLE", getDword(hContact, "ID", -1));
}
setDword(hContact, "InvisibleTS", time(NULL));
+}
+
+CMString CVkProto::RemoveBBC(CMString& tszSrc)
+{
+ static const TCHAR* tszSimpleBBCodes[][2] = {
+ { _T("[b]"), _T("[/b]") },
+ { _T("[u]"), _T("[/u]") },
+ { _T("[i]"), _T("[/i]") },
+ { _T("[s]"), _T("[/s]") },
+ };
+
+ static const TCHAR* tszParamBBCodes[][2] = {
+ { _T("[url="), _T("[/url]") },
+ { _T("[color="), _T("[/color]") },
+ };
+
+ CMString tszRes(tszSrc);
+ CMString tszLow(tszSrc);
+ tszLow.MakeLower();
+
+ for (int i = 0; i < _countof(tszSimpleBBCodes); i++) {
+ CMString tszOpenTag(tszSimpleBBCodes[i][0]);
+ CMString tszCloseTag(tszSimpleBBCodes[i][1]);
+
+ int lenOpen = tszOpenTag.GetLength();
+ int lenClose = tszCloseTag.GetLength();
+
+ int posOpen = 0;
+ int posClose = 0;
+
+ while (true) {
+ if ((posOpen = tszLow.Find(tszOpenTag, posOpen)) < 0)
+ break;
+
+ if ((posClose = tszLow.Find(tszCloseTag, posOpen + lenOpen)) < 0)
+ break;
+
+ tszLow.Delete(posOpen, lenOpen);
+ tszLow.Delete(posClose - lenOpen, lenClose);
+
+ tszRes.Delete(posOpen, lenOpen);
+ tszRes.Delete(posClose - lenOpen, lenClose);
+
+ }
+ }
+
+ for (int i = 0; i < _countof(tszParamBBCodes); i++) {
+ CMString tszOpenTag(tszParamBBCodes[i][0]);
+ CMString tszCloseTag(tszParamBBCodes[i][1]);
+
+ int lenOpen = tszOpenTag.GetLength();
+ int lenClose = tszCloseTag.GetLength();
+
+ int posOpen = 0;
+ int posOpen2 = 0;
+ int posClose = 0;
+
+ while (true) {
+ if ((posOpen = tszLow.Find(tszOpenTag, posOpen)) < 0)
+ break;
+
+ if ((posOpen2 = tszLow.Find(_T("]"), posOpen + lenOpen)) < 0)
+ break;
+
+ if ((posClose = tszLow.Find(tszCloseTag, posOpen2 + 1)) < 0)
+ break;
+
+ tszLow.Delete(posOpen, posOpen2 - posOpen + 1);
+ tszLow.Delete(posClose - posOpen2 + posOpen - 1, lenClose);
+
+ tszRes.Delete(posOpen, posOpen2 - posOpen + 1);
+ tszRes.Delete(posClose - posOpen2 + posOpen - 1, lenClose);
+
+ }
+
+ }
+
+ return tszRes;
+
} \ No newline at end of file