From 7de38a08b97e0554e318b8c25806cef5d47259e6 Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Thu, 12 Jun 2014 17:49:53 +0000 Subject: headers of not adopted plugins moved to !Deprecated git-svn-id: http://svn.miranda-ng.org/main/trunk@9438 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/IEView/res/ieview.rc | 7 +- plugins/IEView/src/HTMLBuilder.cpp | 6 - plugins/IEView/src/Options.cpp | 15 - plugins/IEView/src/Options.h | 3 - plugins/IEView/src/TextToken.cpp | 717 +++++++++++++++++-------------------- plugins/IEView/src/TextToken.h | 1 - plugins/IEView/src/ieview_common.h | 1 - plugins/IEView/src/resource.h | 1 - 8 files changed, 335 insertions(+), 416 deletions(-) (limited to 'plugins/IEView') diff --git a/plugins/IEView/res/ieview.rc b/plugins/IEView/res/ieview.rc index 09852a0d95..6aac7db2ce 100644 --- a/plugins/IEView/res/ieview.rc +++ b/plugins/IEView/res/ieview.rc @@ -7,7 +7,8 @@ // // Generated from the TEXTINCLUDE 2 resource. // -#include "afxres.h" +#include "afxres.h" + ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS @@ -70,7 +71,6 @@ BEGIN "Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,46,279,10 CONTROL "Enable workaround for PNG transparency",IDC_ENABLE_PNGHACK, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,61,279,10 - CONTROL "Enable MathModule support",IDC_ENABLE_MATHMODULE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,76,279,10 CONTROL "Replace smileys in user names",IDC_SMILEYS_IN_NAMES, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,91,279,10 CONTROL "Hide window border",IDC_NO_BORDER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,106,279,10 @@ -168,7 +168,8 @@ END // // Generated from the TEXTINCLUDE 3 resource. // - + + ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED diff --git a/plugins/IEView/src/HTMLBuilder.cpp b/plugins/IEView/src/HTMLBuilder.cpp index 716cb584f3..8545f34264 100644 --- a/plugins/IEView/src/HTMLBuilder.cpp +++ b/plugins/IEView/src/HTMLBuilder.cpp @@ -57,12 +57,6 @@ bool HTMLBuilder::encode(MCONTACT hContact, const char *proto, const wchar_t *te break; } level++; - case 2: - if ((Options::getGeneralFlags()&Options::GENERAL_ENABLE_MATHMODULE) && Options::isMathModule()) { - token = TextToken::tokenizeMath(text); - break; - } - level++; case 3: token = TextToken::tokenizeLinks(text); break; diff --git a/plugins/IEView/src/Options.cpp b/plugins/IEView/src/Options.cpp index 7be2656e0d..a6b7ca5ca9 100644 --- a/plugins/IEView/src/Options.cpp +++ b/plugins/IEView/src/Options.cpp @@ -477,9 +477,6 @@ static INT_PTR CALLBACK IEViewGeneralOptDlgProc(HWND hwndDlg, UINT msg, WPARAM w if (Options::getGeneralFlags() & Options::GENERAL_ENABLE_FLASH) { CheckDlgButton(hwndDlg, IDC_ENABLE_FLASH, TRUE); } - if (Options::getGeneralFlags() & Options::GENERAL_ENABLE_MATHMODULE) { - CheckDlgButton(hwndDlg, IDC_ENABLE_MATHMODULE, TRUE); - } if (Options::getGeneralFlags() & Options::GENERAL_ENABLE_PNGHACK) { CheckDlgButton(hwndDlg, IDC_ENABLE_PNGHACK, TRUE); } @@ -492,7 +489,6 @@ static INT_PTR CALLBACK IEViewGeneralOptDlgProc(HWND hwndDlg, UINT msg, WPARAM w if (Options::getGeneralFlags() & Options::GENERAL_ENABLE_EMBED) { CheckDlgButton(hwndDlg, IDC_ENABLE_EMBED, TRUE); } - EnableWindow(GetDlgItem(hwndDlg, IDC_ENABLE_MATHMODULE), Options::isMathModule()); EnableWindow(GetDlgItem(hwndDlg, IDC_SMILEYS_IN_NAMES), Options::isSmileyAdd()); EnableWindow(GetDlgItem(hwndDlg, IDC_EMBED_SIZE), IsDlgButtonChecked(hwndDlg, IDC_ENABLE_EMBED)); TCHAR* size[] = { _T("320 x 205"), _T("480 x 385") , _T("560 x 349"), _T("640 x 390")}; @@ -508,7 +504,6 @@ static INT_PTR CALLBACK IEViewGeneralOptDlgProc(HWND hwndDlg, UINT msg, WPARAM w switch (LOWORD(wParam)) { case IDC_ENABLE_BBCODES: case IDC_ENABLE_FLASH: - case IDC_ENABLE_MATHMODULE: case IDC_ENABLE_PNGHACK: case IDC_SMILEYS_IN_NAMES: case IDC_NO_BORDER: @@ -533,9 +528,6 @@ static INT_PTR CALLBACK IEViewGeneralOptDlgProc(HWND hwndDlg, UINT msg, WPARAM w if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_FLASH)) { i |= Options::GENERAL_ENABLE_FLASH; } - if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_MATHMODULE)) { - i |= Options::GENERAL_ENABLE_MATHMODULE; - } if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_PNGHACK)) { i |= Options::GENERAL_ENABLE_PNGHACK; } @@ -964,7 +956,6 @@ static INT_PTR CALLBACK IEViewGroupChatsOptDlgProc(HWND hwndDlg, UINT msg, WPARA } bool Options::isInited = false; -bool Options::bMathModule = false; bool Options::bSmileyAdd = false; int Options::avatarServiceFlags = 0; int Options::generalFlags; @@ -1600,7 +1591,6 @@ void Options::init() lastProto = proto; } - bMathModule = 0 != ServiceExists(MTH_GET_GIF_UNICODE); bSmileyAdd = 0 != ServiceExists(MS_SMILEYADD_BATCHPARSE); avatarServiceFlags = 0; if (ServiceExists(MS_AV_GETAVATARBITMAP)) @@ -1642,11 +1632,6 @@ int Options::getEmbedsize() return db_get_dw(NULL, ieviewModuleName, "Embedsize", 0); } -bool Options::isMathModule() -{ - return bMathModule; -} - bool Options::isSmileyAdd() { return bSmileyAdd; diff --git a/plugins/IEView/src/Options.h b/plugins/IEView/src/Options.h index 58f758ceaf..4fbf6fe4a1 100644 --- a/plugins/IEView/src/Options.h +++ b/plugins/IEView/src/Options.h @@ -195,7 +195,6 @@ class Options { private: static int generalFlags; static bool isInited; - static bool bMathModule; static bool bSmileyAdd; static int avatarServiceFlags; static ProtocolSettings* protocolList; @@ -207,7 +206,6 @@ public: }; enum OPTIONS { GENERAL_ENABLE_BBCODES = 0x000001, - GENERAL_ENABLE_MATHMODULE = 0x000002, GENERAL_ENABLE_FLASH = 0x000004, GENERAL_ENABLE_PNGHACK = 0x000008, GENERAL_SMILEYINNAMES = 0x000010, @@ -235,7 +233,6 @@ public: static void setEmbedsize(int size); static int getEmbedsize(); - static bool isMathModule(); static bool isSmileyAdd(); static int getAvatarServiceFlags(); static void init(); diff --git a/plugins/IEView/src/TextToken.cpp b/plugins/IEView/src/TextToken.cpp index 7b27e70614..40fb816bde 100644 --- a/plugins/IEView/src/TextToken.cpp +++ b/plugins/IEView/src/TextToken.cpp @@ -127,7 +127,7 @@ void TextToken::setLink(const wchar_t *_link) static int countNoWhitespace(const wchar_t *str) { int c; - for (c=0; *str!='\n' && *str!='\r' && *str!='\t' && *str!=' ' && *str!='\0'; str++, c++); + for (c = 0; *str != '\n' && *str != '\r' && *str != '\t' && *str != ' ' && *str != '\0'; str++, c++); return c; } @@ -135,125 +135,38 @@ TextToken* TextToken::tokenizeBBCodes(const wchar_t *text) { return tokenizeBBCodes(text, (int)wcslen(text)); } -TextToken* TextToken::tokenizeMath(const wchar_t *text) { - TextToken *firstToken = NULL, *lastToken = NULL, *mathToken = NULL; - static bool mathModInitialized = false; - static wchar_t *mathTagName[] = {NULL, NULL}; - static int mathTagLen[] = {0, 0}; - int i; - if (!mathModInitialized) { - if (ServiceExists(MATH_GET_PARAMS)) { - char* mthDelStart = (char *)CallService(MATH_GET_PARAMS, (WPARAM)MATH_PARAM_STARTDELIMITER, 0); - char* mthDelEnd = (char *)CallService(MATH_GET_PARAMS, (WPARAM)MATH_PARAM_ENDDELIMITER, 0); - if (mthDelStart!=NULL) { - mathTagName[0] = mir_a2t(mthDelStart); - mathTagLen[0] = (int)wcslen(mathTagName[0]); - } - if (mthDelEnd!=NULL) { - mathTagName[1] = mir_a2t(mthDelEnd); - mathTagLen[1] = (int)wcslen(mathTagName[1]); - } - CallService(MTH_FREE_MATH_BUFFER,0, (LPARAM) mthDelStart); - CallService(MTH_FREE_MATH_BUFFER,0, (LPARAM) mthDelEnd); - } - mathModInitialized = true; - } - int textLen = 0; - int l = (int)wcslen(text); - for (i=0; i<=l;) { - bool mathFound = false; - int k = 0, tagDataStart=0, newTokenType = 0, newTokenSize = 0; - if (mathTagName[0] != NULL && mathTagName[1] != NULL) { - if (!wcsnicmp(text+i, mathTagName[0], mathTagLen[0])) { - k = tagDataStart = i + mathTagLen[0]; - for (; k < l; k++) { - if (!wcsnicmp(text+k, mathTagName[1], mathTagLen[1])) { - k += mathTagLen[1]; - mathFound = true; - break; - } - } - } - } - if (mathFound) { - mathToken = new TextToken(MATH, text + tagDataStart, k - mathTagLen[1] - tagDataStart); - char* mathPath=(char*)CallService(MTH_GET_GIF_UNICODE, 0, (LPARAM) mathToken->getTextW()); - if (mathPath!=NULL) { - mathToken->setLink(mathPath); - CallService(MTH_FREE_GIFPATH, 0, (LPARAM) mathPath); - } else { - mathToken->setLink(""); - } - mathToken->setEnd(false); - newTokenType = MATH; - newTokenSize = k - i; - } else { - if (i==l) { - newTokenType = END; - newTokenSize = 1; - } else { - newTokenType = TEXT; - newTokenSize = 1; - } - } - if (newTokenType != TEXT) { - if (textLen >0 ) { - TextToken *newToken = new TextToken(TEXT, text+i-textLen, textLen); - textLen = 0; - if (lastToken == NULL) { - firstToken = newToken; - } else { - lastToken->setNext(newToken); - } - lastToken = newToken; - } - if (newTokenType == MATH) { - if (lastToken == NULL) { - firstToken = mathToken; - } else { - lastToken->setNext(mathToken); - } - lastToken = mathToken; - } - } else { - textLen += newTokenSize; - } - i += newTokenSize; - } - return firstToken; -} // TODO: Add the following BBCodes: code #define BB_TAG_NUM 10 TextToken* TextToken::tokenizeBBCodes(const wchar_t *text, int l) { - static const wchar_t *bbTagName[] = {L"b", L"i", L"u", L"s", L"img", L"color", L"size", L"bimg", L"url", L"code"}; - static int bbTagNameLen[] = {1, 1, 1, 1, 3, 5, 4, 4, 3, 4}; - static int bbTagArg[] = {0, 0, 0, 0, 0, 1, 1, 0, 1, 0}; - static int bbTagId[] = {BB_B, BB_I, BB_U, BB_S, BB_IMG, BB_COLOR, BB_SIZE, BB_BIMG, BB_URL, BB_CODE}; + static const wchar_t *bbTagName[] = { L"b", L"i", L"u", L"s", L"img", L"color", L"size", L"bimg", L"url", L"code" }; + static int bbTagNameLen[] = { 1, 1, 1, 1, 3, 5, 4, 4, 3, 4 }; + static int bbTagArg[] = { 0, 0, 0, 0, 0, 1, 1, 0, 1, 0 }; + static int bbTagId[] = { BB_B, BB_I, BB_U, BB_S, BB_IMG, BB_COLOR, BB_SIZE, BB_BIMG, BB_URL, BB_CODE }; static int bbTagEnd[BB_TAG_NUM]; static int bbTagCount[BB_TAG_NUM]; - int i,j; - TextToken *firstToken = NULL, *lastToken = NULL, * bbToken = NULL; + int i, j; + TextToken *firstToken = NULL, *lastToken = NULL, *bbToken = NULL; int textLen = 0; for (j = 0; j < BB_TAG_NUM; j++) { bbTagCount[j] = 0; bbTagEnd[j] = 0; } for (i = 0; i <= l;) { - int k, tagArgStart=0, tagArgEnd=0, tagDataStart=0, newTokenType = 0, newTokenSize = 0; + int k, tagArgStart = 0, tagArgEnd = 0, tagDataStart = 0, newTokenType = 0, newTokenSize = 0; bool bbFound = false; if (text[i] == '[') { - if (text[i+1] != '/') { + if (text[i + 1] != '/') { for (j = 0; j < BB_TAG_NUM; j++) { k = i + 1; - if (!wcsnicmp(text+k, bbTagName[j], bbTagNameLen[j])) { + if (!wcsnicmp(text + k, bbTagName[j], bbTagNameLen[j])) { tagArgStart = tagArgEnd = 0; k += bbTagNameLen[j]; if (bbTagArg[j]) { if (text[k] != '=') continue; k++; tagArgStart = k; - for (; text[k]!='\0'; k++) { - if (text[k]==']') break; + for (; text[k] != '\0'; k++) { + if (text[k] == ']') break; } tagArgEnd = k; } @@ -262,9 +175,9 @@ TextToken* TextToken::tokenizeBBCodes(const wchar_t *text, int l) { tagDataStart = k; if (k < bbTagEnd[j]) k = bbTagEnd[j]; for (; k < l; k++) { - if (text[k] == '[' && text[k+1] == '/') { + if (text[k] == '[' && text[k + 1] == '/') { k += 2; - if (!wcsnicmp(text+k, bbTagName[j], bbTagNameLen[j])) { + if (!wcsnicmp(text + k, bbTagName[j], bbTagNameLen[j])) { k += bbTagNameLen[j]; if (text[k] == ']') { k++; @@ -291,7 +204,8 @@ TextToken* TextToken::tokenizeBBCodes(const wchar_t *text, int l) { bbTagCount[j]++; if (bbTagArg[j]) { bbToken = new TextToken(BBCODE, text + tagArgStart, tagArgEnd - tagArgStart); - } else { + } + else { bbToken = new TextToken(BBCODE, bbTagName[j], bbTagNameLen[j]); } bbToken->setTag(bbTagId[j]); @@ -315,10 +229,11 @@ TextToken* TextToken::tokenizeBBCodes(const wchar_t *text, int l) { break; } } - } else { + } + else { for (j = 0; j < BB_TAG_NUM; j++) { k = i + 2; - if (bbTagCount[j]>0 && !wcsnicmp(text+k, bbTagName[j], bbTagNameLen[j])) { + if (bbTagCount[j]>0 && !wcsnicmp(text + k, bbTagName[j], bbTagNameLen[j])) { k += bbTagNameLen[j]; if (text[k] == ']') { k++; @@ -338,21 +253,23 @@ TextToken* TextToken::tokenizeBBCodes(const wchar_t *text, int l) { } } if (!bbFound) { - if (i==l) { + if (i == l) { newTokenType = END; newTokenSize = 1; - } else { + } + else { newTokenType = TEXT; newTokenSize = 1; } } if (newTokenType != TEXT) { - if (textLen >0 ) { - TextToken *newToken = new TextToken(TEXT, text+i-textLen, textLen); + if (textLen > 0) { + TextToken *newToken = new TextToken(TEXT, text + i - textLen, textLen); textLen = 0; if (lastToken == NULL) { firstToken = newToken; - } else { + } + else { lastToken->setNext(newToken); } lastToken = newToken; @@ -360,12 +277,14 @@ TextToken* TextToken::tokenizeBBCodes(const wchar_t *text, int l) { if (newTokenType == BBCODE) { if (lastToken == NULL) { firstToken = bbToken; - } else { + } + else { lastToken->setNext(bbToken); } lastToken = bbToken; } - } else { + } + else { textLen += newTokenSize; } i += newTokenSize; @@ -377,47 +296,54 @@ TextToken* TextToken::tokenizeLinks(const wchar_t *text) { TextToken *firstToken = NULL, *lastToken = NULL; int textLen = 0; int l = (int)wcslen(text); - for (int i=0; i<=l;) { + for (int i = 0; i <= l;) { int newTokenType, newTokenSize; - int urlLen = Utils::detectURL(text+i); + int urlLen = Utils::detectURL(text + i); if (i == l) { newTokenType = END; newTokenSize = 1; - } else if (urlLen > 0) { + } + else if (urlLen > 0) { newTokenType = LINK; newTokenSize = urlLen; - } else if (!wcsncmp(text+i, L"www.", 4)) { + } + else if (!wcsncmp(text + i, L"www.", 4)) { newTokenType = WWWLINK; - newTokenSize = countNoWhitespace(text+i); - } else if (!wcsncmp(text+i, L"mailto:", 7)) { + newTokenSize = countNoWhitespace(text + i); + } + else if (!wcsncmp(text + i, L"mailto:", 7)) { newTokenType = LINK; - newTokenSize = countNoWhitespace(text+i); - } else { + newTokenSize = countNoWhitespace(text + i); + } + else { newTokenType = TEXT; newTokenSize = 1; } if (newTokenType != TEXT) { - if (textLen >0 ) { - TextToken *newToken = new TextToken(TEXT, text+i-textLen, textLen); + if (textLen > 0) { + TextToken *newToken = new TextToken(TEXT, text + i - textLen, textLen); textLen = 0; if (lastToken == NULL) { firstToken = newToken; - } else { + } + else { lastToken->setNext(newToken); } lastToken = newToken; } if (newTokenType == WWWLINK || newTokenType == LINK) { - TextToken *newToken = new TextToken(newTokenType, text+i, newTokenSize); + TextToken *newToken = new TextToken(newTokenType, text + i, newTokenSize); newToken->setLink(newToken->getText()); if (lastToken == NULL) { firstToken = newToken; - } else { + } + else { lastToken->setNext(newToken); } lastToken = newToken; } - } else { + } + else { textLen += newTokenSize; } i += newTokenSize; @@ -438,29 +364,32 @@ TextToken* TextToken::tokenizeSmileys(MCONTACT hContact, const char *proto, cons sp.flag = SAFL_PATH | SAFL_UNICODE | (isSent ? SAFL_OUTGOING : 0); sp.wstr = (wchar_t *)text; sp.hContact = hContact; - spRes = (SMADD_BATCHPARSERES *) CallService(MS_SMILEYADD_BATCHPARSE, 0, (LPARAM)&sp); + spRes = (SMADD_BATCHPARSERES *)CallService(MS_SMILEYADD_BATCHPARSE, 0, (LPARAM)&sp); int last_pos = 0; if (spRes != NULL) { for (int i = 0; i < (int)sp.numSmileys; i++) { if (spRes[i].filepath != NULL && strlen((char *)spRes[i].filepath) > 0) { if ((int)spRes[i].startChar - last_pos > 0) { - TextToken *newToken = new TextToken(TEXT, text+last_pos, spRes[i].startChar-last_pos); + TextToken *newToken = new TextToken(TEXT, text + last_pos, spRes[i].startChar - last_pos); if (lastToken == NULL) { firstToken = newToken; - } else { + } + else { lastToken->setNext(newToken); } lastToken = newToken; } - TextToken *newToken = new TextToken(SMILEY, text+spRes[i].startChar, spRes[i].size); + TextToken *newToken = new TextToken(SMILEY, text + spRes[i].startChar, spRes[i].size); if (sp.oflag & SAFL_UNICODE) { newToken->setLink((wchar_t *)spRes[i].filepath); - } else { + } + else { newToken->setLink((char *)spRes[i].filepath); } if (lastToken == NULL) { firstToken = newToken; - } else { + } + else { lastToken->setNext(newToken); } lastToken = newToken; @@ -470,10 +399,11 @@ TextToken* TextToken::tokenizeSmileys(MCONTACT hContact, const char *proto, cons CallService(MS_SMILEYADD_BATCHFREE, 0, (LPARAM)spRes); } if (last_pos < l) { - TextToken *newToken = new TextToken(TEXT, text+last_pos, l-last_pos); + TextToken *newToken = new TextToken(TEXT, text + last_pos, l - last_pos); if (lastToken == NULL) { firstToken = newToken; - } else { + } + else { lastToken->setNext(newToken); } lastToken = newToken; @@ -486,7 +416,7 @@ TextToken* TextToken::tokenizeChatFormatting(const wchar_t *text) { int textLen = 0; int l = (int)wcslen(text); wchar_t* tokenBuffer = new wchar_t[l + 1]; - for (int i=0; i<=l;) { + for (int i = 0; i <= l;) { int newTokenType = TEXT; int newTokenSize = 1; int newTokenTag = 0; @@ -495,66 +425,68 @@ TextToken* TextToken::tokenizeChatFormatting(const wchar_t *text) { bool endToken = false; - if (i==l) { + if (i == l) { newTokenType = END; - } else { + } + else { if (text[i] == '%') { newTokenSize = 2; switch (text[i + 1]) { - case '%': - break; - case 'B': - endToken = true; - case 'b': - newTokenType = BBCODE; - newTokenTag = BB_B; - break; - case 'U': - endToken = true; - case 'u': - newTokenType = BBCODE; - newTokenTag = BB_U; - break; - case 'I': - endToken = true; - case 'i': - newTokenType = BBCODE; - newTokenTag = BB_I; - break; - case 'C': - endToken = true; - case 'c': - newTokenType = BBCODE; - newTokenTag = BB_COLOR; - if (!endToken) { - newTokenText = text + i + 2; - newTokenTextLen = 7; - newTokenSize = 9; - } - break; - case 'F': - endToken = true; - case 'f': - newTokenType = BBCODE; - newTokenTag = BB_BACKGROUND; - if (!endToken) { - newTokenText = text + i + 2; - newTokenTextLen = 7; - newTokenSize = 9; - } - break; - default: - newTokenSize = 1; + case '%': + break; + case 'B': + endToken = true; + case 'b': + newTokenType = BBCODE; + newTokenTag = BB_B; + break; + case 'U': + endToken = true; + case 'u': + newTokenType = BBCODE; + newTokenTag = BB_U; + break; + case 'I': + endToken = true; + case 'i': + newTokenType = BBCODE; + newTokenTag = BB_I; + break; + case 'C': + endToken = true; + case 'c': + newTokenType = BBCODE; + newTokenTag = BB_COLOR; + if (!endToken) { + newTokenText = text + i + 2; + newTokenTextLen = 7; + newTokenSize = 9; + } + break; + case 'F': + endToken = true; + case 'f': + newTokenType = BBCODE; + newTokenTag = BB_BACKGROUND; + if (!endToken) { + newTokenText = text + i + 2; + newTokenTextLen = 7; + newTokenSize = 9; + } + break; + default: + newTokenSize = 1; } } } if (newTokenType != TEXT) { - if (textLen >0 ) { + if (textLen > 0) { TextToken *newToken = new TextToken(TEXT, tokenBuffer, textLen); textLen = 0; if (lastToken == NULL) { firstToken = newToken; - } else { + } + else { lastToken->setNext(newToken); } lastToken = newToken; @@ -565,12 +497,14 @@ TextToken* TextToken::tokenizeChatFormatting(const wchar_t *text) { newToken->setTag(newTokenTag); if (lastToken == NULL) { firstToken = newToken; - } else { + } + else { lastToken->setNext(newToken); } lastToken = newToken; } - } else { + } + else { tokenBuffer[textLen] = text[i]; textLen++; } @@ -586,46 +520,48 @@ wchar_t *TextToken::htmlEncode(const wchar_t *str) if (str == NULL) return NULL; int c = 0; - for (ptr=str; *ptr!='\0'; ptr++) { + for (ptr = str; *ptr != '\0'; ptr++) { bool wasSpace = false; - if (*ptr==' ' && wasSpace) { + if (*ptr == ' ' && wasSpace) { wasSpace = true; c += 6; - } else { + } + else { wasSpace = false; switch (*ptr) { - case '\n': c += 4; break; - case '\r': break; - case '&': c += 5; break; - case '>': c += 4; break; - case '<': c += 4; break; - case '"': c += 6; break; - case ' ': wasSpace = true; - default: c += 1; break; + case '\n': c += 4; break; + case '\r': break; + case '&': c += 5; break; + case '>': c += 4; break; + case '<': c += 4; break; + case '"': c += 6; break; + case ' ': wasSpace = true; + default: c += 1; break; } } } - wchar_t *output = new wchar_t[c+1]; - for (out=output, ptr=str; *ptr!='\0'; ptr++) { + wchar_t *output = new wchar_t[c + 1]; + for (out = output, ptr = str; *ptr != '\0'; ptr++) { bool wasSpace = false; - if (*ptr==' ' && wasSpace) { + if (*ptr == ' ' && wasSpace) { wcscpy(out, L" "); out += 6; - } else { + } + else { wasSpace = false; switch (*ptr) { - case '\n': wcscpy(out, L"
"); out += 4; break; - case '\r': break; - case '&': wcscpy(out, L"&"); out += 5; break; - case '>': wcscpy(out, L">"); out += 4; break; - case '<': wcscpy(out, L"<"); out += 4; break; - case '"': wcscpy(out, L"""); out += 6; break; - case ' ': wasSpace = true; - default: *out = *ptr; out += 1; break; + case '\n': wcscpy(out, L"
"); out += 4; break; + case '\r': break; + case '&': wcscpy(out, L"&"); out += 5; break; + case '>': wcscpy(out, L">"); out += 4; break; + case '<': wcscpy(out, L"<"); out += 4; break; + case '"': wcscpy(out, L"""); out += 6; break; + case ' ': wasSpace = true; + default: *out = *ptr; out += 1; break; } } } - *out = '\0'; + *out = '\0'; return output; } @@ -633,190 +569,199 @@ void TextToken::toString(wchar_t **str, int *sizeAlloced) { wchar_t *eText = NULL, *eLink = NULL; switch (type) { - case TEXT: - eText = htmlEncode(wtext); - Utils::appendText(str, sizeAlloced, L"%s", eText); - break; - case WWWLINK: - case LINK: - { - eText = htmlEncode(wtext); - eLink = htmlEncode(wlink); - const wchar_t *linkPrefix = type == WWWLINK ? L"http://" : L""; - if ((Options::getGeneralFlags()&Options::GENERAL_ENABLE_EMBED)) { - wchar_t *match = wcsstr(wlink, L"youtube.com"); - if (match != NULL) { - match = wcsstr(match + 11, L"v="); - if (match != NULL) { - match += 2; - wchar_t *match2 = wcsstr(match, L"&"); - int len = match2 != NULL ? match2 - match : (int)wcslen(match); - match = mir_wstrdup(match); - match[len] = 0; - int width ; - int height; - int Embedsize = Options::getEmbedsize(); - switch (Embedsize){ - case 0: - width = 320; - height = 205; - break; - case 1: - width = 480; - height = 385; - break; - case 2: - width = 560; - height = 349; - break; - case 3: - width = 640; - height = 390; - break; - - }; - - Utils::appendText(str, sizeAlloced, L"
\ - \ - \ - \ - \ -
", width, height, match, match, width, height); - mir_free(match); - break; - } - } + case TEXT: + eText = htmlEncode(wtext); + Utils::appendText(str, sizeAlloced, L"%s", eText); + break; + case WWWLINK: + case LINK: + { + eText = htmlEncode(wtext); + eLink = htmlEncode(wlink); + const wchar_t *linkPrefix = type == WWWLINK ? L"http://" : L""; + if ((Options::getGeneralFlags()&Options::GENERAL_ENABLE_EMBED)) { + wchar_t *match = wcsstr(wlink, L"youtube.com"); + if (match != NULL) { + match = wcsstr(match + 11, L"v="); + if (match != NULL) { + match += 2; + wchar_t *match2 = wcsstr(match, L"&"); + int len = match2 != NULL ? match2 - match : (int)wcslen(match); + match = mir_wstrdup(match); + match[len] = 0; + int width; + int height; + int Embedsize = Options::getEmbedsize(); + switch (Embedsize){ + case 0: + width = 320; + height = 205; + break; + case 1: + width = 480; + height = 385; + break; + case 2: + width = 560; + height = 349; + break; + case 3: + width = 640; + height = 390; + break; + + }; + + Utils::appendText(str, sizeAlloced, L"
\ + \ + \ + \ + \ +
", width, height, match, match, width, height); + mir_free(match); + break; } - Utils::appendText(str, sizeAlloced, L"%s", linkPrefix, eLink, eText); - } - break; - case SMILEY: - eText = htmlEncode(wtext); - if ((Options::getGeneralFlags()&Options::GENERAL_ENABLE_FLASH) && (wcsstr(wlink, L".swf")!=NULL)) { - Utils::appendText(str, sizeAlloced, - L"\ - %s", - eText, wlink, eText); - } else if ((Options::getGeneralFlags()&Options::GENERAL_ENABLE_PNGHACK) && (wcsstr(wlink, L".png")!=NULL)) { - Utils::appendText(str, sizeAlloced, L"\"%s\"/%s", wlink, eText, eText, eText); - } else { - Utils::appendText(str, sizeAlloced, L"\"%s\"%s", wlink, eText, eText, eText); } - break; - case MATH: - eText = htmlEncode(wtext); - if ((Options::getGeneralFlags()&Options::GENERAL_ENABLE_PNGHACK) && (wcsstr(wlink, L".png")!=NULL)) { - Utils::appendText(str, sizeAlloced, L"\"%s\"%s",wlink , eText, eText); - } else { - Utils::appendText(str, sizeAlloced, L"\"%s\"%s", wlink, eText, eText); - } - break; - case BBCODE: - if (!end) { - switch (tag) { - case BB_B: - //Utils::appendText(str, sizeAlloced, L""); - Utils::appendText(str, sizeAlloced, L""); - break; - case BB_I: - //Utils::appendText(str, sizeAlloced, L""); - Utils::appendText(str, sizeAlloced, L""); - break; - case BB_U: - //Utils::appendText(str, sizeAlloced, L""); - Utils::appendText(str, sizeAlloced, L""); - break; - case BB_S: - //Utils::appendText(str, sizeAlloced, L""); - Utils::appendText(str, sizeAlloced, L""); - break; - case BB_CODE: - //Utils::appendText(str, sizeAlloced, L""); - Utils::appendText(str, sizeAlloced, L"
");
-					break;
-				case BB_IMG:
-					eText = htmlEncode(wtext);
-					if ((Options::getGeneralFlags()&Options::GENERAL_ENABLE_FLASH) && eText != NULL && (wcsstr(eText, L".swf")!=NULL)) {
-						Utils::appendText(str, sizeAlloced,
-		L"
\ -
", - eText); - } else if ((Options::getGeneralFlags()&Options::GENERAL_ENABLE_PNGHACK) && eText != NULL && (wcsstr(eText, L".png")!=NULL)) { - Utils::appendText(str, sizeAlloced, L"", eText); - } else { - if (eText != NULL && wcsncmp(eText, L"http://", 7)) { - Utils::appendText(str, sizeAlloced, L"
this.width ? 'auto' : maxw);\" src=\"file://%s\" />
", eText); - } else { - Utils::appendText(str, sizeAlloced, L"
this.width ? 'auto' : maxw);\" src=\"%s\" />
", eText); - } - } - break; - case BB_BIMG: - eText = htmlEncode(mir_ptr(Utils::toAbsolute(wtext))); - - if ((Options::getGeneralFlags()&Options::GENERAL_ENABLE_FLASH) && (wcsstr(eText, L".swf")!=NULL)) { - Utils::appendText(str, sizeAlloced, - L"
\ -
", - eText); - } else if ((Options::getGeneralFlags()&Options::GENERAL_ENABLE_PNGHACK) && (wcsstr(eText, L".png")!=NULL)) { - Utils::appendText(str, sizeAlloced, L"", eText); - } else { + } + Utils::appendText(str, sizeAlloced, L"%s", linkPrefix, eLink, eText); + } + break; + case SMILEY: + eText = htmlEncode(wtext); + if ((Options::getGeneralFlags()&Options::GENERAL_ENABLE_FLASH) && (wcsstr(wlink, L".swf") != NULL)) { + Utils::appendText(str, sizeAlloced, + L"\ + %s", + eText, wlink, eText); + } + else if ((Options::getGeneralFlags()&Options::GENERAL_ENABLE_PNGHACK) && (wcsstr(wlink, L".png") != NULL)) { + Utils::appendText(str, sizeAlloced, L"\"%s\"/%s", wlink, eText, eText, eText); + } + else { + Utils::appendText(str, sizeAlloced, L"\"%s\"%s", wlink, eText, eText, eText); + } + break; + case MATH: + eText = htmlEncode(wtext); + if ((Options::getGeneralFlags()&Options::GENERAL_ENABLE_PNGHACK) && (wcsstr(wlink, L".png") != NULL)) { + Utils::appendText(str, sizeAlloced, L"\"%s\"%s", wlink, eText, eText); + } + else { + Utils::appendText(str, sizeAlloced, L"\"%s\"%s", wlink, eText, eText); + } + break; + case BBCODE: + if (!end) { + switch (tag) { + case BB_B: + //Utils::appendText(str, sizeAlloced, L""); + Utils::appendText(str, sizeAlloced, L""); + break; + case BB_I: + //Utils::appendText(str, sizeAlloced, L""); + Utils::appendText(str, sizeAlloced, L""); + break; + case BB_U: + //Utils::appendText(str, sizeAlloced, L""); + Utils::appendText(str, sizeAlloced, L""); + break; + case BB_S: + //Utils::appendText(str, sizeAlloced, L""); + Utils::appendText(str, sizeAlloced, L""); + break; + case BB_CODE: + //Utils::appendText(str, sizeAlloced, L""); + Utils::appendText(str, sizeAlloced, L"
");
+				break;
+			case BB_IMG:
+				eText = htmlEncode(wtext);
+				if ((Options::getGeneralFlags()&Options::GENERAL_ENABLE_FLASH) && eText != NULL && (wcsstr(eText, L".swf") != NULL)) {
+					Utils::appendText(str, sizeAlloced,
+						L"
\ +
", + eText); + } + else if ((Options::getGeneralFlags()&Options::GENERAL_ENABLE_PNGHACK) && eText != NULL && (wcsstr(eText, L".png") != NULL)) { + Utils::appendText(str, sizeAlloced, L"", eText); + } + else { + if (eText != NULL && wcsncmp(eText, L"http://", 7)) { Utils::appendText(str, sizeAlloced, L"
this.width ? 'auto' : maxw);\" src=\"file://%s\" />
", eText); } - break; - case BB_URL: - eText = htmlEncode(wtext); - eLink = htmlEncode(wlink); - Utils::appendText(str, sizeAlloced, L"%s", eLink, eText); - break; - case BB_COLOR: - eText = htmlEncode(wtext); - //Utils::appendText(str, sizeAlloced, L"", eText); - Utils::appendText(str, sizeAlloced, L"", eText); - break; - case BB_BACKGROUND: - eText = htmlEncode(wtext); - Utils::appendText(str, sizeAlloced, L"", eText); - break; - case BB_SIZE: - eText = htmlEncode(wtext); - Utils::appendText(str, sizeAlloced, L"", eText); - break; + else { + Utils::appendText(str, sizeAlloced, L"
this.width ? 'auto' : maxw);\" src=\"%s\" />
", eText); + } } - } else { - switch (tag) { - case BB_B: - Utils::appendText(str, sizeAlloced, L"
"); - break; - case BB_I: - Utils::appendText(str, sizeAlloced, L"
"); - break; - case BB_U: - Utils::appendText(str, sizeAlloced, L""); - break; - case BB_S: - Utils::appendText(str, sizeAlloced, L"
"); - break; - case BB_CODE: - Utils::appendText(str, sizeAlloced, L"
"); - break; - case BB_COLOR: - Utils::appendText(str, sizeAlloced, L""); - break; - case BB_SIZE: - Utils::appendText(str, sizeAlloced, L""); - break; - case BB_BACKGROUND: - Utils::appendText(str, sizeAlloced, L""); - break; + break; + case BB_BIMG: + eText = htmlEncode(mir_ptr(Utils::toAbsolute(wtext))); + + if ((Options::getGeneralFlags()&Options::GENERAL_ENABLE_FLASH) && (wcsstr(eText, L".swf") != NULL)) { + Utils::appendText(str, sizeAlloced, + L"
\ +
", + eText); + } + else if ((Options::getGeneralFlags()&Options::GENERAL_ENABLE_PNGHACK) && (wcsstr(eText, L".png") != NULL)) { + Utils::appendText(str, sizeAlloced, L"", eText); + } + else { + Utils::appendText(str, sizeAlloced, L"
this.width ? 'auto' : maxw);\" src=\"file://%s\" />
", eText); } + break; + case BB_URL: + eText = htmlEncode(wtext); + eLink = htmlEncode(wlink); + Utils::appendText(str, sizeAlloced, L"%s", eLink, eText); + break; + case BB_COLOR: + eText = htmlEncode(wtext); + //Utils::appendText(str, sizeAlloced, L"", eText); + Utils::appendText(str, sizeAlloced, L"", eText); + break; + case BB_BACKGROUND: + eText = htmlEncode(wtext); + Utils::appendText(str, sizeAlloced, L"", eText); + break; + case BB_SIZE: + eText = htmlEncode(wtext); + Utils::appendText(str, sizeAlloced, L"", eText); + break; + } + } + else { + switch (tag) { + case BB_B: + Utils::appendText(str, sizeAlloced, L"
"); + break; + case BB_I: + Utils::appendText(str, sizeAlloced, L""); + break; + case BB_U: + Utils::appendText(str, sizeAlloced, L""); + break; + case BB_S: + Utils::appendText(str, sizeAlloced, L"
"); + break; + case BB_CODE: + Utils::appendText(str, sizeAlloced, L"
"); + break; + case BB_COLOR: + Utils::appendText(str, sizeAlloced, L""); + break; + case BB_SIZE: + Utils::appendText(str, sizeAlloced, L"
"); + break; + case BB_BACKGROUND: + Utils::appendText(str, sizeAlloced, L""); + break; } - break; + } + break; } - if (eText!=NULL) delete eText; - if (eLink!=NULL) delete eLink; + if (eText != NULL) delete eText; + if (eLink != NULL) delete eLink; } diff --git a/plugins/IEView/src/TextToken.h b/plugins/IEView/src/TextToken.h index e9b2417ca4..68e607cd69 100644 --- a/plugins/IEView/src/TextToken.h +++ b/plugins/IEView/src/TextToken.h @@ -84,7 +84,6 @@ public: static TextToken* tokenizeLinks(const wchar_t *wtext); static TextToken* tokenizeSmileys(MCONTACT hContact, const char *proto, const wchar_t *wtext, bool isSent); static TextToken* tokenizeBBCodes(const wchar_t *text); - static TextToken* tokenizeMath(const wchar_t *text); static TextToken* tokenizeChatFormatting(const wchar_t *text); }; #endif diff --git a/plugins/IEView/src/ieview_common.h b/plugins/IEView/src/ieview_common.h index fbfb60b3ec..fe3301f549 100644 --- a/plugins/IEView/src/ieview_common.h +++ b/plugins/IEView/src/ieview_common.h @@ -53,7 +53,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include -#include #include #include "IEView.h" diff --git a/plugins/IEView/src/resource.h b/plugins/IEView/src/resource.h index 073073f64e..ce77e9d24f 100644 --- a/plugins/IEView/src/resource.h +++ b/plugins/IEView/src/resource.h @@ -33,7 +33,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define IDC_SCROLL_BACKGROUND_IMAGE 1003 #define IDC_ENABLE_BBCODES 1004 #define IDC_ENABLE_FLASH 1005 -#define IDC_ENABLE_MATHMODULE 1006 #define IDC_ENABLE_PNGHACK 1007 #define IDC_SMILEYS_IN_NAMES 1008 #define IDC_NO_BORDER 1009 -- cgit v1.2.3