summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-03-26 12:18:23 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-03-26 12:18:23 +0000
commit3c64ecdc3c3b3957de35482b337a3785e68fcb21 (patch)
tree63952e12739d09379d44f276034d65bd2fc2743a /src/core
parent7aba633c5009dce7a4214f348ef2841b3e5d34a2 (diff)
removed clutch in StdMsg to publish SIZEOF(fontOptionsList)
git-svn-id: http://svn.miranda-ng.org/main/trunk@4198 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/core')
-rw-r--r--src/core/stdmsg/src/msgdialog.cpp2
-rw-r--r--src/core/stdmsg/src/msglog.cpp11
-rw-r--r--src/core/stdmsg/src/msgoptions.cpp38
-rw-r--r--src/core/stdmsg/src/msgs.cpp42
-rw-r--r--src/core/stdmsg/src/msgs.h3
5 files changed, 40 insertions, 56 deletions
diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp
index 9293591a58..b078aa10aa 100644
--- a/src/core/stdmsg/src/msgdialog.cpp
+++ b/src/core/stdmsg/src/msgdialog.cpp
@@ -874,7 +874,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
UpdateReadChars(hwndDlg, dat->hwndStatus);
PostMessage(GetDlgItem(hwndDlg, IDC_MESSAGE), EM_SETSEL, -1, -1);
}
- DBFreeVariant(&dbv);
+ db_free(&dbv);
}
}
diff --git a/src/core/stdmsg/src/msglog.cpp b/src/core/stdmsg/src/msglog.cpp
index ec601d5952..a76bbeaac5 100644
--- a/src/core/stdmsg/src/msglog.cpp
+++ b/src/core/stdmsg/src/msglog.cpp
@@ -144,7 +144,6 @@ static int AppendToBufferWithRTF(char **buffer, int *cbBufferEnd, int *cbBufferA
*tag = 0;
*tage = 0;
d += sprintf(d, "{\\field{\\*\\fldinst HYPERLINK \"%s\"}{\\fldrslt %s}}", mir_t2a(tagu), mir_t2a(tag + 1));
-// d += sprintf(d, "{\\field{\\*\\fldinst HYPERLINK \"%s\"}{\\fldrslt \\ul\\cf%d %s}}", mir_t2a(tagu), msgDlgFontCount, mir_t2a(tag + 1));
line = tage + 5;
found = 1;
}
@@ -202,15 +201,13 @@ static char *CreateRTFHeader(struct SrmmWindowData *dat)
buffer[0] = '\0';
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "{\\rtf1\\ansi\\deff0{\\fonttbl");
- for (i = 0; i < msgDlgFontCount; i++) {
- LoadMsgDlgFont(i, &lf, NULL);
+ for (i = 0; LoadMsgDlgFont(i, &lf, NULL); i++)
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, FONT_FORMAT, i, lf.lfCharSet, lf.lfFaceName);
- }
+
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "}{\\colortbl ");
- for (i = 0; i < msgDlgFontCount; i++) {
- LoadMsgDlgFont(i, NULL, &colour);
+ for (i = 0; LoadMsgDlgFont(i, NULL, &colour); i++)
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\red%u\\green%u\\blue%u;", GetRValue(colour), GetGValue(colour), GetBValue(colour));
- }
+
if (GetSysColorBrush(COLOR_HOTLIGHT) == NULL)
colour = RGB(0, 0, 255);
else
diff --git a/src/core/stdmsg/src/msgoptions.cpp b/src/core/stdmsg/src/msgoptions.cpp
index 0c557afda0..e2cc34d99e 100644
--- a/src/core/stdmsg/src/msgoptions.cpp
+++ b/src/core/stdmsg/src/msgoptions.cpp
@@ -48,31 +48,30 @@ static const fontOptionsList[] =
{ LPGENT("Notices"), RGB(90, 90, 160), _T("Arial"), 0, -12},
};
-const int msgDlgFontCount = SIZEOF(fontOptionsList);
-
static BYTE MsgDlgGetFontDefaultCharset(const TCHAR* szFont)
{
return DEFAULT_CHARSET;
}
-void LoadMsgDlgFont(int i, LOGFONT* lf, COLORREF * colour)
+bool LoadMsgDlgFont(int i, LOGFONT* lf, COLORREF * colour)
{
+ if (i > SIZEOF(fontOptionsList))
+ return false;
+
char str[32];
- int style;
- DBVARIANT dbv;
- if ( colour ) {
+ if (colour) {
mir_snprintf(str, SIZEOF(str), "SRMFont%dCol", i);
*colour = DBGetContactSettingDword(NULL, SRMMMOD, str, fontOptionsList[i].defColour);
}
- if ( lf ) {
+ if (lf) {
mir_snprintf(str, SIZEOF(str), "SRMFont%dSize", i);
lf->lfHeight = (char) db_get_b(NULL, SRMMMOD, str, fontOptionsList[i].defSize);
lf->lfWidth = 0;
lf->lfEscapement = 0;
lf->lfOrientation = 0;
mir_snprintf(str, SIZEOF(str), "SRMFont%dSty", i);
- style = db_get_b(NULL, SRMMMOD, str, fontOptionsList[i].defStyle);
+ int style = db_get_b(NULL, SRMMMOD, str, fontOptionsList[i].defStyle);
lf->lfWeight = style & FONTF_BOLD ? FW_BOLD : FW_NORMAL;
lf->lfItalic = style & FONTF_ITALIC ? 1 : 0;
lf->lfUnderline = 0;
@@ -82,32 +81,33 @@ void LoadMsgDlgFont(int i, LOGFONT* lf, COLORREF * colour)
lf->lfQuality = DEFAULT_QUALITY;
lf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
mir_snprintf(str, SIZEOF(str), "SRMFont%d", i);
- if (DBGetContactSettingTString(NULL, SRMMMOD, str, &dbv))
+
+ DBVARIANT dbv;
+ if ( DBGetContactSettingTString(NULL, SRMMMOD, str, &dbv))
_tcscpy(lf->lfFaceName, fontOptionsList[i].szDefFace);
else {
lstrcpyn(lf->lfFaceName, dbv.ptszVal, SIZEOF(lf->lfFaceName));
- DBFreeVariant(&dbv);
+ db_free(&dbv);
}
mir_snprintf(str, SIZEOF(str), "SRMFont%dSet", i);
lf->lfCharSet = db_get_b(NULL, SRMMMOD, str, MsgDlgGetFontDefaultCharset(lf->lfFaceName));
-} }
+ }
+ return true;
+}
void RegisterSRMMFonts( void )
{
- FontIDT fontid = {0};
- ColourIDT colourid = {0};
char idstr[10];
- int i, index = 0;
- fontid.cbSize = sizeof(FontID);
+ FontIDT fontid = { sizeof(fontid) };
fontid.flags = FIDF_ALLOWREREGISTER | FIDF_DEFAULTVALID;
- for ( i = 0; i < msgDlgFontCount; i++, index++ ) {
+ for (int i=0; i < SIZEOF(fontOptionsList); i++) {
strcpy(fontid.dbSettingsGroup, SRMMMOD);
_tcscpy(fontid.group, LPGENT("Message Log"));
_tcscpy(fontid.name, fontOptionsList[i].szDescr);
- mir_snprintf(idstr, SIZEOF(idstr), "SRMFont%d", index);
+ mir_snprintf(idstr, SIZEOF(idstr), "SRMFont%d", i);
strcpy(fontid.prefix, idstr);
- fontid.order = index;
+ fontid.order = i;
fontid.flags &= ~FIDF_CLASSMASK;
fontid.flags |= (fontOptionsList[i].defStyle == FONTF_BOLD) ? FIDF_CLASSHEADER : FIDF_CLASSGENERAL;
@@ -120,7 +120,7 @@ void RegisterSRMMFonts( void )
FontRegisterT(&fontid);
}
- colourid.cbSize = sizeof(ColourID);
+ ColourIDT colourid = { sizeof(colourid) };
strcpy(colourid.dbSettingsGroup, SRMMMOD);
strcpy(colourid.setting, SRMSGSET_BKGCOLOUR);
colourid.defcolour = SRMSGDEFSET_BKGCOLOUR;
diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp
index c72f94c9f2..fe65236e7f 100644
--- a/src/core/stdmsg/src/msgs.cpp
+++ b/src/core/stdmsg/src/msgs.cpp
@@ -30,8 +30,6 @@ const CLSID IID_IRichEditOleCallback = { 0x00020D03, 0x00, 0x00, { 0xC0, 0x00, 0
HCURSOR hCurSplitNS, hCurSplitWE, hCurHyperlinkHand;
HANDLE hHookWinEvt, hHookWinPopup, hMsgMenuItem;
-static HANDLE hServices[7];
-static HANDLE hHooks[8];
static int SRMMStatusToPf2(int status)
{
@@ -338,20 +336,10 @@ int PreshutdownSendRecv(WPARAM wParam, LPARAM lParam)
int SplitmsgShutdown(void)
{
- int i;
-
DestroyCursor(hCurSplitNS);
DestroyCursor(hCurHyperlinkHand);
DestroyCursor(hCurSplitWE);
- for (i=0; i < SIZEOF(hHooks); ++i)
- if (hHooks[i])
- UnhookEvent(hHooks[i]);
-
- for ( i=0; i < SIZEOF(hServices); ++i)
- if (hServices[i])
- DestroyServiceFunction(hServices[i]);
-
FreeMsgLogIcons();
FreeLibrary(GetModuleHandleA("riched20"));
OleUninitialize();
@@ -440,21 +428,21 @@ int LoadSendRecvMessageModule(void)
InitOptions();
msgQueue_init();
- hHooks[0] = HookEvent(ME_DB_EVENT_ADDED, MessageEventAdded);
- hHooks[1] = HookEvent(ME_DB_CONTACT_SETTINGCHANGED, MessageSettingChanged);
- hHooks[2] = HookEvent(ME_DB_CONTACT_DELETED, ContactDeleted);
- hHooks[3] = HookEvent(ME_SYSTEM_MODULESLOADED, SplitmsgModulesLoaded);
- hHooks[4] = HookEvent(ME_SKIN_ICONSCHANGED, IconsChanged);
- hHooks[5] = HookEvent(ME_PROTO_CONTACTISTYPING, TypingMessage);
- hHooks[6] = HookEvent(ME_SYSTEM_PRESHUTDOWN, PreshutdownSendRecv);
- hHooks[7] = HookEvent(ME_CLIST_PREBUILDCONTACTMENU, PrebuildContactMenu);
-
- hServices[0] = CreateServiceFunction(MS_MSG_SENDMESSAGE, SendMessageCommand);
- hServices[1] = CreateServiceFunction(MS_MSG_SENDMESSAGEW, SendMessageCommand_W);
- hServices[2] = CreateServiceFunction(MS_MSG_GETWINDOWAPI, GetWindowAPI);
- hServices[3] = CreateServiceFunction(MS_MSG_GETWINDOWCLASS, GetWindowClass);
- hServices[4] = CreateServiceFunction(MS_MSG_GETWINDOWDATA, GetWindowData);
- hServices[5] = CreateServiceFunction("SRMsg/ReadMessage", ReadMessageCommand);
+ HookEvent(ME_DB_EVENT_ADDED, MessageEventAdded);
+ HookEvent(ME_DB_CONTACT_SETTINGCHANGED, MessageSettingChanged);
+ HookEvent(ME_DB_CONTACT_DELETED, ContactDeleted);
+ HookEvent(ME_SYSTEM_MODULESLOADED, SplitmsgModulesLoaded);
+ HookEvent(ME_SKIN_ICONSCHANGED, IconsChanged);
+ HookEvent(ME_PROTO_CONTACTISTYPING, TypingMessage);
+ HookEvent(ME_SYSTEM_PRESHUTDOWN, PreshutdownSendRecv);
+ HookEvent(ME_CLIST_PREBUILDCONTACTMENU, PrebuildContactMenu);
+
+ CreateServiceFunction(MS_MSG_SENDMESSAGE, SendMessageCommand);
+ CreateServiceFunction(MS_MSG_SENDMESSAGEW, SendMessageCommand_W);
+ CreateServiceFunction(MS_MSG_GETWINDOWAPI, GetWindowAPI);
+ CreateServiceFunction(MS_MSG_GETWINDOWCLASS, GetWindowClass);
+ CreateServiceFunction(MS_MSG_GETWINDOWDATA, GetWindowData);
+ CreateServiceFunction("SRMsg/ReadMessage", ReadMessageCommand);
hHookWinEvt = CreateHookableEvent(ME_MSG_WINDOWEVENT);
hHookWinPopup = CreateHookableEvent(ME_MSG_WINDOWPOPUP);
diff --git a/src/core/stdmsg/src/msgs.h b/src/core/stdmsg/src/msgs.h
index 4e62cd530c..1c472835a8 100644
--- a/src/core/stdmsg/src/msgs.h
+++ b/src/core/stdmsg/src/msgs.h
@@ -136,8 +136,7 @@ void InitOptions(void);
#define MSGFONTID_MESSAGEAREA 8
#define MSGFONTID_NOTICE 9
-void LoadMsgDlgFont(int i, LOGFONT* lf, COLORREF* colour);
-extern const int msgDlgFontCount;
+bool LoadMsgDlgFont(int i, LOGFONT* lf, COLORREF* colour);
#define LOADHISTORY_UNREAD 0
#define LOADHISTORY_COUNT 1