summaryrefslogtreecommitdiff
path: root/plugins/SmileyAdd
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-11-10 11:41:26 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-11-10 11:41:26 +0000
commit0f954168b4bac9877e79f9150e7689cf67b98d10 (patch)
tree5132ce0e6550ff96acadfc34b685ea24218f0da4 /plugins/SmileyAdd
parent09fba0e6c57fe19189150de73a7a9ad7f3462224 (diff)
last portion of fixes
git-svn-id: http://svn.miranda-ng.org/main/trunk@6855 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/SmileyAdd')
-rw-r--r--plugins/SmileyAdd/src/AniSmileyObject.cpp84
-rw-r--r--plugins/SmileyAdd/src/anim.cpp8
-rw-r--r--plugins/SmileyAdd/src/customsmiley.cpp28
-rw-r--r--plugins/SmileyAdd/src/dlgboxsubclass.cpp114
-rw-r--r--plugins/SmileyAdd/src/download.cpp6
-rw-r--r--plugins/SmileyAdd/src/general.cpp61
-rw-r--r--plugins/SmileyAdd/src/general.h9
-rw-r--r--plugins/SmileyAdd/src/imagecache.cpp294
-rw-r--r--plugins/SmileyAdd/src/imagecache.h51
-rw-r--r--plugins/SmileyAdd/src/options.cpp83
-rw-r--r--plugins/SmileyAdd/src/smltool.cpp83
11 files changed, 232 insertions, 589 deletions
diff --git a/plugins/SmileyAdd/src/AniSmileyObject.cpp b/plugins/SmileyAdd/src/AniSmileyObject.cpp
index 85cad0197b..0b54d08968 100644
--- a/plugins/SmileyAdd/src/AniSmileyObject.cpp
+++ b/plugins/SmileyAdd/src/AniSmileyObject.cpp
@@ -42,21 +42,21 @@ class CAniSmileyObject : public ISmileyBase
private:
typedef enum { animStdOle, animDrctRichEd, animHpp } AnimType;
- POINTL m_rectOrig;
- SIZEL m_rectExt;
+ POINTL m_rectOrig;
+ SIZEL m_rectExt;
- COLORREF m_bkg;
+ COLORREF m_bkg;
- SmileyType* m_sml;
- ImageBase* m_img;
- unsigned m_nFramePosition;
+ SmileyType *m_sml;
+ ImageBase *m_img;
+ unsigned m_nFramePosition;
- long m_counter;
- unsigned m_richFlags;
- long m_lastObjNum;
+ long m_counter;
+ unsigned m_richFlags;
+ long m_lastObjNum;
- AnimType m_animtype;
- bool m_allowAni;
+ AnimType m_animtype;
+ bool m_allowAni;
public:
CAniSmileyObject(SmileyType* sml, COLORREF clr, bool ishpp)
@@ -89,22 +89,19 @@ public:
if (m_img != NULL) return;
m_img = m_sml->CreateCachedImage();
- if (m_img && m_img->IsAnimated() && opt.AnimateDlg)
- {
+ if (m_img && m_img->IsAnimated() && opt.AnimateDlg) {
m_nFramePosition = 0;
m_img->SelectFrame(m_nFramePosition);
long frtm = m_img->GetFrameDelay();
m_counter = frtm / 10 + ((frtm % 10) >= 5);
regAniSmileys.insert(this);
- if (timerId == 0)
- {
+ if (timerId == 0) {
timerId = 0xffffffff;
CallFunctionAsync(sttMainThreadCallback, NULL);
}
}
- else
- m_nFramePosition = m_sml->GetStaticFrame();
+ else m_nFramePosition = m_sml->GetStaticFrame();
}
void UnloadSmiley(void)
@@ -132,19 +129,14 @@ public:
HRESULT hr = RichEditOle->GetObject(m_lastObjNum, &reObj, REO_GETOBJ_NO_INTERFACES);
if (hr == S_OK && reObj.dwUser == (DWORD)(ISmileyBase*)this && reObj.clsid == CLSID_NULL)
- {
m_richFlags = reObj.dwFlags;
- }
- else
- {
+ else {
long objectCount = RichEditOle->GetObjectCount();
- for (long i = objectCount; i--; )
- {
+ for (long i = objectCount; i--; ) {
HRESULT hr = RichEditOle->GetObject(i, &reObj, REO_GETOBJ_NO_INTERFACES);
if (FAILED(hr)) continue;
- if (reObj.dwUser == (DWORD)(ISmileyBase*)this && reObj.clsid == CLSID_NULL)
- {
+ if (reObj.dwUser == (DWORD)(ISmileyBase*)this && reObj.clsid == CLSID_NULL) {
m_lastObjNum = i;
m_richFlags = reObj.dwFlags;
break;
@@ -153,8 +145,7 @@ public:
}
RichEditOle->Release();
- if ((m_richFlags & REO_SELECTED) == 0)
- {
+ if ((m_richFlags & REO_SELECTED) == 0) {
CHARRANGE sel;
SendMessage(m_hwnd, EM_EXGETSEL, 0, (LPARAM)&sel);
if (reObj.cp >= sel.cpMin && reObj.cp < sel.cpMax)
@@ -184,8 +175,7 @@ public:
m_img->DrawInternal(hdcMem, rc.left, rc.top, m_sizeExtent.cx - 1, m_sizeExtent.cy - 1);
- if (m_richFlags & REO_SELECTED)
- {
+ if (m_richFlags & REO_SELECTED) {
HBRUSH hbr = CreateSolidBrush(m_bkg ^ 0xFFFFFF);
FrameRect(hdcMem, &rc, hbr);
DeleteObject(hbr);
@@ -204,8 +194,7 @@ public:
void DrawOnRichEdit(void)
{
HDC hdc = GetDC(m_hwnd);
- if (RectVisible(hdc, &m_orect))
- {
+ if (RectVisible(hdc, &m_orect)) {
RECT crct;
GetClientRect(m_hwnd, &crct);
@@ -221,8 +210,7 @@ public:
SelectClipRgn(hdc, res < 1 ? NULL : hrgnOld);
DeleteObject(hrgnOld);
}
- else
- {
+ else {
m_visible = false;
m_allowAni = false;
UnloadSmiley();
@@ -242,8 +230,7 @@ public:
nmh.rcRect = m_orect;
SendMessage(GetParent(m_hwnd), WM_NOTIFY, (WPARAM)m_hwnd, (LPARAM)&nmh);
- switch (nmh.bAction)
- {
+ switch (nmh.bAction) {
case FVCA_DRAW:
// support for pseudo-edit mode and event details
m_animtype = m_dirAniAllow ? animDrctRichEd : animStdOle;
@@ -271,26 +258,20 @@ public:
case FVCA_NONE:
m_visible = false;
break;
-
- default:
- break;
}
}
void ProcessTimerTick(void)
{
- if (m_visible && m_img && --m_counter <= 0)
- {
+ if (m_visible && m_img && --m_counter <= 0) {
m_nFramePosition = m_img->SelectNextFrame(m_nFramePosition);
long frtm = m_img->GetFrameDelay();
m_counter = frtm / 10 + ((frtm % 10) >= 5);
- switch (m_animtype)
- {
+ switch (m_animtype) {
case animStdOle:
if (m_allowAni) SendOnViewChange();
- else
- {
+ else {
m_visible = false;
UnloadSmiley();
}
@@ -318,25 +299,21 @@ public:
else UnloadSmiley();
if (lpRect == NULL) return;
- if (m_animtype == animStdOle)
- {
+ if (m_animtype == animStdOle) {
m_animtype = animDrctRichEd;
GetDrawingProp();
}
- if (lpRect->top == -1)
- {
+ if (lpRect->top == -1) {
m_rectOrig.x = lpRect->left;
m_rectOrig.y = lpRect->bottom - m_sizeExtent.cy;
m_rectExt.cy = m_sizeExtent.cy;
}
- else if (lpRect->bottom == -1)
- {
+ else if (lpRect->bottom == -1) {
m_rectOrig.x = lpRect->left;
m_rectOrig.y = lpRect->top;
}
- else
- {
+ else {
m_rectOrig.x = lpRect->left;
m_rectOrig.y = lpRect->top;
m_rectExt.cy = lpRect->bottom - lpRect->top;
@@ -367,8 +344,7 @@ public:
m_rectExt = m_sizeExtent;
- switch (m_animtype)
- {
+ switch (m_animtype) {
case animDrctRichEd:
{
m_rectExt.cy = pRectBounds->bottom - m_rectOrig.y;
diff --git a/plugins/SmileyAdd/src/anim.cpp b/plugins/SmileyAdd/src/anim.cpp
index d84afa5bab..46b66000aa 100644
--- a/plugins/SmileyAdd/src/anim.cpp
+++ b/plugins/SmileyAdd/src/anim.cpp
@@ -18,8 +18,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "general.h"
-Animate::Animate(SmileyType *sml, RECT& rect, HDC hdcMem, HBRUSH hbr, bool clip)
- : m_sml(sml), m_img(NULL),
+Animate::Animate(SmileyType *sml, RECT& rect, HDC hdcMem, HBRUSH hbr, bool clip) :
+ m_sml(sml),
+ m_img(NULL),
m_nFramePosition(0), m_sel(false), m_clip(clip),
m_offset(0), m_running(false),
m_hdcMem(hdcMem), m_hbr(hbr)
@@ -30,7 +31,8 @@ Animate::Animate(SmileyType *sml, RECT& rect, HDC hdcMem, HBRUSH hbr, bool clip)
Animate::~Animate()
{
- if (m_img) m_img->Release();
+ if (m_img)
+ m_img->Release();
}
diff --git a/plugins/SmileyAdd/src/customsmiley.cpp b/plugins/SmileyAdd/src/customsmiley.cpp
index 8dd946429d..053028aaaa 100644
--- a/plugins/SmileyAdd/src/customsmiley.cpp
+++ b/plugins/SmileyAdd/src/customsmiley.cpp
@@ -24,18 +24,15 @@ SmileyPackCListType g_SmileyPackCStore;
bool SmileyPackCListType::AddSmileyPack(HANDLE hContact, TCHAR* dir)
{
bool res = true;
- if (GetSmileyPack(hContact) == NULL)
- {
+ if (GetSmileyPack(hContact) == NULL) {
SmileyPackCType *smileyPack = new SmileyPackCType;
res = smileyPack->LoadSmileyDir(dir);
- if (res)
- {
+ if (res) {
smileyPack->SetId(hContact);
m_SmileyPacks.insert(smileyPack);
}
- else
- delete smileyPack;
+ else delete smileyPack;
}
return res;
}
@@ -86,11 +83,11 @@ bool SmileyCType::CreateTriggerText(char* text)
TCHAR *txt = mir_utf8decodeT(res);
res[reslen] = save;
- if (txt == NULL) return false;
+ if (txt == NULL)
+ return false;
m_TriggerText = txt;
mir_free(txt);
-
return true;
}
@@ -106,16 +103,13 @@ bool SmileyPackCType::LoadSmileyDir(TCHAR* dir)
_tfinddata_t c_file;
INT_PTR hFile = _tfindfirst((TCHAR*)dirs.c_str(), &c_file);
- if (hFile > -1L)
- {
+ if (hFile > -1L) {
do {
- if (c_file.name[0] != '.')
- {
+ if (c_file.name[0] != '.') {
CMString fullpath = dir;
fullpath = fullpath + _T("\\") + c_file.name;
TCHAR* div = _tcsrchr(c_file.name, '.');
- if (div)
- {
+ if (div) {
*div = 0;
SmileyCType *smlc = new SmileyCType(fullpath, c_file.name);
if (smlc->GetTriggerText().IsEmpty())
@@ -124,7 +118,8 @@ bool SmileyPackCType::LoadSmileyDir(TCHAR* dir)
m_SmileyList.insert(smlc);
}
}
- } while( _tfindnext( hFile, &c_file ) == 0 );
+ }
+ while( _tfindnext( hFile, &c_file ) == 0 );
_findclose( hFile );
AddTriggersToSmileyLookup();
return true;
@@ -141,12 +136,11 @@ bool SmileyPackCType::LoadSmiley(TCHAR* path)
CMString name = dirs.Mid(slash+1, dot - slash - 1);
- for (int i=0; i < m_SmileyList.getCount(); i++) {
+ for (int i=0; i < m_SmileyList.getCount(); i++)
if (m_SmileyList[i].GetTriggerText() == name) {
m_SmileyList[i].LoadFromResource(dirs, 0);
return true;
}
- }
m_SmileyList.insert(new SmileyCType(dirs, (TCHAR*)name.c_str()));
diff --git a/plugins/SmileyAdd/src/dlgboxsubclass.cpp b/plugins/SmileyAdd/src/dlgboxsubclass.cpp
index 554258dee7..634c7b0c90 100644
--- a/plugins/SmileyAdd/src/dlgboxsubclass.cpp
+++ b/plugins/SmileyAdd/src/dlgboxsubclass.cpp
@@ -112,23 +112,19 @@ public:
RECT rect;
POINT pt;
- if (OldButtonPlace)
- {
- if (isSplit && db_get_b(NULL, "SRMsg", "ShowQuote", FALSE))
- {
+ if (OldButtonPlace) {
+ if (isSplit && db_get_b(NULL, "SRMsg", "ShowQuote", FALSE)) {
GetWindowRect(QuoteB, &rect);
pt.x = rect.right + 12;
}
- else
- {
+ else {
GetWindowRect(MEdit, &rect);
pt.x = rect.left;
}
GetWindowRect(MOK, &rect);
pt.y = rect.top;
}
- else
- {
+ else {
GetWindowRect(LButton, &rect);
pt.y = rect.top;
@@ -154,24 +150,25 @@ public:
TCHAR szClassName[32] = _T("");
GetClassName(hwnd, szClassName, SIZEOF(szClassName));
- if (_tcscmp(szClassName, _T("#32770"))) return false;
+ if (_tcscmp(szClassName, _T("#32770")))
+ return false;
- if ((REdit = GetDlgItem(hwnd, MI_IDC_LOG)) != NULL)
- {
+ if ((REdit = GetDlgItem(hwnd, MI_IDC_LOG)) != NULL) {
GetClassName(REdit, szClassName, SIZEOF(szClassName));
if (_tcscmp(szClassName, _T("RichEdit20A")) != 0 &&
- _tcscmp(szClassName, _T("RichEdit20W")) != 0 &&
- _tcscmp(szClassName, _T("RICHEDIT50W")) != 0) return false;
+ _tcscmp(szClassName, _T("RichEdit20W")) != 0 &&
+ _tcscmp(szClassName, _T("RICHEDIT50W")) != 0)
+ return false;
}
else return false;
- if ((MEdit = GetDlgItem(hwnd, MI_IDC_MESSAGE)) != NULL)
- {
+ if ((MEdit = GetDlgItem(hwnd, MI_IDC_MESSAGE)) != NULL) {
GetClassName(MEdit, szClassName, SIZEOF(szClassName));
if (_tcscmp(szClassName, _T("Edit")) != 0 &&
- _tcscmp(szClassName, _T("RichEdit20A")) != 0 &&
- _tcscmp(szClassName, _T("RichEdit20W")) != 0 &&
- _tcscmp(szClassName, _T("RICHEDIT50W")) != 0) return false;
+ _tcscmp(szClassName, _T("RichEdit20A")) != 0 &&
+ _tcscmp(szClassName, _T("RichEdit20W")) != 0 &&
+ _tcscmp(szClassName, _T("RICHEDIT50W")) != 0)
+ return false;
}
else return false;
@@ -197,16 +194,14 @@ public:
doSmileyButton &= SmileyPack != NULL && SmileyPack->VisibleSmileyCount() != 0;
bool showButtonLine;
- if (IsOldSrmm())
- {
+ if (IsOldSrmm()) {
isSplit = db_get_b(NULL,"SRMsg","Split", TRUE) != 0;
doSmileyReplace = (isSplit || !isSend);
doSmileyButton &= isSplit || isSend;
showButtonLine = db_get_b(NULL, "SRMsg", "ShowButtonLine", TRUE) != 0;
}
- else
- {
+ else {
doSmileyReplace = true;
OldButtonPlace = false;
showButtonLine = db_get_b(NULL, "SRMM", "ShowButtonLine", TRUE) != 0;
@@ -214,15 +209,13 @@ public:
doSmileyButton &= OldButtonPlace || showButtonLine;
- if (ProtocolName[0] != 0)
- {
+ if (ProtocolName[0] != 0) {
INT_PTR cap = CallProtoService(ProtocolName, PS_GETCAPS, PFLAGNUM_1, 0);
doSmileyButton &= ((cap & (PF1_IMSEND | PF1_CHAT)) != 0);
doSmileyReplace &= ((cap & (PF1_IMRECV | PF1_CHAT)) != 0);
}
- if (doSmileyButton && opt.PluginSupportEnabled)
- {
+ if (doSmileyButton && opt.PluginSupportEnabled) {
//create smiley button
RECT rect = CalcSmileyButtonPos();
@@ -242,13 +235,11 @@ public:
// Conversion to bitmap done to prevent Miranda from scaling the image
SmileyType* sml = FindButtonSmiley(SmileyPack);
- if (sml != NULL)
- {
+ if (sml != NULL) {
hSmlBmp = sml->GetBitmap(GetSysColor(COLOR_BTNFACE), 0, 0);
SendMessage(hSmlButton, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hSmlBmp);
}
- else
- {
+ else {
hSmlIco = GetDefaultIcon();
SendMessage(hSmlButton, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hSmlIco);
}
@@ -303,16 +294,13 @@ static void MsgWndDetect(HWND hwndDlg, HANDLE hContact, msgData* datm)
{
MsgWndData dat;
- if (dat.IsMessageSendDialog(hwndDlg))
- {
+ if (dat.IsMessageSendDialog(hwndDlg)) {
dat.hwnd = hwndDlg;
- if (datm != NULL)
- {
+ if (datm != NULL) {
dat.isSend = datm->isSend != 0;
dat.hContact = datm->hContact;
}
- else
- dat.hContact = hContact;
+ else dat.hContact = hContact;
// Get the protocol for this contact to display correct smileys.
char *protonam = GetContactProto( DecodeMetaContact(dat.hContact));
@@ -346,18 +334,17 @@ static void MsgWndDetect(HWND hwndDlg, HANDLE hContact, msgData* datm)
static LRESULT CALLBACK MessageDlgSubclass(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
MsgWndData* dat = IsMsgWnd(hwnd);
- if (dat == NULL) return 0;
+ if (dat == NULL)
+ return 0;
- switch(uMsg)
- {
+ switch(uMsg) {
case DM_OPTIONSAPPLIED:
dat->clear();
dat->CreateSmileyButton();
break;
case DM_APPENDTOLOG:
- if (opt.PluginSupportEnabled)
- {
+ if (opt.PluginSupportEnabled) {
//get length of text now before things can get added...
GETTEXTLENGTHEX gtl;
gtl.codepage = 1200;
@@ -385,8 +372,7 @@ static LRESULT CALLBACK MessageDlgSubclass(HWND hwnd, UINT uMsg, WPARAM wParam,
break;
case WM_SIZE:
- if (dat->doSmileyButton)
- {
+ if (dat->doSmileyButton) {
RECT rect = dat->CalcSmileyButtonPos();
SetWindowPos(dat->hSmlButton, NULL, rect.left, rect.top,
0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
@@ -394,12 +380,10 @@ static LRESULT CALLBACK MessageDlgSubclass(HWND hwnd, UINT uMsg, WPARAM wParam,
break;
case DM_APPENDTOLOG:
- if (dat->doSmileyReplace)
- {
+ if (dat->doSmileyReplace) {
SmileyPackCType* smcp;
SmileyPackType* SmileyPack = GetSmileyPack(dat->ProtocolName, dat->hContact, &smcp);
- if (SmileyPack != NULL)
- {
+ if (SmileyPack != NULL) {
const CHARRANGE sel = { dat->idxLastChar, LONG_MAX };
ReplaceSmileys(dat->REdit, SmileyPack, smcp, sel, false, false, false);
}
@@ -407,12 +391,10 @@ static LRESULT CALLBACK MessageDlgSubclass(HWND hwnd, UINT uMsg, WPARAM wParam,
break;
case DM_REMAKELOG:
- if (dat->doSmileyReplace)
- {
+ if (dat->doSmileyReplace) {
SmileyPackCType* smcp;
SmileyPackType* SmileyPack = GetSmileyPack(dat->ProtocolName, dat->hContact, &smcp);
- if (SmileyPack != NULL)
- {
+ if (SmileyPack != NULL) {
static const CHARRANGE sel = { 0, LONG_MAX };
ReplaceSmileys(dat->REdit, SmileyPack, smcp, sel, false, false, false);
}
@@ -420,9 +402,7 @@ static LRESULT CALLBACK MessageDlgSubclass(HWND hwnd, UINT uMsg, WPARAM wParam,
break;
case WM_COMMAND:
- if (LOWORD(wParam) == IDC_SMLBUTTON &&
- HIWORD(wParam) == BN_CLICKED)
- {
+ if (LOWORD(wParam) == IDC_SMLBUTTON && HIWORD(wParam) == BN_CLICKED) {
SmileyToolWindowParam *stwp = new SmileyToolWindowParam;
stwp->pSmileyPack = GetSmileyPack(dat->ProtocolName, dat->hContact);
@@ -434,14 +414,12 @@ static LRESULT CALLBACK MessageDlgSubclass(HWND hwnd, UINT uMsg, WPARAM wParam,
RECT rect;
GetWindowRect(dat->hSmlButton, &rect);
- if (dat->OldButtonPlace)
- {
+ if (dat->OldButtonPlace) {
stwp->direction = 3;
stwp->xPosition = rect.left;
stwp->yPosition = rect.top + 4;
}
- else
- {
+ else {
stwp->direction = 0;
stwp->xPosition = rect.left;
stwp->yPosition = rect.top + 24;
@@ -450,10 +428,7 @@ static LRESULT CALLBACK MessageDlgSubclass(HWND hwnd, UINT uMsg, WPARAM wParam,
mir_forkthread(SmileyToolThread, stwp);
}
- if (LOWORD(wParam) == MI_IDC_ADD &&
- HIWORD(wParam) == BN_CLICKED &&
- dat->doSmileyButton)
- {
+ if (LOWORD(wParam) == MI_IDC_ADD && HIWORD(wParam) == BN_CLICKED && dat->doSmileyButton) {
RECT rect = dat->CalcSmileyButtonPos();
SetWindowPos(dat->hSmlButton, NULL, rect.left, rect.top,
0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
@@ -467,12 +442,10 @@ static LRESULT CALLBACK MessageDlgSubclass(HWND hwnd, UINT uMsg, WPARAM wParam,
static int MsgDlgHook(WPARAM, LPARAM lParam)
{
const MessageWindowEventData *wndEvtData = (MessageWindowEventData*)lParam;
- switch(wndEvtData->uType)
- {
+ switch(wndEvtData->uType) {
case MSG_WINDOW_EVT_OPENING:
MsgWndDetect(wndEvtData->hwndWindow, wndEvtData->hContact, NULL);
- if (wndEvtData->cbSize >= sizeof(MessageWindowEventData))
- {
+ if (wndEvtData->cbSize >= sizeof(MessageWindowEventData)) {
SetRichOwnerCallback(wndEvtData->hwndWindow, wndEvtData->hwndInput, wndEvtData->hwndLog);
if (wndEvtData->hwndLog)
@@ -483,13 +456,11 @@ static int MsgDlgHook(WPARAM, LPARAM lParam)
break;
case MSG_WINDOW_EVT_OPEN:
- if (wndEvtData->cbSize >= sizeof(MessageWindowEventData))
- {
+ if (wndEvtData->cbSize >= sizeof(MessageWindowEventData)) {
SetRichOwnerCallback(wndEvtData->hwndWindow, wndEvtData->hwndInput, wndEvtData->hwndLog);
if (wndEvtData->hwndLog)
SetRichCallback(wndEvtData->hwndLog, wndEvtData->hContact, true, true);
- if (wndEvtData->hwndInput)
- {
+ if (wndEvtData->hwndInput) {
SetRichCallback(wndEvtData->hwndInput, wndEvtData->hContact, true, true);
SendMessage(wndEvtData->hwndInput, WM_REMAKERICH, 0, 0);
}
@@ -497,8 +468,7 @@ static int MsgDlgHook(WPARAM, LPARAM lParam)
break;
case MSG_WINDOW_EVT_CLOSE:
- if (wndEvtData->cbSize >= sizeof(MessageWindowEventData) && wndEvtData->hwndLog)
- {
+ if (wndEvtData->cbSize >= sizeof(MessageWindowEventData) && wndEvtData->hwndLog) {
CloseRichCallback(wndEvtData->hwndLog);
CloseRichOwnerCallback(wndEvtData->hwndWindow);
}
diff --git a/plugins/SmileyAdd/src/download.cpp b/plugins/SmileyAdd/src/download.cpp
index c3a68a11d3..879dace326 100644
--- a/plugins/SmileyAdd/src/download.cpp
+++ b/plugins/SmileyAdd/src/download.cpp
@@ -40,7 +40,7 @@ static bool threadRunning;
bool InternetDownloadFile(const char *szUrl, char* szDest, HANDLE &hHttpDwnl)
{
int result = 0xBADBAD;
- char* szRedirUrl = NULL;
+ char *szRedirUrl = NULL;
NETLIBHTTPREQUEST nlhr = {0};
// initialize the netlib request
@@ -60,9 +60,7 @@ bool InternetDownloadFile(const char *szUrl, char* szDest, HANDLE &hHttpDwnl)
while (result == 0xBADBAD) {
// download the page
- NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION,
- (WPARAM)hNetlibUser,(LPARAM)&nlhr);
-
+ NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUser,(LPARAM)&nlhr);
if (nlhrReply) {
hHttpDwnl = nlhrReply->nlc;
// if the recieved code is 200 OK
diff --git a/plugins/SmileyAdd/src/general.cpp b/plugins/SmileyAdd/src/general.cpp
index 2d736ae9e8..b10c77cdae 100644
--- a/plugins/SmileyAdd/src/general.cpp
+++ b/plugins/SmileyAdd/src/general.cpp
@@ -46,40 +46,29 @@ int CalculateTextHeight(HDC hdc, CHARFORMAT2* chf)
return fontSize.cy;
}
-
HICON GetDefaultIcon(bool copy)
{
HICON resIco = Skin_GetIcon("SmileyAdd_ButtonSmiley");
- if ( resIco == NULL || resIco == (HICON)CALLSERVICE_NOTFOUND )
- {
- resIco = (HICON)LoadImage(g_hInst, MAKEINTRESOURCE(IDI_SMILINGICON),
- IMAGE_ICON, 0, 0, copy ? 0 : LR_SHARED);
- }
- else
- {
- if (copy)
- {
- resIco = (HICON)CopyImage(resIco, IMAGE_ICON, 0, 0, 0);
- Skin_ReleaseIcon("SmileyAdd_ButtonSmiley");
- }
+ if (resIco == NULL)
+ resIco = (HICON)LoadImage(g_hInst, MAKEINTRESOURCE(IDI_SMILINGICON), IMAGE_ICON, 0, 0, copy ? 0 : LR_SHARED);
+ else if (copy) {
+ resIco = (HICON)CopyImage(resIco, IMAGE_ICON, 0, 0, 0);
+ Skin_ReleaseIcon("SmileyAdd_ButtonSmiley");
}
return resIco;
}
-
const TCHAR* GetImageExt(CMString &fname)
{
const TCHAR* ext = _T("");
int fileId = _topen(fname.c_str(), O_RDONLY | _O_BINARY);
- if (fileId != -1)
- {
+ if (fileId != -1) {
BYTE buf[6];
int bytes = _read(fileId, buf, sizeof(buf));
- if (bytes > 4)
- {
+ if (bytes > 4) {
if ( *(unsigned short*)buf == 0xd8ff )
ext = _T("jpg");
else if ( *(unsigned short*)buf == 0x4d42 )
@@ -94,8 +83,6 @@ const TCHAR* GetImageExt(CMString &fname)
return ext;
}
-
-
HICON ImageList_GetIconFixed (HIMAGELIST himl, INT i, UINT fStyle)
{
ICONINFO ii;
@@ -150,22 +137,19 @@ void pathToAbsolute(const CMString& pSrc, CMString& pOut)
{
TCHAR szOutPath[MAX_PATH];
- TCHAR* szVarPath = Utils_ReplaceVarsT(pSrc.c_str());
- if (szVarPath == (TCHAR*)CALLSERVICE_NOTFOUND || szVarPath == NULL)
- {
+ TCHAR *szVarPath = Utils_ReplaceVarsT(pSrc.c_str());
+ if (szVarPath == (TCHAR*)CALLSERVICE_NOTFOUND || szVarPath == NULL) {
TCHAR szExpPath[MAX_PATH];
ExpandEnvironmentStrings(pSrc.c_str(), szExpPath, SIZEOF(szExpPath));
PathToAbsoluteT(szExpPath, szOutPath);
}
- else
- {
+ else {
PathToAbsoluteT(szVarPath, szOutPath);
mir_free(szVarPath);
}
pOut = szOutPath;
}
-
/////////////////////////////////////////////////////////////////////////////////////////
// UrlDecode - converts URL chars like %20 into printable characters
@@ -181,16 +165,12 @@ void UrlDecode(char* str)
{
char* s = str, *d = str;
- while(*s)
- {
- if (*s == '%')
- {
+ while(*s) {
+ if (*s == '%') {
int digit1 = SingleHexToDecimal(s[1]);
- if ( digit1 != -1 )
- {
+ if (digit1 != -1) {
int digit2 = SingleHexToDecimal(s[2]);
- if ( digit2 != -1 )
- {
+ if (digit2 != -1) {
s += 3;
*d++ = (char)((digit1 << 4) | digit2);
continue;
@@ -211,15 +191,11 @@ bool InitGdiPlus(void)
static const TCHAR errmsg[] = _T("GDI+ not installed.\n")
_T("GDI+ can be downloaded here: http://www.microsoft.com/downloads");
- __try
- {
+ __try {
if (g_gdiplusToken == 0 && !gdiPlusFail)
- {
Gdiplus::GdiplusStartup(&g_gdiplusToken, &gdiplusStartupInput, NULL);
- }
}
- __except ( EXCEPTION_EXECUTE_HANDLER )
- {
+ __except(EXCEPTION_EXECUTE_HANDLER) {
gdiPlusFail = true;
ReportError(errmsg);
}
@@ -229,8 +205,7 @@ bool InitGdiPlus(void)
void DestroyGdiPlus(void)
{
- if (g_gdiplusToken != 0)
- {
+ if (g_gdiplusToken != 0) {
Gdiplus::GdiplusShutdown(g_gdiplusToken);
g_gdiplusToken = 0;
}
@@ -262,4 +237,4 @@ void ReportError(const TCHAR* errmsg)
pd.iSeconds = -1;
if (PUAddPopupT(&pd) == CALLSERVICE_NOTFOUND)
MessageBox(NULL, errmsg, title, MB_OK | MB_ICONWARNING | MB_TOPMOST);
-} \ No newline at end of file
+}
diff --git a/plugins/SmileyAdd/src/general.h b/plugins/SmileyAdd/src/general.h
index 302d898f18..8bd96c3eb9 100644
--- a/plugins/SmileyAdd/src/general.h
+++ b/plugins/SmileyAdd/src/general.h
@@ -154,15 +154,6 @@ public:
#define A2T_SM (wchar_t*)A2W_SM
#define W2T_SM(p1) (TCHAR*)p1
-
-inline unsigned short GetWinVer(void)
-{
- unsigned short ver = LOWORD(GetVersion());
- ver = (ver & 0xFF) << 8 | (ver >> 8);
- return ver;
-}
-
-
// init functions
void InstallDialogBoxHook(void);
void RemoveDialogBoxHook(void);
diff --git a/plugins/SmileyAdd/src/imagecache.cpp b/plugins/SmileyAdd/src/imagecache.cpp
index 87b95f5a60..e9cd07afa6 100644
--- a/plugins/SmileyAdd/src/imagecache.cpp
+++ b/plugins/SmileyAdd/src/imagecache.cpp
@@ -32,8 +32,7 @@ static void CALLBACK timerProc(HWND, UINT, UINT_PTR, DWORD)
{
WaitForSingleObject(g_hMutexIm, 3000);
const time_t ts = time(NULL) - 10;
- if ( lastmodule && ts > laststamp)
- {
+ if ( lastmodule && ts > laststamp) {
FreeLibrary(lastmodule);
lastmodule = NULL;
lastdllname.Empty();
@@ -65,8 +64,7 @@ static HMODULE LoadDll(const CMString& file)
{
WaitForSingleObject(g_hMutexIm, 3000);
- if (lastdllname != file)
- {
+ if (lastdllname != file) {
FreeLibrary(lastmodule);
lastdllname = file;
@@ -112,10 +110,9 @@ void ImageBase::ProcessTimerTick(time_t ts)
{
WaitForSingleObject(g_hMutexIm, 3000);
if (m_lRefCount == 0 && m_timestamp < ts )
- {
if (!g_imagecache.remove(this))
delete this;
- }
+
ReleaseMutex(g_hMutexIm);
}
@@ -131,8 +128,7 @@ int ImageBase::CompareImg(const ImageBase* p1, const ImageBase* p2)
void ImageBase::Draw(HDC hdc, RECT& rc, bool clip)
{
HRGN hrgn = NULL;
- if (clip)
- {
+ if (clip) {
hrgn = CreateRectRgn(rc.left, rc.top, rc.right, rc.bottom);
SelectClipRgn(hdc, hrgn);
}
@@ -151,8 +147,7 @@ void ImageBase::Draw(HDC hdc, RECT& rc, bool clip)
DrawInternal(hdc, x, y, scaleX, scaleY);
- if (clip)
- {
+ if (clip) {
SelectClipRgn(hdc, NULL);
DeleteObject(hrgn);
}
@@ -163,8 +158,7 @@ HBITMAP ImageBase::GetBitmap(COLORREF bkgClr, int sizeX, int sizeY)
{
RECT rc = { 0, 0, sizeX, sizeY };
- if (sizeX == 0 || sizeY == 0)
- {
+ if (sizeX == 0 || sizeY == 0) {
SIZE iSize;
GetSize(iSize);
@@ -203,8 +197,7 @@ IconType::IconType(const unsigned id, const CMString& file, const int index, con
{
m_SmileyIcon = NULL;
- switch (type)
- {
+ switch (type) {
case icoDll:
{
const HMODULE hModule = LoadDll(file);
@@ -241,17 +234,18 @@ HICON IconType::GetIcon(void)
void IconType::GetSize(SIZE& size)
{
- if (m_SmileyIcon != NULL)
- {
- ICONINFO ii;
- BITMAP bm;
- GetIconInfo(m_SmileyIcon, &ii);
- GetObject(ii.hbmColor, sizeof(bm), &bm);
- size.cx = bm.bmWidth;
- size.cy = bm.bmHeight;
- DeleteObject(ii.hbmMask);
- DeleteObject(ii.hbmColor);
- }
+ if (m_SmileyIcon == NULL)
+ return;
+
+ ICONINFO ii;
+ GetIconInfo(m_SmileyIcon, &ii);
+
+ BITMAP bm;
+ GetObject(ii.hbmColor, sizeof(bm), &bm);
+ size.cx = bm.bmWidth;
+ size.cy = bm.bmHeight;
+ DeleteObject(ii.hbmMask);
+ DeleteObject(ii.hbmColor);
}
@@ -270,8 +264,7 @@ void ImageListItemType::DrawInternal(HDC hdc, int x, int y, int sizeX, int sizeY
if (sizeX >= iSize.cx && sizeY >= iSize.cy)
ImageList_Draw(m_hImList, m_index, hdc, x, y, ILD_TRANSPARENT);
- else
- {
+ else {
HICON hIcon = ImageList_GetIconFixed(m_hImList, m_index, ILD_TRANSPARENT);
DrawIconEx(hdc, x, y, hIcon, sizeX, sizeY, 0, NULL, DI_NORMAL);
DestroyIcon(hIcon);
@@ -303,8 +296,7 @@ ImageType::ImageType(const unsigned id, const CMString& file, IStream* pStream)
else
m_bmp = new Gdiplus::Bitmap(T2W_SM(file.c_str()));
- if (m_bmp->GetLastStatus() != Gdiplus::Ok)
- {
+ if (m_bmp->GetLastStatus() != Gdiplus::Ok) {
delete m_bmp;
m_bmp = NULL;
return;
@@ -313,8 +305,7 @@ ImageType::ImageType(const unsigned id, const CMString& file, IStream* pStream)
GUID pageGuid = Gdiplus::FrameDimensionTime;
m_nFrameCount = m_bmp->GetFrameCount(&pageGuid);
- if (IsAnimated())
- {
+ if (IsAnimated()) {
int nSize = m_bmp->GetPropertyItemSize(PropertyTagFrameDelay);
m_pPropertyItem = (Gdiplus::PropertyItem*) new char[nSize];
m_bmp->GetPropertyItem(PropertyTagFrameDelay, nSize, m_pPropertyItem);
@@ -327,17 +318,15 @@ ImageType::ImageType(const unsigned id, const CMString& file, const int index, c
m_bmp = NULL;
m_pPropertyItem = NULL;
m_nCurrentFrame = 0;
- m_nFrameCount = 0;
+ m_nFrameCount = 0;
if (!InitGdiPlus()) return;
- switch (type)
- {
+ switch (type) {
case icoDll:
{
const HMODULE hModule = LoadDll(file);
- if (hModule != NULL)
- {
+ if (hModule != NULL) {
HICON hIcon = (HICON) LoadImage(hModule, MAKEINTRESOURCE(-index), IMAGE_ICON, 0, 0, 0);
m_bmp = new Gdiplus::Bitmap(hIcon);
DestroyIcon(hIcon);
@@ -357,8 +346,7 @@ ImageType::ImageType(const unsigned id, const CMString& file, const int index, c
break;
}
- if (m_bmp->GetLastStatus() != Gdiplus::Ok)
- {
+ if (m_bmp->GetLastStatus() != Gdiplus::Ok) {
delete m_bmp;
m_bmp = NULL;
return;
@@ -375,8 +363,7 @@ ImageType::~ImageType(void)
void ImageType::SelectFrame(int frame)
{
if ((unsigned)frame >= (unsigned)m_nFrameCount) frame = 0;
- if (IsAnimated() && frame != m_nCurrentFrame)
- {
+ if (IsAnimated() && frame != m_nCurrentFrame) {
m_nCurrentFrame = frame;
GUID pageGuid = Gdiplus::FrameDimensionTime;
m_bmp->SelectActiveFrame(&pageGuid, frame);
@@ -389,11 +376,10 @@ void ImageType::DrawInternal(HDC hdc, int x, int y, int sizeX, int sizeY)
if (m_bmp == NULL) return;
WaitForSingleObject(g_hMutexIm, 3000);
- {
- Gdiplus::Graphics grp(hdc);
-// if (opt.HQScaling) grp.SetInterpolationMode(Gdiplus::InterpolationModeBicubic);
- grp.DrawImage(m_bmp, x, y, sizeX, sizeY);
- }
+
+ Gdiplus::Graphics grp(hdc);
+ grp.DrawImage(m_bmp, x, y, sizeX, sizeY);
+
ReleaseMutex(g_hMutexIm);
}
@@ -418,16 +404,11 @@ HICON ImageType::GetIcon(void)
void ImageType::GetSize(SIZE& size)
{
- if (m_bmp)
- {
+ if (m_bmp) {
size.cx = m_bmp->GetWidth();
size.cy = m_bmp->GetHeight();
}
- else
- {
- size.cx = 0;
- size.cy = 0;
- }
+ else size.cx = size.cy = 0;
}
@@ -454,14 +435,12 @@ ImageFType::ImageFType(const unsigned id, const CMString& file)
FREE_IMAGE_TYPE imt = fei->FI_GetImageType(dib);
unsigned bpp = fei->FI_GetBPP(dib);
- if (transp && bpp != 32 || imt == FIT_RGBA16)
- {
+ if (transp && bpp != 32 || imt == FIT_RGBA16) {
FIBITMAP *tdib = fei->FI_ConvertTo32Bits(dib);
fei->FI_Unload(dib);
dib = tdib;
}
- else if (!transp && bpp > 24)
- {
+ else if (!transp && bpp > 24) {
FIBITMAP *tdib = fei->FI_ConvertTo24Bits(dib);
fei->FI_Unload(dib);
dib = tdib;
@@ -489,17 +468,13 @@ void ImageFType::DrawInternal(HDC hdc, int x, int y, int sizeX, int sizeY)
BITMAP bm;
GetObject(m_bmp, sizeof(bm), &bm);
- if (bm.bmBitsPixel == 32)
- {
+ if (bm.bmBitsPixel == 32) {
BLENDFUNCTION bf = {0};
bf.SourceConstantAlpha = 255;
bf.AlphaFormat = AC_SRC_ALPHA;
GdiAlphaBlend(hdc, x, y, sizeX, sizeY, hdcImg, 0, 0, bm.bmWidth, bm.bmHeight, bf);
}
- else
- {
- BitBlt(hdc, x, y, sizeX, sizeY, hdcImg, 0, 0, SRCCOPY);
- }
+ else BitBlt(hdc, x, y, sizeX, sizeY, hdcImg, 0, 0, SRCCOPY);
SelectObject(hdcImg, oldBmp);
DeleteDC(hdcImg);
@@ -507,9 +482,8 @@ void ImageFType::DrawInternal(HDC hdc, int x, int y, int sizeX, int sizeY)
HICON ImageFType::GetIcon(void)
{
- if (m_bmp == NULL) return NULL;
-
- HICON hIcon;
+ if (m_bmp == NULL)
+ return NULL;
BITMAP bm;
GetObject(m_bmp, sizeof(bm), &bm);
@@ -518,187 +492,23 @@ HICON ImageFType::GetIcon(void)
ii.fIcon = TRUE;
ii.xHotspot = 0;
ii.yHotspot = 0;
-
- if (bm.bmBitsPixel == 32 && GetWinVer() < 0x0501)
- {
- int slen = bm.bmWidth * 4;
- int len = bm.bmHeight * slen;
-
- BYTE* p = (BYTE*)mir_alloc(len);
- BYTE* maskBits = (BYTE*)mir_calloc(len);
- BYTE* colorBits = (BYTE*)mir_calloc(len);
-
- GetBitmapBits(m_bmp, len, p);
-
- for (int y = 0; y < bm.bmHeight; ++y)
- {
- int shift = y * slen;
- BYTE *px = p + shift;
- BYTE *color = colorBits + shift;
- BYTE *mask = maskBits + shift;
-
- for (int x = 0; x < bm.bmWidth; ++x)
- {
- for(int i = 0; i < 4; i++)
- {
- mask[i] = px[3];
- color[i] = px[i];
- }
-
- px += 4;
- mask += 4;
- color += 4;
- }
- }
-
- ii.hbmMask = CreateBitmap(bm.bmWidth, bm.bmHeight, 1, 32, maskBits);
- ii.hbmColor = CreateBitmap(bm.bmWidth, bm.bmHeight, 1, 32, colorBits);
-
- hIcon = CreateIconIndirect(&ii);
-
- DeleteObject(ii.hbmMask);
- DeleteObject(ii.hbmColor);
-
- mir_free(p);
- mir_free(maskBits);
- mir_free(colorBits);
- }
- else
- {
- ii.hbmMask = CreateBitmap(bm.bmWidth, bm.bmHeight, 1, 1, NULL);
- ii.hbmColor = m_bmp;
- hIcon = CreateIconIndirect(&ii);
- DeleteObject(ii.hbmMask);
- }
+ ii.hbmMask = CreateBitmap(bm.bmWidth, bm.bmHeight, 1, 1, NULL);
+ ii.hbmColor = m_bmp;
+ HICON hIcon = CreateIconIndirect(&ii);
+ DeleteObject(ii.hbmMask);
return hIcon;
}
void ImageFType::GetSize(SIZE& size)
{
- if (m_bmp)
- {
+ if (m_bmp) {
BITMAP bm;
GetObject(m_bmp, sizeof(bm), &bm);
size.cx = bm.bmWidth;
size.cy = bm.bmHeight;
}
- else
- {
- size.cx = 0;
- size.cy = 0;
- }
-}
-/*
-ImageFAniType::ImageFAniType(const unsigned id, const CMString& file)
-: ImageFType(id)
-{
- m_fmbmp = NULL;
- m_nCurrentFrame = -1;
- m_FrameDelay = NULL;
-
- FREE_IMAGE_FORMAT fif = fei->FI_GetFileTypeT(file.c_str(), 0);
- if (fif == FIF_UNKNOWN)
- fif = fei->FI_GetFIFFromFilenameT(file.c_str());
-
- m_fmbmp = fei->FI_OpenMultiBitmap(fif, T2A_SM(file.c_str()), FALSE, TRUE, TRUE, GIF_PLAYBACK);
- if (m_fmbmp == NULL) return;
-
- m_nFrameCount = fei->FI_GetPageCount(m_fmbmp);
- m_bmpl = (HBITMAP*)mir_calloc(m_nFrameCount*sizeof(HBITMAP));
- m_FrameDelay = (int*)mir_calloc(m_nFrameCount*sizeof(int));
- SelectFrame(0);
-}
-
-ImageFAniType::~ImageFAniType()
-{
- if (m_fmbmp) fei->FI_CloseMultiBitmap(m_fmbmp, 0);
- for (int i=0; i<m_nFrameCount; ++i)
- if (m_bmp) DeleteObject(m_bmpl[i]);
-
- mir_free(m_bmpl);
- mir_free(m_FrameDelay);
-}
-
-void ImageFAniType::SelectFrame(int frame)
-{
- if ((unsigned)frame >= (unsigned)m_nFrameCount) frame = 0;
- if (frame == m_nCurrentFrame) return;
- m_nCurrentFrame = frame;
-
- if (m_bmpl[frame])
- {
- m_bmp = m_bmpl[frame];
- return;
- }
-
- FITAG *tag = NULL;
-
- FIBITMAP *dib = fei->FI_LockPage(m_fmbmp, frame);
- if (dib == NULL)
- return;
-
- if (fei->FI_GetMetadata(FIMD_ANIMATION, dib, "FrameTime", &tag))
- m_FrameDelay[frame] = *(LONG *)fei->FI_GetTagValue(tag) / 10;
-
- m_bmpl[frame] = m_bmp = fei->FI_CreateHBITMAPFromDIB(dib);
-
- if (fei->FI_IsTransparent(dib))
- fei->FI_Premultiply(m_bmp);
-
- fei->FI_UnlockPage(m_fmbmp, dib, FALSE);
+ else size.cx = size.cy = 0;
}
-*/
-
-#pragma optimize("gt", on)
-
-// MurmurHash2, by Austin Appleby
-unsigned int __fastcall hash( const void * key, unsigned int len )
-{
- // 'm' and 'r' are mixing constants generated offline.
- // They're not really 'magic', they just happen to work well.
- const unsigned int m = 0x5bd1e995;
- const int r = 24;
-
- // Initialize the hash to a 'random' value
- unsigned int h = len;
-
- // Mix 4 bytes at a time into the hash
- const unsigned char * data = (const unsigned char *)key;
-
- while(len >= 4)
- {
- unsigned int k = *(unsigned int *)data;
-
- k *= m;
- k ^= k >> r;
- k *= m;
-
- h *= m;
- h ^= k;
-
- data += 4;
- len -= 4;
- }
-
- // Handle the last few bytes of the input array
- switch(len)
- {
- case 3: h ^= data[2] << 16;
- case 2: h ^= data[1] << 8;
- case 1: h ^= data[0];
- h *= m;
- };
-
- // Do a few final mixes of the hash to ensure the last few
- // bytes are well-incorporated.
- h ^= h >> 13;
- h *= m;
- h ^= h >> 15;
-
- return h;
-}
-#pragma optimize("", on)
-
void InitImageCache(void)
{
@@ -719,23 +529,21 @@ void DestroyImageCache(void)
CloseHandle(g_hMutexIm);
}
-
ImageBase* AddCacheImage(const CMString& file, int index)
{
CMString tmpfile(file); tmpfile.AppendFormat(_T("#%d"), index);
- unsigned id = hash(tmpfile.c_str(), (unsigned int)tmpfile.GetLength() * sizeof(TCHAR));
+ unsigned id = mir_hash(tmpfile.c_str(), tmpfile.GetLength() * sizeof(TCHAR));
WaitForSingleObject(g_hMutexIm, 3000);
ImageBase srch(id);
ImageBase *img = g_imagecache.find(&srch);
- if (img == NULL)
- {
+ if (img == NULL) {
int ind = file.ReverseFind('.');
if (ind == -1)
return NULL;
- CMString ext = file.Right(ind+1);
+ CMString ext = file.Mid(ind+1);
ext.MakeLower();
if (ext == _T("dll") || ext == _T("exe"))
img = opt.HQScaling ? (ImageBase*)new ImageType(id, file, index, icoDll) : (ImageBase*)new IconType(id, file, index, icoDll);
@@ -752,14 +560,12 @@ ImageBase* AddCacheImage(const CMString& file, int index)
g_imagecache.insert(img);
- if (timerId == 0)
- {
+ if (timerId == 0) {
timerId = 0xffffffff;
CallFunctionAsync(sttMainThreadCallback, NULL);
}
}
- else
- img->AddRef();
+ else img->AddRef();
ReleaseMutex(g_hMutexIm);
diff --git a/plugins/SmileyAdd/src/imagecache.h b/plugins/SmileyAdd/src/imagecache.h
index d8abe2e6b6..615dbecc44 100644
--- a/plugins/SmileyAdd/src/imagecache.h
+++ b/plugins/SmileyAdd/src/imagecache.h
@@ -23,7 +23,7 @@ class ImageBase
protected:
unsigned m_id;
long m_lRefCount;
- time_t m_timestamp;
+ time_t m_timestamp;
public:
@@ -33,19 +33,19 @@ public:
long AddRef(void);
long Release(void);
- void ProcessTimerTick(time_t ts);
+ void ProcessTimerTick(time_t ts);
- virtual void GetSize(SIZE& /* size */) {};
+ virtual void GetSize(SIZE& /* size */) {};
virtual int GetFrameCount(void) const { return 0; }
virtual int GetFrameDelay(void) const { return 0; }
- virtual HICON GetIcon(void) { return NULL; };
- virtual void DrawInternal(HDC /* dc */, int /* x */, int /* y */, int /* sizeX */, int /* sizeY */) {};
- virtual void SelectFrame(int /* frame */) {}
+ virtual HICON GetIcon(void) { return NULL; };
+ virtual void DrawInternal(HDC /* dc */, int /* x */, int /* y */, int /* sizeX */, int /* sizeY */) {};
+ virtual void SelectFrame(int /* frame */) {}
bool IsAnimated(void) const { return GetFrameCount() > 1; }
HBITMAP GetBitmap(COLORREF bkgClr, int sizeX, int sizeY);
void Draw(HDC dc, RECT &rc, bool clip);
- int SelectNextFrame(const int frame);
+ int SelectNextFrame(const int frame);
static int CompareImg(const ImageBase* p1, const ImageBase* p2);
};
@@ -93,7 +93,7 @@ public:
class ImageType : public ImageBase
{
private:
- int m_nCurrentFrame;
+ int m_nCurrentFrame;
int m_nFrameCount;
Gdiplus::Bitmap* m_bmp;
@@ -102,13 +102,13 @@ private:
public:
ImageType(const unsigned id, const CMString& file, IStream* pStream);
- ImageType(const unsigned id, const CMString& file, const int index, const IcoTypeEnum type);
+ ImageType(const unsigned id, const CMString& file, const int index, const IcoTypeEnum type);
~ImageType();
- void SelectFrame(int frame);
+ void SelectFrame(int frame);
- void DrawInternal(HDC dc, int x, int y, int sizeX, int sizeY);
- HICON GetIcon(void);
+ void DrawInternal(HDC dc, int x, int y, int sizeX, int sizeY);
+ HICON GetIcon(void);
void GetSize(SIZE& size);
int GetFrameDelay(void) const;
@@ -122,37 +122,14 @@ protected:
public:
- ImageFType(const unsigned id);
+ ImageFType(const unsigned id);
ImageFType(const unsigned id, const CMString& file);
~ImageFType();
void DrawInternal(HDC dc, int x, int y, int sizeX, int sizeY);
- HICON GetIcon(void);
+ HICON GetIcon(void);
void GetSize(SIZE& size);
};
-/*
-class ImageFAniType : public ImageFType
-{
-private:
- int m_nCurrentFrame;
- int m_nFrameCount;
- int *m_FrameDelay;
-
- FIMULTIBITMAP *m_fmbmp;
- HBITMAP* m_bmpl;
-
-public:
-
- ImageFAniType(const unsigned id, const CMString& file);
- ~ImageFAniType();
-
- void SelectFrame(int frame);
-
- int GetFrameDelay(void) const { return m_FrameDelay[m_nCurrentFrame]; }
- int GetFrameCount(void) const { return m_nFrameCount; }
-};
-*/
-
ImageBase* AddCacheImage(const CMString& file, int index);
diff --git a/plugins/SmileyAdd/src/options.cpp b/plugins/SmileyAdd/src/options.cpp
index 90daa34791..7bc1f76290 100644
--- a/plugins/SmileyAdd/src/options.cpp
+++ b/plugins/SmileyAdd/src/options.cpp
@@ -72,23 +72,17 @@ int SmileysOptionsInitialize(WPARAM addInfo, LPARAM)
//
static INT_PTR CALLBACK DlgProcSmileysOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- OptionsDialogType* pOD;
- INT_PTR Result;
-
- pOD = (OptionsDialogType*) GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- if (pOD == NULL)
- {
+ OptionsDialogType *pOD = (OptionsDialogType*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ if (pOD == NULL) {
pOD = new OptionsDialogType(hwndDlg);
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR) pOD);
}
- Result = pOD->DialogProcedure(msg, wParam, lParam);
+ INT_PTR Result = pOD->DialogProcedure(msg, wParam, lParam);
SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, Result);
if (msg == WM_NCDESTROY)
- {
delete pOD;
- }
return Result;
}
@@ -99,8 +93,7 @@ BOOL OptionsDialogType::DialogProcedure(UINT msg, WPARAM wParam, LPARAM lParam)
{
BOOL Result = FALSE;
- switch(msg)
- {
+ switch(msg) {
case WM_INITDIALOG:
InitDialog();
Result = TRUE;
@@ -111,11 +104,9 @@ BOOL OptionsDialogType::DialogProcedure(UINT msg, WPARAM wParam, LPARAM lParam)
break;
case WM_COMMAND:
- switch (LOWORD(wParam))
- {
+ switch (LOWORD(wParam)) {
case IDC_FILENAME:
- switch(HIWORD(wParam))
- {
+ switch(HIWORD(wParam)) {
case EN_KILLFOCUS:
FilenameChanged();
break;
@@ -128,30 +119,26 @@ BOOL OptionsDialogType::DialogProcedure(UINT msg, WPARAM wParam, LPARAM lParam)
case IDC_BROWSE:
if (HIWORD(wParam) == BN_CLICKED)
- {
- if (BrowseForSmileyPacks(GetSelProto()))
- {
+ if (BrowseForSmileyPacks(GetSelProto())) {
UpdateControls(true);
SetChanged();
}
- }
break;
case IDC_SMLOPTBUTTON:
- if (HIWORD(wParam) == BN_CLICKED) ShowSmileyPreview();
+ if (HIWORD(wParam) == BN_CLICKED)
+ ShowSmileyPreview();
break;
case IDC_USESTDPACK:
- if (HIWORD(wParam) == BN_CLICKED)
- {
+ if (HIWORD(wParam) == BN_CLICKED) {
PopulateSmPackList();
SetChanged();
}
break;
case IDC_PLUGENABLED:
- if (HIWORD(wParam) == BN_CLICKED)
- {
+ if (HIWORD(wParam) == BN_CLICKED) {
BOOL en = IsDlgButtonChecked(m_hwndDialog, IDC_PLUGENABLED) == BST_UNCHECKED;
EnableWindow(GetDlgItem(m_hwndDialog, IDC_SMLBUT), en);
SetChanged();
@@ -160,20 +147,15 @@ BOOL OptionsDialogType::DialogProcedure(UINT msg, WPARAM wParam, LPARAM lParam)
case IDC_ADDCATEGORY:
if (HIWORD(wParam) == BN_CLICKED)
- {
AddCategory();
- }
break;
case IDC_DELETECATEGORY:
if (HIWORD(wParam) == BN_CLICKED)
- {
- if (tmpsmcat.DeleteCustomCategory(GetSelProto()))
- {
+ if (tmpsmcat.DeleteCustomCategory(GetSelProto())) {
PopulateSmPackList();
SetChanged();
}
- }
break;
case IDC_SPACES:
@@ -188,16 +170,19 @@ BOOL OptionsDialogType::DialogProcedure(UINT msg, WPARAM wParam, LPARAM lParam)
case IDC_DCURSORSMILEY:
case IDC_DISABLECUSTOM:
case IDC_HQSCALING:
- if (HIWORD(wParam) == BN_CLICKED) SetChanged();
+ if (HIWORD(wParam) == BN_CLICKED)
+ SetChanged();
break;
case IDC_SELCLR:
- if (HIWORD(wParam) == CPN_COLOURCHANGED) SetChanged();
+ if (HIWORD(wParam) == CPN_COLOURCHANGED)
+ SetChanged();
break;
case IDC_MAXCUSTSMSZ:
case IDC_MINSMSZ:
- if (HIWORD(wParam) == EN_CHANGE && GetFocus() == (HWND)lParam) SetChanged();
+ if (HIWORD(wParam) == EN_CHANGE && GetFocus() == (HWND)lParam)
+ SetChanged();
break;
}
break;
@@ -207,11 +192,9 @@ BOOL OptionsDialogType::DialogProcedure(UINT msg, WPARAM wParam, LPARAM lParam)
break;
case WM_NOTIFY:
- switch(((LPNMHDR)lParam)->idFrom)
- {
+ switch(((LPNMHDR)lParam)->idFrom) {
case 0:
- switch (((LPNMHDR)lParam)->code)
- {
+ switch (((LPNMHDR)lParam)->code) {
case PSN_APPLY:
ApplyChanges();
break;
@@ -219,8 +202,7 @@ BOOL OptionsDialogType::DialogProcedure(UINT msg, WPARAM wParam, LPARAM lParam)
break;
case IDC_CATEGORYLIST:
- switch (((LPNMHDR)lParam)->code)
- {
+ switch (((LPNMHDR)lParam)->code) {
case NM_CLICK:
{
TVHITTESTINFO ht = {0};
@@ -244,14 +226,10 @@ BOOL OptionsDialogType::DialogProcedure(UINT msg, WPARAM wParam, LPARAM lParam)
case TVN_SELCHANGEDA:
case TVN_SELCHANGEDW:
- {
- LPNMTREEVIEW pnmtv = (LPNMTREEVIEW) lParam;
- if (pnmtv->itemNew.state & TVIS_SELECTED)
- UpdateControls();
- }
- break;
+ LPNMTREEVIEW pnmtv = (LPNMTREEVIEW) lParam;
+ if (pnmtv->itemNew.state & TVIS_SELECTED)
+ UpdateControls();
}
- break;
}
break;
}
@@ -259,7 +237,6 @@ BOOL OptionsDialogType::DialogProcedure(UINT msg, WPARAM wParam, LPARAM lParam)
return Result;
}
-
void OptionsDialogType::AddCategory(void)
{
TCHAR cat[30];
@@ -275,7 +252,6 @@ void OptionsDialogType::AddCategory(void)
}
}
-
void OptionsDialogType::UserAction(HTREEITEM hItem)
{
HWND hLstView = GetDlgItem(m_hwndDialog, IDC_CATEGORYLIST);
@@ -633,18 +609,15 @@ void OptionsType::ReadPackFileName(CMString& filename, const CMString& name, con
void OptionsType::WritePackFileName(const CMString& filename, const CMString& name)
{
CMString settingKey = name + _T("-filename");
- db_set_ts(NULL, "SmileyAdd", T2A_SM(settingKey.c_str()),
- filename.c_str());
+ db_set_ts(NULL, "SmileyAdd", T2A_SM(settingKey.c_str()), filename.c_str());
}
void OptionsType::ReadCustomCategories(CMString& cats)
{
DBVARIANT dbv;
-
INT_PTR res = db_get_ts(NULL, "SmileyAdd", "CustomCategories", &dbv);
- if (res == 0)
- {
+ if (res == 0) {
cats = dbv.ptszVal;
db_free(&dbv);
}
@@ -663,10 +636,8 @@ void OptionsType::WriteCustomCategories(const CMString& cats)
void OptionsType::ReadContactCategory(HANDLE hContact, CMString& cats)
{
DBVARIANT dbv;
-
INT_PTR res = db_get_ts(hContact, "SmileyAdd", "CustomCategory", &dbv);
- if (res == 0)
- {
+ if (res == 0) {
cats = dbv.ptszVal;
db_free(&dbv);
}
diff --git a/plugins/SmileyAdd/src/smltool.cpp b/plugins/SmileyAdd/src/smltool.cpp
index 314a833547..821a0bc3d9 100644
--- a/plugins/SmileyAdd/src/smltool.cpp
+++ b/plugins/SmileyAdd/src/smltool.cpp
@@ -74,20 +74,15 @@ public:
LRESULT CALLBACK DlgProcSmileyToolWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- SmileyToolWindowType* pOD;
- LRESULT Result;
-
- pOD = (SmileyToolWindowType*) GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ SmileyToolWindowType *pOD = (SmileyToolWindowType*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
if (pOD == NULL) {
pOD = new SmileyToolWindowType(hwndDlg);
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR) pOD);
}
- Result = pOD->DialogProcedure(msg, wParam, lParam);
- // SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, Result);
+ LRESULT Result = pOD->DialogProcedure(msg, wParam, lParam);
- if (msg == WM_NCDESTROY)
- {
+ if (msg == WM_NCDESTROY) {
delete pOD;
Result = FALSE;
}
@@ -117,8 +112,7 @@ LRESULT SmileyToolWindowType::DialogProcedure(UINT msg, WPARAM wParam, LPARAM lP
{
LRESULT Result = FALSE;
- switch (msg)
- {
+ switch (msg) {
case WM_ACTIVATE:
if (wParam == WA_INACTIVE)
DestroyWindow(m_hwndDialog);
@@ -192,17 +186,14 @@ void CALLBACK smileyServiceCallback(void* arg)
void SmileyToolWindowType::InsertSmiley(void)
{
- if (m_CurrentHotTrack >= 0 && m_hWndTarget != NULL)
- {
+ if (m_CurrentHotTrack >= 0 && m_hWndTarget != NULL) {
SmileyType *sml = m_pSmileyPack->GetSmiley(m_CurrentHotTrack);
- if (sml->IsService())
- {
+ if (sml->IsService()) {
smlsrvstruct* p = new smlsrvstruct(sml, m_hContact);
CallFunctionAsync(smileyServiceCallback, p);
}
- else
- {
+ else {
CMString insertText;
if (opt.SurroundSmileyWithSpaces) insertText = ' ';
@@ -220,8 +211,7 @@ void SmileyToolWindowType::InsertSmiley(void)
void SmileyToolWindowType::SmileySel(int but)
{
- if (but != m_CurrentHotTrack)
- {
+ if (but != m_CurrentHotTrack) {
SCROLLINFO si;
si.cbSize = sizeof (si);
si.fMask = SIF_POS;
@@ -229,16 +219,14 @@ void SmileyToolWindowType::SmileySel(int but)
GetScrollInfo (m_hwndDialog, SB_VERT, &si);
HDC hdc = GetDC(m_hwndDialog);
- if (m_CurrentHotTrack >= 0)
- {
+ if (m_CurrentHotTrack >= 0) {
RECT rect = CalculateButtonToCoordinates(m_CurrentHotTrack, si.nPos);
DrawFocusRect(hdc, &rect);
m_CurrentHotTrack = -1;
SendMessage(m_hToolTip, TTM_ACTIVATE, FALSE, 0);
}
m_CurrentHotTrack = but;
- if (m_CurrentHotTrack >= 0)
- {
+ if (m_CurrentHotTrack >= 0) {
TOOLINFO ti = {0};
ti.cbSize = sizeof(ti);
ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
@@ -268,44 +256,43 @@ void SmileyToolWindowType::ScrollV(int action, int dist)
// Save the position for comparison later on
int yPos = si.nPos;
- switch (action)
- {
- // user clicked the HOME keyboard key
+ switch (action) {
+ // user clicked the HOME keyboard key
case SB_TOP:
si.nPos = si.nMin;
break;
- // user clicked the END keyboard key
+ // user clicked the END keyboard key
case SB_BOTTOM:
si.nPos = si.nMax;
break;
- // user clicked the top arrow
+ // user clicked the top arrow
case SB_LINEUP:
si.nPos -= 1;
break;
- // user clicked the bottom arrow
+ // user clicked the bottom arrow
case SB_LINEDOWN:
si.nPos += 1;
break;
- // user clicked the scroll bar shaft above the scroll box
+ // user clicked the scroll bar shaft above the scroll box
case SB_PAGEUP:
si.nPos -= si.nPage;
break;
- // user clicked the scroll bar shaft below the scroll box
+ // user clicked the scroll bar shaft below the scroll box
case SB_PAGEDOWN:
si.nPos += si.nPage;
break;
- // user dragged the scroll box
+ // user dragged the scroll box
case SB_THUMBTRACK:
si.nPos = si.nTrackPos;
break;
- // user dragged the scroll box
+ // user dragged the scroll box
case SB_MYMOVE:
si.nPos += dist;
break;
@@ -316,9 +303,9 @@ void SmileyToolWindowType::ScrollV(int action, int dist)
SetScrollInfo (m_hwndDialog, SB_VERT, &si, TRUE);
GetScrollInfo (m_hwndDialog, SB_VERT, &si);
// If the position has changed, scroll window and update it
- if (si.nPos != yPos)
- {
- if (m_AniPack) m_AniPack->SetOffset(si.nPos*GetRowSize());
+ if (si.nPos != yPos) {
+ if (m_AniPack)
+ m_AniPack->SetOffset(si.nPos*GetRowSize());
ScrollWindowEx(m_hwndDialog, 0, (yPos - si.nPos) * GetRowSize(),
NULL, NULL, NULL, NULL, SW_INVALIDATE);
@@ -422,15 +409,12 @@ void SmileyToolWindowType::KeyUp(WPARAM wParam, LPARAM lParam)
return;
}
- if (numKey != -1)
- {
- if (rowSel == -1)
- {
+ if (numKey != -1) {
+ if (rowSel == -1) {
rowSel = numKey;
but = (opt.IEViewStyle ? m_NumberOfHorizontalButtons : 1) * rowSel;
}
- else
- {
+ else {
colSel = numKey;
if (opt.IEViewStyle)
but = colSel + m_NumberOfHorizontalButtons * rowSel;
@@ -443,7 +427,8 @@ void SmileyToolWindowType::KeyUp(WPARAM wParam, LPARAM lParam)
if (but >= (int)m_NumberOfButtons) but = m_NumberOfButtons-1;
SmileySel(but);
- if (colSel != -1) InsertSmiley();
+ if (colSel != -1)
+ InsertSmiley();
}
@@ -492,8 +477,7 @@ void SmileyToolWindowType::InitDialog(LPARAM lParam)
width = rc.right - rc.left;
height = rc.bottom - rc.top;
- switch (m_Direction)
- {
+ switch (m_Direction) {
case 1:
m_XPosition-=width;
break;
@@ -533,12 +517,9 @@ void SmileyToolWindowType::InitDialog(LPARAM lParam)
SmileyPackType::SmileyVectorType &sml = m_pSmileyPack->GetSmileyList();
for (unsigned i=0; i<m_NumberOfButtons; i++)
- {
if (!sml[i].IsHidden())
- {
m_AniPack->Add(&sml[i], CalculateButtonToCoordinates(i, 0), opt.IEViewStyle);
- }
- }
+
m_AniPack->SetOffset(0);
if (opt.AnimateSel) SetTimer(m_hwndDialog, 1, 100, NULL);
@@ -573,7 +554,8 @@ void SmileyToolWindowType::PaintWindow(void)
CreateSmileyBitmap(hdcMem);
- if (m_AniPack) m_AniPack->Draw(hdcMem);
+ if (m_AniPack)
+ m_AniPack->Draw(hdcMem);
BitBlt(hdc, 0, 0, m_BitmapWidth.cx, m_WindowSizeY, hdcMem, 0, 0, SRCCOPY);
@@ -581,7 +563,8 @@ void SmileyToolWindowType::PaintWindow(void)
DeleteObject(hBmp);
DeleteDC(hdcMem);
- if (m_CurrentHotTrack == -2) m_CurrentHotTrack = -1;
+ if (m_CurrentHotTrack == -2)
+ m_CurrentHotTrack = -1;
EndPaint(m_hwndDialog, &ps);
}