diff options
author | George Hazan <george.hazan@gmail.com> | 2015-03-28 12:53:07 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-03-28 12:53:07 +0000 |
commit | 7bb399de4c4afa30fe016d25260a105448476374 (patch) | |
tree | 8cbf620506f348dad9234f818d6c22b5876a097c /plugins/IEView | |
parent | e4302ad10ffffed04d4e11bfe9b11d2b389656a1 (diff) |
- crash fix;
- code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@12534 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/IEView')
-rw-r--r-- | plugins/IEView/src/TextToken.cpp | 275 | ||||
-rw-r--r-- | plugins/IEView/src/TextToken.h | 53 | ||||
-rw-r--r-- | plugins/IEView/src/Version.h | 2 |
3 files changed, 132 insertions, 198 deletions
diff --git a/plugins/IEView/src/TextToken.cpp b/plugins/IEView/src/TextToken.cpp index 165bff9889..cdf201db18 100644 --- a/plugins/IEView/src/TextToken.cpp +++ b/plugins/IEView/src/TextToken.cpp @@ -21,28 +21,28 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "ieview_common.h"
-TextToken::TextToken(int type, const char *text, int len)
+TextToken::TextToken(int _type, const char *_text, int _len)
{
next = NULL;
tag = 0;
end = false;
- this->type = type;
- this->text = mir_strndup(text, len);
- this->wtext = mir_a2t(this->text);
- this->link = NULL;
- this->wlink = NULL;
+ type = _type;
+ text = mir_strndup(_text, _len);
+ wtext = mir_a2t(_text);
+ link = NULL;
+ wlink = NULL;
}
-TextToken::TextToken(int type, const wchar_t *wtext, int len)
+TextToken::TextToken(int _type, const wchar_t *_wtext, int _len)
{
next = NULL;
tag = 0;
end = false;
- this->type = type;
- this->wtext = mir_tstrndup(wtext, len);
- this->text = mir_t2a(this->wtext);
- this->link = NULL;
- this->wlink = NULL;
+ type = _type;
+ wtext = mir_tstrndup(_wtext, _len);
+ text = mir_t2a(_wtext);
+ link = NULL;
+ wlink = NULL;
}
TextToken::~TextToken()
@@ -53,61 +53,6 @@ TextToken::~TextToken() mir_free(wlink);
}
-TextToken * TextToken::getNext()
-{
- return next;
-}
-
-void TextToken::setNext(TextToken *ptr)
-{
- next = ptr;
-}
-
-int TextToken::getType()
-{
- return type;
-}
-
-const char *TextToken::getText()
-{
- return text;
-}
-
-const wchar_t *TextToken::getTextW()
-{
- return wtext;
-}
-
-int TextToken::getTag()
-{
- return tag;
-}
-
-void TextToken::setTag(int tag)
-{
- this->tag = tag;
-}
-
-bool TextToken::isEnd()
-{
- return end;
-}
-
-void TextToken::setEnd(bool b)
-{
- this->end = b;
-}
-
-const char *TextToken::getLink()
-{
- return link;
-}
-
-const wchar_t *TextToken::getLinkW()
-{
- return wlink;
-}
-
void TextToken::setLink(const char *_link)
{
replaceStr(link, _link);
@@ -268,27 +213,23 @@ TextToken* TextToken::tokenizeBBCodes(const wchar_t *text, int l) if (textLen > 0) {
TextToken *newToken = new TextToken(TEXT, text + i - textLen, textLen);
textLen = 0;
- if (lastToken == NULL) {
+ if (lastToken == NULL)
firstToken = newToken;
- }
- else {
+ else
lastToken->setNext(newToken);
- }
lastToken = newToken;
}
if (newTokenType == BBCODE) {
- if (lastToken == NULL) {
+ if (lastToken == NULL)
firstToken = bbToken;
- }
- else {
+ else
lastToken->setNext(bbToken);
- }
+
lastToken = bbToken;
}
}
- else {
- textLen += newTokenSize;
- }
+ else textLen += newTokenSize;
+
i += newTokenSize;
}
return firstToken;
@@ -326,29 +267,26 @@ TextToken* TextToken::tokenizeLinks(const wchar_t *text) if (textLen > 0) {
TextToken *newToken = new TextToken(TEXT, text + i - textLen, textLen);
textLen = 0;
- if (lastToken == NULL) {
+ 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);
newToken->setLink(newToken->getText());
- if (lastToken == NULL) {
+ if (lastToken == NULL)
firstToken = newToken;
- }
- else {
+ else
lastToken->setNext(newToken);
- }
+
lastToken = newToken;
}
}
- else {
- textLen += newTokenSize;
- }
+ else textLen += newTokenSize;
+
i += newTokenSize;
}
return firstToken;
@@ -358,9 +296,8 @@ TextToken* TextToken::tokenizeSmileys(MCONTACT hContact, const char *proto, cons {
TextToken *firstToken = NULL, *lastToken = NULL;
int l = (int)wcslen(text);
- if (!Options::isSmileyAdd()) {
+ if (!Options::isSmileyAdd())
return new TextToken(TEXT, text, l);
- }
SMADD_BATCHPARSE2 sp;
sp.cbSize = sizeof(sp);
@@ -375,41 +312,37 @@ TextToken* TextToken::tokenizeSmileys(MCONTACT hContact, const char *proto, cons 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);
- if (lastToken == NULL) {
+ if (lastToken == NULL)
firstToken = newToken;
- }
- else {
+ else
lastToken->setNext(newToken);
- }
+
lastToken = newToken;
}
TextToken *newToken = new TextToken(SMILEY, text + spRes[i].startChar, spRes[i].size);
- if (sp.oflag & SAFL_UNICODE) {
+ if (sp.oflag & SAFL_UNICODE)
newToken->setLink((wchar_t *)spRes[i].filepath);
- }
- else {
+ else
newToken->setLink((char *)spRes[i].filepath);
- }
- if (lastToken == NULL) {
+
+ if (lastToken == NULL)
firstToken = newToken;
- }
- else {
+ else
lastToken->setNext(newToken);
- }
+
lastToken = newToken;
last_pos = spRes[i].startChar + spRes[i].size;
}
}
CallService(MS_SMILEYADD_BATCHFREE, 0, (LPARAM)spRes);
}
- if (last_pos < l) {
+ if (last_pos < l) {
TextToken *newToken = new TextToken(TEXT, text + last_pos, l - last_pos);
- if (lastToken == NULL) {
+ if (lastToken == NULL)
firstToken = newToken;
- }
- else {
+ else
lastToken->setNext(newToken);
- }
+
lastToken = newToken;
}
return firstToken;
@@ -430,9 +363,8 @@ TextToken* TextToken::tokenizeChatFormatting(const wchar_t *text) bool endToken = false;
- if (i == l) {
+ if (i == l)
newTokenType = END;
- }
else {
if (text[i] == '%') {
newTokenSize = 2;
@@ -488,24 +420,22 @@ TextToken* TextToken::tokenizeChatFormatting(const wchar_t *text) if (textLen > 0) {
TextToken *newToken = new TextToken(TEXT, tokenBuffer, textLen);
textLen = 0;
- if (lastToken == NULL) {
+ if (lastToken == NULL)
firstToken = newToken;
- }
- else {
+ else
lastToken->setNext(newToken);
- }
+
lastToken = newToken;
}
if (newTokenType == BBCODE) {
TextToken *newToken = new TextToken(newTokenType, newTokenText, newTokenTextLen);
newToken->setEnd(endToken);
newToken->setTag(newTokenTag);
- if (lastToken == NULL) {
+ if (lastToken == NULL)
firstToken = newToken;
- }
- else {
+ else
lastToken->setNext(newToken);
- }
+
lastToken = newToken;
}
}
@@ -528,9 +458,8 @@ wchar_t *TextToken::htmlEncode(const wchar_t *str) int c = 0;
bool wasSpace = false;
for (ptr = str; *ptr != '\0'; ptr++) {
- if (*ptr == ' ' && wasSpace) {
+ if (*ptr == ' ' && wasSpace)
c += 6;
- }
else {
wasSpace = false;
switch (*ptr) {
@@ -545,6 +474,8 @@ wchar_t *TextToken::htmlEncode(const wchar_t *str) }
}
}
+
+ wasSpace = false;
wchar_t *output = new wchar_t[c + 1];
for (out = output, ptr = str; *ptr != '\0'; ptr++) {
if (*ptr == ' ' && wasSpace) {
@@ -579,65 +510,65 @@ void TextToken::toString(wchar_t **str, int *sizeAlloced) 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=");
+ {
+ 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 += 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 = 0;
- int height = 0;
- 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;
+ 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 = 0;
+ int height = 0;
+ 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"<div><object width=\"%d\" height=\"%d\">\
- <param name=\"movie\" value=\"http://www.youtube.com/v/%s&feature=player_embedded&version=3\"/>\
- <param name=\"allowFullScreen\" value=\"true\"/>\
- <param name=\"allowScriptAccess\" value=\"true\"/>\
- <embed src=\"http://www.youtube.com/v/%s&feature=player_embedded&version=3\" type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" allowScriptAccess=\"always\" width=\"%d\" height=\"%d\"/>\
- </object></div>", width, height, match, match, width, height);
- mir_free(match);
- break;
+ Utils::appendText(str, sizeAlloced, L"<div><object width=\"%d\" height=\"%d\">\
+ <param name=\"movie\" value=\"http://www.youtube.com/v/%s&feature=player_embedded&version=3\"/>\
+ <param name=\"allowFullScreen\" value=\"true\"/>\
+ <param name=\"allowScriptAccess\" value=\"true\"/>\
+ <embed src=\"http://www.youtube.com/v/%s&feature=player_embedded&version=3\" type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" allowScriptAccess=\"always\" width=\"%d\" height=\"%d\"/>\
+ </object></div>", width, height, match, match, width, height);
+ mir_free(match);
+ break;
+ }
}
}
+ Utils::appendText(str, sizeAlloced, L"<a class=\"link\" target=\"_self\" href=\"%s%s\">%s</a>", linkPrefix, eLink, eText);
}
- Utils::appendText(str, sizeAlloced, L"<a class=\"link\" target=\"_self\" href=\"%s%s\">%s</a>", linkPrefix, eLink, eText);
- }
- break;
+ break;
case SMILEY:
eText = htmlEncode(wtext);
if ((Options::getGeneralFlags()&Options::GENERAL_ENABLE_FLASH) && (wcsstr(wlink, L".swf") != NULL)) {
Utils::appendText(str, sizeAlloced,
L"<span title=\"%s\" class=\"img\"><object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" \
- codebase=\"http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0\" >\
- <param NAME=\"movie\" VALUE=\"%s\"><param NAME=\"quality\" VALUE=\"high\"><PARAM NAME=\"loop\" VALUE=\"true\"></object></span>",
- eText, wlink);
+ codebase=\"http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0\" >\
+ <param NAME=\"movie\" VALUE=\"%s\"><param NAME=\"quality\" VALUE=\"high\"><PARAM NAME=\"loop\" VALUE=\"true\"></object></span>",
+ eText, wlink);
}
else {
Utils::appendText(str, sizeAlloced, L"<img class=\"img\" src=\"file://%s\" title=\"%s\" alt=\"%s\" />", wlink, eText, eText);
@@ -675,9 +606,9 @@ void TextToken::toString(wchar_t **str, int *sizeAlloced) if ((Options::getGeneralFlags()&Options::GENERAL_ENABLE_FLASH) && eText != NULL && (wcsstr(eText, L".swf") != NULL)) {
Utils::appendText(str, sizeAlloced,
L"<div style=\"width: 100%%; border: 0; overflow: hidden;\"><object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" \
- codebase=\"http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0\" width=\"100%%\" >\
- <param NAME=\"movie\" VALUE=\"%s\"><param NAME=\"quality\" VALUE=\"high\"><PARAM NAME=\"loop\" VALUE=\"true\"></object></div>",
- eText);
+ codebase=\"http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0\" width=\"100%%\" >\
+ <param NAME=\"movie\" VALUE=\"%s\"><param NAME=\"quality\" VALUE=\"high\"><PARAM NAME=\"loop\" VALUE=\"true\"></object></div>",
+ eText);
}
else {
if (eText != NULL && wcsncmp(eText, L"http://", 7) && wcsncmp(eText, L"https://", 8)) {
@@ -694,9 +625,9 @@ void TextToken::toString(wchar_t **str, int *sizeAlloced) if ((Options::getGeneralFlags()&Options::GENERAL_ENABLE_FLASH) && (wcsstr(eText, L".swf") != NULL)) {
Utils::appendText(str, sizeAlloced,
L"<div style=\"width: 100%%; border: 0; overflow: hidden;\"><object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" \
- codebase=\"http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0\" width=\"100%%\" >\
- <param NAME=\"movie\" VALUE=\"%s\"><param NAME=\"quality\" VALUE=\"high\"><PARAM NAME=\"loop\" VALUE=\"true\"></object></div>",
- eText);
+ codebase=\"http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0\" width=\"100%%\" >\
+ <param NAME=\"movie\" VALUE=\"%s\"><param NAME=\"quality\" VALUE=\"high\"><PARAM NAME=\"loop\" VALUE=\"true\"></object></div>",
+ eText);
}
else {
Utils::appendText(str, sizeAlloced, L"<div style=\"width: 100%%; border: 0; overflow: hidden;\"><img class=\"img\" style=\"width: expression((maxw = this.parentNode.offsetWidth ) > this.width ? 'auto' : maxw);\" src=\"file://%s\" /></div>", eText);
diff --git a/plugins/IEView/src/TextToken.h b/plugins/IEView/src/TextToken.h index 3789ce9350..6f3c9fc1a3 100644 --- a/plugins/IEView/src/TextToken.h +++ b/plugins/IEView/src/TextToken.h @@ -60,30 +60,33 @@ public: TextToken(int type, const char *text, int len);
TextToken(int type, const wchar_t *wtext, int len);
~TextToken();
- int getType();
- const char * getText();
- const wchar_t* getTextW();
- const char * getLink();
- const wchar_t * getLinkW();
- void setLink(const char *link);
- void setLink(const wchar_t *wlink);
- int getTag();
- void setTag(int);
- bool isEnd();
- void setEnd(bool);
- TextToken * getNext();
- void setNext(TextToken *);
- // void toString(char **str, int *sizeAlloced);
- void toString(wchar_t **str, int *sizeAlloced);
- // static char * htmlEncode(const char *str);
- // static char * urlEncode2(const char *str);
- // static TextToken* tokenizeLinks(const char *text);
- // static TextToken* tokenizeSmileys(const char *proto, const char *text);
- // UNICODE
- wchar_t * htmlEncode(const wchar_t *str);
- 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* tokenizeChatFormatting(const wchar_t *text);
+
+ __inline int getType() const { return type; }
+ __inline int getTag() const { return tag; }
+
+ __inline TextToken* getNext() const { return next; }
+
+ __inline const char* getText() const { return text; }
+ __inline const wchar_t* getTextW() const { return wtext; }
+
+ __inline const char* getLink() const { return link; }
+ __inline const wchar_t* getLinkW() const { return wlink; }
+
+ __inline bool isEnd() const { return end; }
+
+ __inline void setTag(int _val) { tag = _val; }
+ __inline void setEnd(bool _val) { end = _val; }
+ __inline void setNext(TextToken *_val) { next = _val; }
+
+ void setLink(const char *link);
+ void setLink(const wchar_t *wlink);
+
+ void toString(wchar_t **str, int *sizeAlloced);
+ wchar_t* htmlEncode(const wchar_t *str);
+
+ 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* tokenizeChatFormatting(const wchar_t *text);
};
#endif
diff --git a/plugins/IEView/src/Version.h b/plugins/IEView/src/Version.h index 05cd7a1571..a7523e31ad 100644 --- a/plugins/IEView/src/Version.h +++ b/plugins/IEView/src/Version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 1
#define __MINOR_VERSION 4
#define __RELEASE_NUM 0
-#define __BUILD_NUM 2
+#define __BUILD_NUM 3
#include <stdver.h>
|