summaryrefslogtreecommitdiff
path: root/plugins/SmileyAdd
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-04-03 18:05:17 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-04-03 18:05:17 +0000
commita4f31a97e407280dc7e306a6c96948b53f9c0cab (patch)
tree8e76329ed4784e0c8e1ee81070c5b9985989263a /plugins/SmileyAdd
parentf07feab44bd3ef047229f511fadb3a151f200654 (diff)
SmileyAdd:
- array indexes totally unborkred; - code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@4296 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/SmileyAdd')
-rw-r--r--plugins/SmileyAdd/src/AniSmileyObject.cpp5
-rw-r--r--plugins/SmileyAdd/src/SmileyBase.cpp2
-rw-r--r--plugins/SmileyAdd/src/anim.cpp8
-rw-r--r--plugins/SmileyAdd/src/customsmiley.cpp20
-rw-r--r--plugins/SmileyAdd/src/dlgboxsubclass.cpp16
-rw-r--r--plugins/SmileyAdd/src/download.cpp9
-rw-r--r--plugins/SmileyAdd/src/imagecache.cpp8
-rw-r--r--plugins/SmileyAdd/src/options.cpp141
-rw-r--r--plugins/SmileyAdd/src/richcall.cpp114
-rw-r--r--plugins/SmileyAdd/src/services.cpp22
-rw-r--r--plugins/SmileyAdd/src/smileyroutines.cpp232
-rw-r--r--plugins/SmileyAdd/src/smileys.cpp105
-rw-r--r--plugins/SmileyAdd/src/smileys.h5
13 files changed, 272 insertions, 415 deletions
diff --git a/plugins/SmileyAdd/src/AniSmileyObject.cpp b/plugins/SmileyAdd/src/AniSmileyObject.cpp
index e94ec9d855..85cad0197b 100644
--- a/plugins/SmileyAdd/src/AniSmileyObject.cpp
+++ b/plugins/SmileyAdd/src/AniSmileyObject.cpp
@@ -111,8 +111,7 @@ public:
{
regAniSmileys.remove(this);
- if (timerId && (timerId+1) && regAniSmileys.getCount() == 0)
- {
+ if (timerId && (timerId+1) && regAniSmileys.getCount() == 0) {
KillTimer(NULL, timerId);
timerId = 0;
}
@@ -427,7 +426,7 @@ ISmileyBase* CreateAniSmileyObject(SmileyType* sml, COLORREF clr, bool ishpp)
static void CALLBACK timerProc(HWND, UINT, UINT_PTR, DWORD)
{
- for (int i=0; i<regAniSmileys.getCount(); ++i)
+ for (int i=0; i < regAniSmileys.getCount(); i++)
regAniSmileys[i]->ProcessTimerTick();
}
diff --git a/plugins/SmileyAdd/src/SmileyBase.cpp b/plugins/SmileyAdd/src/SmileyBase.cpp
index f0107e758c..badb6d43e8 100644
--- a/plugins/SmileyAdd/src/SmileyBase.cpp
+++ b/plugins/SmileyAdd/src/SmileyBase.cpp
@@ -374,7 +374,7 @@ void CloseSmileys(void)
int CheckForTip(int x, int y, HWND hwnd, TCHAR** smltxt)
{
- for (int i=0; i < regSmileys.getCount(); ++i)
+ for (int i=0; i < regSmileys.getCount(); i++)
if (regSmileys[i]->QueryHitPointSpecial(x, y, hwnd, smltxt))
return i;
diff --git a/plugins/SmileyAdd/src/anim.cpp b/plugins/SmileyAdd/src/anim.cpp
index d454d940e3..0fbf663346 100644
--- a/plugins/SmileyAdd/src/anim.cpp
+++ b/plugins/SmileyAdd/src/anim.cpp
@@ -156,26 +156,26 @@ void AnimatedPack::Add(SmileyType *sml, RECT rect, bool clip)
void AnimatedPack::Draw(HDC hdc)
{
- for (int i=0; i<m_AniList.getCount(); i++)
+ for (int i=0; i < m_AniList.getCount(); i++)
m_AniList[i].Draw(hdc);
}
void AnimatedPack::SetOffset(int off)
{
- for (int i=0; i<m_AniList.getCount(); i++)
+ for (int i=0; i < m_AniList.getCount(); i++)
m_AniList[i].SetOffset(off, m_wsize);
}
void AnimatedPack::SetSel(RECT& rect)
{
- for (int i=0; i<m_AniList.getCount(); i++)
+ for (int i=0; i < m_AniList.getCount(); i++)
m_AniList[i].SetSel(rect.left, rect.top);
}
void AnimatedPack::ProcessTimerTick(HWND hwnd)
{
- for (int i=0; i<m_AniList.getCount(); i++)
+ for (int i=0; i < m_AniList.getCount(); i++)
m_AniList[i].ProcessTimerTick(hwnd);
}
diff --git a/plugins/SmileyAdd/src/customsmiley.cpp b/plugins/SmileyAdd/src/customsmiley.cpp
index 448d3dc99b..4c0a75a11a 100644
--- a/plugins/SmileyAdd/src/customsmiley.cpp
+++ b/plugins/SmileyAdd/src/customsmiley.cpp
@@ -43,9 +43,8 @@ bool SmileyPackCListType::AddSmileyPack(HANDLE hContact, TCHAR* dir)
bool SmileyPackCListType::AddSmiley(HANDLE hContact, TCHAR* path)
{
- SmileyPackCType* smpack = GetSmileyPack(hContact);
- if (smpack == NULL)
- {
+ SmileyPackCType *smpack = GetSmileyPack(hContact);
+ if (smpack == NULL) {
smpack = new SmileyPackCType;
smpack->SetId(hContact);
@@ -58,9 +57,9 @@ bool SmileyPackCListType::AddSmiley(HANDLE hContact, TCHAR* path)
SmileyPackCType* SmileyPackCListType::GetSmileyPack(HANDLE id)
{
for (int i = 0; i < m_SmileyPacks.getCount(); i++)
- {
- if (m_SmileyPacks[i].GetId() == id) return &m_SmileyPacks[i];
- }
+ if (m_SmileyPacks[i].GetId() == id)
+ return &m_SmileyPacks[i];
+
return NULL;
}
@@ -142,10 +141,8 @@ bool SmileyPackCType::LoadSmiley(TCHAR* path)
bkstring name = dirs.substr(slash+1, dot - slash - 1);
- for (int i=0; i < m_SmileyList.getCount(); i++)
- {
- if (m_SmileyList[i].GetTriggerText() == name)
- {
+ for (int i=0; i < m_SmileyList.getCount(); i++) {
+ if (m_SmileyList[i].GetTriggerText() == name) {
m_SmileyList[i].LoadFromResource(dirs, 0);
return true;
}
@@ -164,8 +161,7 @@ bool SmileyPackCType::LoadSmiley(TCHAR* path)
void SmileyPackCType::AddTriggersToSmileyLookup(void)
{
bkstring empty;
- for (int dist=0; dist<m_SmileyList.getCount(); dist++)
- {
+ for (int dist=0; dist<m_SmileyList.getCount(); dist++) {
SmileyLookup *dats = new SmileyLookup(m_SmileyList[dist].GetTriggerText(), false, dist, empty);
m_SmileyLookup.insert(dats);
}
diff --git a/plugins/SmileyAdd/src/dlgboxsubclass.cpp b/plugins/SmileyAdd/src/dlgboxsubclass.cpp
index d10d8f9246..554258dee7 100644
--- a/plugins/SmileyAdd/src/dlgboxsubclass.cpp
+++ b/plugins/SmileyAdd/src/dlgboxsubclass.cpp
@@ -114,7 +114,7 @@ public:
if (OldButtonPlace)
{
- if (isSplit && DBGetContactSettingByte(NULL, "SRMsg", "ShowQuote", FALSE))
+ if (isSplit && db_get_b(NULL, "SRMsg", "ShowQuote", FALSE))
{
GetWindowRect(QuoteB, &rect);
pt.x = rect.right + 12;
@@ -199,17 +199,17 @@ public:
bool showButtonLine;
if (IsOldSrmm())
{
- isSplit = DBGetContactSettingByte(NULL,"SRMsg","Split", TRUE) != 0;
+ isSplit = db_get_b(NULL,"SRMsg","Split", TRUE) != 0;
doSmileyReplace = (isSplit || !isSend);
doSmileyButton &= isSplit || isSend;
- showButtonLine = DBGetContactSettingByte(NULL, "SRMsg", "ShowButtonLine", TRUE) != 0;
+ showButtonLine = db_get_b(NULL, "SRMsg", "ShowButtonLine", TRUE) != 0;
}
else
{
doSmileyReplace = true;
OldButtonPlace = false;
- showButtonLine = DBGetContactSettingByte(NULL, "SRMM", "ShowButtonLine", TRUE) != 0;
+ showButtonLine = db_get_b(NULL, "SRMM", "ShowButtonLine", TRUE) != 0;
}
doSmileyButton &= OldButtonPlace || showButtonLine;
@@ -275,10 +275,8 @@ bool IsOldSrmm(void)
int UpdateSrmmDlg(WPARAM wParam, LPARAM /* lParam */)
{
WaitForSingleObject(g_hMutex, 2000);
- for (int i=0; i<g_MsgWndList.getCount(); ++i)
- {
- if (wParam == 0 || g_MsgWndList[i]->hContact == (HANDLE)wParam)
- {
+ for (int i=0; i < g_MsgWndList.getCount(); ++i) {
+ if (wParam == 0 || g_MsgWndList[i]->hContact == (HANDLE)wParam) {
SendMessage(g_MsgWndList[i]->hwnd, WM_SETREDRAW, FALSE, 0);
SendMessage(g_MsgWndList[i]->hwnd, DM_OPTIONSAPPLIED, 0, 0);
SendMessage(g_MsgWndList[i]->hwnd, WM_SETREDRAW, TRUE, 0);
@@ -541,7 +539,7 @@ void RemoveDialogBoxHook(void)
if (g_hMessageHookPre) UnhookWindowsHookEx(g_hMessageHookPre);
WaitForSingleObject(g_hMutex, 2000);
- for (int i=0; i<g_MsgWndList.getCount(); ++i)
+ for (int i=0; i<g_MsgWndList.getCount(); i++)
delete g_MsgWndList[i];
g_MsgWndList.destroy();
ReleaseMutex(g_hMutex);
diff --git a/plugins/SmileyAdd/src/download.cpp b/plugins/SmileyAdd/src/download.cpp
index c0eed54ec6..95e4564030 100644
--- a/plugins/SmileyAdd/src/download.cpp
+++ b/plugins/SmileyAdd/src/download.cpp
@@ -140,11 +140,9 @@ void __cdecl SmileyDownloadThread(void*)
bool needext = false;
HANDLE hHttpDwnl = NULL;
WaitForSingleObject(g_hDlMutex, 3000);
- while (!Miranda_Terminated() && dlQueue.getCount())
- {
+ while (!Miranda_Terminated() && dlQueue.getCount()) {
ReleaseMutex(g_hDlMutex);
- if (_taccess(dlQueue[0].fname.c_str(), 0) != 0)
- {
+ if (_taccess(dlQueue[0].fname.c_str(), 0) != 0) {
InternetDownloadFile(T2A_SM(dlQueue[0].url.c_str()), T2A_SM(dlQueue[0].fname.c_str()), hHttpDwnl);
WaitForSingleObject(g_hDlMutex, 3000);
@@ -152,8 +150,7 @@ void __cdecl SmileyDownloadThread(void*)
if (dlQueue[0].needext) { fname += GetImageExt(fname); needext = true; }
_trename(dlQueue[0].fname.c_str(), fname.c_str());
}
- else
- WaitForSingleObject(g_hDlMutex, 3000);
+ else WaitForSingleObject(g_hDlMutex, 3000);
dlQueue.remove(0);
}
diff --git a/plugins/SmileyAdd/src/imagecache.cpp b/plugins/SmileyAdd/src/imagecache.cpp
index 16d01d1f7e..28de0704b8 100644
--- a/plugins/SmileyAdd/src/imagecache.cpp
+++ b/plugins/SmileyAdd/src/imagecache.cpp
@@ -42,14 +42,12 @@ static void CALLBACK timerProc(HWND, UINT, UINT_PTR, DWORD)
lastdllname.clear();
}
- for (int i=g_imagecache.getCount(); i--; )
+ for (int i=g_imagecache.getCount()-1; i >= 0; i--)
g_imagecache[i].ProcessTimerTick(ts);
- if (g_imagecache.getCount() == 0)
- {
+ if (g_imagecache.getCount() == 0) {
g_imagecache.destroy();
- if (timerId && (timerId+1) && lastmodule == NULL)
- {
+ if (timerId && (timerId+1) && lastmodule == NULL) {
KillTimer(NULL, timerId);
timerId = 0;
}
diff --git a/plugins/SmileyAdd/src/options.cpp b/plugins/SmileyAdd/src/options.cpp
index ed0f0222d5..e6915189e6 100644
--- a/plugins/SmileyAdd/src/options.cpp
+++ b/plugins/SmileyAdd/src/options.cpp
@@ -363,25 +363,19 @@ void OptionsDialogType::PopulateSmPackList(void)
tvi.item.stateMask = TVIS_STATEIMAGEMASK | TVIS_SELECTED;
SmileyCategoryListType::SmileyCategoryVectorType& smc = *tmpsmcat.GetSmileyCategoryList();
- for (int i = 0; i < smc.getCount(); i++)
- {
- if (!useOne || !smc[i].IsProto())
- {
+ for (int i=0; i < smc.getCount(); i++) {
+ if (!useOne || !smc[i].IsProto()) {
tvi.item.pszText = (TCHAR*)smc[i].GetDisplayName().c_str();
- if (!smc[i].IsProto())
- {
+ if (!smc[i].IsProto()) {
tvi.item.iImage = 0;
tvi.item.iSelectedImage = 0;
}
- else
- {
+ else {
tvi.item.iImage = i;
tvi.item.iSelectedImage = i;
}
tvi.item.lParam = i;
- tvi.item.state =
- INDEXTOSTATEIMAGEMASK(smPack.LoadSmileyFile(smc[i].GetFilename(), true, true) ? 2 : 1);
-
+ tvi.item.state = INDEXTOSTATEIMAGEMASK(smPack.LoadSmileyFile(smc[i].GetFilename(), true, true) ? 2 : 1);
TreeView_InsertItem(hLstView, &tvi);
smPack.Clear();
@@ -435,17 +429,12 @@ void OptionsDialogType::InitDialog(void)
tmpsmcat = g_SmileyCategories;
SmileyCategoryListType::SmileyCategoryVectorType& smc = *g_SmileyCategories.GetSmileyCategoryList();
- for (int i = 0; i < smc.getCount(); i++)
- {
+ for (int i=0; i < smc.getCount(); i++) {
HICON hIcon = NULL;
- if (smc[i].IsProto())
- {
- hIcon=(HICON)CallProtoService(T2A_SM(smc[i].GetName().c_str()), PS_LOADICON,
- PLI_PROTOCOL | PLIF_SMALL, 0);
+ if (smc[i].IsProto()) {
+ hIcon = (HICON)CallProtoService(T2A_SM(smc[i].GetName().c_str()), PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0);
if (hIcon == NULL || (INT_PTR)hIcon == CALLSERVICE_NOTFOUND)
- {
- hIcon=(HICON)CallProtoService(T2A_SM(smc[i].GetName().c_str()), PS_LOADICON, PLI_PROTOCOL, 0);
- }
+ hIcon = (HICON)CallProtoService(T2A_SM(smc[i].GetName().c_str()), PS_LOADICON, PLI_PROTOCOL, 0);
}
if (hIcon == NULL || hIcon == (HICON)CALLSERVICE_NOTFOUND)
hIcon = GetDefaultIcon();
@@ -496,10 +485,8 @@ void OptionsDialogType::ApplyChanges(void)
// Cleanup database
SmileyCategoryListType::SmileyCategoryVectorType& smc = *g_SmileyCategories.GetSmileyCategoryList();
- for (int i = 0; i < smc.getCount(); i++)
- {
- if (tmpsmcat.GetSmileyCategory(smc[i].GetName()) == NULL)
- {
+ for (int i=0; i < smc.getCount(); i++) {
+ if (tmpsmcat.GetSmileyCategory(smc[i].GetName()) == NULL) {
bkstring empty;
opt.WritePackFileName(empty, smc[i].GetName());
}
@@ -526,11 +513,8 @@ bool OptionsDialogType::BrowseForSmileyPacks(int item)
bkstring inidir;
SmileyCategoryType* smc = tmpsmcat.GetSmileyCategory(item);
if (smc->GetFilename().empty())
- {
pathToAbsolute(_T("Smileys"), inidir);
- }
- else
- {
+ else {
pathToAbsolute(smc->GetFilename(), inidir);
inidir.erase(inidir.find_last_of('\\'));
}
@@ -557,8 +541,7 @@ bool OptionsDialogType::BrowseForSmileyPacks(int item)
OFN_EXPLORER | OFN_LONGNAMES | OFN_NOCHANGEDIR;
ofn.lpstrDefExt = _T("msl");
- if (GetOpenFileName(&ofn))
- {
+ if (GetOpenFileName(&ofn)) {
bkstring relpath;
pathToRelative(filename, relpath);
smc->SetFilename(relpath);
@@ -575,8 +558,7 @@ void OptionsDialogType::FilenameChanged(void)
GetDlgItemText(m_hwndDialog, IDC_FILENAME, str, SIZEOF(str));
SmileyCategoryType* smc = tmpsmcat.GetSmileyCategory(GetSelProto());
- if (smc->GetFilename() != str)
- {
+ if (smc->GetFilename() != str) {
bkstring temp(str);
smc->SetFilename(temp);
UpdateControls();
@@ -602,70 +584,63 @@ void OptionsDialogType::ShowSmileyPreview(void)
mir_forkthread(SmileyToolThread, stwp);
}
-
void OptionsType::Save(void)
{
- DBWriteContactSettingByte(NULL, "SmileyAdd", "PluginSupportEnabled", PluginSupportEnabled);
- DBWriteContactSettingByte(NULL, "SmileyAdd", "EnforceSpaces", EnforceSpaces);
- DBWriteContactSettingByte(NULL, "SmileyAdd", "ScaleToTextheight", ScaleToTextheight);
- DBWriteContactSettingByte(NULL, "SmileyAdd", "UseOneForAll", UseOneForAll);
- DBWriteContactSettingByte(NULL, "SmileyAdd", "SurroundSmileyWithSpaces", SurroundSmileyWithSpaces);
- DBWriteContactSettingByte(NULL, "SmileyAdd", "ScaleAllSmileys", ScaleAllSmileys);
- DBWriteContactSettingByte(NULL, "SmileyAdd", "IEViewStyle", IEViewStyle);
- DBWriteContactSettingByte(NULL, "SmileyAdd", "AnimateSel", AnimateSel);
- DBWriteContactSettingByte(NULL, "SmileyAdd", "AnimateDlg", AnimateDlg);
- DBWriteContactSettingByte(NULL, "SmileyAdd", "InputSmileys", InputSmileys);
- DBWriteContactSettingByte(NULL, "SmileyAdd", "DCursorSmiley", DCursorSmiley);
- DBWriteContactSettingByte(NULL, "SmileyAdd", "DisableCustom", DisableCustom);
- DBWriteContactSettingByte(NULL, "SmileyAdd", "HQScaling", HQScaling);
- DBWriteContactSettingByte(NULL, "SmileyAdd", "ButtonStatus", (BYTE)ButtonStatus);
- DBWriteContactSettingDword(NULL, "SmileyAdd", "SelWndBkgClr", SelWndBkgClr);
- DBWriteContactSettingDword(NULL, "SmileyAdd", "MaxCustomSmileySize", MaxCustomSmileySize);
- DBWriteContactSettingDword(NULL, "SmileyAdd", "MinSmileySize", MinSmileySize);
+ db_set_b(NULL, "SmileyAdd", "PluginSupportEnabled", PluginSupportEnabled);
+ db_set_b(NULL, "SmileyAdd", "EnforceSpaces", EnforceSpaces);
+ db_set_b(NULL, "SmileyAdd", "ScaleToTextheight", ScaleToTextheight);
+ db_set_b(NULL, "SmileyAdd", "UseOneForAll", UseOneForAll);
+ db_set_b(NULL, "SmileyAdd", "SurroundSmileyWithSpaces", SurroundSmileyWithSpaces);
+ db_set_b(NULL, "SmileyAdd", "ScaleAllSmileys", ScaleAllSmileys);
+ db_set_b(NULL, "SmileyAdd", "IEViewStyle", IEViewStyle);
+ db_set_b(NULL, "SmileyAdd", "AnimateSel", AnimateSel);
+ db_set_b(NULL, "SmileyAdd", "AnimateDlg", AnimateDlg);
+ db_set_b(NULL, "SmileyAdd", "InputSmileys", InputSmileys);
+ db_set_b(NULL, "SmileyAdd", "DCursorSmiley", DCursorSmiley);
+ db_set_b(NULL, "SmileyAdd", "DisableCustom", DisableCustom);
+ db_set_b(NULL, "SmileyAdd", "HQScaling", HQScaling);
+ db_set_b(NULL, "SmileyAdd", "ButtonStatus", (BYTE)ButtonStatus);
+ db_set_dw(NULL, "SmileyAdd", "SelWndBkgClr", SelWndBkgClr);
+ db_set_dw(NULL, "SmileyAdd", "MaxCustomSmileySize", MaxCustomSmileySize);
+ db_set_dw(NULL, "SmileyAdd", "MinSmileySize", MinSmileySize);
}
-
void OptionsType::Load(void)
{
- PluginSupportEnabled = DBGetContactSettingByte(NULL, "SmileyAdd", "PluginSupportEnabled", TRUE) != 0;
- EnforceSpaces = DBGetContactSettingByte(NULL, "SmileyAdd", "EnforceSpaces", FALSE) != 0;
- ScaleToTextheight = DBGetContactSettingByte(NULL, "SmileyAdd", "ScaleToTextheight", FALSE) != 0;
- UseOneForAll = DBGetContactSettingByte(NULL, "SmileyAdd", "UseOneForAll", TRUE) != 0;
+ PluginSupportEnabled = db_get_b(NULL, "SmileyAdd", "PluginSupportEnabled", TRUE) != 0;
+ EnforceSpaces = db_get_b(NULL, "SmileyAdd", "EnforceSpaces", FALSE) != 0;
+ ScaleToTextheight = db_get_b(NULL, "SmileyAdd", "ScaleToTextheight", FALSE) != 0;
+ UseOneForAll = db_get_b(NULL, "SmileyAdd", "UseOneForAll", TRUE) != 0;
SurroundSmileyWithSpaces =
- DBGetContactSettingByte(NULL, "SmileyAdd", "SurroundSmileyWithSpaces", FALSE) != 0;
- ScaleAllSmileys = DBGetContactSettingByte(NULL, "SmileyAdd", "ScaleAllSmileys", FALSE) != 0;
- IEViewStyle = DBGetContactSettingByte(NULL, "SmileyAdd", "IEViewStyle", FALSE) != 0;
- AnimateSel = DBGetContactSettingByte(NULL, "SmileyAdd", "AnimateSel", TRUE) != 0;
- AnimateDlg = DBGetContactSettingByte(NULL, "SmileyAdd", "AnimateDlg", TRUE) != 0;
- InputSmileys = DBGetContactSettingByte(NULL, "SmileyAdd", "InputSmileys", TRUE) != 0;
- DCursorSmiley = DBGetContactSettingByte(NULL, "SmileyAdd", "DCursorSmiley", FALSE) != 0;
- DisableCustom = DBGetContactSettingByte(NULL, "SmileyAdd", "DisableCustom", FALSE) != 0;
- HQScaling = DBGetContactSettingByte(NULL, "SmileyAdd", "HQScaling", FALSE) != 0;
-
- ButtonStatus = DBGetContactSettingByte(NULL, "SmileyAdd", "ButtonStatus", 1);
- SelWndBkgClr = DBGetContactSettingDword(NULL, "SmileyAdd", "SelWndBkgClr", GetSysColor(COLOR_WINDOW));
- MaxCustomSmileySize = DBGetContactSettingDword(NULL, "SmileyAdd", "MaxCustomSmileySize", 0);
- MinSmileySize = DBGetContactSettingDword(NULL, "SmileyAdd", "MinSmileySize", 0);
+ db_get_b(NULL, "SmileyAdd", "SurroundSmileyWithSpaces", FALSE) != 0;
+ ScaleAllSmileys = db_get_b(NULL, "SmileyAdd", "ScaleAllSmileys", FALSE) != 0;
+ IEViewStyle = db_get_b(NULL, "SmileyAdd", "IEViewStyle", FALSE) != 0;
+ AnimateSel = db_get_b(NULL, "SmileyAdd", "AnimateSel", TRUE) != 0;
+ AnimateDlg = db_get_b(NULL, "SmileyAdd", "AnimateDlg", TRUE) != 0;
+ InputSmileys = db_get_b(NULL, "SmileyAdd", "InputSmileys", TRUE) != 0;
+ DCursorSmiley = db_get_b(NULL, "SmileyAdd", "DCursorSmiley", FALSE) != 0;
+ DisableCustom = db_get_b(NULL, "SmileyAdd", "DisableCustom", FALSE) != 0;
+ HQScaling = db_get_b(NULL, "SmileyAdd", "HQScaling", FALSE) != 0;
+
+ ButtonStatus = db_get_b(NULL, "SmileyAdd", "ButtonStatus", 1);
+ SelWndBkgClr = db_get_dw(NULL, "SmileyAdd", "SelWndBkgClr", GetSysColor(COLOR_WINDOW));
+ MaxCustomSmileySize = db_get_dw(NULL, "SmileyAdd", "MaxCustomSmileySize", 0);
+ MinSmileySize = db_get_dw(NULL, "SmileyAdd", "MinSmileySize", 0);
}
-void OptionsType::ReadPackFileName(bkstring& filename, const bkstring& name,
- const bkstring& defaultFilename)
+void OptionsType::ReadPackFileName(bkstring& filename, const bkstring& name, const bkstring& defaultFilename)
{
- DBVARIANT dbv;
bkstring settingKey = name + _T("-filename");
- INT_PTR res = DBGetContactSettingTString(NULL, "SmileyAdd", T2A_SM(settingKey.c_str()), &dbv);
- if (res == 0)
- {
+ DBVARIANT dbv;
+ if (!db_get_ts(NULL, "SmileyAdd", T2A_SM(settingKey.c_str()), &dbv)) {
filename = dbv.ptszVal;
- DBFreeVariant(&dbv);
+ db_free(&dbv);
}
- else
- filename = defaultFilename;
+ else filename = defaultFilename;
}
-
void OptionsType::WritePackFileName(const bkstring& filename, const bkstring& name)
{
bkstring settingKey = name + _T("-filename");
@@ -678,11 +653,11 @@ void OptionsType::ReadCustomCategories(bkstring& cats)
{
DBVARIANT dbv;
- INT_PTR res = DBGetContactSettingTString(NULL, "SmileyAdd", "CustomCategories", &dbv);
+ INT_PTR res = db_get_ts(NULL, "SmileyAdd", "CustomCategories", &dbv);
if (res == 0)
{
cats = dbv.ptszVal;
- DBFreeVariant(&dbv);
+ db_free(&dbv);
}
}
@@ -700,11 +675,11 @@ void OptionsType::ReadContactCategory(HANDLE hContact, bkstring& cats)
{
DBVARIANT dbv;
- INT_PTR res = DBGetContactSettingTString(hContact, "SmileyAdd", "CustomCategory", &dbv);
+ INT_PTR res = db_get_ts(hContact, "SmileyAdd", "CustomCategory", &dbv);
if (res == 0)
{
cats = dbv.ptszVal;
- DBFreeVariant(&dbv);
+ db_free(&dbv);
}
}
diff --git a/plugins/SmileyAdd/src/richcall.cpp b/plugins/SmileyAdd/src/richcall.cpp
index 582a1122ae..8ddc79d4a3 100644
--- a/plugins/SmileyAdd/src/richcall.cpp
+++ b/plugins/SmileyAdd/src/richcall.cpp
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "general.h"
-typedef struct
+struct RichEditData
{
HWND hwnd;
HANDLE hContact;
@@ -26,28 +26,28 @@ typedef struct
int tipActive;
bool inputarea;
bool dontReplace;
-} RichEditData;
+};
-typedef struct
+struct RichEditOwnerData
{
HWND hwnd;
HWND hwndInput;
HWND hwndLog;
-} RichEditOwnerData;
+};
static int CompareRichEditData(const RichEditData* p1, const RichEditData* p2)
{
return (int)((INT_PTR)p1->hwnd - (INT_PTR)p2->hwnd);
}
-static LIST<RichEditData> g_RichEditList(10, CompareRichEditData);
+static LIST<RichEditData> g_RichEditList(10, CompareRichEditData);
static int CompareRichEditData(const RichEditOwnerData* p1, const RichEditOwnerData* p2)
{
return (int)((INT_PTR)p1->hwnd - (INT_PTR)p2->hwnd);
}
-static LIST<RichEditOwnerData> g_RichEditOwnerList(5, CompareRichEditData);
+static LIST<RichEditOwnerData> g_RichEditOwnerList(5, CompareRichEditData);
static void SetPosition(HWND hwnd)
{
@@ -56,16 +56,14 @@ static void SetPosition(HWND hwnd)
return;
ITextDocument* TextDocument;
- if (RichEditOle->QueryInterface(IID_ITextDocument, (void**)&TextDocument) != S_OK)
- {
+ if (RichEditOle->QueryInterface(IID_ITextDocument, (void**)&TextDocument) != S_OK) {
RichEditOle->Release();
return;
}
// retrieve text range
ITextRange* TextRange;
- if (TextDocument->Range(0, 0, &TextRange) != S_OK)
- {
+ if (TextDocument->Range(0, 0, &TextRange) != S_OK) {
TextDocument->Release();
RichEditOle->Release();
return;
@@ -73,8 +71,7 @@ static void SetPosition(HWND hwnd)
TextDocument->Release();
int objectCount = RichEditOle->GetObjectCount();
- for (int i = objectCount - 1; i >= 0; i--)
- {
+ for (int i = objectCount - 1; i >= 0; i--) {
REOBJECT reObj = {0};
reObj.cbStruct = sizeof(REOBJECT);
@@ -94,24 +91,20 @@ static void SetPosition(HWND hwnd)
POINT pt;
RECT rect;
hr = TextRange->GetPoint(tomStart | TA_BOTTOM | TA_LEFT, &pt.x, &pt.y);
- if (hr == S_OK)
- {
+ if (hr == S_OK) {
res = ScreenToClient(hwnd, &pt);
rect.bottom = pt.y;
rect.left = pt.x;
}
- else
- rect.bottom = -1;
+ else rect.bottom = -1;
hr = TextRange->GetPoint(tomStart | TA_TOP | TA_LEFT, &pt.x, &pt.y);
- if (hr == S_OK)
- {
+ if (hr == S_OK) {
res = ScreenToClient(hwnd, &pt);
rect.top = pt.y;
rect.left = pt.x;
}
- else
- rect.top = -1;
+ else rect.top = -1;
igsc->SetPosition(hwnd, &rect);
igsc->Release();
@@ -124,46 +117,37 @@ static void SetTooltip(long x, long y, HWND hwnd, RichEditData* rdt)
{
TCHAR* smltxt;
int needtip = CheckForTip(x, y, hwnd, &smltxt);
- if (needtip != rdt->tipActive)
- {
- TOOLINFO ti = {0};
- ti.cbSize = sizeof(ti);
- ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
- ti.hwnd = hwnd;
- ti.uId = (UINT_PTR)ti.hwnd;
-
- if (needtip != -1)
- {
- if (rdt->tipActive == -1)
- {
- rdt->hToolTip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, _T(""),
- TTS_NOPREFIX | WS_POPUP,
- CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
- hwnd, NULL, g_hInst, NULL);
-
- SendMessage(rdt->hToolTip, TTM_ADDTOOL, 0, (LPARAM)&ti);
- }
+ if (needtip == rdt->tipActive)
+ return;
- ti.lpszText = smltxt;
- SendMessage(rdt->hToolTip, TTM_UPDATETIPTEXT, 0, (LPARAM)&ti);
- SendMessage(rdt->hToolTip, TTM_ACTIVATE, TRUE, 0);
- }
- else
- {
- if (rdt->tipActive != -1)
- {
- SendMessage(rdt->hToolTip, TTM_ACTIVATE, FALSE, 0);
- DestroyWindow(rdt->hToolTip);
- rdt->hToolTip = NULL;
- }
+ TOOLINFO ti = { sizeof(ti) };
+ ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
+ ti.hwnd = hwnd;
+ ti.uId = (UINT_PTR)ti.hwnd;
+
+ if (needtip != -1) {
+ if (rdt->tipActive == -1) {
+ rdt->hToolTip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, _T(""), TTS_NOPREFIX | WS_POPUP,
+ CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwnd, NULL, g_hInst, NULL);
+
+ SendMessage(rdt->hToolTip, TTM_ADDTOOL, 0, (LPARAM)&ti);
}
- rdt->tipActive = needtip;
+
+ ti.lpszText = smltxt;
+ SendMessage(rdt->hToolTip, TTM_UPDATETIPTEXT, 0, (LPARAM)&ti);
+ SendMessage(rdt->hToolTip, TTM_ACTIVATE, TRUE, 0);
}
+ else if (rdt->tipActive != -1) {
+ SendMessage(rdt->hToolTip, TTM_ACTIVATE, FALSE, 0);
+ DestroyWindow(rdt->hToolTip);
+ rdt->hToolTip = NULL;
+ }
+
+ rdt->tipActive = needtip;
}
static const CHARRANGE allsel = { 0, LONG_MAX };
-
static void ReplaceContactSmileys(RichEditData *rdt, const CHARRANGE &sel, bool ignoreLast, bool unFreeze)
{
if ((rdt->inputarea && !opt.InputSmileys) || rdt->dontReplace) return;
@@ -180,7 +164,8 @@ static void ReplaceContactSmileysWithText(RichEditData *rdt, CHARRANGE &sel, boo
static void SmileyToTextCutPrep(RichEditData* rdt)
{
- if ((rdt->inputarea && !opt.InputSmileys) || rdt->dontReplace) return;
+ if ((rdt->inputarea && !opt.InputSmileys) || rdt->dontReplace)
+ return;
SendMessage(rdt->hwnd, WM_SETREDRAW, FALSE, 0);
CHARRANGE sel;
@@ -190,7 +175,8 @@ static void SmileyToTextCutPrep(RichEditData* rdt)
static void SmileyToTextCutRest(RichEditData* rdt)
{
- if ((rdt->inputarea && !opt.InputSmileys) || rdt->dontReplace) return;
+ if ((rdt->inputarea && !opt.InputSmileys) || rdt->dontReplace)
+ return;
CHARRANGE sel;
SendMessage(rdt->hwnd, EM_EXGETSEL, 0, (LPARAM)&sel);
@@ -228,16 +214,10 @@ static LRESULT CALLBACK RichEditSubclass(HWND hwnd, UINT uMsg, WPARAM wParam, LP
case WM_KEYDOWN:
if ((wParam == 'C' || wParam == VK_INSERT) && (GetKeyState(VK_CONTROL) & 0x8000))
- {
SmileyToTextCutPrep(rdt);
- }
- else if ((wParam == 'X' && (GetKeyState(VK_CONTROL) & 0x8000)) ||
- (wParam == VK_DELETE && (GetKeyState(VK_SHIFT) & 0x8000)))
- {
+ else if ((wParam == 'X' && (GetKeyState(VK_CONTROL) & 0x8000)) || (wParam == VK_DELETE && (GetKeyState(VK_SHIFT) & 0x8000)))
SmileyToTextCutPrep(rdt);
- }
- else if (wParam == VK_TAB && ((GetKeyState(VK_CONTROL) | GetKeyState(VK_SHIFT)) & 0x8000) == 0)
- {
+ else if (wParam == VK_TAB && ((GetKeyState(VK_CONTROL) | GetKeyState(VK_SHIFT)) & 0x8000) == 0) {
SendMessage(hwnd, EM_EXGETSEL, 0, (LPARAM)&sel);
sel.cpMin = max(sel.cpMin - 20, 0);
@@ -455,8 +435,8 @@ void CloseRichOwnerCallback(HWND hwnd)
RichEditOwnerData* rdto = g_RichEditOwnerList[ind];
CloseRichCallback(rdto->hwndInput);
CloseRichCallback(rdto->hwndLog);
-
delete rdto;
+
g_RichEditOwnerList.remove(ind);
mir_unsubclassWindow(hwnd, RichEditOwnerSubclass);
@@ -464,7 +444,7 @@ void CloseRichOwnerCallback(HWND hwnd)
void ProcessAllInputAreas(bool restoreText)
{
- for (int i=g_RichEditList.getCount(); i--; ) {
+ for (int i=g_RichEditList.getCount()-1; i >= 0; i--) {
RichEditData* rdt = g_RichEditList[i];
if (rdt->inputarea) {
if (restoreText) {
@@ -479,11 +459,11 @@ void ProcessAllInputAreas(bool restoreText)
void RichEditData_Destroy(void)
{
int i;
- for (i=g_RichEditList.getCount(); i--; )
+ for (i=g_RichEditList.getCount()-1; i >= 0; i--)
CloseRichCallback(g_RichEditList[i]->hwnd);
g_RichEditList.destroy();
- for (i=g_RichEditOwnerList.getCount(); i--; )
+ for (i=g_RichEditOwnerList.getCount()-1; i >= 0; i--)
CloseRichOwnerCallback(g_RichEditOwnerList[i]->hwnd);
g_RichEditOwnerList.destroy();
}
diff --git a/plugins/SmileyAdd/src/services.cpp b/plugins/SmileyAdd/src/services.cpp
index ecf3339f51..64b8c71d06 100644
--- a/plugins/SmileyAdd/src/services.cpp
+++ b/plugins/SmileyAdd/src/services.cpp
@@ -49,10 +49,10 @@ SmileyPackType* GetSmileyPack(const char* proto, HANDLE hContact, SmileyPackCTyp
if (protonam != NULL)
{
DBVARIANT dbv;
- if (DBGetContactSettingTString(hContact, protonam, "Transport", &dbv) == 0)
+ if (db_get_ts(hContact, protonam, "Transport", &dbv) == 0)
{
categoryName = dbv.ptszVal;
- DBFreeVariant(&dbv);
+ db_free(&dbv);
}
else
categoryName = A2T_SM(protonam);
@@ -306,23 +306,21 @@ INT_PTR ParseTextBatch(WPARAM, LPARAM lParam)
else
LookupAllSmileys(SmileyPack, smcp, A2T_SM(smre->astr), smllist, false);
- if (smllist.getCount() == 0) return 0;
+ if (smllist.getCount() == 0)
+ return 0;
SMADD_BATCHPARSERES *res = new SMADD_BATCHPARSERES[smllist.getCount()];
SMADD_BATCHPARSERES* cres = res;
- for (int j = 0; j < smllist.getCount(); j++)
- {
+ for (int j=0; j < smllist.getCount(); j++) {
cres->startChar = smllist[j].loc.cpMin;
cres->size = smllist[j].loc.cpMax - smllist[j].loc.cpMin;
- if (smllist[j].sml)
- {
+ if (smllist[j].sml) {
if (smre->flag & SAFL_PATH)
cres->filepath = smllist[j].sml->GetFilePath().c_str();
else
cres->hIcon = smllist[j].sml->GetIconDup();
}
- else
- {
+ else {
if (smre->flag & SAFL_PATH)
cres->filepath = smllist[j].smlc->GetFilePath().c_str();
else
@@ -384,7 +382,7 @@ INT_PTR CustomCatMenu(WPARAM wParam, LPARAM lParam)
NotifyEventHooks(hEvent1, (WPARAM)hContact, 0);
}
- for (int i = 0; i < menuHandleArray.getCount(); i++)
+ for (int i=0; i < menuHandleArray.getCount(); i++)
CallService(MS_CLIST_REMOVECONTACTMENUITEM, (WPARAM)menuHandleArray[i], 0);
menuHandleArray.destroy();
@@ -403,7 +401,7 @@ int RebuildContactMenu(WPARAM wParam, LPARAM)
bool haveMenu = IsSmileyProto(protnam);
if (haveMenu && opt.UseOneForAll) {
unsigned cnt = 0;
- for (int i=0; i < smc.getCount(); ++i)
+ for (int i=0; i < smc.getCount(); i++)
cnt += smc[i].IsCustom();
haveMenu = cnt != 0;
}
@@ -412,7 +410,7 @@ int RebuildContactMenu(WPARAM wParam, LPARAM)
CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hContactMenuItem, (LPARAM)&mi);
- for (int i = 0; i < menuHandleArray.getCount(); ++i)
+ for (int i=0; i < menuHandleArray.getCount(); i++)
CallService(MS_CLIST_REMOVECONTACTMENUITEM, (WPARAM)menuHandleArray[i], 0);
menuHandleArray.destroy();
diff --git a/plugins/SmileyAdd/src/smileyroutines.cpp b/plugins/SmileyAdd/src/smileyroutines.cpp
index 63440e4a83..651c34b0c3 100644
--- a/plugins/SmileyAdd/src/smileyroutines.cpp
+++ b/plugins/SmileyAdd/src/smileyroutines.cpp
@@ -52,45 +52,34 @@ void LookupAllSmileys(SmileyPackType* smileyPack, SmileyPackCType* smileyCPack,
int i = 0;
if (sml)
- {
- for (int j=0; j<sml->getCount(); j++)
- {
+ for (int j=0; j < sml->getCount(); j++) {
(*sml)[j].find(tmpstr, smileys[i], false);
i++;
}
- }
if (smlc)
- {
- for (int j=0; j<smlc->getCount(); j++)
- {
+ for (int j=0; j < smlc->getCount(); j++) {
(*smlc)[j].find(tmpstr, smileys[i], false);
i++;
}
- }
- int* csmlit = (int*)alloca(smlsz * sizeof(int));
- if (csmlit == NULL) return;
+ int *csmlit = (int*)alloca(smlsz * sizeof(int));
memset(csmlit, 0, smlsz * sizeof(int));
long numCharsSoFar = 0;
bkstring::size_type smloff = 0;
- for (;;)
- {
+ while (true) {
int firstSml = -1;
int firstSmlRef = -1;
SmileyLookup::SmileyLocVecType* smlf = NULL;
- for (int csml=0; csml<smlsz; csml++)
- {
+ for (int csml=0; csml < smlsz; csml++) {
SmileyLookup::SmileyLocVecType& smlv = smileys[csml];
int tsml;
- for (tsml = csmlit[csml]; tsml < smlv.getCount(); tsml++)
- {
- if (smlv[tsml].pos >= smloff)
- {
+ for (tsml = csmlit[csml]; tsml < smlv.getCount(); tsml++) {
+ if (smlv[tsml].pos >= smloff) {
if (firstSmlRef == -1 || smlv[tsml].pos < (*smlf)[firstSmlRef].pos ||
(smlv[tsml].pos == (*smlf)[firstSmlRef].pos && smlv[tsml].len > (*smlf)[firstSmlRef].len))
{
@@ -104,61 +93,52 @@ void LookupAllSmileys(SmileyPackType* smileyPack, SmileyPackCType* smileyCPack,
csmlit[csml] = tsml;
}
- // Check if smiley found
- if (firstSml != -1)
- {
- ReplaceSmileyType *dat = new ReplaceSmileyType;
+ // // Nothing to parse, exiting
+ if (firstSml == -1)
+ break;
- const TCHAR* textToSearch = lpstrText + smloff;
- const TCHAR* textSmlStart = lpstrText + (*smlf)[firstSmlRef].pos;
- const TCHAR* textSmlEnd = textSmlStart + (*smlf)[firstSmlRef].len;
+ ReplaceSmileyType *dat = new ReplaceSmileyType;
- // check if leading space exist
- const TCHAR* prech = _tcsdec(textToSearch, textSmlStart);
- dat->ldspace = prech != NULL ? _istspace(*prech) != 0 : smloff == 0;
+ const TCHAR* textToSearch = lpstrText + smloff;
+ const TCHAR* textSmlStart = lpstrText + (*smlf)[firstSmlRef].pos;
+ const TCHAR* textSmlEnd = textSmlStart + (*smlf)[firstSmlRef].len;
- // check if trailing space exist
- dat->trspace = *textSmlEnd == 0 || _istspace(*textSmlEnd);
+ // check if leading space exist
+ const TCHAR* prech = _tcsdec(textToSearch, textSmlStart);
+ dat->ldspace = prech != NULL ? _istspace(*prech) != 0 : smloff == 0;
- // compute text location in RichEdit
- dat->loc.cpMin = (long)_tcsnccnt(textToSearch, (*smlf)[firstSmlRef].pos - smloff) + numCharsSoFar;
- dat->loc.cpMax = numCharsSoFar = (long)_tcsnccnt(textSmlStart, (*smlf)[firstSmlRef].len) + dat->loc.cpMin;
+ // check if trailing space exist
+ dat->trspace = *textSmlEnd == 0 || _istspace(*textSmlEnd);
- if (!opt.EnforceSpaces || (dat->ldspace && dat->trspace))
- {
- dat->ldspace |= !opt.SurroundSmileyWithSpaces;
- dat->trspace |= !opt.SurroundSmileyWithSpaces;
+ // compute text location in RichEdit
+ dat->loc.cpMin = (long)_tcsnccnt(textToSearch, (*smlf)[firstSmlRef].pos - smloff) + numCharsSoFar;
+ dat->loc.cpMax = numCharsSoFar = (long)_tcsnccnt(textSmlStart, (*smlf)[firstSmlRef].len) + dat->loc.cpMin;
- if (firstSml < smlszo)
- {
- dat->sml = smileyPack->GetSmiley((*sml)[firstSml].GetIndex());
- dat->smlc = NULL;
- }
- else
- {
- dat->smlc = smileyCPack->GetSmiley((*smlc)[firstSml-smlszo].GetIndex());
- dat->sml = NULL;
- }
+ if (!opt.EnforceSpaces || (dat->ldspace && dat->trspace)) {
+ dat->ldspace |= !opt.SurroundSmileyWithSpaces;
+ dat->trspace |= !opt.SurroundSmileyWithSpaces;
- if (dat->sml != NULL || dat->smlc != NULL)
- {
- // First smiley found record it
- smllist.insert(dat);
- if (firstOnly) break;
- }
- else
- delete dat;
+ if (firstSml < smlszo) {
+ dat->sml = smileyPack->GetSmiley((*sml)[firstSml].GetIndex());
+ dat->smlc = NULL;
+ }
+ else {
+ dat->smlc = smileyCPack->GetSmiley((*smlc)[firstSml-smlszo].GetIndex());
+ dat->sml = NULL;
}
- else
- delete dat;
- // Advance string pointer to search for the next smiley
- smloff = (*smlf)[firstSmlRef].pos + (*smlf)[firstSmlRef].len;
- csmlit[firstSml]++;
+ if (dat->sml != NULL || dat->smlc != NULL) {
+ // First smiley found record it
+ smllist.insert(dat);
+ if (firstOnly) break;
+ }
+ else delete dat;
}
- else
- // Nothing to parse exit
- break;
+ else delete dat;
+
+ // Advance string pointer to search for the next smiley
+ smloff = (*smlf)[firstSmlRef].pos + (*smlf)[firstSmlRef].len;
+ csmlit[firstSml]++;
}
delete[] smileys;
}
@@ -169,13 +149,11 @@ void FindSmileyInText(SmileyPackType* smp, const TCHAR* str,
{
SmileysQueueType smllist;
LookupAllSmileys(smp, NULL, str, smllist, true);
- if (smllist.getCount() == 0)
- {
+ if (smllist.getCount() == 0) {
size = 0;
*sml = NULL;
}
- else
- {
+ else {
first = smllist[0].loc.cpMin;
size = smllist[0].loc.cpMax - smllist[0].loc.cpMin;
*sml = smllist[0].sml;
@@ -187,24 +165,19 @@ SmileyType* FindButtonSmiley(SmileyPackType* smp)
{
unsigned start, size;
SmileyType* sml;
-
FindSmileyInText(smp, smp->GetButtonSmiley(), start, size, &sml);
-
return sml;
}
void UpdateSelection(CHARRANGE& sel, int pos, int dif)
{
- if (sel.cpMax == sel.cpMin)
- {
- if (sel.cpMax < LONG_MAX && sel.cpMax > pos)
- {
+ if (sel.cpMax == sel.cpMin) {
+ if (sel.cpMax < LONG_MAX && sel.cpMax > pos) {
sel.cpMax += dif;
sel.cpMin += dif;
}
}
- else
- {
+ else {
if (sel.cpMax >= pos && sel.cpMax < LONG_MAX) sel.cpMax += dif;
if (sel.cpMin > pos) sel.cpMin += dif;
}
@@ -220,15 +193,13 @@ void ReplaceSmileys(HWND hwnd, SmileyPackType* smp, SmileyPackCType* smcp, const
return;
ITextDocument* TextDocument;
- if (RichEditOle->QueryInterface(IID_ITextDocument, (void**)&TextDocument) != S_OK)
- {
+ if (RichEditOle->QueryInterface(IID_ITextDocument, (void**)&TextDocument) != S_OK) {
RichEditOle->Release();
return;
}
long cnt;
- if (smp == NULL && smcp == NULL)
- {
+ if (smp == NULL && smcp == NULL) {
if (unFreeze) TextDocument->Unfreeze(&cnt);
TextDocument->Release();
RichEditOle->Release();
@@ -237,8 +208,7 @@ void ReplaceSmileys(HWND hwnd, SmileyPackType* smp, SmileyPackCType* smcp, const
// retrieve text range
ITextRange* TextRange;
- if (TextDocument->Range(sel.cpMin, sel.cpMax, &TextRange) != S_OK)
- {
+ if (TextDocument->Range(sel.cpMin, sel.cpMax, &TextRange) != S_OK) {
TextDocument->Release();
RichEditOle->Release();
return;
@@ -246,8 +216,7 @@ void ReplaceSmileys(HWND hwnd, SmileyPackType* smp, SmileyPackCType* smcp, const
// retrieve text to parse for smileys
BSTR btxt = 0;
- if (TextRange->GetText(&btxt) != S_OK)
- {
+ if (TextRange->GetText(&btxt) != S_OK) {
TextRange->Release();
TextDocument->Release();
RichEditOle->Release();
@@ -257,14 +226,11 @@ void ReplaceSmileys(HWND hwnd, SmileyPackType* smp, SmileyPackCType* smcp, const
TextRange->Release();
SmileysQueueType smllist;
-
-
LookupAllSmileys(smp, smcp, W2T_SM(btxt), smllist, false);
SysFreeString(btxt);
- if (smllist.getCount() != 0)
- {
+ if (smllist.getCount() != 0) {
// disable screen updates
TextDocument->Freeze(&cnt);
@@ -296,15 +262,11 @@ void ReplaceSmileys(HWND hwnd, SmileyPackType* smp, SmileyPackCType* smcp, const
// Determine background color
// This logic trying to minimize number of background color changes
static COLORREF bkgColor = GetSysColor(COLOR_WINDOW);
-// if (!insemf)
-// {
- COLORREF bkgColorPv = (COLORREF)SendMessage(hwnd, EM_SETBKGNDCOLOR, 0, bkgColor);
- if (bkgColorPv != bkgColor)
- {
- bkgColor = bkgColorPv;
- SendMessage(hwnd, EM_SETBKGNDCOLOR, 0, bkgColor);
- }
-// }
+ COLORREF bkgColorPv = (COLORREF)SendMessage(hwnd, EM_SETBKGNDCOLOR, 0, bkgColor);
+ if (bkgColorPv != bkgColor) {
+ bkgColor = bkgColorPv;
+ SendMessage(hwnd, EM_SETBKGNDCOLOR, 0, bkgColor);
+ }
HDC hdc = GetDC(hwnd);
int sclX = GetDeviceCaps(hdc, LOGPIXELSX);
@@ -315,20 +277,18 @@ void ReplaceSmileys(HWND hwnd, SmileyPackType* smp, SmileyPackCType* smcp, const
BSTR spaceb = SysAllocString(_T(" "));
// Replace smileys specified in the list in RichEdit
- for (int j = smllist.getCount(); j--; )
- {
+ for (int j = smllist.getCount()-1; j >= 0; j--) {
CHARRANGE& smlpos = smllist[j].loc;
- if (ignoreLast && oldSel.cpMax == smlpos.cpMax) continue;
+ if (ignoreLast && oldSel.cpMax == smlpos.cpMax)
+ continue;
smlpos.cpMin += sel.cpMin;
smlpos.cpMax += sel.cpMin;
// Find all back to back smileys and for propper hidden text detection
- if ( numBTBSm == 0 )
- {
+ if (numBTBSm == 0) {
CHARRANGE lastPos = smlpos;
- for (int jn = j; jn--; )
- {
+ for (int jn = j; jn--; ) {
if (jn != j && smllist[jn].loc.cpMax != lastPos.cpMin)
break;
@@ -340,8 +300,7 @@ void ReplaceSmileys(HWND hwnd, SmileyPackType* smp, SmileyPackCType* smcp, const
TextFont->GetHidden(&hid);
if (hid == tomFalse) numBTBSm = 0;
}
- if ( numBTBSm != 0 )
- {
+ if (numBTBSm != 0) {
--numBTBSm;
continue;
}
@@ -355,20 +314,19 @@ void ReplaceSmileys(HWND hwnd, SmileyPackType* smp, SmileyPackCType* smcp, const
BSTR btxt = NULL;
- if (smlc == NULL && sml->IsText())
- {
+ if (smlc == NULL && sml->IsText()) {
btxt = SysAllocString(T2W_SM(sml->GetToolText().c_str()));
TextSelection->SetText(btxt);
}
- else
- {
+ else {
TextSelection->GetText(&btxt);
// Get font properties
SendMessage(hwnd, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&chf);
//do not look for smileys in hyperlinks
- if ((chf.dwEffects & (CFE_LINK | CFE_HIDDEN)) != 0) continue;
+ if ((chf.dwEffects & (CFE_LINK | CFE_HIDDEN)) != 0)
+ continue;
SIZE osize;
if (sml)
@@ -376,11 +334,11 @@ void ReplaceSmileys(HWND hwnd, SmileyPackType* smp, SmileyPackCType* smcp, const
else
smlc->GetSize(osize);
- if (osize.cx == 0 || osize.cy == 0) continue;
+ if (osize.cx == 0 || osize.cy == 0)
+ continue;
int sizeX, sizeY;
- if (opt.ScaleToTextheight)
- {
+ if (opt.ScaleToTextheight) {
sizeY = CalculateTextHeight(hdc, &chf);
sizeX = osize.cx * sizeY / osize.cy;
@@ -390,14 +348,12 @@ void ReplaceSmileys(HWND hwnd, SmileyPackType* smp, SmileyPackCType* smcp, const
int dy = osize.cy - sizeY;
sizeY += dy & 1;
}
- else
- {
+ else {
sizeX = osize.cx;
sizeY = osize.cy;
}
- if (smlc != NULL && opt.MaxCustomSmileySize && (unsigned)sizeY > opt.MaxCustomSmileySize)
- {
+ if (smlc != NULL && opt.MaxCustomSmileySize && (unsigned)sizeY > opt.MaxCustomSmileySize) {
sizeY = opt.MaxCustomSmileySize;
sizeX = osize.cx * sizeY / osize.cy;
@@ -408,8 +364,7 @@ void ReplaceSmileys(HWND hwnd, SmileyPackType* smp, SmileyPackCType* smcp, const
sizeY += dy & 1;
}
- if (opt.MinSmileySize && (unsigned)sizeY < opt.MinSmileySize)
- {
+ if (opt.MinSmileySize && (unsigned)sizeY < opt.MinSmileySize) {
sizeY = opt.MinSmileySize;
sizeX = osize.cx * sizeY / osize.cy;
@@ -429,8 +384,7 @@ void ReplaceSmileys(HWND hwnd, SmileyPackType* smp, SmileyPackCType* smcp, const
if (chf.dwEffects & CFE_AUTOBACKCOLOR) chf.crBackColor = bkgColor;
// insert space after
- if (!smllist[j].trspace && useHidden)
- {
+ if (!smllist[j].trspace && useHidden) {
TextSelection->SetStart(smlpos.cpMax);
TextSelection->TypeText(spaceb);
UpdateSelection(oldSel, smlpos.cpMax , 1);
@@ -439,16 +393,12 @@ void ReplaceSmileys(HWND hwnd, SmileyPackType* smp, SmileyPackCType* smcp, const
TextSelection->SetRange(smlpos.cpMin, smlpos.cpMax);
}
- if (g_HiddenTextSupported && useHidden)
- {
+ if (g_HiddenTextSupported && useHidden) {
TextFont->SetHidden(tomTrue);
TextSelection->SetEnd(smlpos.cpMin);
UpdateSelection(oldSel, smlpos.cpMin , 1);
}
- else
- {
- UpdateSelection(oldSel, smlpos.cpMin, -(int)SysStringLen(btxt)+1);
- }
+ else UpdateSelection(oldSel, smlpos.cpMin, -(int)SysStringLen(btxt)+1);
ISmileyBase* smileyBase = CreateAniSmileyObject(smlc ? smlc : sml, chf.crBackColor, ishpp);
if (smileyBase == NULL) continue;
@@ -463,9 +413,7 @@ void ReplaceSmileys(HWND hwnd, SmileyPackType* smp, SmileyPackCType* smcp, const
RichEditOle->GetClientSite(&pOleClientSite);
// Now Add the object to the RichEdit
- REOBJECT reobject = { 0 };
-
- reobject.cbStruct = sizeof(REOBJECT);
+ REOBJECT reobject = { sizeof(REOBJECT) };
reobject.cp = REO_CP_SELECTION;
reobject.dvaspect = DVASPECT_CONTENT;
reobject.poleobj = smileyBase;
@@ -479,8 +427,7 @@ void ReplaceSmileys(HWND hwnd, SmileyPackType* smp, SmileyPackCType* smcp, const
smileyBase->Release();
// insert space before
- if (!smllist[j].ldspace && useHidden)
- {
+ if (!smllist[j].ldspace && useHidden) {
TextSelection->SetRange(smlpos.cpMin, smlpos.cpMin);
TextSelection->TypeText(spaceb);
UpdateSelection(oldSel, smlpos.cpMin , 1);
@@ -502,8 +449,7 @@ void ReplaceSmileys(HWND hwnd, SmileyPackType* smp, SmileyPackCType* smcp, const
if (cnt == 0) UpdateWindow(hwnd);
}
- if (unFreeze)
- {
+ if (unFreeze) {
TextDocument->Unfreeze(&cnt);
if (cnt == 0) UpdateWindow(hwnd);
}
@@ -521,16 +467,14 @@ void ReplaceSmileysWithText(HWND hwnd, CHARRANGE& sel, bool keepFrozen)
return;
ITextDocument* TextDocument;
- if (RichEditOle->QueryInterface(IID_ITextDocument, (void**)&TextDocument) != S_OK)
- {
+ if (RichEditOle->QueryInterface(IID_ITextDocument, (void**)&TextDocument) != S_OK) {
RichEditOle->Release();
return;
}
// retrieve text range
ITextRange* TextRange;
- if (TextDocument->Range(0, 0, &TextRange) != S_OK)
- {
+ if (TextDocument->Range(0, 0, &TextRange) != S_OK) {
TextDocument->Release();
RichEditOle->Release();
return;
@@ -546,16 +490,15 @@ void ReplaceSmileysWithText(HWND hwnd, CHARRANGE& sel, bool keepFrozen)
SendMessage(hwnd, EM_EXGETSEL, 0, (LPARAM)&oldSel);
int objectCount = RichEditOle->GetObjectCount();
- for (int i = objectCount - 1; i >= 0; i--)
- {
+ for (int i = objectCount-1; i >= 0; i--) {
REOBJECT reObj = {0};
reObj.cbStruct = sizeof(REOBJECT);
HRESULT hr = RichEditOle->GetObject(i, &reObj, REO_GETOBJ_POLEOBJ);
- if (FAILED(hr)) continue;
+ if (FAILED(hr))
+ continue;
- if (reObj.cp < sel.cpMin)
- {
+ if (reObj.cp < sel.cpMin) {
reObj.poleobj->Release();
break;
}
@@ -565,7 +508,8 @@ void ReplaceSmileysWithText(HWND hwnd, CHARRANGE& sel, bool keepFrozen)
reObj.poleobj->QueryInterface(IID_ISmileyAddSmiley, (void**) &igsc);
reObj.poleobj->Release();
- if (igsc == NULL) continue;
+ if (igsc == NULL)
+ continue;
TextRange->SetRange(reObj.cp, reObj.cp + 1);
diff --git a/plugins/SmileyAdd/src/smileys.cpp b/plugins/SmileyAdd/src/smileys.cpp
index 75df1bfadd..6b18c9cd57 100644
--- a/plugins/SmileyAdd/src/smileys.cpp
+++ b/plugins/SmileyAdd/src/smileys.cpp
@@ -210,7 +210,6 @@ 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+"));
-
{
bkstring emptystr;
m_SmileyLookup.insert(new SmileyLookup(urlRegEx, true, -1, emptystr));
@@ -218,10 +217,8 @@ void SmileyPackType::AddTriggersToSmileyLookup(void)
m_SmileyLookup.insert(new SmileyLookup(timeRegEx, true, -1, emptystr));
}
- for (int dist = 0; dist < m_SmileyList.getCount(); dist++)
- {
- if (m_SmileyList[dist].IsRegEx())
- {
+ for (int dist = 0; dist < m_SmileyList.getCount(); dist++) {
+ if (m_SmileyList[dist].IsRegEx()) {
SmileyLookup* dats = new SmileyLookup(m_SmileyList[dist].GetTriggerText(), true, dist, GetFilename());
if (dats->IsValid())
m_SmileyLookup.insert(dats);
@@ -229,24 +226,20 @@ void SmileyPackType::AddTriggersToSmileyLookup(void)
errorFound = true;
if (m_SmileyList[dist].m_InsertText.empty()) m_SmileyList[dist].m_InsertText = m_SmileyList[dist].m_ToolText;
}
- else if (!m_SmileyList[dist].IsService())
- {
+ else if (!m_SmileyList[dist].IsService()) {
bool first = true;
int li = 0;
_TMatcher * m0 = p->createTMatcher(m_SmileyList[dist].GetTriggerText());
while (m0->findNextMatch())
{
int stind = m0->getStartingIndex();
- if (li != stind)
- {
+ if (li != stind) {
bkstring out;
ReplaceAllSpecials(m0->getString().substr(li, stind - li), out);
SmileyLookup *dats = new SmileyLookup(out, false, dist, GetFilename());
- if (dats->IsValid())
- {
+ if (dats->IsValid()) {
m_SmileyLookup.insert(dats);
- if (first)
- {
+ if (first) {
m_SmileyList[dist].m_InsertText = out;
first = false;
}
@@ -256,16 +249,13 @@ void SmileyPackType::AddTriggersToSmileyLookup(void)
}
int stind = (int)m0->getString().size();
- if (li < stind)
- {
+ if (li < stind) {
bkstring out;
ReplaceAllSpecials(m0->getString().substr(li, stind - li), out);
SmileyLookup *dats = new SmileyLookup(out, false, dist, GetFilename());
- if (dats->IsValid())
- {
+ if (dats->IsValid()) {
m_SmileyLookup.insert(dats);
- if (first)
- {
+ if (first) {
m_SmileyList[dist].m_InsertText = out;
first = false;
}
@@ -277,14 +267,12 @@ void SmileyPackType::AddTriggersToSmileyLookup(void)
delete p;
}
-
void SmileyPackType::ReplaceAllSpecials(const bkstring& Input, bkstring& Output)
{
Output = _TPattern::replace(_T("%%_{1,2}%%"), Input, _T(" "));
Output = _TPattern::replace(_T("%%''%%"), Output, _T("\""));
}
-
void SmileyPackType::Clear(void)
{
m_SmileyList.destroy();
@@ -720,8 +708,7 @@ SmileyPackType* SmileyPackListType::GetSmileyPack(bkstring& filename)
bkstring modpath;
pathToAbsolute(filename, modpath);
- for (int i = 0; i < m_SmileyPacks.getCount(); i++)
- {
+ for (int i=0; i < m_SmileyPacks.getCount(); i++) {
bkstring modpath1;
pathToAbsolute(m_SmileyPacks[i].GetFilename(), modpath1);
if (lstrcmpi(modpath.c_str(), modpath1.c_str()) == 0) return &m_SmileyPacks[i];
@@ -779,17 +766,17 @@ 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 bkstring& name)
{
- for (int i = 0; i < m_SmileyCategories.getCount(); i++)
- {
- if (name.comparei(m_SmileyCategories[i].GetName()) == 0) return &m_SmileyCategories[i];
- }
+ for (int i=0; i < m_SmileyCategories.getCount(); i++)
+ if (name.comparei(m_SmileyCategories[i].GetName()) == 0)
+ return &m_SmileyCategories[i];
+
return NULL;
}
@@ -810,11 +797,9 @@ SmileyPackType* SmileyCategoryListType::GetSmileyPack(bkstring& categoryname)
void SmileyCategoryListType::SaveSettings(void)
{
bkstring 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 (m_SmileyCategories[i].IsCustom()) {
if (!catstr.empty()) catstr += '#';
catstr += m_SmileyCategories[i].GetName();
}
@@ -825,7 +810,8 @@ void SmileyCategoryListType::SaveSettings(void)
void SmileyCategoryListType::AddAndLoad(const bkstring& name, const bkstring& displayName)
{
- if (GetSmileyCategory(name) != NULL) return;
+ if (GetSmileyCategory(name) != NULL)
+ return;
AddCategory(name, displayName, smcExt);
// Load only if other smileys have been loaded already
@@ -845,14 +831,11 @@ void SmileyCategoryListType::AddCategory(const bkstring& name, const bkstring& d
bool SmileyCategoryListType::DeleteCustomCategory(int index)
{
- if (index < m_SmileyCategories.getCount())
- {
- if (m_SmileyCategories[index].IsCustom())
- {
+ if (index < m_SmileyCategories.getCount()) {
+ if (m_SmileyCategories[index].IsCustom()) {
m_SmileyCategories.remove(index);
return true;
}
-
}
return false;
}
@@ -887,27 +870,22 @@ void SmileyCategoryListType::DeleteAccountAsCategory(PROTOACCOUNT *acc)
{
bkstring tname(A2T_SM(acc->szModuleName));
- HANDLE hContact = db_find_first();
- while (hContact != NULL)
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char* proto = GetContactProto(hContact);
- if (proto)
- {
- DBVARIANT dbv;
- if (DBGetContactSettingTString(hContact, proto, "Transport", &dbv) == 0)
- {
- bool found = (tname.comparei(dbv.ptszVal) == 0);
- DBFreeVariant(&dbv);
- if (found) return;
- }
+ if (proto == NULL)
+ continue;
+
+ DBVARIANT dbv;
+ if (!db_get_ts(hContact, proto, "Transport", &dbv)) {
+ bool found = (tname.comparei(dbv.ptszVal) == 0);
+ db_free(&dbv);
+ if (found)
+ return;
}
- hContact = db_find_next(hContact);
}
- for (int i = 0; i < m_SmileyCategories.getCount(); i++)
- {
- if (tname.comparei(m_SmileyCategories[i].GetName()) == 0)
- {
+ for (int i=0; i < m_SmileyCategories.getCount(); i++) {
+ if (tname.comparei(m_SmileyCategories[i].GetName()) == 0) {
m_SmileyCategories.remove(i);
break;
}
@@ -920,11 +898,9 @@ void SmileyCategoryListType::AddContactTransportAsCategory(HANDLE hContact, cons
if (proto == NULL) return;
DBVARIANT dbv;
- if (DBGetContactSettingTString(hContact, proto, "Transport", &dbv) == 0)
- {
- if (dbv.ptszVal[0] == '\0')
- {
- DBFreeVariant(&dbv);
+ if (!db_get_ts(hContact, proto, "Transport", &dbv)) {
+ if (dbv.ptszVal[0] == '\0') {
+ db_free(&dbv);
return;
}
char* trsp = mir_strdup(T2A_SM(dbv.ptszVal));
@@ -945,8 +921,7 @@ void SmileyCategoryListType::AddContactTransportAsCategory(HANDLE hContact, cons
mir_free(trsp);
bkstring displayName = dbv.ptszVal;
- if (packname != NULL)
- {
+ if (packname != NULL) {
char path[MAX_PATH];
mir_snprintf(path, sizeof(path), "Smileys\\nova\\%s.msl", packname);
@@ -958,14 +933,12 @@ void SmileyCategoryListType::AddContactTransportAsCategory(HANDLE hContact, cons
AddCategory(displayName, displayName, smcProto, paths);
}
- else
- AddCategory(displayName, displayName, smcProto, defaultFile);
+ else AddCategory(displayName, displayName, smcProto, defaultFile);
- DBFreeVariant(&dbv);
+ db_free(&dbv);
}
}
-
void SmileyCategoryListType::AddAllProtocolsAsCategory(void)
{
bkstring displayName = TranslateT("Standard");
diff --git a/plugins/SmileyAdd/src/smileys.h b/plugins/SmileyAdd/src/smileys.h
index 8b3d4b7add..ad0eb059bc 100644
--- a/plugins/SmileyAdd/src/smileys.h
+++ b/plugins/SmileyAdd/src/smileys.h
@@ -102,8 +102,7 @@ template<class T> struct SMOBJLIST : public OBJLIST<T>
SMOBJLIST<T>& operator += (const SMOBJLIST<T>& lst)
{
- for (int i=0; i<lst.getCount(); ++i)
- {
+ for (int i=0; i < lst.getCount(); i++) {
T *p = new T(lst[i]);
insert(p);
}
@@ -112,7 +111,7 @@ template<class T> struct SMOBJLIST : public OBJLIST<T>
void splice(SMOBJLIST<T>& lst)
{
- for (int i=0; i<lst.getCount(); ++i)
+ for (int i=0; i < lst.getCount(); i++)
insert(&lst[i]);
lst.LIST<T>::destroy();
}