summaryrefslogtreecommitdiff
path: root/plugins/AVS/src/acc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/AVS/src/acc.cpp')
-rw-r--r--plugins/AVS/src/acc.cpp563
1 files changed, 247 insertions, 316 deletions
diff --git a/plugins/AVS/src/acc.cpp b/plugins/AVS/src/acc.cpp
index ea9a39e6fb..35551f2e0f 100644
--- a/plugins/AVS/src/acc.cpp
+++ b/plugins/AVS/src/acc.cpp
@@ -78,20 +78,18 @@ typedef struct
void ResizeFlash(HWND hwnd, ACCData* data)
{
- if ((data->hContact != NULL || data->proto[0] != '\0') && ServiceExists(MS_FAVATAR_RESIZE))
- {
+ if ((data->hContact != NULL || data->proto[0] != '\0') && ServiceExists(MS_FAVATAR_RESIZE)) {
RECT rc;
GetClientRect(hwnd, &rc);
- if (data->borderColor != -1 || data->avatarBorderColor != -1)
- {
- rc.left ++;
+ if (data->borderColor != -1 || data->avatarBorderColor != -1) {
+ rc.left++;
rc.right -= 2;
- rc.top ++;
+ rc.top++;
rc.bottom -= 2;
}
- FLASHAVATAR fa = {0};
+ FLASHAVATAR fa = { 0 };
fa.hContact = data->hContact;
fa.cProto = data->proto;
fa.hParentWindow = hwnd;
@@ -103,10 +101,8 @@ void ResizeFlash(HWND hwnd, ACCData* data)
void SetBkgFlash(HWND hwnd, ACCData* data)
{
- if ((data->hContact != NULL || data->proto[0] != '\0')
- && ServiceExists(MS_FAVATAR_SETBKCOLOR))
- {
- FLASHAVATAR fa = {0};
+ if ((data->hContact != NULL || data->proto[0] != '\0') && ServiceExists(MS_FAVATAR_SETBKCOLOR)) {
+ FLASHAVATAR fa = { 0 };
fa.hContact = data->hContact;
fa.cProto = data->proto;
fa.hParentWindow = hwnd;
@@ -115,7 +111,7 @@ void SetBkgFlash(HWND hwnd, ACCData* data)
if (data->bkgColor != -1)
CallService(MS_FAVATAR_SETBKCOLOR, (WPARAM)&fa, (LPARAM)data->bkgColor);
else
- CallService(MS_FAVATAR_SETBKCOLOR, (WPARAM)&fa, (LPARAM)RGB(255,255,255));
+ CallService(MS_FAVATAR_SETBKCOLOR, (WPARAM)&fa, (LPARAM)RGB(255, 255, 255));
}
}
@@ -124,9 +120,8 @@ void DestroyFlash(HWND hwnd, ACCData* data)
if (!data->showingFlash)
return;
- if ((data->hContact != NULL || data->proto[0] != '\0') && ServiceExists(MS_FAVATAR_DESTROY))
- {
- FLASHAVATAR fa = {0};
+ if ((data->hContact != NULL || data->proto[0] != '\0') && ServiceExists(MS_FAVATAR_DESTROY)) {
+ FLASHAVATAR fa = { 0 };
fa.hContact = data->hContact;
fa.cProto = data->proto;
fa.hParentWindow = hwnd;
@@ -143,17 +138,13 @@ void StartFlash(HWND hwnd, ACCData* data)
return;
int format;
- if (data->hContact != NULL)
- {
+ if (data->hContact != NULL) {
format = db_get_w(data->hContact, "ContactPhoto", "Format", 0);
}
- else if (data->proto[0] != '\0')
- {
+ else if (data->proto[0] != '\0') {
protoPicCacheEntry *ace = NULL;
- for (int i = 0; i < g_MyAvatars.getCount(); i++)
- {
- if (!lstrcmpA(data->proto, g_MyAvatars[i].szProtoname))
- {
+ for (int i = 0; i < g_MyAvatars.getCount(); i++) {
+ if (!lstrcmpA(data->proto, g_MyAvatars[i].szProtoname)) {
ace = &g_MyAvatars[i];
break;
}
@@ -164,13 +155,12 @@ void StartFlash(HWND hwnd, ACCData* data)
else
format = 0;
}
- else
- return;
+ else return;
if (format != PA_FORMAT_XML && format != PA_FORMAT_SWF)
return;
- FLASHAVATAR fa = {0};
+ FLASHAVATAR fa = { 0 };
fa.hContact = data->hContact;
fa.cProto = data->proto;
fa.hParentWindow = hwnd;
@@ -216,18 +206,14 @@ ERR:
return FALSE;
}
-void AnimatedGifDispodeFrame(ACCData* data)
+void AnimatedGifDispodeFrame(ACCData *data)
{
- if (data->ag.frame.disposal_method == GIF_DISPOSAL_PREVIOUS)
- {
+ if (data->ag.frame.disposal_method == GIF_DISPOSAL_PREVIOUS) {
// TODO
}
- else if (data->ag.frame.disposal_method == GIF_DISPOSAL_BACKGROUND)
- {
- for (int y = 0; y < data->ag.frame.height; y++)
- {
- RGBQUAD *scanline = (RGBQUAD *) fei->FI_GetScanLine(data->ag.dib,
- data->ag.logicalHeight - (y + data->ag.frame.top) - 1) + data->ag.frame.left;
+ else if (data->ag.frame.disposal_method == GIF_DISPOSAL_BACKGROUND) {
+ for (int y = 0; y < data->ag.frame.height; y++) {
+ RGBQUAD *scanline = (RGBQUAD*)fei->FI_GetScanLine(data->ag.dib, data->ag.logicalHeight - (y + data->ag.frame.top) - 1) + data->ag.frame.left;
for (int x = 0; x < data->ag.frame.width; x++)
*scanline++ = data->ag.background;
}
@@ -238,8 +224,7 @@ void AnimatedGifMountFrame(ACCData* data, int page)
{
data->ag.frame.num = page;
- if (data->ag.hbms[page] != NULL)
- {
+ if (data->ag.hbms[page] != NULL) {
data->ag.frame.disposal_method = GIF_DISPOSAL_LEAVE;
return;
}
@@ -269,20 +254,19 @@ void AnimatedGifMountFrame(ACCData* data, int page)
else
data->ag.frame.disposal_method = 0;
- data->ag.frame.width = fei->FI_GetWidth(dib);
+ data->ag.frame.width = fei->FI_GetWidth(dib);
data->ag.frame.height = fei->FI_GetHeight(dib);
-
//decode page
int palSize = fei->FI_GetColorsUsed(dib);
RGBQUAD *pal = fei->FI_GetPalette(dib);
bool have_transparent = false;
int transparent_color = -1;
- if ( fei->FI_IsTransparent(dib)) {
+ if (fei->FI_IsTransparent(dib)) {
int count = fei->FI_GetTransparencyCount(dib);
BYTE *table = fei->FI_GetTransparencyTable(dib);
- for ( int i = 0; i < count; i++ ) {
- if ( table[i] == 0 ) {
+ for (int i = 0; i < count; i++) {
+ if (table[i] == 0) {
have_transparent = true;
transparent_color = i;
break;
@@ -291,11 +275,11 @@ void AnimatedGifMountFrame(ACCData* data, int page)
}
//copy page data into logical buffer, with full alpha opaqueness
- for ( int y = 0; y < data->ag.frame.height; y++ ) {
- RGBQUAD *scanline = (RGBQUAD *)fei->FI_GetScanLine(data->ag.dib, data->ag.logicalHeight - (y + data->ag.frame.top) - 1) + data->ag.frame.left;
+ for (int y = 0; y < data->ag.frame.height; y++) {
+ RGBQUAD *scanline = (RGBQUAD*)fei->FI_GetScanLine(data->ag.dib, data->ag.logicalHeight - (y + data->ag.frame.top) - 1) + data->ag.frame.left;
BYTE *pageline = fei->FI_GetScanLine(dib, data->ag.frame.height - y - 1);
- for ( int x = 0; x < data->ag.frame.width; x++ ) {
- if ( !have_transparent || *pageline != transparent_color ) {
+ for (int x = 0; x < data->ag.frame.width; x++) {
+ if (!have_transparent || *pageline != transparent_color) {
*scanline = pal[*pageline];
scanline->rgbReserved = 255;
}
@@ -311,14 +295,12 @@ void AnimatedGifMountFrame(ACCData* data, int page)
void AnimatedGifDeleteTmpValues(ACCData* data)
{
- if (data->ag.multi != NULL)
- {
+ if (data->ag.multi != NULL) {
fei->FI_CloseMultiBitmap(data->ag.multi, 0);
data->ag.multi = NULL;
}
- if (data->ag.dib != NULL)
- {
+ if (data->ag.dib != NULL) {
fei->FI_Unload(data->ag.dib);
data->ag.dib = NULL;
}
@@ -331,8 +313,7 @@ void DestroyAnimatedGif(HWND hwnd, ACCData* data)
AnimatedGifDeleteTmpValues(data);
- if (data->ag.hbms != NULL)
- {
+ if (data->ag.hbms != NULL) {
for (int i = 0; i < data->ag.frameCount; i++)
if (data->ag.hbms[i] != NULL)
DeleteObject(data->ag.hbms[i]);
@@ -341,8 +322,7 @@ void DestroyAnimatedGif(HWND hwnd, ACCData* data)
data->ag.hbms = NULL;
}
- if (data->ag.times != NULL)
- {
+ if (data->ag.times != NULL) {
free(data->ag.times);
data->ag.times = NULL;
}
@@ -355,13 +335,11 @@ void StartAnimatedGif(HWND hwnd, ACCData* data)
if (fei == NULL)
return;
- int x, y;
AVATARCACHEENTRY *ace = NULL;
-
if (data->hContact != NULL)
- ace = (AVATARCACHEENTRY *) GetAvatarBitmap((WPARAM) data->hContact, 0);
+ ace = (AVATARCACHEENTRY*)GetAvatarBitmap(data->hContact, 0);
else
- ace = (AVATARCACHEENTRY *) GetMyAvatar(0, (LPARAM) data->proto);
+ ace = (AVATARCACHEENTRY*)GetMyAvatar(0, (LPARAM)data->proto);
if (ace == NULL)
return;
@@ -385,23 +363,22 @@ void StartAnimatedGif(HWND hwnd, ACCData* data)
if (!AnimatedGifGetData(data))
goto ERR;
- //allocate entire logical area
+ // allocate entire logical area
data->ag.dib = fei->FI_Allocate(data->ag.logicalWidth, data->ag.logicalHeight, 32, 0, 0, 0);
if (data->ag.dib == NULL)
goto ERR;
- //fill with background color to start
- for (y = 0; y < data->ag.logicalHeight; y++)
- {
- RGBQUAD *scanline = (RGBQUAD *) fei->FI_GetScanLine(data->ag.dib, y);
- for (x = 0; x < data->ag.logicalWidth; x++)
+ // fill with background color to start
+ for (int y = 0; y < data->ag.logicalHeight; y++) {
+ RGBQUAD *scanline = (RGBQUAD*)fei->FI_GetScanLine(data->ag.dib, y);
+ for (int x = 0; x < data->ag.logicalWidth; x++)
*scanline++ = data->ag.background;
}
- data->ag.hbms = (HBITMAP *) malloc(sizeof(HBITMAP) * data->ag.frameCount);
+ data->ag.hbms = (HBITMAP *)malloc(sizeof(HBITMAP) * data->ag.frameCount);
memset(data->ag.hbms, 0, sizeof(HBITMAP) * data->ag.frameCount);
- data->ag.times = (int *) malloc(sizeof(int) * data->ag.frameCount);
+ data->ag.times = (int *)malloc(sizeof(int) * data->ag.frameCount);
memset(data->ag.times, 0, sizeof(int) * data->ag.frameCount);
AnimatedGifMountFrame(data, 0);
@@ -430,21 +407,17 @@ void StartAnimation(HWND hwnd, ACCData* data)
BOOL ScreenToClient(HWND hWnd, LPRECT lpRect)
{
- BOOL ret;
-
POINT pt;
-
pt.x = lpRect->left;
pt.y = lpRect->top;
- ret = ScreenToClient(hWnd, &pt);
-
- if (!ret) return ret;
+ BOOL ret = ScreenToClient(hWnd, &pt);
+ if (!ret)
+ return ret;
lpRect->left = pt.x;
lpRect->top = pt.y;
-
pt.x = lpRect->right;
pt.y = lpRect->bottom;
@@ -452,15 +425,13 @@ BOOL ScreenToClient(HWND hWnd, LPRECT lpRect)
lpRect->right = pt.x;
lpRect->bottom = pt.y;
-
return ret;
}
static void Invalidate(HWND hwnd)
{
- ACCData* data = (ACCData *) GetWindowLongPtr(hwnd, 0);
- if (data->bkgColor == -1)
- {
+ ACCData *data = (ACCData*)GetWindowLongPtr(hwnd, 0);
+ if (data->bkgColor == -1) {
HWND parent = GetParent(hwnd);
RECT rc;
GetWindowRect(hwnd, &rc);
@@ -472,12 +443,12 @@ static void Invalidate(HWND hwnd)
static void NotifyAvatarChange(HWND hwnd)
{
- PSHNOTIFY pshn = {0};
+ PSHNOTIFY pshn = { 0 };
pshn.hdr.idFrom = GetDlgCtrlID(hwnd);
pshn.hdr.hwndFrom = hwnd;
pshn.hdr.code = NM_AVATAR_CHANGED;
pshn.lParam = 0;
- SendMessage(GetParent(hwnd), WM_NOTIFY, 0, (LPARAM) &pshn);
+ SendMessage(GetParent(hwnd), WM_NOTIFY, 0, (LPARAM)&pshn);
}
static void DrawText(HDC hdc, HFONT hFont, const RECT &rc, const TCHAR *text)
@@ -493,157 +464,141 @@ static void DrawText(HDC hdc, HFONT hFont, const RECT &rc, const TCHAR *text)
// Calc text size
RECT tr_ret = tr;
- DrawText(hdc, text, -1, &tr_ret,
- DT_WORDBREAK | DT_NOPREFIX | DT_CENTER | DT_CALCRECT);
+ DrawText(hdc, text, -1, &tr_ret, DT_WORDBREAK | DT_NOPREFIX | DT_CENTER | DT_CALCRECT);
// Calc needed size
tr.top += ((tr.bottom - tr.top) - (tr_ret.bottom - tr_ret.top)) / 2;
tr.bottom = tr.top + (tr_ret.bottom - tr_ret.top);
- DrawText(hdc, text, -1, &tr,
- DT_WORDBREAK | DT_NOPREFIX | DT_CENTER);
+ DrawText(hdc, text, -1, &tr, DT_WORDBREAK | DT_NOPREFIX | DT_CENTER);
SelectObject(hdc, oldFont);
}
-static LRESULT CALLBACK ACCWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
- ACCData* data = (ACCData *) GetWindowLongPtr(hwnd, 0);
- switch(msg)
- {
- case WM_NCCREATE:
- {
- SetWindowLongPtr(hwnd, GWL_STYLE, GetWindowLongPtr(hwnd, GWL_STYLE) | BS_OWNERDRAW);
- SetWindowLongPtr(hwnd, GWL_EXSTYLE, GetWindowLongPtr(hwnd, GWL_EXSTYLE) | WS_EX_TRANSPARENT);
-
- data = (ACCData*) mir_alloc(sizeof(ACCData));
- if (data == NULL)
- return FALSE;
- SetWindowLongPtr(hwnd, 0, (LONG_PTR)data);
-
- ZeroMemory(data, sizeof(ACCData));
- data->hHook = HookEventMessage(ME_AV_AVATARCHANGED, hwnd, DM_AVATARCHANGED);
- data->hHookMy = HookEventMessage(ME_AV_MYAVATARCHANGED, hwnd, DM_MYAVATARCHANGED);
- data->hFont = (HFONT) GetStockObject(DEFAULT_GUI_FONT);
- data->borderColor = -1;
- data->bkgColor = -1;
- data->avatarBorderColor = -1;
- data->respectHidden = TRUE;
- data->showingFlash = FALSE;
- data->resizeIfSmaller = TRUE;
- data->showingAnimatedGif = FALSE;
- data->fAero = FALSE;
-
- return TRUE;
- }
- case WM_NCDESTROY:
- {
- DestroyAnimation(hwnd, data);
- if (data)
- {
- UnhookEvent(data->hHook);
- UnhookEvent(data->hHookMy);
- mir_free(data);
- }
- SetWindowLongPtr(hwnd, 0, (LONG_PTR)NULL);
- break;
- }
- case WM_SETFONT:
- {
- data->hFont = (HFONT)wParam;
- Invalidate(hwnd);
- break;
+static LRESULT CALLBACK ACCWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ ACCData *data = (ACCData*)GetWindowLongPtr(hwnd, 0);
+
+ switch (msg) {
+ case WM_NCCREATE:
+ SetWindowLongPtr(hwnd, GWL_STYLE, GetWindowLongPtr(hwnd, GWL_STYLE) | BS_OWNERDRAW);
+ SetWindowLongPtr(hwnd, GWL_EXSTYLE, GetWindowLongPtr(hwnd, GWL_EXSTYLE) | WS_EX_TRANSPARENT);
+
+ data = (ACCData*)mir_alloc(sizeof(ACCData));
+ if (data == NULL)
+ return FALSE;
+ SetWindowLongPtr(hwnd, 0, (LONG_PTR)data);
+
+ ZeroMemory(data, sizeof(ACCData));
+ data->hHook = HookEventMessage(ME_AV_AVATARCHANGED, hwnd, DM_AVATARCHANGED);
+ data->hHookMy = HookEventMessage(ME_AV_MYAVATARCHANGED, hwnd, DM_MYAVATARCHANGED);
+ data->hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
+ data->borderColor = -1;
+ data->bkgColor = -1;
+ data->avatarBorderColor = -1;
+ data->respectHidden = TRUE;
+ data->showingFlash = FALSE;
+ data->resizeIfSmaller = TRUE;
+ data->showingAnimatedGif = FALSE;
+ data->fAero = FALSE;
+ return TRUE;
+
+ case WM_NCDESTROY:
+ DestroyAnimation(hwnd, data);
+ if (data) {
+ UnhookEvent(data->hHook);
+ UnhookEvent(data->hHookMy);
+ mir_free(data);
}
- case AVATAR_SETCONTACT:
- {
- DestroyAnimation(hwnd, data);
+ SetWindowLongPtr(hwnd, 0, (LONG_PTR)NULL);
+ break;
- data->hContact = lParam;
- if (lParam == NULL)
- data->proto[0] = '\0';
- else
- lstrcpynA(data->proto, GetContactProto(data->hContact), sizeof(data->proto));
+ case WM_SETFONT:
+ data->hFont = (HFONT)wParam;
+ Invalidate(hwnd);
+ break;
- StartAnimation(hwnd, data);
+ case AVATAR_SETCONTACT:
+ DestroyAnimation(hwnd, data);
- NotifyAvatarChange(hwnd);
- Invalidate(hwnd);
- return TRUE;
- }
- case AVATAR_SETPROTOCOL:
- {
- DestroyAnimation(hwnd, data);
-
- data->hContact = NULL;
- if (lParam == NULL)
- data->proto[0] = '\0';
- else
- lstrcpynA(data->proto, (char *) lParam, sizeof(data->proto));
+ data->hContact = lParam;
+ if (lParam == NULL)
+ data->proto[0] = '\0';
+ else
+ lstrcpynA(data->proto, GetContactProto(data->hContact), sizeof(data->proto));
- StartAnimation(hwnd, data);
+ StartAnimation(hwnd, data);
- NotifyAvatarChange(hwnd);
- Invalidate(hwnd);
- return TRUE;
- }
- case AVATAR_SETBKGCOLOR:
- {
- data->bkgColor = (COLORREF) lParam;
- if (data->showingFlash)
- SetBkgFlash(hwnd, data);
- NotifyAvatarChange(hwnd);
- Invalidate(hwnd);
- return TRUE;
- }
- case AVATAR_SETBORDERCOLOR:
- {
- data->borderColor = (COLORREF) lParam;
- if (data->showingFlash)
- ResizeFlash(hwnd, data);
- NotifyAvatarChange(hwnd);
- Invalidate(hwnd);
- return TRUE;
- }
- case AVATAR_SETAVATARBORDERCOLOR:
- {
- data->avatarBorderColor = (COLORREF) lParam;
- if (data->showingFlash)
- ResizeFlash(hwnd, data);
- NotifyAvatarChange(hwnd);
- Invalidate(hwnd);
- return TRUE;
- }
- case AVATAR_SETAVATARROUNDCORNERRADIUS:
- {
- data->avatarRoundCornerRadius = (int) lParam;
- NotifyAvatarChange(hwnd);
- Invalidate(hwnd);
- return TRUE;
- }
- case AVATAR_SETNOAVATARTEXT:
- {
- lstrcpyn(data->noAvatarText, TranslateTS((TCHAR*) lParam), SIZEOF(data->noAvatarText));
- Invalidate(hwnd);
- return TRUE;
- }
- case AVATAR_RESPECTHIDDEN:
- {
- data->respectHidden = (BOOL) lParam;
- NotifyAvatarChange(hwnd);
- Invalidate(hwnd);
- return TRUE;
- }
- case AVATAR_SETRESIZEIFSMALLER:
- {
- data->resizeIfSmaller = (BOOL) lParam;
- NotifyAvatarChange(hwnd);
- Invalidate(hwnd);
- return TRUE;
- }
+ NotifyAvatarChange(hwnd);
+ Invalidate(hwnd);
+ return TRUE;
- case AVATAR_SETAEROCOMPATDRAWING:
- data->fAero = lParam;
- return(TRUE);
+ case AVATAR_SETPROTOCOL:
+ DestroyAnimation(hwnd, data);
- case AVATAR_GETUSEDSPACE:
+ data->hContact = NULL;
+ if (lParam == NULL)
+ data->proto[0] = '\0';
+ else
+ lstrcpynA(data->proto, (char *)lParam, sizeof(data->proto));
+
+ StartAnimation(hwnd, data);
+
+ NotifyAvatarChange(hwnd);
+ Invalidate(hwnd);
+ return TRUE;
+
+ case AVATAR_SETBKGCOLOR:
+ data->bkgColor = (COLORREF)lParam;
+ if (data->showingFlash)
+ SetBkgFlash(hwnd, data);
+ NotifyAvatarChange(hwnd);
+ Invalidate(hwnd);
+ return TRUE;
+
+ case AVATAR_SETBORDERCOLOR:
+ data->borderColor = (COLORREF)lParam;
+ if (data->showingFlash)
+ ResizeFlash(hwnd, data);
+ NotifyAvatarChange(hwnd);
+ Invalidate(hwnd);
+ return TRUE;
+
+ case AVATAR_SETAVATARBORDERCOLOR:
+ data->avatarBorderColor = (COLORREF)lParam;
+ if (data->showingFlash)
+ ResizeFlash(hwnd, data);
+ NotifyAvatarChange(hwnd);
+ Invalidate(hwnd);
+ return TRUE;
+
+ case AVATAR_SETAVATARROUNDCORNERRADIUS:
+ data->avatarRoundCornerRadius = (int)lParam;
+ NotifyAvatarChange(hwnd);
+ Invalidate(hwnd);
+ return TRUE;
+
+ case AVATAR_SETNOAVATARTEXT:
+ lstrcpyn(data->noAvatarText, TranslateTS((TCHAR*)lParam), SIZEOF(data->noAvatarText));
+ Invalidate(hwnd);
+ return TRUE;
+
+ case AVATAR_RESPECTHIDDEN:
+ data->respectHidden = (BOOL)lParam;
+ NotifyAvatarChange(hwnd);
+ Invalidate(hwnd);
+ return TRUE;
+
+ case AVATAR_SETRESIZEIFSMALLER:
+ data->resizeIfSmaller = (BOOL)lParam;
+ NotifyAvatarChange(hwnd);
+ Invalidate(hwnd);
+ return TRUE;
+
+ case AVATAR_SETAEROCOMPATDRAWING:
+ data->fAero = lParam;
+ return(TRUE);
+
+ case AVATAR_GETUSEDSPACE:
{
int *width = (int *)wParam;
int *height = (int *)lParam;
@@ -652,16 +607,14 @@ static LRESULT CALLBACK ACCWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
GetClientRect(hwnd, &rc);
// Get avatar
- if (data->showingFlash && ServiceExists(MS_FAVATAR_GETINFO))
- {
- FLASHAVATAR fa = {0};
+ if (data->showingFlash && ServiceExists(MS_FAVATAR_GETINFO)) {
+ FLASHAVATAR fa = { 0 };
fa.hContact = data->hContact;
fa.cProto = data->proto;
fa.hParentWindow = hwnd;
fa.id = 1675;
CallService(MS_FAVATAR_GETINFO, (WPARAM)&fa, 0);
- if (fa.hWindow != NULL)
- {
+ if (fa.hWindow != NULL) {
*width = rc.right - rc.left;
*height = rc.bottom - rc.top;
return TRUE;
@@ -670,13 +623,12 @@ static LRESULT CALLBACK ACCWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
avatarCacheEntry *ace;
if (data->hContact == NULL)
- ace = (avatarCacheEntry *) CallService(MS_AV_GETMYAVATAR, 0, (LPARAM) data->proto);
+ ace = (avatarCacheEntry *)CallService(MS_AV_GETMYAVATAR, 0, (LPARAM)data->proto);
else
- ace = (avatarCacheEntry *) CallService(MS_AV_GETAVATARBITMAP, (WPARAM) data->hContact, 0);
+ ace = (avatarCacheEntry *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)data->hContact, 0);
if (ace == NULL || ace->bmHeight == 0 || ace->bmWidth == 0
- || (data->respectHidden && (ace->dwFlags & AVS_HIDEONCLIST)))
- {
+ || (data->respectHidden && (ace->dwFlags & AVS_HIDEONCLIST))) {
*width = 0;
*height = 0;
return TRUE;
@@ -686,52 +638,45 @@ static LRESULT CALLBACK ACCWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
int targetWidth = rc.right - rc.left;
int targetHeight = rc.bottom - rc.top;
- if (!data->resizeIfSmaller && ace->bmHeight <= targetHeight && ace->bmWidth <= targetWidth)
- {
+ if (!data->resizeIfSmaller && ace->bmHeight <= targetHeight && ace->bmWidth <= targetWidth) {
*height = ace->bmHeight;
*width = ace->bmWidth;
}
- else if (ace->bmHeight > ace->bmWidth)
- {
+ else if (ace->bmHeight > ace->bmWidth) {
float dScale = targetHeight / (float)ace->bmHeight;
*height = targetHeight;
- *width = (int) (ace->bmWidth * dScale);
+ *width = (int)(ace->bmWidth * dScale);
}
- else
- {
+ else {
float dScale = targetWidth / (float)ace->bmWidth;
- *height = (int) (ace->bmHeight * dScale);
+ *height = (int)(ace->bmHeight * dScale);
*width = targetWidth;
}
-
- return TRUE;
}
- case DM_AVATARCHANGED:
- {
- if (data->hContact == wParam)
- {
- DestroyAnimation(hwnd, data);
- StartAnimation(hwnd, data);
+ return TRUE;
- NotifyAvatarChange(hwnd);
- Invalidate(hwnd);
- }
- break;
+ case DM_AVATARCHANGED:
+ if (data->hContact == wParam) {
+ DestroyAnimation(hwnd, data);
+ StartAnimation(hwnd, data);
+
+ NotifyAvatarChange(hwnd);
+ Invalidate(hwnd);
}
- case DM_MYAVATARCHANGED:
- {
- if (data->hContact == NULL && strcmp(data->proto, (char*) wParam) == 0)
- {
- DestroyAnimation(hwnd, data);
- StartAnimation(hwnd, data);
+ break;
- NotifyAvatarChange(hwnd);
- Invalidate(hwnd);
- }
- break;
+ case DM_MYAVATARCHANGED:
+ if (data->hContact == NULL && strcmp(data->proto, (char*)wParam) == 0) {
+ DestroyAnimation(hwnd, data);
+ StartAnimation(hwnd, data);
+
+ NotifyAvatarChange(hwnd);
+ Invalidate(hwnd);
}
- case WM_NCPAINT:
- case WM_PAINT:
+ break;
+
+ case WM_NCPAINT:
+ case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwnd, &ps);
@@ -745,27 +690,23 @@ static LRESULT CALLBACK ACCWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
GetClientRect(hwnd, &rc);
// Draw background
- if (data->bkgColor != -1)
- {
+ if (data->bkgColor != -1) {
HBRUSH hbrush = CreateSolidBrush(data->bkgColor);
FillRect(hdc, &rc, hbrush);
DeleteObject(hbrush);
}
if (data->hContact == NULL && data->proto[0] == '\0'
- && db_get_b(NULL, AVS_MODULE, "GlobalUserAvatarNotConsistent", 1))
- {
+ && db_get_b(NULL, AVS_MODULE, "GlobalUserAvatarNotConsistent", 1)) {
DrawText(hdc, data->hFont, rc, TranslateT("Protocols have different avatars"));
}
// Has a flash avatar
- else if (data->showingFlash)
- {
+ else if (data->showingFlash) {
// Don't draw
// Draw control border if needed
- if (data->borderColor == -1 && data->avatarBorderColor != -1)
- {
+ if (data->borderColor == -1 && data->avatarBorderColor != -1) {
HBRUSH hbrush = CreateSolidBrush(data->avatarBorderColor);
FrameRect(hdc, &rc, hbrush);
DeleteObject(hbrush);
@@ -774,10 +715,9 @@ static LRESULT CALLBACK ACCWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
// Has an animated gif
// Has a "normal" image
- else
- {
+ else {
// Draw avatar
- AVATARDRAWREQUEST avdrq = {0};
+ AVATARDRAWREQUEST avdrq = { 0 };
avdrq.cbSize = sizeof(avdrq);
avdrq.rcDraw = rc;
avdrq.hContact = data->hContact;
@@ -794,13 +734,11 @@ static LRESULT CALLBACK ACCWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
avdrq.radius = data->avatarRoundCornerRadius;
INT_PTR ret;
- if (data->showingAnimatedGif)
- {
+ if (data->showingAnimatedGif) {
InternalDrawAvatar(&avdrq, data->ag.hbms[data->ag.frame.num], data->ag.logicalWidth, data->ag.logicalHeight, 0);
ret = 1;
- if (!data->ag.started)
- {
+ if (!data->ag.started) {
SetTimer(hwnd, 0, data->ag.times[data->ag.frame.num], NULL);
data->ag.started = TRUE;
}
@@ -813,8 +751,7 @@ static LRESULT CALLBACK ACCWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
}
// Draw control border
- if (data->borderColor != -1)
- {
+ if (data->borderColor != -1) {
HBRUSH hbrush = CreateSolidBrush(data->borderColor);
FrameRect(hdc, &rc, hbrush);
DeleteObject(hbrush);
@@ -823,79 +760,73 @@ static LRESULT CALLBACK ACCWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
SetBkMode(hdc, oldBkMode);
EndPaint(hwnd, &ps);
- return TRUE;
}
- case WM_ERASEBKGND:
+ return TRUE;
+
+ case WM_ERASEBKGND:
{
- HDC hdc = (HDC) wParam;
+ HDC hdc = (HDC)wParam;
RECT rc;
GetClientRect(hwnd, &rc);
// Draw background
- if (data->bkgColor != -1)
- {
+ if (data->bkgColor != -1) {
HBRUSH hbrush = CreateSolidBrush(data->bkgColor);
FillRect(hdc, &rc, hbrush);
DeleteObject(hbrush);
}
// Draw control border
- if (data->borderColor != -1)
- {
+ if (data->borderColor != -1) {
HBRUSH hbrush = CreateSolidBrush(data->borderColor);
FrameRect(hdc, &rc, hbrush);
DeleteObject(hbrush);
}
-
- return TRUE;
}
- case WM_SIZE:
- {
- if (data->showingFlash)
- ResizeFlash(hwnd, data);
- InvalidateRect(hwnd, NULL, TRUE);
- break;
- }
- case WM_TIMER:
- {
- if (wParam != 0)
- break;
- KillTimer(hwnd, 0);
+ return TRUE;
- if (!data->showingAnimatedGif)
- break;
+ case WM_SIZE:
+ if (data->showingFlash)
+ ResizeFlash(hwnd, data);
+ InvalidateRect(hwnd, NULL, TRUE);
+ break;
- AnimatedGifDispodeFrame(data);
+ case WM_TIMER:
+ if (wParam != 0)
+ break;
+ KillTimer(hwnd, 0);
- int frame = data->ag.frame.num + 1;
- if (frame >= data->ag.frameCount)
- {
- // Don't need fi data no more
- AnimatedGifDeleteTmpValues(data);
- frame = 0;
- }
- AnimatedGifMountFrame(data, frame);
+ if (!data->showingAnimatedGif)
+ break;
- data->ag.started = FALSE;
- InvalidateRect(hwnd, NULL, FALSE);
+ AnimatedGifDispodeFrame(data);
- break;
+ int frame = data->ag.frame.num + 1;
+ if (frame >= data->ag.frameCount) {
+ // Don't need fi data no more
+ AnimatedGifDeleteTmpValues(data);
+ frame = 0;
}
+ AnimatedGifMountFrame(data, frame);
+
+ data->ag.started = FALSE;
+ InvalidateRect(hwnd, NULL, FALSE);
+
+ break;
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}
-
int LoadACC()
{
- WNDCLASSEX wc = {0};
- wc.cbSize = sizeof(wc);
- wc.lpszClassName = AVATAR_CONTROL_CLASS;
- wc.lpfnWndProc = ACCWndProc;
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);
- wc.cbWndExtra = sizeof(ACCData*);
- wc.hbrBackground = 0;
- wc.style = CS_GLOBALCLASS;
+ WNDCLASSEX wc = { 0 };
+ wc.cbSize = sizeof(wc);
+ wc.lpszClassName = AVATAR_CONTROL_CLASS;
+ wc.lpfnWndProc = ACCWndProc;
+ wc.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wc.cbWndExtra = sizeof(ACCData*);
+ wc.hbrBackground = 0;
+ wc.style = CS_GLOBALCLASS;
RegisterClassEx(&wc);
return 0;
}