summaryrefslogtreecommitdiff
path: root/plugins/FavContacts
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-07-07 13:18:55 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-07-07 13:18:55 +0000
commit198f78183833d6f9c7256286c23acda597575c2a (patch)
treed99d62d2b619b62333fce496a093e1bddf9e7162 /plugins/FavContacts
parentbf7e27ebc315e2663f6f271e9e631c724ad64082 (diff)
FavContacts:
- MCONTACTs sometimes were drawn as groups; - code cleaning; git-svn-id: http://svn.miranda-ng.org/main/trunk@9722 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/FavContacts')
-rw-r--r--plugins/FavContacts/src/Version.h16
-rw-r--r--plugins/FavContacts/src/contact_cache.cpp129
-rw-r--r--plugins/FavContacts/src/contact_cache.h23
-rw-r--r--plugins/FavContacts/src/main.cpp311
4 files changed, 220 insertions, 259 deletions
diff --git a/plugins/FavContacts/src/Version.h b/plugins/FavContacts/src/Version.h
index dcb7975f45..6a8c822637 100644
--- a/plugins/FavContacts/src/Version.h
+++ b/plugins/FavContacts/src/Version.h
@@ -1,14 +1,14 @@
-#define __MAJOR_VERSION 0
-#define __MINOR_VERSION 0
-#define __RELEASE_NUM 0
-#define __BUILD_NUM 7
+#define __MAJOR_VERSION 0
+#define __MINOR_VERSION 1
+#define __RELEASE_NUM 0
+#define __BUILD_NUM 1
#include <stdver.h>
-#define __PLUGIN_NAME "Favorite contacts"
-#define __FILENAME "FavContacts.dll"
+#define __PLUGIN_NAME "Favorite contacts"
+#define __FILENAME "FavContacts.dll"
#define __DESCRIPTION "Favorite contacts menu."
-#define __AUTHOR "Victor Pavlychko"
-#define __AUTHOREMAIL "nullbie@gmail.com"
+#define __AUTHOR "Victor Pavlychko"
+#define __AUTHOREMAIL "nullbie@gmail.com"
#define __AUTHORWEB "http://miranda-ng.org/p/FavContacts/"
#define __COPYRIGHT "© 2007-2009 Victor Pavlychko"
diff --git a/plugins/FavContacts/src/contact_cache.cpp b/plugins/FavContacts/src/contact_cache.cpp
index 2ba319b59a..bda23904e2 100644
--- a/plugins/FavContacts/src/contact_cache.cpp
+++ b/plugins/FavContacts/src/contact_cache.cpp
@@ -1,43 +1,65 @@
#include "headers.h"
+static int CompareItem(const CContactCache::TContactInfo *p1, const CContactCache::TContactInfo *p2)
+{
+ if (p1->rate > p2->rate) return -1;
+ if (p1->rate < p2->rate) return 1;
+ return 0;
+}
+
+CContactCache::CContactCache() :
+ m_cache(50, CompareItem)
+{
+ InitializeCriticalSection(&m_cs);
+
+ int(__cdecl CContactCache::*pfn)(WPARAM, LPARAM);
+ pfn = &CContactCache::OnDbEventAdded;
+ HookEventObj(ME_DB_EVENT_ADDED, *(MIRANDAHOOKOBJ *)&pfn, this);
+
+ Rebuild();
+}
+
+CContactCache::~CContactCache()
+{
+ for (int i = 0; i < m_cache.getCount(); i++)
+ delete m_cache[i];
+
+ DeleteCriticalSection(&m_cs);
+}
+
int __cdecl CContactCache::OnDbEventAdded(WPARAM hContact, LPARAM lParam)
{
HANDLE hEvent = (HANDLE)lParam;
- DBEVENTINFO dbei = {0};
- dbei.cbSize = sizeof(dbei);
+ DBEVENTINFO dbei = { sizeof(dbei) };
db_event_get(hEvent, &dbei);
- if (dbei.eventType != EVENTTYPE_MESSAGE) return 0;
+ if (dbei.eventType != EVENTTYPE_MESSAGE)
+ return 0;
float weight = GetEventWeight(time(NULL) - dbei.timestamp);
float q = GetTimeWeight(time(NULL) - m_lastUpdate);
m_lastUpdate = time(NULL);
- if (!weight) return 0;
-
- Lock();
- bool found = false;
- for (int i = 0; i < m_cache.getCount(); ++i)
- {
- m_cache[i].rate *= q;
- if (m_cache[i].hContact == hContact)
- {
- found = true;
- m_cache[i].rate += weight;
+ if (!weight)
+ return 0;
+
+ TContactInfo *pFound = NULL;
+ mir_cslock lck(m_cs);
+ for (int i = m_cache.getCount()-1; i >= 0; i--) {
+ TContactInfo *p = m_cache[i];
+ p->rate *= q;
+ if (p->hContact == hContact) {
+ p->rate += weight;
+ pFound = p;
+ m_cache.remove(i); // reinsert to maintain the sort order
}
}
- if (!found)
- {
- TContactInfo *info = new TContactInfo;
- info->hContact = hContact;
- info->rate = weight;
- m_cache.insert(info);
- } else
- {
- qsort(m_cache.getArray(), m_cache.getCount(), sizeof(TContactInfo *), TContactInfo::cmp2);
+ if (!pFound) {
+ pFound = new TContactInfo;
+ pFound->hContact = hContact;
+ pFound->rate = weight;
}
-
- Unlock();
+ m_cache.insert(pFound);
return 0;
}
@@ -59,22 +81,6 @@ float CContactCache::GetTimeWeight(unsigned long age)
return exp(age * (log(ceil) - log(floor)) / depth);
}
-CContactCache::CContactCache(): m_cache(50, TContactInfo::cmp)
-{
- InitializeCriticalSection(&m_cs);
-
- int (__cdecl CContactCache::*pfn)(WPARAM, LPARAM);
- pfn = &CContactCache::OnDbEventAdded;
- HookEventObj(ME_DB_EVENT_ADDED, *(MIRANDAHOOKOBJ *)&pfn, this);
-
- Rebuild();
-}
-
-CContactCache::~CContactCache()
-{
- DeleteCriticalSection(&m_cs);
-}
-
void CContactCache::Rebuild()
{
unsigned long timestamp = time(NULL);
@@ -88,8 +94,7 @@ void CContactCache::Rebuild()
for (HANDLE hEvent = db_event_last(hContact); hEvent; hEvent = db_event_prev(hContact, hEvent)) {
DBEVENTINFO dbei = { sizeof(dbei) };
if (!db_event_get(hEvent, &dbei)) {
- if (float weight = GetEventWeight(timestamp - dbei.timestamp))
- {
+ if (float weight = GetEventWeight(timestamp - dbei.timestamp)) {
if (dbei.eventType == EVENTTYPE_MESSAGE)
info->rate += weight;
}
@@ -104,32 +109,29 @@ void CContactCache::Rebuild()
MCONTACT CContactCache::get(int rate)
{
if (rate >= 0 && rate < m_cache.getCount())
- return m_cache[rate].hContact;
+ return m_cache[rate]->hContact;
return NULL;
}
float CContactCache::getWeight(int rate)
{
if (rate >= 0 && rate < m_cache.getCount())
- return m_cache[rate].rate;
+ return m_cache[rate]->rate;
return -1;
}
static bool AppendInfo(TCHAR *buf, int size, MCONTACT hContact, int info)
{
- CONTACTINFO ci = {0};
+ CONTACTINFO ci = { 0 };
ci.cbSize = sizeof(ci);
ci.hContact = hContact;
ci.dwFlag = info;
ci.dwFlag |= CNF_UNICODE;
-
bool ret = false;
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci) && (ci.type == CNFT_ASCIIZ) && ci.pszVal)
- {
- if (*ci.pszVal && (lstrlen(ci.pszVal) < size-2))
- {
+ if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci) && (ci.type == CNFT_ASCIIZ) && ci.pszVal) {
+ if (*ci.pszVal && (lstrlen(ci.pszVal) < size - 2)) {
lstrcpy(buf, ci.pszVal);
ret = true;
}
@@ -147,16 +149,15 @@ void CContactCache::TContactInfo::LoadInfo()
p[0] = p[1] = 0;
static const int items[] = {
- CNF_FIRSTNAME, CNF_LASTNAME, CNF_NICK , CNF_CUSTOMNICK, CNF_EMAIL, CNF_CITY, CNF_STATE,
+ CNF_FIRSTNAME, CNF_LASTNAME, CNF_NICK, CNF_CUSTOMNICK, CNF_EMAIL, CNF_CITY, CNF_STATE,
CNF_COUNTRY, CNF_PHONE, CNF_HOMEPAGE, CNF_ABOUT, CNF_UNIQUEID, CNF_MYNOTES, CNF_STREET,
CNF_CONAME, CNF_CODEPT, CNF_COCITY, CNF_COSTATE, CNF_COSTREET, CNF_COCOUNTRY
};
for (int i = 0; i < SIZEOF(items); ++i)
- {
if (AppendInfo(p, SIZEOF(info) - (p - info), hContact, items[i]))
p += lstrlen(p) + 1;
- }
+
*p = 0;
infoLoaded = true;
@@ -173,7 +174,7 @@ TCHAR *nb_stristr(TCHAR *str, TCHAR *substr)
CharUpperBuff(str_up, lstrlen(str_up));
CharUpperBuff(substr_up, lstrlen(substr_up));
- TCHAR* p = _tcsstr(str_up, substr_up);
+ TCHAR *p = _tcsstr(str_up, substr_up);
return p ? (str + (p - str_up)) : NULL;
}
@@ -181,33 +182,29 @@ bool CContactCache::filter(int rate, TCHAR *str)
{
if (!str || !*str)
return true;
- m_cache[rate].LoadInfo();
+ m_cache[rate]->LoadInfo();
HKL kbdLayoutActive = GetKeyboardLayout(GetCurrentThreadId());
HKL kbdLayouts[10];
int nKbdLayouts = GetKeyboardLayoutList(SIZEOF(kbdLayouts), kbdLayouts);
TCHAR buf[256];
- BYTE keyState[256] = {0};
+ BYTE keyState[256] = { 0 };
- for (int iLayout = 0; iLayout < nKbdLayouts; ++iLayout)
- {
+ for (int iLayout = 0; iLayout < nKbdLayouts; ++iLayout) {
if (kbdLayoutActive == kbdLayouts[iLayout])
- {
lstrcpy(buf, str);
- } else
- {
+ else {
int i;
- for (i = 0; str[i]; ++i)
- {
+ for (i = 0; str[i]; ++i) {
UINT vk = VkKeyScanEx(str[i], kbdLayoutActive);
UINT scan = MapVirtualKeyEx(vk, 0, kbdLayoutActive);
- ToUnicodeEx(vk, scan, keyState, buf+i, SIZEOF(buf)-i, 0, kbdLayouts[iLayout]);
+ ToUnicodeEx(vk, scan, keyState, buf + i, SIZEOF(buf) - i, 0, kbdLayouts[iLayout]);
}
buf[i] = 0;
}
- for (TCHAR *p = m_cache[rate].info; p && *p; p = p + lstrlen(p) + 1)
+ for (TCHAR *p = m_cache[rate]->info; p && *p; p = p + lstrlen(p) + 1)
if (nb_stristr(p, buf))
return true;
}
diff --git a/plugins/FavContacts/src/contact_cache.h b/plugins/FavContacts/src/contact_cache.h
index b3ad95e027..dceba2b967 100644
--- a/plugins/FavContacts/src/contact_cache.h
+++ b/plugins/FavContacts/src/contact_cache.h
@@ -6,27 +6,13 @@ class CContactCache
public:
enum { INFOSIZE = 1024 };
-private:
-
struct TContactInfo
{
MCONTACT hContact;
float rate;
- TCHAR info[INFOSIZE];
bool infoLoaded;
-
- static int cmp(const TContactInfo *p1, const TContactInfo *p2)
- {
- if (p1->rate > p2->rate) return -1;
- if (p1->rate < p2->rate) return 1;
- return 0;
- }
-
- static int cmp2(const void *a1, const void *a2)
- {
- return cmp(*(const TContactInfo **)a1, *(const TContactInfo **)a2);
- }
-
+ TCHAR info[INFOSIZE];
+
TContactInfo()
{
info[0] = info[1] = 0;
@@ -36,7 +22,8 @@ private:
void LoadInfo();
};
- OBJLIST<TContactInfo> m_cache;
+private:
+ LIST<TContactInfo> m_cache;
unsigned long m_lastUpdate;
CRITICAL_SECTION m_cs;
@@ -48,8 +35,6 @@ public:
CContactCache();
~CContactCache();
- void Lock() { EnterCriticalSection(&m_cs); }
- void Unlock() { LeaveCriticalSection(&m_cs); }
void Rebuild();
MCONTACT get(int rate);
diff --git a/plugins/FavContacts/src/main.cpp b/plugins/FavContacts/src/main.cpp
index 9bf93c4acf..2521f730c6 100644
--- a/plugins/FavContacts/src/main.cpp
+++ b/plugins/FavContacts/src/main.cpp
@@ -40,10 +40,10 @@ PLUGININFOEX pluginInfo = {
{0xce2c0401, 0xf9e0, 0x40d7, {0x8e, 0x95, 0x1a, 0x41, 0x97, 0xd7, 0xab, 0x4}}
};
-static IconItem iconList[] =
+static IconItem iconList[] =
{
{ LPGEN("Favorite Contact"), "favcontacts_favorite", IDI_FAVORITE },
- { LPGEN("Regular Contact"), "favcontacts_regular", IDI_REGULAR },
+ { LPGEN("Regular Contact"), "favcontacts_regular", IDI_REGULAR },
};
#define MS_FAVCONTACTS_SHOWMENU "FavContacts/ShowMenu"
@@ -70,9 +70,9 @@ float g_widthMultiplier = 0;
UINT g_maxItemWidth = 0;
CContactCache *g_contactCache = NULL;
-TCHAR g_filter[1024] = {0};
+TCHAR g_filter[1024] = { 0 };
-Options g_Options = {0};
+Options g_Options = { 0 };
static HANDLE hDialogsList = NULL;
static MCONTACT hContactToActivate = NULL;
@@ -91,14 +91,9 @@ extern "C" __declspec(dllexport) PLUGININFOEX *MirandaPluginInfoEx(DWORD miranda
static __forceinline COLORREF sttShadeColor(COLORREF clLine1, COLORREF clBack)
{
return RGB(
- (GetRValue(clLine1) * 66UL + GetRValue(clBack) * 34UL) / 100,
- (GetGValue(clLine1) * 66UL + GetGValue(clBack) * 34UL) / 100,
- (GetBValue(clLine1) * 66UL + GetBValue(clBack) * 34UL) / 100);
-}
-
-static bool sttIsGroup(int id)
-{
- return (id == 1) ? true : (pcli->pfnGetGroupName(id-1, NULL) != NULL);
+ (GetRValue(clLine1) * 66UL + GetRValue(clBack) * 34UL) / 100,
+ (GetGValue(clLine1) * 66UL + GetGValue(clBack) * 34UL) / 100,
+ (GetBValue(clLine1) * 66UL + GetBValue(clBack) * 34UL) / 100);
}
static TCHAR* sttGetGroupName(int id)
@@ -109,7 +104,7 @@ static TCHAR* sttGetGroupName(int id)
return TranslateT("Favorite Contacts");
}
- return pcli->pfnGetGroupName(id-1, NULL);
+ return pcli->pfnGetGroupName(id - 1, NULL);
}
int ProcessTBLoaded(WPARAM wParam, LPARAM lParam)
@@ -128,11 +123,9 @@ int ProcessReloadFonts(WPARAM wParam, LPARAM lParam)
if (g_Options.hfntName) DeleteObject(g_Options.hfntName);
if (g_Options.hfntSecond) DeleteObject(g_Options.hfntSecond);
- LOGFONT lf = {0};
- FontIDT fontid = {0};
- fontid.cbSize = sizeof(fontid);
+ LOGFONT lf = { 0 };
+ FontIDT fontid = { sizeof(fontid) };
lstrcpy(fontid.group, LPGENT("Favorite Contacts"));
-
lstrcpy(fontid.name, LPGENT("Contact name"));
g_Options.clLine1 = CallService(MS_FONT_GETT, (WPARAM)&fontid, (LPARAM)&lf);
g_Options.hfntName = CreateFontIndirect(&lf);
@@ -147,10 +140,8 @@ int ProcessReloadFonts(WPARAM wParam, LPARAM lParam)
lstrcpy(fontid.name, LPGENT("Selected second line (color)"));
g_Options.clLine2Sel = CallService(MS_FONT_GETT, (WPARAM)&fontid, (LPARAM)&lf);
- ColourIDT colourid = {0};
- colourid.cbSize = sizeof(colourid);
+ ColourIDT colourid = { sizeof(colourid) };
lstrcpy(colourid.group, LPGENT("Favorite Contacts"));
-
lstrcpy(colourid.name, LPGENT("Background"));
g_Options.clBack = CallService(MS_COLOUR_GETT, (WPARAM)&colourid, (LPARAM)&lf);
@@ -176,8 +167,7 @@ int ProcessModulesLoaded(WPARAM wParam, LPARAM lParam)
/////////////////////////////////////////////////////////////////////////////////////
- FontIDT fontid = {0};
- fontid.cbSize = sizeof(fontid);
+ FontIDT fontid = { sizeof(fontid) };
lstrcpy(fontid.group, LPGENT("Favorite Contacts"));
lstrcpyA(fontid.dbSettingsGroup, "FavContacts");
lstrcpy(fontid.backgroundGroup, LPGENT("Favorite Contacts"));
@@ -217,8 +207,7 @@ int ProcessModulesLoaded(WPARAM wParam, LPARAM lParam)
/////////////////////////////////////////////////////////////////////////////////////
- ColourIDT colourid = {0};
- colourid.cbSize = sizeof(colourid);
+ ColourIDT colourid = { sizeof(colourid) };
lstrcpy(colourid.group, LPGENT("Favorite Contacts"));
lstrcpyA(colourid.dbSettingsGroup, "FavContacts");
@@ -238,8 +227,7 @@ int ProcessModulesLoaded(WPARAM wParam, LPARAM lParam)
/////////////////////////////////////////////////////////////////////////////////////
- HOTKEYDESC hotkey = {0};
- hotkey.cbSize = sizeof(hotkey);
+ HOTKEYDESC hotkey = { sizeof(hotkey) };
hotkey.pszName = "FavContacts/ShowMenu";
hotkey.pszDescription = LPGEN("Show favorite contacts");
hotkey.pszSection = "Contacts";
@@ -289,7 +277,7 @@ extern "C" __declspec(dllexport) int Load(void)
RegisterClassEx(&wcl);
g_hwndMenuHost = CreateWindow(_T("FavContactsMenuHostWnd"), NULL, 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP, NULL, g_hInst, NULL);
- SetWindowPos(g_hwndMenuHost, 0, 0, 0, 0, 0, SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE|SWP_DEFERERASE|SWP_NOSENDCHANGING|SWP_HIDEWINDOW);
+ SetWindowPos(g_hwndMenuHost, 0, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_DEFERERASE | SWP_NOSENDCHANGING | SWP_HIDEWINDOW);
sttLoadOptions();
@@ -307,14 +295,14 @@ extern "C" __declspec(dllexport) int Load(void)
LoadHttpApi();
- #ifdef _DEBUG
- CLISTMENUITEM mi = { sizeof(mi) };
- mi.icolibItem = LoadSkinnedIconHandle(SKINICON_OTHER_OPTIONS);
- mi.position = 1900000000;
- mi.pszName = LPGEN("&Favorite Contacts...");
- mi.pszService = MS_FAVCONTACTS_SHOWMENU;
- Menu_AddMainMenuItem(&mi);
- #endif
+#ifdef _DEBUG
+ CLISTMENUITEM mi = { sizeof(mi) };
+ mi.icolibItem = LoadSkinnedIconHandle(SKINICON_OTHER_OPTIONS);
+ mi.position = 1900000000;
+ mi.pszName = LPGEN("&Favorite Contacts...");
+ mi.pszService = MS_FAVCONTACTS_SHOWMENU;
+ Menu_AddMainMenuItem(&mi);
+#endif
return 0;
}
@@ -333,42 +321,41 @@ extern "C" __declspec(dllexport) int Unload(void)
static void sttLoadOptions()
{
- g_Options.bSecondLine = db_get_b(NULL, "FavContacts", "SecondLine", 1);
- g_Options.bAvatars = db_get_b(NULL, "FavContacts", "Avatars", 1);
- g_Options.bAvatarBorder = db_get_b(NULL, "FavContacts", "AvatarBorder", 0);
- g_Options.wAvatarRadius = db_get_w(NULL, "FavContacts", "AvatarRadius", 3);
- g_Options.bNoTransparentBorder = db_get_b(NULL, "FavContacts", "NoTransparentBorder",
- !db_get_b(NULL, "FavContacts", "AvatarBorderTransparent", 1));
- g_Options.bSysColors = db_get_b(NULL, "FavContacts", "SysColors", 0);
- g_Options.bCenterHotkey = db_get_b(NULL, "FavContacts", "CenterHotkey", 1);
- g_Options.bUseGroups = db_get_b(NULL, "FavContacts", "UseGroups", 0);
- g_Options.bUseColumns = db_get_b(NULL, "FavContacts", "UseColumns", 1);
- g_Options.bRightAvatars = db_get_b(NULL, "FavContacts", "RightAvatars", 0);
- g_Options.bDimIdle = db_get_b(NULL, "FavContacts", "DimIdle", 1);
-
- g_Options.wMaxRecent = db_get_b(NULL, "FavContacts", "MaxRecent", 10);
+ g_Options.bSecondLine = db_get_b(NULL, "FavContacts", "SecondLine", 1);
+ g_Options.bAvatars = db_get_b(NULL, "FavContacts", "Avatars", 1);
+ g_Options.bAvatarBorder = db_get_b(NULL, "FavContacts", "AvatarBorder", 0);
+ g_Options.wAvatarRadius = db_get_w(NULL, "FavContacts", "AvatarRadius", 3);
+ g_Options.bNoTransparentBorder = db_get_b(NULL, "FavContacts", "NoTransparentBorder",
+ !db_get_b(NULL, "FavContacts", "AvatarBorderTransparent", 1));
+ g_Options.bSysColors = db_get_b(NULL, "FavContacts", "SysColors", 0);
+ g_Options.bCenterHotkey = db_get_b(NULL, "FavContacts", "CenterHotkey", 1);
+ g_Options.bUseGroups = db_get_b(NULL, "FavContacts", "UseGroups", 0);
+ g_Options.bUseColumns = db_get_b(NULL, "FavContacts", "UseColumns", 1);
+ g_Options.bRightAvatars = db_get_b(NULL, "FavContacts", "RightAvatars", 0);
+ g_Options.bDimIdle = db_get_b(NULL, "FavContacts", "DimIdle", 1);
+
+ g_Options.wMaxRecent = db_get_b(NULL, "FavContacts", "MaxRecent", 10);
}
static void sttSaveOptions()
{
- db_set_b(NULL, "FavContacts", "SecondLine", g_Options.bSecondLine);
- db_set_b(NULL, "FavContacts", "Avatars", g_Options.bAvatars);
- db_set_b(NULL, "FavContacts", "AvatarBorder", g_Options.bAvatarBorder);
- db_set_w(NULL, "FavContacts", "AvatarRadius", g_Options.wAvatarRadius);
- db_set_b(NULL, "FavContacts", "NoTransparentBorder", g_Options.bNoTransparentBorder);
- db_set_b(NULL, "FavContacts", "SysColors", g_Options.bSysColors);
- db_set_b(NULL, "FavContacts", "CenterHotkey", g_Options.bCenterHotkey);
- db_set_b(NULL, "FavContacts", "UseGroups", g_Options.bUseGroups);
- db_set_b(NULL, "FavContacts", "UseColumns", g_Options.bUseColumns);
- db_set_b(NULL, "FavContacts", "RightAvatars", g_Options.bRightAvatars);
- db_set_b(NULL, "FavContacts", "DimIdle", g_Options.bDimIdle);
- db_set_w(NULL, "FavContacts", "MaxRecent", g_Options.wMaxRecent);
+ db_set_b(NULL, "FavContacts", "SecondLine", g_Options.bSecondLine);
+ db_set_b(NULL, "FavContacts", "Avatars", g_Options.bAvatars);
+ db_set_b(NULL, "FavContacts", "AvatarBorder", g_Options.bAvatarBorder);
+ db_set_w(NULL, "FavContacts", "AvatarRadius", g_Options.wAvatarRadius);
+ db_set_b(NULL, "FavContacts", "NoTransparentBorder", g_Options.bNoTransparentBorder);
+ db_set_b(NULL, "FavContacts", "SysColors", g_Options.bSysColors);
+ db_set_b(NULL, "FavContacts", "CenterHotkey", g_Options.bCenterHotkey);
+ db_set_b(NULL, "FavContacts", "UseGroups", g_Options.bUseGroups);
+ db_set_b(NULL, "FavContacts", "UseColumns", g_Options.bUseColumns);
+ db_set_b(NULL, "FavContacts", "RightAvatars", g_Options.bRightAvatars);
+ db_set_b(NULL, "FavContacts", "DimIdle", g_Options.bDimIdle);
+ db_set_w(NULL, "FavContacts", "MaxRecent", g_Options.wMaxRecent);
}
static BOOL sttMeasureItem_Group(LPMEASUREITEMSTRUCT lpmis, Options *options)
{
- if (true)
- {
+ if (true) {
HDC hdc = GetDC(g_hwndMenuHost);
HFONT hfntSave = (HFONT)SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT));
TCHAR *name = sttGetGroupName(lpmis->itemData);
@@ -390,23 +377,20 @@ static BOOL sttMeasureItem_Contact(LPMEASUREITEMSTRUCT lpmis, Options *options)
MCONTACT hContact = (MCONTACT)lpmis->itemData;
lpmis->itemHeight = 4;
- lpmis->itemWidth = 8+10;
+ lpmis->itemWidth = 8 + 10;
- if (true)
- {
+ if (true) {
lpmis->itemWidth += 20;
}
- if (true)
- {
+ if (true) {
SIZE sz;
int textWidth = 0;
HDC hdc = GetDC(g_hwndMenuHost);
HFONT hfntSave = (HFONT)SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT));
- if (options->bSecondLine)
- {
+ if (options->bSecondLine) {
DBVARIANT dbv;
TCHAR *title;
bool bFree = false;
@@ -440,11 +424,9 @@ static BOOL sttMeasureItem_Contact(LPMEASUREITEMSTRUCT lpmis, Options *options)
lpmis->itemHeight += sz.cy;
}
- if (options->bAvatars)
- {
+ if (options->bAvatars) {
AVATARCACHEENTRY *ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, hContact, 0);
- if (ace && (ace != (AVATARCACHEENTRY *)CALLSERVICE_NOTFOUND))
- {
+ if (ace && (ace != (AVATARCACHEENTRY *)CALLSERVICE_NOTFOUND)) {
int avatarWidth = lpmis->itemHeight;
if (ace->bmWidth < ace->bmHeight)
avatarWidth = lpmis->itemHeight * ace->bmWidth / ace->bmHeight;
@@ -458,7 +440,7 @@ static BOOL sttMeasureItem_Contact(LPMEASUREITEMSTRUCT lpmis, Options *options)
return TRUE;
}
-static BOOL sttMeasureItem(LPMEASUREITEMSTRUCT lpmis, Options *options=NULL)
+static BOOL sttMeasureItem(LPMEASUREITEMSTRUCT lpmis, Options *options = NULL)
{
if (!options) options = &g_Options;
@@ -466,7 +448,7 @@ static BOOL sttMeasureItem(LPMEASUREITEMSTRUCT lpmis, Options *options=NULL)
return FALSE;
BOOL res = FALSE;
- if (sttIsGroup(lpmis->itemData))
+ if (lpmis->itemData == 1)
res = sttMeasureItem_Group(lpmis, options);
else if (CallService(MS_DB_CONTACT_IS, lpmis->itemData, 0))
res = sttMeasureItem_Contact(lpmis, options);
@@ -498,7 +480,7 @@ static BOOL sttDrawItem_Group(LPDRAWITEMSTRUCT lpdis, Options *options = NULL)
TCHAR *name = sttGetGroupName(lpdis->itemData);
if (!options->bSysColors)
SelectObject(lpdis->hDC, g_Options.hfntName);
- DrawText(lpdis->hDC, name, lstrlen(name), &lpdis->rcItem, DT_NOPREFIX|DT_SINGLELINE|DT_VCENTER|DT_CENTER);
+ DrawText(lpdis->hDC, name, lstrlen(name), &lpdis->rcItem, DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER | DT_CENTER);
SelectObject(lpdis->hDC, hfntSave);
@@ -515,7 +497,7 @@ void ImageList_DrawDimmed(HIMAGELIST himl, int i, HDC hdc, int left, int top, UI
HBITMAP hbmOld = (HBITMAP)SelectObject(dcMem, hbm);
BitBlt(dcMem, 0, 0, dx, dx, hdc, left, top, SRCCOPY);
ImageList_Draw(himl, i, dcMem, 0, 0, fStyle);
- BLENDFUNCTION bf = {0};
+ BLENDFUNCTION bf = { 0 };
bf.SourceConstantAlpha = 180;
GdiAlphaBlend(hdc, left, top, dx, dy, dcMem, 0, 0, dx, dy, bf);
SelectObject(dcMem, hbmOld);
@@ -528,8 +510,8 @@ static BOOL sttDrawItem_Contact(LPDRAWITEMSTRUCT lpdis, Options *options = NULL)
MCONTACT hContact = (MCONTACT)lpdis->itemData;
HDC hdcTemp = CreateCompatibleDC(lpdis->hDC);
- HBITMAP hbmTemp = CreateCompatibleBitmap(lpdis->hDC, lpdis->rcItem.right-lpdis->rcItem.left, lpdis->rcItem.bottom-lpdis->rcItem.top);
- HBITMAP hbmSave = (HBITMAP)SelectObject(hdcTemp, hbmTemp);
+ HBITMAP hbmTemp = CreateCompatibleBitmap(lpdis->hDC, lpdis->rcItem.right - lpdis->rcItem.left, lpdis->rcItem.bottom - lpdis->rcItem.top);
+ HBITMAP hbmSave = (HBITMAP)SelectObject(hdcTemp, hbmTemp);
RECT rcSave = lpdis->rcItem;
OffsetRect(&lpdis->rcItem, -lpdis->rcItem.left, -lpdis->rcItem.top);
@@ -563,9 +545,9 @@ static BOOL sttDrawItem_Contact(LPDRAWITEMSTRUCT lpdis, Options *options = NULL)
}
if (options->bSysColors) {
clLine2 = RGB(
- (GetRValue(clLine1) * 66UL + GetRValue(clBack) * 34UL) / 100,
- (GetGValue(clLine1) * 66UL + GetGValue(clBack) * 34UL) / 100,
- (GetBValue(clLine1) * 66UL + GetBValue(clBack) * 34UL) / 100);
+ (GetRValue(clLine1) * 66UL + GetRValue(clBack) * 34UL) / 100,
+ (GetGValue(clLine1) * 66UL + GetGValue(clBack) * 34UL) / 100,
+ (GetBValue(clLine1) * 66UL + GetBValue(clBack) * 34UL) / 100);
}
else {
HBRUSH hbr = CreateSolidBrush(clBack);
@@ -586,20 +568,20 @@ static BOOL sttDrawItem_Contact(LPDRAWITEMSTRUCT lpdis, Options *options = NULL)
if (db_get_dw(hContact, proto, "IdleTS", 0)) {
ImageList_DrawDimmed(hIml, iIcon, hdcTemp,
- lpdis->rcItem.left, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2,
- ILD_TRANSPARENT);
+ lpdis->rcItem.left, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2,
+ ILD_TRANSPARENT);
}
else {
ImageList_Draw(hIml, iIcon, hdcTemp,
- lpdis->rcItem.left, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2,
- ILD_TRANSPARENT);
+ lpdis->rcItem.left, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2,
+ ILD_TRANSPARENT);
}
lpdis->rcItem.left += 20;
if (options->wMaxRecent && db_get_b(hContact, "FavContacts", "IsFavourite", 0)) {
DrawIconEx(hdcTemp, lpdis->rcItem.right - 18, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2,
- Skin_GetIconByHandle(iconList[0].hIcolib), 16, 16, 0, NULL, DI_NORMAL);
+ Skin_GetIconByHandle(iconList[0].hIcolib), 16, 16, 0, NULL, DI_NORMAL);
lpdis->rcItem.right -= 20;
}
@@ -610,7 +592,7 @@ static BOOL sttDrawItem_Contact(LPDRAWITEMSTRUCT lpdis, Options *options = NULL)
if (ace->bmWidth < ace->bmHeight)
avatarWidth = (lpdis->rcItem.bottom - lpdis->rcItem.top) * ace->bmWidth / ace->bmHeight;
- AVATARDRAWREQUEST avdr = {0};
+ AVATARDRAWREQUEST avdr = { 0 };
avdr.cbSize = sizeof(avdr);
avdr.hContact = hContact;
avdr.hTargetDC = hdcTemp;
@@ -645,7 +627,7 @@ static BOOL sttDrawItem_Contact(LPDRAWITEMSTRUCT lpdis, Options *options = NULL)
if (!options->bSysColors) SelectObject(hdcTemp, g_Options.hfntName);
SetTextColor(hdcTemp, clLine1);
- DrawText(hdcTemp, name, lstrlen(name), &lpdis->rcItem, DT_NOPREFIX|DT_SINGLELINE|DT_TOP|DT_LEFT);
+ DrawText(hdcTemp, name, lstrlen(name), &lpdis->rcItem, DT_NOPREFIX | DT_SINGLELINE | DT_TOP | DT_LEFT);
SIZE sz; GetTextExtentPoint32(hdcTemp, name, lstrlen(name), &sz);
lpdis->rcItem.top += sz.cy + 3;
@@ -666,7 +648,7 @@ static BOOL sttDrawItem_Contact(LPDRAWITEMSTRUCT lpdis, Options *options = NULL)
if (!options->bSysColors) SelectObject(hdcTemp, g_Options.hfntSecond);
SetTextColor(hdcTemp, clLine2);
- DrawText(hdcTemp, title, lstrlen(title), &lpdis->rcItem, DT_NOPREFIX|DT_SINGLELINE|DT_TOP|DT_LEFT);
+ DrawText(hdcTemp, title, lstrlen(title), &lpdis->rcItem, DT_NOPREFIX | DT_SINGLELINE | DT_TOP | DT_LEFT);
if (bFree) db_free(&dbv);
}
@@ -674,25 +656,25 @@ static BOOL sttDrawItem_Contact(LPDRAWITEMSTRUCT lpdis, Options *options = NULL)
SelectObject(hdcTemp, hfntSave);
BitBlt(lpdis->hDC,
- rcSave.left, rcSave.top,
- rcSave.right-rcSave.left, rcSave.bottom-rcSave.top,
- hdcTemp, 0, 0, SRCCOPY);
+ rcSave.left, rcSave.top,
+ rcSave.right - rcSave.left, rcSave.bottom - rcSave.top,
+ hdcTemp, 0, 0, SRCCOPY);
- SelectObject(hdcTemp, hbmSave);
- DeleteObject(hbmTemp);
- DeleteDC(hdcTemp);
+ SelectObject(hdcTemp, hbmSave);
+ DeleteObject(hbmTemp);
+ DeleteDC(hdcTemp);
return TRUE;
}
-static BOOL sttDrawItem(LPDRAWITEMSTRUCT lpdis, Options *options=NULL)
+static BOOL sttDrawItem(LPDRAWITEMSTRUCT lpdis, Options *options = NULL)
{
if (!options) options = &g_Options;
if (!lpdis->itemData)
return FALSE;
- if (sttIsGroup(lpdis->itemData))
+ if (lpdis->itemData == 1)
return sttDrawItem_Group(lpdis, options);
if (CallService(MS_DB_CONTACT_IS, lpdis->itemData, 0))
@@ -709,8 +691,8 @@ static LRESULT CALLBACK MenuHostWndProc(HWND hwnd, UINT message, WPARAM wParam,
case WM_MEASUREITEM:
{
LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT)lParam;
-
- if (lpmis->CtlType != ODT_MENU) return FALSE;
+ if (lpmis->CtlType != ODT_MENU)
+ return FALSE;
if ((lpmis->itemID >= CLISTMENUIDMIN) && (lpmis->itemID <= CLISTMENUIDMAX))
return CallService(MS_CLIST_MENUMEASUREITEM, wParam, lParam);
@@ -721,8 +703,8 @@ static LRESULT CALLBACK MenuHostWndProc(HWND hwnd, UINT message, WPARAM wParam,
case WM_DRAWITEM:
{
LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
-
- if (lpdis->CtlType != ODT_MENU) return FALSE;
+ if (lpdis->CtlType != ODT_MENU)
+ return FALSE;
if ((lpdis->itemID >= CLISTMENUIDMIN) && (lpdis->itemID <= CLISTMENUIDMAX))
return CallService(MS_CLIST_MENUDRAWITEM, wParam, lParam);
@@ -731,55 +713,52 @@ static LRESULT CALLBACK MenuHostWndProc(HWND hwnd, UINT message, WPARAM wParam,
}
case WM_MENUCHAR:
- {
- while (GetMenuItemCount((HMENU)lParam) > 1)
- RemoveMenu((HMENU)lParam, 1, MF_BYPOSITION);
+ while (GetMenuItemCount((HMENU)lParam) > 1)
+ RemoveMenu((HMENU)lParam, 1, MF_BYPOSITION);
- if (LOWORD(wParam) == VK_BACK) {
- if (int l = lstrlen(g_filter))
- g_filter[l-1] = 0;
- }
- else if (_istalnum(LOWORD(wParam))) {
- if (lstrlen(g_filter) < SIZEOF(g_filter)-1) {
- TCHAR s[] = { LOWORD(wParam), 0 };
- lstrcat(g_filter, s);
- }
+ if (LOWORD(wParam) == VK_BACK) {
+ if (int l = lstrlen(g_filter))
+ g_filter[l - 1] = 0;
+ }
+ else if (_istalnum(LOWORD(wParam))) {
+ if (lstrlen(g_filter) < SIZEOF(g_filter) - 1) {
+ TCHAR s[] = { LOWORD(wParam), 0 };
+ lstrcat(g_filter, s);
}
-
- int nRecent = 0;
+ }
+ {
int maxRecent = g_Options.wMaxRecent ? g_Options.wMaxRecent : 10;
- for (int i = 0; nRecent < maxRecent; ++i) {
+ for (int i = 0, nRecent = 0; nRecent < maxRecent; ++i) {
MCONTACT hContact = g_contactCache->get(i);
if (!hContact) break;
if (!g_contactCache->filter(i, g_filter)) continue;
- AppendMenu((HMENU)lParam, MF_OWNERDRAW, nRecent+1, (LPCTSTR)hContact);
+ AppendMenu((HMENU)lParam, MF_OWNERDRAW, nRecent + 1, (LPCTSTR)hContact);
++nRecent;
}
- return MAKELRESULT(1, MNC_SELECT);
}
+ return MAKELRESULT(1, MNC_SELECT);
case WM_MENURBUTTONUP:
- {
- MENUITEMINFO mii = { sizeof(mii) };
- mii.fMask = MIIM_DATA;
- GetMenuItemInfo((HMENU)lParam, wParam, TRUE, &mii);
- MCONTACT hContact = (MCONTACT)mii.dwItemData;
- if (!CallService(MS_DB_CONTACT_IS, mii.dwItemData, 0)) return FALSE;
-
- HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, hContact, 0);
-
- POINT pt;
- GetCursorPos(&pt);
- HWND hwndSave = GetForegroundWindow();
- SetForegroundWindow(g_hwndMenuHost);
- int res = TrackPopupMenu(hMenu, TPM_RECURSE|TPM_RIGHTBUTTON|TPM_RETURNCMD, pt.x, pt.y, 0, g_hwndMenuHost, NULL);
- SetForegroundWindow(hwndSave);
- DestroyMenu(hMenu);
-
- CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(res, MPCF_CONTACTMENU), hContact);
- return TRUE;
- }
+ MENUITEMINFO mii = { sizeof(mii) };
+ mii.fMask = MIIM_DATA;
+ GetMenuItemInfo((HMENU)lParam, wParam, TRUE, &mii);
+ MCONTACT hContact = (MCONTACT)mii.dwItemData;
+ if (!CallService(MS_DB_CONTACT_IS, mii.dwItemData, 0))
+ return FALSE;
+
+ HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, hContact, 0);
+
+ POINT pt;
+ GetCursorPos(&pt);
+ HWND hwndSave = GetForegroundWindow();
+ SetForegroundWindow(g_hwndMenuHost);
+ int res = TrackPopupMenu(hMenu, TPM_RECURSE | TPM_RIGHTBUTTON | TPM_RETURNCMD, pt.x, pt.y, 0, g_hwndMenuHost, NULL);
+ SetForegroundWindow(hwndSave);
+ DestroyMenu(hMenu);
+
+ CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(res, MPCF_CONTACTMENU), hContact);
+ return TRUE;
}
return DefWindowProc(hwnd, message, wParam, lParam);
@@ -789,8 +768,8 @@ int sttShowMenu(bool centered)
{
TFavContacts favList;
HMENU hMenu = CreatePopupMenu();
- SIZE szMenu = {0};
- SIZE szColumn = {0};
+ SIZE szMenu = { 0 };
+ SIZE szColumn = { 0 };
TCHAR *prevGroup = NULL;
int i, idItem = 100;
MCONTACT hContact;
@@ -806,7 +785,7 @@ int sttShowMenu(bool centered)
for (i = 0; i < favList.getCount(); ++i) {
hContact = favList[i]->getHandle();
- MEASUREITEMSTRUCT mis = {0};
+ MEASUREITEMSTRUCT mis = { 0 };
mis.CtlID = 0;
mis.CtlType = ODT_MENU;
@@ -817,11 +796,11 @@ int sttShowMenu(bool centered)
szColumn.cx = szColumn.cy = 0;
}
- DWORD groupID = (DWORD)Clist_GroupExists(favList[i]->getGroup())+1;
+ DWORD groupID = (DWORD)Clist_GroupExists(favList[i]->getGroup()) + 1;
AppendMenu(hMenu,
- MF_OWNERDRAW|MF_SEPARATOR| ((prevGroup && g_Options.bUseColumns) ? MF_MENUBREAK : 0),
- ++idItem, (LPCTSTR)groupID);
+ MF_OWNERDRAW | MF_SEPARATOR | ((prevGroup && g_Options.bUseColumns) ? MF_MENUBREAK : 0),
+ ++idItem, (LPCTSTR)groupID);
mis.itemData = groupID;
mis.itemID = idItem;
@@ -863,7 +842,7 @@ int sttShowMenu(bool centered)
g_filter[0] = 0;
if (int res = TrackPopupMenu(hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, g_hwndMenuHost, NULL)) {
- MENUITEMINFO mii = {0};
+ MENUITEMINFO mii = { 0 };
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_DATA;
GetMenuItemInfo(hMenu, res, FALSE, &mii);
@@ -897,12 +876,12 @@ INT_PTR svcOpenContact(WPARAM wParam, LPARAM lParam)
return 0;
}
-int ProcessSrmmEvent( WPARAM wParam, LPARAM lParam )
+int ProcessSrmmEvent(WPARAM wParam, LPARAM lParam)
{
MessageWindowEventData *event = (MessageWindowEventData *)lParam;
if (event->uType == MSG_WINDOW_EVT_OPEN) {
- if ( !hDialogsList )
+ if (!hDialogsList)
hDialogsList = WindowList_Create();
WindowList_Add(hDialogsList, event->hwndWindow, event->hContact);
@@ -926,8 +905,7 @@ int ProcessSrmmEvent( WPARAM wParam, LPARAM lParam )
hContactToActivate = NULL;
}
- else if ( event->uType == MSG_WINDOW_EVT_CLOSING )
- {
+ else if (event->uType == MSG_WINDOW_EVT_CLOSING) {
if (hDialogsList)
WindowList_Remove(hDialogsList, event->hwndWindow);
}
@@ -958,17 +936,18 @@ int ProcessSrmmIconClick(WPARAM hContact, LPARAM lParam)
return 0;
}
-///////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////
// Options
+
static void sttResetListOptions(HWND hwndList)
{
- SendMessage(hwndList,CLM_SETBKBITMAP,0,(LPARAM)(HBITMAP)NULL);
- SendMessage(hwndList,CLM_SETBKCOLOR,GetSysColor(COLOR_WINDOW),0);
- SendMessage(hwndList,CLM_SETGREYOUTFLAGS,0,0);
- SendMessage(hwndList,CLM_SETLEFTMARGIN,4,0);
- SendMessage(hwndList,CLM_SETINDENT,10,0);
- SendMessage(hwndList,CLM_SETHIDEEMPTYGROUPS,1,0);
- SendMessage(hwndList,CLM_SETHIDEOFFLINEROOT,1,0);
+ SendMessage(hwndList, CLM_SETBKBITMAP, 0, (LPARAM)(HBITMAP)NULL);
+ SendMessage(hwndList, CLM_SETBKCOLOR, GetSysColor(COLOR_WINDOW), 0);
+ SendMessage(hwndList, CLM_SETGREYOUTFLAGS, 0, 0);
+ SendMessage(hwndList, CLM_SETLEFTMARGIN, 4, 0);
+ SendMessage(hwndList, CLM_SETINDENT, 10, 0);
+ SendMessage(hwndList, CLM_SETHIDEEMPTYGROUPS, 1, 0);
+ SendMessage(hwndList, CLM_SETHIDEOFFLINEROOT, 1, 0);
for (int i = 0; i <= FONTID_MAX; ++i)
SendMessage(hwndList, CLM_SETTEXTCOLOR, i, GetSysColor(COLOR_WINDOWTEXT));
}
@@ -998,8 +977,8 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA
SetDlgItemInt(hwnd, IDC_TXT_MAXRECENT, g_Options.wMaxRecent, FALSE);
SetWindowLongPtr(GetDlgItem(hwnd, IDC_CLIST), GWL_STYLE,
- GetWindowLongPtr(GetDlgItem(hwnd, IDC_CLIST), GWL_STYLE)|CLS_CHECKBOXES|CLS_HIDEEMPTYGROUPS|CLS_USEGROUPS|CLS_GREYALTERNATE|CLS_GROUPCHECKBOXES);
- SendMessage(GetDlgItem(hwnd, IDC_CLIST), CLM_SETEXSTYLE, CLS_EX_DISABLEDRAGDROP|CLS_EX_TRACKSELECT, 0);
+ GetWindowLongPtr(GetDlgItem(hwnd, IDC_CLIST), GWL_STYLE) | CLS_CHECKBOXES | CLS_HIDEEMPTYGROUPS | CLS_USEGROUPS | CLS_GREYALTERNATE | CLS_GROUPCHECKBOXES);
+ SendMessage(GetDlgItem(hwnd, IDC_CLIST), CLM_SETEXSTYLE, CLS_EX_DISABLEDRAGDROP | CLS_EX_TRACKSELECT, 0);
sttResetListOptions(GetDlgItem(hwnd, IDC_CLIST));
hSelectedContact = db_find_first();
@@ -1032,7 +1011,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA
{
LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
if (lpdis->CtlID == IDC_CANVAS) {
- MEASUREITEMSTRUCT mis = {0};
+ MEASUREITEMSTRUCT mis = { 0 };
DRAWITEMSTRUCT dis = *lpdis;
FillRect(lpdis->hDC, &lpdis->rcItem, GetSysColorBrush(COLOR_BTNFACE));
@@ -1128,7 +1107,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA
for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
BYTE fav = SendDlgItemMessage(hwnd, IDC_CLIST, CLM_GETCHECKMARK,
- SendDlgItemMessage(hwnd, IDC_CLIST, CLM_FINDCONTACT, hContact, 0), 0);
+ SendDlgItemMessage(hwnd, IDC_CLIST, CLM_FINDCONTACT, hContact, 0), 0);
if (fav != db_get_b(hContact, "FavContacts", "IsFavourite", 0))
db_set_b(hContact, "FavContacts", "IsFavourite", fav);
if (fav) CallService(MS_AV_GETAVATARBITMAP, hContact, 0);
@@ -1139,15 +1118,15 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA
switch (((LPNMHDR)lParam)->code) {
case CLN_OPTIONSCHANGED:
- sttResetListOptions(GetDlgItem(hwnd,IDC_CLIST));
+ sttResetListOptions(GetDlgItem(hwnd, IDC_CLIST));
break;
case CLN_NEWCONTACT:
iSelection = (int)((NMCLISTCONTROL *)lParam)->hItem;
for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if (SendDlgItemMessage(hwnd, IDC_CLIST, CLM_FINDCONTACT, hContact, 0) == iSelection) {
- SendDlgItemMessage(hwnd, IDC_CLIST, CLM_SETCHECKMARK, iSelection,
- db_get_b(hContact, "FavContacts", "IsFavourite", 0));
+ SendDlgItemMessage(hwnd, IDC_CLIST, CLM_SETCHECKMARK, iSelection,
+ db_get_b(hContact, "FavContacts", "IsFavourite", 0));
break;
}
}