diff options
author | George Hazan <george.hazan@gmail.com> | 2015-08-18 11:46:12 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-08-18 11:46:12 +0000 |
commit | d3b77308122587707580ec1f308dbdda38c806ac (patch) | |
tree | b679ff06efef0772c06fe6b2c9b4d84840324eaf /plugins/SmileyAdd/src/smileys.cpp | |
parent | 758cf835f21b2f73da541857afac0f3b226ea20e (diff) |
- naming conflict;
- warning fixes;
- code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@14984 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/SmileyAdd/src/smileys.cpp')
-rw-r--r-- | plugins/SmileyAdd/src/smileys.cpp | 411 |
1 files changed, 193 insertions, 218 deletions
diff --git a/plugins/SmileyAdd/src/smileys.cpp b/plugins/SmileyAdd/src/smileys.cpp index d373dc2190..698e6195a6 100644 --- a/plugins/SmileyAdd/src/smileys.cpp +++ b/plugins/SmileyAdd/src/smileys.cpp @@ -27,7 +27,6 @@ SmileyCategoryListType g_SmileyCategories; // SmileyType
//
-
SmileyType::SmileyType(void)
{
m_SmileyIcon = NULL;
@@ -35,10 +34,10 @@ SmileyType::SmileyType(void) m_flags = 0;
m_index = 0;
m_size.cx = 0;
- m_size.cy = 0;
+ m_size.cy = 0;
}
-SmileyType::~SmileyType()
+SmileyType::~SmileyType()
{
if (m_xepimg) m_xepimg->Release();
m_xepimg = NULL;
@@ -49,9 +48,8 @@ SmileyType::~SmileyType() HICON SmileyType::GetIcon(void)
-{
- if (m_SmileyIcon == NULL)
- {
+{
+ if (m_SmileyIcon == NULL) {
ImageBase* img = CreateCachedImage();
if (!img) return NULL;
img->SelectFrame(m_index);
@@ -62,8 +60,8 @@ HICON SmileyType::GetIcon(void) }
-HICON SmileyType::GetIconDup(void)
-{
+HICON SmileyType::GetIconDup(void)
+{
ImageBase* img = CreateCachedImage();
img->SelectFrame(m_index);
HICON hIcon = img->GetIcon();
@@ -94,11 +92,9 @@ bool SmileyType::LoadFromResource(const CMString& file, const int index) void SmileyType::GetSize(SIZE& size)
{
- if (m_size.cy == 0)
- {
+ if (m_size.cy == 0) {
ImageBase* img = CreateCachedImage();
- if (img)
- {
+ if (img) {
img->GetSize(m_size);
img->Release();
}
@@ -109,8 +105,7 @@ void SmileyType::GetSize(SIZE& size) ImageBase* SmileyType::CreateCachedImage(void)
{
- if (m_xepimg)
- {
+ if (m_xepimg) {
m_xepimg->AddRef();
return m_xepimg;
}
@@ -120,7 +115,7 @@ ImageBase* SmileyType::CreateCachedImage(void) void SmileyType::SetImList(HIMAGELIST hImLst, long i)
{
- if (m_xepimg) m_xepimg->Release();
+ if (m_xepimg) m_xepimg->Release();
m_xepimg = new ImageListItemType(0, hImLst, i);
}
@@ -147,8 +142,8 @@ SmileyPackType::SmileyPackType() errorFound = false;
}
-SmileyType* SmileyPackType::GetSmiley(unsigned index)
-{
+SmileyType* SmileyPackType::GetSmiley(unsigned index)
+{
return (index < (unsigned)m_SmileyList.getCount()) ? &m_SmileyList[index] : NULL;
}
@@ -171,8 +166,8 @@ static DWORD_PTR ConvertServiceParam(MCONTACT hContact, const TCHAR *param) void SmileyType::CallSmileyService(MCONTACT hContact)
{
- _TPattern * srvsplit = _TPattern::compile(_T("(.*)\\|(.*)\\|(.*)"));
- _TMatcher * m0 = srvsplit->createTMatcher(GetTriggerText());
+ _TPattern *srvsplit = _TPattern::compile(_T("(.*)\\|(.*)\\|(.*)"));
+ _TMatcher *m0 = srvsplit->createTMatcher(GetTriggerText());
m0->findFirstMatch();
CMString name = m0->getGroup(1);
@@ -185,14 +180,13 @@ void SmileyType::CallSmileyService(MCONTACT hContact) char str[MAXMODULELABELLENGTH];
const char *proto = "";
- if (name[0] == '/')
- {
+ if (name[0] == '/') {
proto = (const char*)GetContactProto(hContact);
if (proto == NULL) return;
}
mir_snprintf(str, "%s%s", proto, T2A_SM(name.c_str()));
CallService(str,
- ConvertServiceParam(hContact, par1.c_str()),
+ ConvertServiceParam(hContact, par1.c_str()),
ConvertServiceParam(hContact, par2.c_str()));
}
@@ -203,14 +197,14 @@ SmileyPackType::~SmileyPackType() if (m_hSmList != NULL) ImageList_Destroy(m_hSmList);
}
-static const TCHAR urlRegEx[] =
- _T("(?:ftp|https|http|file|aim|webcal|irc|msnim|xmpp|gopher|mailto|news|nntp|telnet|wais|prospero)://?[\\w.?%:/$+;]*");
+static const TCHAR urlRegEx[] =
+_T("(?:ftp|https|http|file|aim|webcal|irc|msnim|xmpp|gopher|mailto|news|nntp|telnet|wais|prospero)://?[\\w.?%:/$+;]*");
static const TCHAR pathRegEx[] = _T("[\\s\"][a-zA-Z]:[\\\\/][\\w.\\-\\\\/]*");
static const TCHAR timeRegEx[] = _T("\\d{1,2}:\\d{2}:\\d{2}|\\d{1,2}:\\d{2}");
void SmileyPackType::AddTriggersToSmileyLookup(void)
{
- _TPattern * p = _TPattern::compile(_T("\\s+"));
+ _TPattern *p = _TPattern::compile(_T("\\s+"));
{
CMString emptystr;
m_SmileyLookup.insert(new SmileyLookup(urlRegEx, true, -1, emptystr));
@@ -223,7 +217,7 @@ void SmileyPackType::AddTriggersToSmileyLookup(void) SmileyLookup* dats = new SmileyLookup(m_SmileyList[dist].GetTriggerText(), true, dist, GetFilename());
if (dats->IsValid())
m_SmileyLookup.insert(dats);
- else
+ else
errorFound = true;
if (m_SmileyList[dist].m_InsertText.IsEmpty())
m_SmileyList[dist].m_InsertText = m_SmileyList[dist].m_ToolText;
@@ -231,14 +225,13 @@ void SmileyPackType::AddTriggersToSmileyLookup(void) else if (!m_SmileyList[dist].IsService()) {
bool first = true;
int li = 0;
- _TMatcher * m0 = p->createTMatcher(m_SmileyList[dist].GetTriggerText());
- while (m0->findNextMatch())
- {
+ _TMatcher *m0 = p->createTMatcher(m_SmileyList[dist].GetTriggerText());
+ while (m0->findNextMatch()) {
int stind = m0->getStartingIndex();
if (li != stind) {
CMString out;
ReplaceAllSpecials(m0->getString().Mid(li, stind - li), out);
- SmileyLookup *dats = new SmileyLookup(out, false, dist, GetFilename());
+ SmileyLookup *dats = new SmileyLookup(out, false, dist, GetFilename());
if (dats->IsValid()) {
m_SmileyLookup.insert(dats);
if (first) {
@@ -254,7 +247,7 @@ void SmileyPackType::AddTriggersToSmileyLookup(void) if (li < stind) {
CMString out;
ReplaceAllSpecials(m0->getString().Mid(li, stind - li), out);
- SmileyLookup *dats = new SmileyLookup(out, false, dist, GetFilename());
+ SmileyLookup *dats = new SmileyLookup(out, false, dist, GetFilename());
if (dats->IsValid()) {
m_SmileyLookup.insert(dats);
if (first) {
@@ -328,24 +321,24 @@ bool SmileyPackType::LoadSmileyFile(const CMString& filename, const CMString& pa // Read xep file in
int len = _read(fh, buf, flen);
- *(wchar_t*)(buf+len) = 0;
+ *(wchar_t*)(buf + len) = 0;
// Close file
_close(fh);
CMString tbuf;
- if (len>2 && *(wchar_t*)buf == 0xfeff)
- tbuf = W2T_SM((wchar_t*)buf+1);
- else if (len>3 && buf[0]=='\xef' && buf[1]=='\xbb' && buf[2]=='\xbf')
- tbuf = W2T_SM(A2W_SM(buf+3, CP_UTF8));
+ if (len > 2 && *(wchar_t*)buf == 0xfeff)
+ tbuf = W2T_SM((wchar_t*)buf + 1);
+ else if (len > 3 && buf[0] == '\xef' && buf[1] == '\xbb' && buf[2] == '\xbf')
+ tbuf = W2T_SM(A2W_SM(buf + 3, CP_UTF8));
else
tbuf = A2T_SM(buf);
delete[] buf;
bool res;
- if (filename.Find(_T(".xep")) == -1)
+ if (filename.Find(_T(".xep")) == -1)
res = LoadSmileyFileMSL(tbuf, onlyInfo, modpath);
else
res = LoadSmileyFileXEP(tbuf, onlyInfo, modpath);
@@ -356,40 +349,37 @@ bool SmileyPackType::LoadSmileyFile(const CMString& filename, const CMString& pa return res;
}
-bool SmileyPackType::LoadSmileyFileMSL(CMString& tbuf, bool onlyInfo, CMString& modpath)
+bool SmileyPackType::LoadSmileyFileMSL(CMString &tbuf, bool onlyInfo, CMString &modpath)
{
- _TPattern * pathsplit = _TPattern::compile(_T("(.*\\\\)(.*)\\.|$"));
- _TMatcher * m0 = pathsplit->createTMatcher(modpath);
-
- m0->findFirstMatch();
- const CMString pathstr = m0->getGroup(1);
- const CMString packstr = m0->getGroup(2);
-
- delete m0;
- delete pathsplit;
-
- _TPattern * otherf = _TPattern::compile(
- _T("^\\s*(Name|Author|Date|Version|ButtonSmiley)\\s*=\\s*\"(.*)\""),
- _TPattern::MULTILINE_MATCHING);
-
- m0 = otherf->createTMatcher(tbuf);
-
- while (m0->findNextMatch())
+ CMString pathstr, packstr;
{
- if (m0->getGroup(1) == _T("Name")) m_Name = m0->getGroup(2);
- if (m0->getGroup(1) == _T("Author")) m_Author = m0->getGroup(2);
- if (m0->getGroup(1) == _T("Date")) m_Date = m0->getGroup(2);
- if (m0->getGroup(1) == _T("Version")) m_Version = m0->getGroup(2);
- if (m0->getGroup(1) == _T("ButtonSmiley")) m_ButtonSmiley = m0->getGroup(2);
+ _TPattern *pathsplit = _TPattern::compile(_T("(.*\\\\)(.*)\\.|$"));
+ _TMatcher *m0 = pathsplit->createTMatcher(modpath);
+ m0->findFirstMatch();
+ pathstr = m0->getGroup(1);
+ packstr = m0->getGroup(2);
+ delete m0;
+ delete pathsplit;
+ }
+ {
+ _TPattern *otherf = _TPattern::compile(
+ _T("^\\s*(Name|Author|Date|Version|ButtonSmiley)\\s*=\\s*\"(.*)\""),
+ _TPattern::MULTILINE_MATCHING);
+
+ _TMatcher *m0 = otherf->createTMatcher(tbuf);
+ while (m0->findNextMatch()) {
+ if (m0->getGroup(1) == _T("Name")) m_Name = m0->getGroup(2);
+ if (m0->getGroup(1) == _T("Author")) m_Author = m0->getGroup(2);
+ if (m0->getGroup(1) == _T("Date")) m_Date = m0->getGroup(2);
+ if (m0->getGroup(1) == _T("Version")) m_Version = m0->getGroup(2);
+ if (m0->getGroup(1) == _T("ButtonSmiley")) m_ButtonSmiley = m0->getGroup(2);
+ }
+ delete m0;
+ delete otherf;
}
- delete m0;
- delete otherf;
if (!onlyInfo) {
- selec.x = 0;
- selec.y = 0;
- win.x = 0;
- win.y = 0;
+ selec.x = selec.y = win.x = win.y = 0;
{
_TPattern *pat = _TPattern::compile(
_T("^\\s*(Selection|Window)Size\\s*=\\s*(\\d+)\\s*,\\s*(\\d+)"),
@@ -409,7 +399,7 @@ bool SmileyPackType::LoadSmileyFileMSL(CMString& tbuf, bool onlyInfo, CMString& delete pat;
}
- _TPattern * smiley = _TPattern::compile(
+ _TPattern *smiley = _TPattern::compile(
_T("^\\s*Smiley(\\*)?\\s*=") // Is Hidden
_T("(?:\\s*\"(.*)\")") // Smiley file name
_T("(?:[\\s,]+(\\-?\\d+))") // Icon resource id
@@ -418,69 +408,70 @@ bool SmileyPackType::LoadSmileyFileMSL(CMString& tbuf, bool onlyInfo, CMString& _T("(?:[\\s,]+\"(.*?)\")?"), // Tooltip text
_TPattern::MULTILINE_MATCHING);
- _TMatcher * m0 = smiley->createTMatcher(tbuf);
SmileyVectorType hiddenSmileys;
-
unsigned smnum = 0;
- while (m0->findNextMatch()) {
- CMString resname = m0->getGroup(2);
- if (resname.Find(_T("http://")) != -1) {
- if (GetSmileyFile(resname, packstr))
- continue;
- }
- else if (!resname.IsEmpty())
- resname.Insert(0, pathstr);
-
- SmileyType *dat = new SmileyType;
-
- const int iconIndex = _ttol(m0->getGroup(3).c_str());
+ {
+ _TMatcher *m0 = smiley->createTMatcher(tbuf);
+ while (m0->findNextMatch()) {
+ CMString resname = m0->getGroup(2);
+ if (resname.Find(_T("http://")) != -1) {
+ if (GetSmileyFile(resname, packstr))
+ continue;
+ }
+ else if (!resname.IsEmpty())
+ resname.Insert(0, pathstr);
- dat->SetHidden(m0->getStartingIndex(1) >= 0);
- if (m0->getStartingIndex(4) >= 0) {
- dat->SetRegEx(m0->getGroup(4) == _T("R"));
- dat->SetService(m0->getGroup(4) == _T("S"));
- }
- dat->m_TriggerText = m0->getGroup(5);
- if (dat->IsRegEx()) {
- if (m0->getStartingIndex(6) >= 0)
- ReplaceAllSpecials(m0->getGroup(6), dat->m_InsertText);
+ SmileyType *dat = new SmileyType;
- if (m0->getStartingIndex(7) >= 0)
- ReplaceAllSpecials(m0->getGroup(7), dat->m_ToolText);
- else
- dat->m_ToolText = dat->m_InsertText;
- }
- else {
- if (m0->getStartingIndex(6) >= 0)
- ReplaceAllSpecials(m0->getGroup(6), dat->m_ToolText);
- else
- ReplaceAllSpecials(dat->m_TriggerText, dat->m_ToolText);
- }
+ const int iconIndex = _ttol(m0->getGroup(3).c_str());
- bool noerr;
- if (resname.IsEmpty()) {
- dat->SetHidden(true);
- dat->SetText(true);
- noerr = true;
- }
- else noerr = dat->LoadFromResource(resname, iconIndex);
+ dat->SetHidden(m0->getStartingIndex(1) >= 0);
+ if (m0->getStartingIndex(4) >= 0) {
+ dat->SetRegEx(m0->getGroup(4) == _T("R"));
+ dat->SetService(m0->getGroup(4) == _T("S"));
+ }
+ dat->m_TriggerText = m0->getGroup(5);
+ if (dat->IsRegEx()) {
+ if (m0->getStartingIndex(6) >= 0)
+ ReplaceAllSpecials(m0->getGroup(6), dat->m_InsertText);
+
+ if (m0->getStartingIndex(7) >= 0)
+ ReplaceAllSpecials(m0->getGroup(7), dat->m_ToolText);
+ else
+ dat->m_ToolText = dat->m_InsertText;
+ }
+ else {
+ if (m0->getStartingIndex(6) >= 0)
+ ReplaceAllSpecials(m0->getGroup(6), dat->m_ToolText);
+ else
+ ReplaceAllSpecials(dat->m_TriggerText, dat->m_ToolText);
+ }
- if (dat->IsHidden())
- hiddenSmileys.insert(dat);
- else
- m_SmileyList.insert(dat);
+ bool noerr;
+ if (resname.IsEmpty()) {
+ dat->SetHidden(true);
+ dat->SetText(true);
+ noerr = true;
+ }
+ else noerr = dat->LoadFromResource(resname, iconIndex);
- if (!noerr) {
- static const TCHAR errmsg[] = LPGENT("Smiley #%u in file %s for smiley pack %s not found.");
- TCHAR msgtxt[1024];
- mir_sntprintf(msgtxt, _countof(msgtxt), TranslateTS(errmsg), smnum, resname.c_str(), modpath.c_str());
- CallService(MS_NETLIB_LOG, (WPARAM)hNetlibUser, _T2A(msgtxt));
- errorFound = true;
+ if (dat->IsHidden())
+ hiddenSmileys.insert(dat);
+ else
+ m_SmileyList.insert(dat);
+
+ if (!noerr) {
+ static const TCHAR errmsg[] = LPGENT("Smiley #%u in file %s for smiley pack %s not found.");
+ TCHAR msgtxt[1024];
+ mir_sntprintf(msgtxt, _countof(msgtxt), TranslateTS(errmsg), smnum, resname.c_str(), modpath.c_str());
+ CallService(MS_NETLIB_LOG, (WPARAM)hNetlibUser, _T2A(msgtxt));
+ errorFound = true;
+ }
+ smnum++;
}
- smnum++;
+ delete smiley;
+ delete m0;
}
- delete m0;
- delete smiley;
m_VisibleCount = m_SmileyList.getCount();
@@ -524,33 +515,30 @@ static IStream* DecodeBase64Data(const char* pData) }
-bool SmileyPackType::LoadSmileyFileXEP(CMString& tbuf, bool onlyInfo, CMString& )
+bool SmileyPackType::LoadSmileyFileXEP(CMString& tbuf, bool onlyInfo, CMString&)
{
_TMatcher *m0, *m1, *m2;
- _TPattern * dbname_re = _TPattern::compile(_T("<DataBaseName>\\s*\"(.*?)\"\\s*</DataBaseName>"),
+ _TPattern *dbname_re = _TPattern::compile(_T("<DataBaseName>\\s*\"(.*?)\"\\s*</DataBaseName>"),
_TPattern::MULTILINE_MATCHING);
- _TPattern * author_re = _TPattern::compile(_T("<PackageAuthor>\\s*\"(.*?)\"\\s*</PackageAuthor>"),
+ _TPattern *author_re = _TPattern::compile(_T("<PackageAuthor>\\s*\"(.*?)\"\\s*</PackageAuthor>"),
_TPattern::MULTILINE_MATCHING);
- _TPattern * settings_re = _TPattern::compile(_T("<settings>(.*?)</settings>"),
+ _TPattern *settings_re = _TPattern::compile(_T("<settings>(.*?)</settings>"),
_TPattern::MULTILINE_MATCHING | _TPattern::DOT_MATCHES_ALL);
m0 = settings_re->createTMatcher(tbuf);
- if (m0->findFirstMatch())
- {
+ if (m0->findFirstMatch()) {
CMString settings = m0->getGroup(1);
m1 = author_re->createTMatcher(settings);
- if (m1->findFirstMatch())
- {
+ if (m1->findFirstMatch()) {
m_Author = m1->getGroup(1);
DecodeHTML(m_Author);
}
delete m1;
m1 = dbname_re->createTMatcher(settings);
- if (m1->findFirstMatch())
- {
+ if (m1->findFirstMatch()) {
m_Name = m1->getGroup(1);
DecodeHTML(m_Name);
}
@@ -562,32 +550,28 @@ bool SmileyPackType::LoadSmileyFileXEP(CMString& tbuf, bool onlyInfo, CMString& delete author_re;
delete settings_re;
- if (!onlyInfo)
- {
- _TPattern * record_re = _TPattern::compile(_T("<record.*?ImageIndex=\"(.*?)\".*?>(?:\\s*\"(.*?)\")?(.*?)</record>"),
+ if (!onlyInfo) {
+ _TPattern *record_re = _TPattern::compile(_T("<record.*?ImageIndex=\"(.*?)\".*?>(?:\\s*\"(.*?)\")?(.*?)</record>"),
_TPattern::MULTILINE_MATCHING | _TPattern::DOT_MATCHES_ALL);
- _TPattern * expression_re = _TPattern::compile(_T("<Expression>\\s*\"(.*?)\"\\s*</Expression>"),
+ _TPattern *expression_re = _TPattern::compile(_T("<Expression>\\s*\"(.*?)\"\\s*</Expression>"),
_TPattern::MULTILINE_MATCHING);
- _TPattern * pastetext_re = _TPattern::compile(_T("<PasteText>\\s*\"(.*?)\"\\s*</PasteText>"),
+ _TPattern *pastetext_re = _TPattern::compile(_T("<PasteText>\\s*\"(.*?)\"\\s*</PasteText>"),
_TPattern::MULTILINE_MATCHING);
- _TPattern * images_re = _TPattern::compile(_T("<images>(.*?)</images>"),
+ _TPattern *images_re = _TPattern::compile(_T("<images>(.*?)</images>"),
_TPattern::MULTILINE_MATCHING | _TPattern::DOT_MATCHES_ALL);
- _TPattern * image_re = _TPattern::compile(_T("<Image>(.*?)</Image>"),
+ _TPattern *image_re = _TPattern::compile(_T("<Image>(.*?)</Image>"),
_TPattern::MULTILINE_MATCHING | _TPattern::DOT_MATCHES_ALL);
- _TPattern * imagedt_re = _TPattern::compile(_T("<!\\[CDATA\\[(.*?)\\]\\]>"),
- _TPattern::MULTILINE_MATCHING );
+ _TPattern *imagedt_re = _TPattern::compile(_T("<!\\[CDATA\\[(.*?)\\]\\]>"),
+ _TPattern::MULTILINE_MATCHING);
m0 = images_re->createTMatcher(tbuf);
- if (m0->findFirstMatch())
- {
+ if (m0->findFirstMatch()) {
CMString images = m0->getGroup(1);
m1 = imagedt_re->createTMatcher(images);
- if (m1->findFirstMatch())
- {
+ if (m1->findFirstMatch()) {
IStream* pStream = DecodeBase64Data(T2A_SM(m1->getGroup(1).c_str()));
- if (pStream != NULL)
- {
+ if (pStream != NULL) {
if (m_hSmList != NULL) ImageList_Destroy(m_hSmList);
m_hSmList = ImageList_Read(pStream);
pStream->Release();
@@ -598,9 +582,8 @@ bool SmileyPackType::LoadSmileyFileXEP(CMString& tbuf, bool onlyInfo, CMString& delete m0;
m0 = record_re->createTMatcher(tbuf);
- while (m0->findNextMatch())
- {
- SmileyType *dat = new SmileyType;
+ while (m0->findNextMatch()) {
+ SmileyType *dat = new SmileyType;
dat->SetRegEx(true);
dat->SetImList(m_hSmList, _ttol(m0->getGroup(1).c_str()));
@@ -610,16 +593,14 @@ bool SmileyPackType::LoadSmileyFileXEP(CMString& tbuf, bool onlyInfo, CMString& CMString rec = m0->getGroup(3);
m1 = expression_re->createTMatcher(rec);
- if (m1->findFirstMatch())
- {
+ if (m1->findFirstMatch()) {
dat->m_TriggerText = m1->getGroup(1);
DecodeHTML(dat->m_TriggerText);
}
delete m1;
m1 = pastetext_re->createTMatcher(rec);
- if (m1->findFirstMatch())
- {
+ if (m1->findFirstMatch()) {
dat->m_InsertText = m1->getGroup(1);
DecodeHTML(dat->m_InsertText);
}
@@ -627,16 +608,13 @@ bool SmileyPackType::LoadSmileyFileXEP(CMString& tbuf, bool onlyInfo, CMString& dat->SetHidden(dat->m_InsertText.IsEmpty());
m1 = image_re->createTMatcher(rec);
- if (m1->findFirstMatch())
- {
+ if (m1->findFirstMatch()) {
CMString images = m1->getGroup(1);
m2 = imagedt_re->createTMatcher(images);
- if (m2->findFirstMatch())
- {
+ if (m2->findFirstMatch()) {
IStream* pStream = DecodeBase64Data(T2A_SM(m2->getGroup(1).c_str()));
- if (pStream != NULL)
- {
+ if (pStream != NULL) {
dat->LoadFromImage(pStream);
pStream->Release();
}
@@ -663,8 +641,8 @@ bool SmileyPackType::LoadSmileyFileXEP(CMString& tbuf, bool onlyInfo, CMString& selec.x = 0;
selec.y = 0;
- win.x = 0;
- win.y = 0;
+ win.x = 0;
+ win.y = 0;
return true;
}
@@ -678,8 +656,7 @@ bool SmileyPackType::LoadSmileyFileXEP(CMString& tbuf, bool onlyInfo, CMString& bool SmileyPackListType::AddSmileyPack(CMString& filename, CMString& packname)
{
bool res = true;
- if (GetSmileyPack(filename) == NULL)
- { //not exist yet, so add
+ if (GetSmileyPack(filename) == NULL) { //not exist yet, so add
SmileyPackType *smileyPack = new SmileyPackType;
res = smileyPack->LoadSmileyFile(filename, packname, FALSE);
@@ -697,7 +674,7 @@ SmileyPackType* SmileyPackListType::GetSmileyPack(CMString& filename) CMString modpath;
pathToAbsolute(filename, modpath);
- for (int i=0; i < m_SmileyPacks.getCount(); i++) {
+ for (int i = 0; i < m_SmileyPacks.getCount(); i++) {
CMString modpath1;
pathToAbsolute(m_SmileyPacks[i].GetFilename(), modpath1);
if (mir_tstrcmpi(modpath.c_str(), modpath1.c_str()) == 0) return &m_SmileyPacks[i];
@@ -716,13 +693,13 @@ void SmileyPackListType::ClearAndFreeAll() //
-SmileyCategoryType::SmileyCategoryType(SmileyPackListType* pSPS, const CMString& name,
- const CMString& displayName,
+SmileyCategoryType::SmileyCategoryType(SmileyPackListType* pSPS, const CMString& name,
+ const CMString& displayName,
const CMString& defaultFilename, SmcType typ)
-{
- m_pSmileyPackStore = pSPS;
- type = typ;
- m_Name = name;
+{
+ m_pSmileyPackStore = pSPS;
+ type = typ;
+ m_Name = name;
m_DisplayName = displayName;
visible = true;
@@ -732,12 +709,11 @@ SmileyCategoryType::SmileyCategoryType(SmileyPackListType* pSPS, const CMString& void SmileyCategoryType::Load(void)
{
- bool visiblecat = opt.UsePhysProto ? !IsAcc() : !IsPhysProto();
- bool visible = opt.UseOneForAll ? !IsProto() : visiblecat;
-
- if (visible && !m_Filename.IsEmpty()){
+ bool bVisibleCat = opt.UsePhysProto ? !IsAcc() : !IsPhysProto();
+ bool bVisible = opt.UseOneForAll ? !IsProto() : bVisibleCat;
+ if (bVisible && !m_Filename.IsEmpty()) {
bool loaded = m_pSmileyPackStore->AddSmileyPack(m_Filename, m_DisplayName);
- if (!loaded){
+ if (!loaded) {
ClearFilename();
SaveSettings();
}
@@ -745,15 +721,15 @@ void SmileyCategoryType::Load(void) }
-SmileyPackType* SmileyCategoryType::GetSmileyPack(void)
-{
- return m_pSmileyPackStore->GetSmileyPack(m_Filename);
+SmileyPackType* SmileyCategoryType::GetSmileyPack(void)
+{
+ return m_pSmileyPackStore->GetSmileyPack(m_Filename);
}
void SmileyCategoryType::SaveSettings(void)
-{
- opt.WritePackFileName(m_Filename, m_Name);
+{
+ opt.WritePackFileName(m_Filename, m_Name);
}
//
@@ -764,14 +740,14 @@ void SmileyCategoryListType::ClearAndLoadAll(void) {
m_pSmileyPackStore->ClearAndFreeAll();
- for (int i=0; i < m_SmileyCategories.getCount(); i++)
+ for (int i = 0; i < m_SmileyCategories.getCount(); i++)
m_SmileyCategories[i].Load();
}
SmileyCategoryType* SmileyCategoryListType::GetSmileyCategory(const CMString& name)
{
- for (int i=0; i < m_SmileyCategories.getCount(); i++)
+ for (int i = 0; i < m_SmileyCategories.getCount(); i++)
if (name.CompareNoCase(m_SmileyCategories[i].GetName()) == 0)
return &m_SmileyCategories[i];
@@ -785,17 +761,17 @@ SmileyCategoryType* SmileyCategoryListType::GetSmileyCategory(unsigned index) }
-SmileyPackType* SmileyCategoryListType::GetSmileyPack(CMString& categoryname)
+SmileyPackType* SmileyCategoryListType::GetSmileyPack(CMString& categoryname)
{
SmileyCategoryType* smc = GetSmileyCategory(categoryname);
- return smc != NULL ? smc->GetSmileyPack() : NULL;
+ return smc != NULL ? smc->GetSmileyPack() : NULL;
}
void SmileyCategoryListType::SaveSettings(void)
{
CMString catstr;
- for (int i=0; i < m_SmileyCategories.getCount(); i++) {
+ for (int i = 0; i < m_SmileyCategories.getCount(); i++) {
m_SmileyCategories[i].SaveSettings();
if (m_SmileyCategories[i].IsCustom()) {
if (!catstr.IsEmpty()) catstr += '#';
@@ -814,16 +790,16 @@ void SmileyCategoryListType::AddAndLoad(const CMString& name, const CMString& di AddCategory(name, displayName, smcExt);
// Load only if other smileys have been loaded already
if (m_SmileyCategories.getCount() > 1)
- m_SmileyCategories[m_SmileyCategories.getCount()-1].Load();
+ m_SmileyCategories[m_SmileyCategories.getCount() - 1].Load();
}
-void SmileyCategoryListType::AddCategory(const CMString& name, const CMString& displayName,
+void SmileyCategoryListType::AddCategory(const CMString& name, const CMString& displayName,
SmcType typ, const CMString& defaultFilename)
{
if (GetSmileyCategory(name) == NULL)
- m_SmileyCategories.insert(new SmileyCategoryType(m_pSmileyPackStore, name,
- displayName, defaultFilename, typ));
+ m_SmileyCategories.insert(new SmileyCategoryType(m_pSmileyPackStore, name,
+ displayName, defaultFilename, typ));
}
@@ -840,22 +816,21 @@ bool SmileyCategoryListType::DeleteCustomCategory(int index) void SmileyCategoryListType::AddAccountAsCategory(PROTOACCOUNT *acc, const CMString& defaultFile)
{
- if (Proto_IsAccountEnabled(acc) && acc->szProtoName && IsSmileyProto(acc->szModuleName))
- {
+ if (Proto_IsAccountEnabled(acc) && acc->szProtoName && IsSmileyProto(acc->szModuleName)) {
CMString displayName(acc->tszAccountName ? acc->tszAccountName : A2T_SM(acc->szModuleName));
CMString PhysProtoName, paths;
DBVARIANT dbv;
-
- if (db_get_ts(NULL, acc->szModuleName, "AM_BaseProto", &dbv) == 0){
+
+ if (db_get_ts(NULL, acc->szModuleName, "AM_BaseProto", &dbv) == 0) {
PhysProtoName = _T("AllProto");
PhysProtoName += dbv.ptszVal;
- db_free(&dbv);
+ db_free(&dbv);
}
if (!PhysProtoName.IsEmpty())
paths = g_SmileyCategories.GetSmileyCategory(PhysProtoName) ? g_SmileyCategories.GetSmileyCategory(PhysProtoName)->GetFilename() : _T("");
-
- if (paths.IsEmpty()){
+
+ if (paths.IsEmpty()) {
const char* packnam = acc->szProtoName;
if (mir_strcmp(packnam, "JABBER") == 0)
packnam = "JGMail";
@@ -865,7 +840,7 @@ void SmileyCategoryListType::AddAccountAsCategory(PROTOACCOUNT *acc, const CMStr char path[MAX_PATH];
mir_snprintf(path, _countof(path), "Smileys\\nova\\%s.msl", packnam);
- paths = A2T_SM(path);
+ paths = A2T_SM(path);
CMString patha;
pathToAbsolute(paths, patha);
@@ -882,7 +857,7 @@ void SmileyCategoryListType::AddProtoAsCategory(char *acc, const CMString& defau {
if (acc == NULL)
return;
-
+
const char* packnam = acc;
if (mir_strcmp(packnam, "JABBER") == 0)
packnam = "JGMail";
@@ -922,7 +897,7 @@ void SmileyCategoryListType::DeleteAccountAsCategory(PROTOACCOUNT *acc) }
}
- for (int i=0; i < m_SmileyCategories.getCount(); i++) {
+ for (int i = 0; i < m_SmileyCategories.getCount(); i++) {
if (tname.CompareNoCase(m_SmileyCategories[i].GetName()) == 0) {
m_SmileyCategories.remove(i);
break;
@@ -946,15 +921,15 @@ void SmileyCategoryListType::AddContactTransportAsCategory(MCONTACT hContact, co const char *packname = NULL;
if (strstr(trsp, "msn") != NULL)
- packname = "msn";
+ packname = "msn";
else if (strstr(trsp, "icq") != NULL)
- packname = "icq";
+ packname = "icq";
else if (strstr(trsp, "yahoo") != NULL)
- packname = "yahoo";
+ packname = "yahoo";
else if (strstr(trsp, "aim") != NULL)
- packname = "aim";
+ packname = "aim";
else if (strstr(trsp, "lcs") != NULL)
- packname = "msn";
+ packname = "msn";
mir_free(trsp);
@@ -963,13 +938,13 @@ void SmileyCategoryListType::AddContactTransportAsCategory(MCONTACT hContact, co char path[MAX_PATH];
mir_snprintf(path, _countof(path), "Smileys\\nova\\%s.msl", packname);
- CMString paths = A2T_SM(path), patha;
+ CMString paths = A2T_SM(path), patha;
pathToAbsolute(paths, patha);
- if (_taccess(patha.c_str(), 0) != 0)
+ if (_taccess(patha.c_str(), 0) != 0)
paths = defaultFile;
- AddCategory(displayName, displayName, smcTransportProto, paths);
+ AddCategory(displayName, displayName, smcTransportProto, paths);
}
else AddCategory(displayName, displayName, smcTransportProto, defaultFile);
@@ -983,19 +958,19 @@ void SmileyCategoryListType::AddAllProtocolsAsCategory(void) CMString tname = _T("Standard");
AddCategory(tname, displayName, smcStd);
- const CMString& defaultFile = GetSmileyCategory(tname)->GetFilename();
+ const CMString &defaultFile = GetSmileyCategory(tname)->GetFilename();
PROTOCOLDESCRIPTOR **proto;
int protoCount = 0;
Proto_EnumProtocols(&protoCount, &proto);
- for (int i = 0; i < protoCount; i++){
- PROTOCOLDESCRIPTOR* pd = proto[i];
+ for (int i = 0; i < protoCount; i++) {
+ PROTOCOLDESCRIPTOR *pd = proto[i];
if (pd->type == PROTOTYPE_PROTOCOL && pd->cbSize == sizeof(*pd))
- AddProtoAsCategory(pd->szName, defaultFile);
+ AddProtoAsCategory(pd->szName, defaultFile);
}
- PROTOACCOUNT **accList;
+ PROTOACCOUNT **accList;
Proto_EnumAccounts(&protoCount, &accList);
for (int i = 0; i < protoCount; i++)
AddAccountAsCategory(accList[i], defaultFile);
@@ -1006,12 +981,12 @@ void SmileyCategoryListType::AddAllProtocolsAsCategory(void) CMString cats;
opt.ReadCustomCategories(cats);
- int cppv = 0;
+ int cppv = 0;
for (;;) {
int cp = cats.Find('#', cppv);
if (cp == -1)
break;
-
+
displayName = cats.Mid(cppv, cp - cppv);
AddCategory(displayName, displayName, smcCustom, defaultFile);
cppv = cp + 1;
@@ -1044,13 +1019,13 @@ SmileyLookup::SmileyLookup(const CMString& str, const bool regexs, const int ind delete matcher;
}
else {
- static const TCHAR errmsg[] = LPGENT("Regular expression \"%s\" in smiley pack \"%s\" malformed.") ;
+ static const TCHAR errmsg[] = LPGENT("Regular expression \"%s\" in smiley pack \"%s\" malformed.");
mir_sntprintf(msgtxt, _countof(msgtxt), TranslateTS(errmsg), str.c_str(), smpt.c_str());
}
if (!m_valid)
CallService(MS_NETLIB_LOG, (WPARAM)hNetlibUser, _T2A(msgtxt));
- }
+ }
else {
m_text = str;
m_pattern = NULL;
@@ -1071,7 +1046,7 @@ void SmileyLookup::Find(const CMString& str, SmileyLocVecType& smlcur, bool firs if (m_text.IsEmpty()) {
_TMatcher* matcher = m_pattern->createTMatcher(str);
- while( matcher->findNextMatch()) {
+ while (matcher->findNextMatch()) {
int st = matcher->getStartingIndex();
int sz = matcher->getEndingIndex() - st;
if (sz != 0) {
@@ -1084,7 +1059,7 @@ void SmileyLookup::Find(const CMString& str, SmileyLocVecType& smlcur, bool firs }
else {
const TCHAR* pos = str.c_str();
- while( (pos = _tcsstr(pos, m_text.c_str())) != NULL ) {
+ while ((pos = _tcsstr(pos, m_text.c_str())) != NULL) {
smlcur.insert(new SmileyLocType(pos - str.c_str(), m_text.GetLength()));
pos += m_text.GetLength();
if (firstOnly && m_ind != -1)
|