From 1fcc1afe0d54bc1034dd500837050dd972e45161 Mon Sep 17 00:00:00 2001 From: George Hazan <george.hazan@gmail.com> Date: Fri, 26 Oct 2012 00:01:16 +0000 Subject: - old crap killed in NewXStatusNotify - code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@2081 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/NewXstatusNotify/src/common.h | 46 +- plugins/NewXstatusNotify/src/indsnd.cpp | 44 +- plugins/NewXstatusNotify/src/indsnd.h | 26 +- plugins/NewXstatusNotify/src/main.cpp | 725 ++++++++++++------------------- plugins/NewXstatusNotify/src/options.cpp | 124 +++--- plugins/NewXstatusNotify/src/options.h | 22 +- plugins/NewXstatusNotify/src/popup.cpp | 26 +- plugins/NewXstatusNotify/src/popup.h | 46 +- plugins/NewXstatusNotify/src/utils.cpp | 76 ++-- plugins/NewXstatusNotify/src/utils.h | 22 +- plugins/NewXstatusNotify/src/xstatus.cpp | 295 ++++++------- plugins/NewXstatusNotify/src/xstatus.h | 30 +- plugins/Popup/src/history.cpp | 30 +- 13 files changed, 633 insertions(+), 879 deletions(-) (limited to 'plugins') diff --git a/plugins/NewXstatusNotify/src/common.h b/plugins/NewXstatusNotify/src/common.h index 3cc765af4d..fcab9e4e93 100644 --- a/plugins/NewXstatusNotify/src/common.h +++ b/plugins/NewXstatusNotify/src/common.h @@ -4,19 +4,19 @@ Copyright (c) 2005-2007 Vasilich Copyright (c) 2007-2011 yaho - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef COMMON_H @@ -89,21 +89,21 @@ #define GENDER_FEMALE 2 #define ID_STATUS_FROMOFFLINE 1 -#define ID_STATUS_EXTRASTATUS 40081 -#define ID_STATUS_MIN ID_STATUS_OFFLINE -#define ID_STATUS_MAX ID_STATUS_OUTTOLUNCH -#define ID_STATUS_MAX2 ID_STATUS_EXTRASTATUS + 1 -#define STATUS_COUNT ID_STATUS_MAX2 - ID_STATUS_MIN -#define Index(ID_STATUS) ID_STATUS - ID_STATUS_OFFLINE +#define ID_STATUS_EXTRASTATUS 40081 +#define ID_STATUS_MIN ID_STATUS_OFFLINE +#define ID_STATUS_MAX ID_STATUS_OUTTOLUNCH +#define ID_STATUS_MAX2 ID_STATUS_EXTRASTATUS + 1 +#define STATUS_COUNT ID_STATUS_MAX2 - ID_STATUS_MIN +#define Index(ID_STATUS) ID_STATUS - ID_STATUS_OFFLINE #define COLOR_BG_AVAILDEFAULT RGB(173,206,247) -#define COLOR_BG_NAVAILDEFAULT RGB(255,189,189) +#define COLOR_BG_NAVAILDEFAULT RGB(255,189,189) #define COLOR_TX_DEFAULT RGB(0,0,0) -#define ICO_NOTIFICATION_OFF "notification_off" -#define ICO_NOTIFICATION_ON "notification_on" +#define ICO_NOTIFICATION_OFF "notification_off" +#define ICO_NOTIFICATION_ON "notification_on" -#define JS_PARSE_XMPP_URI "/ParseXmppURI" +#define JS_PARSE_XMPP_URI "/ParseXmppURI" typedef struct tagSTATUS { diff --git a/plugins/NewXstatusNotify/src/indsnd.cpp b/plugins/NewXstatusNotify/src/indsnd.cpp index 5516fc945d..3c27a6bb6e 100644 --- a/plugins/NewXstatusNotify/src/indsnd.cpp +++ b/plugins/NewXstatusNotify/src/indsnd.cpp @@ -4,19 +4,19 @@ Copyright (c) 2005-2007 Vasilich Copyright (c) 2007-2011 yaho - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "common.h" @@ -192,8 +192,8 @@ INT_PTR CALLBACK DlgProcSoundUIPage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA ListView_SetItemText(hList, lvi.iItem, 1, buff); } - CheckDlgButton(hwndDlg, IDC_CHECK_NOTIFYSOUNDS, DBGetContactSettingByte(hContact, MODULE, "EnableSounds", 1)); - CheckDlgButton(hwndDlg, IDC_CHECK_NOTIFYPOPUPS, DBGetContactSettingByte(hContact, MODULE, "EnablePopups", 1)); + CheckDlgButton(hwndDlg, IDC_CHECK_NOTIFYSOUNDS, db_get_b(hContact, MODULE, "EnableSounds", 1)); + CheckDlgButton(hwndDlg, IDC_CHECK_NOTIFYPOPUPS, db_get_b(hContact, MODULE, "EnablePopups", 1)); ShowWindow(GetDlgItem(hwndDlg, IDC_INDSNDLIST), opt.UseIndSnd ? SW_SHOW : SW_HIDE); ShowWindow(GetDlgItem(hwndDlg, IDC_TEXT_ENABLE_IS), opt.UseIndSnd ? SW_HIDE : SW_SHOW); @@ -283,9 +283,9 @@ INT_PTR CALLBACK DlgProcSoundUIPage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA TCHAR stzSoundPath[MAX_PATH] = { 0 }; CallService(MS_UTILS_PATHTORELATIVET, (WPARAM)buff, (LPARAM)stzSoundPath); if (lvi.lParam == ID_STATUS_FROMOFFLINE) - DBWriteContactSettingTString(hContact, MODULE, "UserFromOffline", stzSoundPath); + db_set_ws(hContact, MODULE, "UserFromOffline", stzSoundPath); else - DBWriteContactSettingTString(hContact, MODULE, StatusList[Index(lvi.lParam)].lpzSkinSoundName, stzSoundPath); + db_set_ws(hContact, MODULE, StatusList[Index(lvi.lParam)].lpzSkinSoundName, stzSoundPath); } } @@ -380,10 +380,10 @@ void SetAllContactsIcons(HWND hwndList) char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0); if (szProto) { - EnableSounds = DBGetContactSettingByte(hContact, MODULE, "EnableSounds", 1); - EnablePopups = DBGetContactSettingByte(hContact, MODULE, "EnablePopups", 1); - EnableXStatus = DBGetContactSettingByte(hContact, MODULE, "EnableXStatusNotify", 1); - EnableLogging = DBGetContactSettingByte(hContact, MODULE, "EnableLogging", 1); + EnableSounds = db_get_b(hContact, MODULE, "EnableSounds", 1); + EnablePopups = db_get_b(hContact, MODULE, "EnablePopups", 1); + EnableXStatus = db_get_b(hContact, MODULE, "EnableXStatusNotify", 1); + EnableLogging = db_get_b(hContact, MODULE, "EnableLogging", 1); } else EnableSounds = EnablePopups = EnableXStatus = EnableLogging = 0; @@ -647,7 +647,7 @@ INT_PTR CALLBACK DlgProcFiltering(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM else DBWriteContactSettingByte(hContact, MODULE, "EnablePopups", 0); - if(GetExtraImage(hList, hItem, EXTRA_IMAGE_XSTATUS) == EXTRA_IMAGE_XSTATUS) + if (GetExtraImage(hList, hItem, EXTRA_IMAGE_XSTATUS) == EXTRA_IMAGE_XSTATUS) DBDeleteContactSetting(hContact, MODULE, "EnableXStatusNotify"); else DBWriteContactSettingByte(hContact, MODULE, "EnableXStatusNotify", 0); diff --git a/plugins/NewXstatusNotify/src/indsnd.h b/plugins/NewXstatusNotify/src/indsnd.h index c4dde34ea1..461201839c 100644 --- a/plugins/NewXstatusNotify/src/indsnd.h +++ b/plugins/NewXstatusNotify/src/indsnd.h @@ -4,19 +4,19 @@ Copyright (c) 2005-2007 Vasilich Copyright (c) 2007-2011 yaho - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef INDSND_H diff --git a/plugins/NewXstatusNotify/src/main.cpp b/plugins/NewXstatusNotify/src/main.cpp index 1d18649706..a75b04472d 100644 --- a/plugins/NewXstatusNotify/src/main.cpp +++ b/plugins/NewXstatusNotify/src/main.cpp @@ -4,19 +4,19 @@ Copyright (c) 2005-2007 Vasilich Copyright (c) 2007-2011 yaho - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "common.h" @@ -29,9 +29,7 @@ HINSTANCE hInst; - LIST<DBEVENT> eventList( 10 ); -LIST<XSTATUSCHANGE> xstatusList( 10 ); HANDLE hStatusModeChange, hServiceMenu, hHookContactStatusChanged, hEnableDisableMenu; HANDLE hToolbarButton; @@ -73,16 +71,14 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_USERONL BYTE GetGender(HANDLE hContact) { char *szProto =(char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); - if (szProto) - { - switch (DBGetContactSettingByte(hContact, szProto, "Gender", 0)) - { - case 'M': case 'm': - return GENDER_MALE; - case 'F': case 'f': - return GENDER_FEMALE; - default: - return GENDER_UNSPECIFIED; + if (szProto) { + switch (db_get_b(hContact, szProto, "Gender", 0)) { + case 'M': case 'm': + return GENDER_MALE; + case 'F': case 'f': + return GENDER_FEMALE; + default: + return GENDER_UNSPECIFIED; } } @@ -96,43 +92,12 @@ HANDLE GetIconHandle(char *szIcon) return (HANDLE)CallService(MS_SKIN2_GETICONHANDLE, 0, (LPARAM)szSettingName); } -__inline void AddXSC(XSTATUSCHANGE *xsc) -{ - xstatusList.insert(xsc); -} - -__inline void RemoveXSC(XSTATUSCHANGE *xsc) -{ - int id = xstatusList.getIndex(xsc); - if (id != -1) - xstatusList.remove(id); -} - -XSTATUSCHANGE *FindXSC(HANDLE hContact) -{ - for (int i = 0; i < xstatusList.getCount(); i++) { - XSTATUSCHANGE* xsc = xstatusList[i]; - if (xsc->hContact == hContact) - return xsc; - } - - return NULL; -} - -XSTATUSCHANGE *FindAndRemoveXSC(HANDLE hContact) -{ - XSTATUSCHANGE *result = FindXSC(hContact); - if (result) RemoveXSC(result); - return result; -} - bool IsNewExtraStatus(HANDLE hContact, char *szSetting, TCHAR *newStatusTitle) { DBVARIANT dbv; bool result = true; - if (!DBGetContactSettingTString(hContact, MODULE, szSetting, &dbv)) - { + if ( !DBGetContactSettingTString(hContact, MODULE, szSetting, &dbv)) { result = _tcscmp(newStatusTitle, dbv.ptszVal) ? true : false; DBFreeVariant(&dbv); } @@ -145,97 +110,62 @@ int ProcessExtraStatus(DBCONTACTWRITESETTING *cws, HANDLE hContact) XSTATUSCHANGE *xsc; char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); - if (ProtoServiceExists(szProto, JS_PARSE_XMPP_URI)) - { + if ( ProtoServiceExists(szProto, JS_PARSE_XMPP_URI)) { if (cws->value.type == DBVT_DELETED) return 0; if (hContact == NULL) return 0; - if (strstr(cws->szSetting, "/mood/") || strstr(cws->szSetting, "/activity/")) // Jabber mood or activity changed - { + if (strstr(cws->szSetting, "/mood/") || strstr(cws->szSetting, "/activity/")) { // Jabber mood or activity changed char *szSetting; int type; - if (strstr(cws->szSetting, "/mood/")) - { + if (strstr(cws->szSetting, "/mood/")) { type = TYPE_JABBER_MOOD; szSetting = "LastJabberMood"; } - else - { + else { type = TYPE_JABBER_ACTIVITY; szSetting = "LastJabberActivity"; } - if (strstr(cws->szSetting, "title")) - { + if (strstr(cws->szSetting, "title")) { TCHAR *stzValue = db2t(&cws->value); - if (stzValue) - { - if (!IsNewExtraStatus(hContact, szSetting, stzValue)) - { + if (stzValue) { + if ( !IsNewExtraStatus(hContact, szSetting, stzValue)) { mir_free(stzValue); return 0; } xsc = NewXSC(hContact, szProto, type, NOTIFY_NEW_XSTATUS, stzValue, NULL); - DBWriteContactSettingTString(hContact, MODULE, szSetting, stzValue); + db_set_ws(hContact, MODULE, szSetting, stzValue); } - else - { + else { xsc = NewXSC(hContact, szProto, type, NOTIFY_REMOVE, NULL, NULL); - DBWriteContactSettingTString(hContact, MODULE, szSetting, _T("")); + db_set_ws(hContact, MODULE, szSetting, _T("")); } - AddXSC(xsc); - if (xsc != NULL) - { - ExtraStatusChanged(xsc); - FreeXSC(xsc); - } + ExtraStatusChanged(xsc); } - else if (strstr(cws->szSetting, "text")) - { - xsc = FindAndRemoveXSC(hContact); + else if (strstr(cws->szSetting, "text")) { TCHAR *stzValue = db2t(&cws->value); - if (stzValue) - { - if (xsc != NULL) - xsc->stzText = stzValue; - else - xsc = NewXSC(hContact, szProto, type, NOTIFY_NEW_MESSAGE, NULL, stzValue); - } - - if (xsc != NULL) - { - ExtraStatusChanged(xsc); - FreeXSC(xsc); - } + xsc = NewXSC(hContact, szProto, type, NOTIFY_NEW_MESSAGE, NULL, stzValue); + ExtraStatusChanged(xsc); } return 1; } } - else if (strstr(cws->szSetting, "XStatus") || strcmp(cws->szSetting, "StatusNote") == 0) - { - if (strcmp(cws->szSetting, "XStatusName") == 0) - { - xsc = FindAndRemoveXSC(hContact); - if (xsc) FreeXSC(xsc); - + else if (strstr(cws->szSetting, "XStatus") || strcmp(cws->szSetting, "StatusNote") == 0) { + if (strcmp(cws->szSetting, "XStatusName") == 0) { if (cws->value.type == DBVT_DELETED) - { xsc = NewXSC(hContact, szProto, TYPE_ICQ_XSTATUS, NOTIFY_REMOVE, NULL, NULL); - } - else - { + else { TCHAR *stzValue = db2t(&cws->value); - if (!stzValue) - { + if ( !stzValue) { TCHAR buff[64]; - int statusID = DBGetContactSettingByte(hContact, szProto, "XStatusId", -1); + int statusID = db_get_b(hContact, szProto, "XStatusId", -1); GetDefaultXstatusName(statusID, szProto, buff, SIZEOF(buff)); stzValue = mir_tstrdup(buff); } @@ -243,35 +173,15 @@ int ProcessExtraStatus(DBCONTACTWRITESETTING *cws, HANDLE hContact) xsc = NewXSC(hContact, szProto, TYPE_ICQ_XSTATUS, NOTIFY_NEW_XSTATUS, stzValue, NULL); } - AddXSC(xsc); - if (xsc != NULL) - { - ExtraStatusChanged(xsc); - FreeXSC(xsc); - } + ExtraStatusChanged(xsc); } - else if (strstr(cws->szSetting, "XStatusMsg") || strcmp(cws->szSetting, "StatusNote") == 0) - { + else if (strstr(cws->szSetting, "XStatusMsg") || strcmp(cws->szSetting, "StatusNote") == 0) { if (cws->value.type == DBVT_DELETED) return 1; TCHAR *stzValue = db2t(&cws->value); - xsc = FindXSC(hContact); - if (xsc) - { - if (xsc->action == NOTIFY_NEW_XSTATUS) - xsc->stzText = stzValue; - } - else - { - xsc = NewXSC(hContact, szProto, TYPE_ICQ_XSTATUS, NOTIFY_NEW_MESSAGE, NULL, stzValue); - AddXSC(xsc); - } - if (xsc != NULL) - { - ExtraStatusChanged(xsc); - FreeXSC(xsc); - } + xsc = NewXSC(hContact, szProto, TYPE_ICQ_XSTATUS, NOTIFY_NEW_MESSAGE, NULL, stzValue); + ExtraStatusChanged(xsc); } return 1; @@ -312,64 +222,56 @@ static int CompareStatusMsg(STATUSMSGINFO *smi, DBCONTACTWRITESETTING *cws_new) DBVARIANT dbv_old; int ret; - switch (cws_new->value.type) - { - case DBVT_DELETED: - smi->newstatusmsg = NULL; - break; - case DBVT_ASCIIZ: + switch (cws_new->value.type) { + case DBVT_DELETED: + smi->newstatusmsg = NULL; + break; + + case DBVT_ASCIIZ: + smi->newstatusmsg = (CheckStr(cws_new->value.pszVal, 0, 1) ? NULL : mir_dupToUnicodeEx(cws_new->value.pszVal, CP_ACP)); + break; + + case DBVT_UTF8: + smi->newstatusmsg = (CheckStr(cws_new->value.pszVal, 0, 1) ? NULL : mir_dupToUnicodeEx(cws_new->value.pszVal, CP_UTF8)); + break; + + case DBVT_WCHAR: + smi->newstatusmsg = (CheckStrW(cws_new->value.pwszVal, 0, 1) ? NULL : mir_wstrdup(cws_new->value.pwszVal)); + break; + + default: + smi->newstatusmsg = NULL; + break; + } - smi->newstatusmsg = (CheckStr(cws_new->value.pszVal, 0, 1) ? NULL : mir_dupToUnicodeEx(cws_new->value.pszVal, CP_ACP)); + if ( !DBGetContactSettingW(smi->hContact, "UserOnline", "OldStatusMsg", &dbv_old)) { + switch (dbv_old.type) { + case DBVT_ASCIIZ: + smi->oldstatusmsg = (CheckStr(dbv_old.pszVal, 0, 1) ? NULL : mir_dupToUnicodeEx(dbv_old.pszVal, CP_ACP)); break; + case DBVT_UTF8: - smi->newstatusmsg = (CheckStr(cws_new->value.pszVal, 0, 1) ? NULL : mir_dupToUnicodeEx(cws_new->value.pszVal, CP_UTF8)); + smi->oldstatusmsg = (CheckStr(dbv_old.pszVal, 0, 1) ? NULL : mir_dupToUnicodeEx(dbv_old.pszVal, CP_UTF8)); break; - case DBVT_WCHAR: - smi->newstatusmsg = (CheckStrW(cws_new->value.pwszVal, 0, 1) ? NULL : mir_wstrdup(cws_new->value.pwszVal)); + case DBVT_WCHAR: + smi->oldstatusmsg = (CheckStrW(dbv_old.pwszVal, 0, 1) ? NULL : mir_wstrdup(dbv_old.pwszVal)); break; + default: - smi->newstatusmsg = NULL; + smi->oldstatusmsg = NULL; break; - } - - if (! - - DBGetContactSettingW(smi->hContact, "UserOnline", "OldStatusMsg", &dbv_old) - - ) - { - switch (dbv_old.type) - { - case DBVT_ASCIIZ: - - smi->oldstatusmsg = (CheckStr(dbv_old.pszVal, 0, 1) ? NULL : mir_dupToUnicodeEx(dbv_old.pszVal, CP_ACP)); - break; - case DBVT_UTF8: - smi->oldstatusmsg = (CheckStr(dbv_old.pszVal, 0, 1) ? NULL : mir_dupToUnicodeEx(dbv_old.pszVal, CP_UTF8)); - break; - case DBVT_WCHAR: - smi->oldstatusmsg = (CheckStrW(dbv_old.pwszVal, 0, 1) ? NULL : mir_wstrdup(dbv_old.pwszVal)); - - break; - default: - smi->oldstatusmsg = NULL; - break; } - if (cws_new->value.type == DBVT_DELETED) - if ( - - dbv_old.type == DBVT_WCHAR) + if (cws_new->value.type == DBVT_DELETED) { + if (dbv_old.type == DBVT_WCHAR) ret = CheckStrW(dbv_old.pwszVal, 2, 0); - else if (dbv_old.type == DBVT_UTF8 || - - dbv_old.type == DBVT_ASCIIZ) + else if (dbv_old.type == DBVT_UTF8 || dbv_old.type == DBVT_ASCIIZ) ret = CheckStr(dbv_old.pszVal, 2, 0); else ret = 2; + } else if (dbv_old.type != cws_new->value.type) - ret = (lstrcmpW(smi->newstatusmsg, smi->oldstatusmsg) ? CheckStrW(smi->newstatusmsg, 1, 2) : 0); else if (dbv_old.type == DBVT_ASCIIZ) @@ -377,21 +279,18 @@ static int CompareStatusMsg(STATUSMSGINFO *smi, DBCONTACTWRITESETTING *cws_new) else if (dbv_old.type == DBVT_UTF8) ret = (lstrcmpA(cws_new->value.pszVal, dbv_old.pszVal) ? CheckStr(cws_new->value.pszVal, 1, 2) : 0); + else if (dbv_old.type == DBVT_WCHAR) ret = (lstrcmpW(cws_new->value.pwszVal, dbv_old.pwszVal) ? CheckStrW(cws_new->value.pwszVal, 1, 2) : 0); DBFreeVariant(&dbv_old); } - else - { + else { if (cws_new->value.type == DBVT_DELETED) ret = 0; - else if ( - - cws_new->value.type == DBVT_WCHAR) + else if (cws_new->value.type == DBVT_WCHAR) ret = CheckStrW(cws_new->value.pwszVal, 1, 0); else if (cws_new->value.type == DBVT_UTF8 || - cws_new->value.type == DBVT_ASCIIZ) ret = CheckStr(cws_new->value.pszVal, 1, 0); else @@ -418,7 +317,8 @@ BOOL TimeoutCheck() return FALSE; } -TCHAR* AddCR(const TCHAR *statusmsg) { +TCHAR* AddCR(const TCHAR *statusmsg) +{ TCHAR *tmp; const TCHAR *found; int i = 0, len = lstrlen(statusmsg), j; @@ -426,26 +326,25 @@ TCHAR* AddCR(const TCHAR *statusmsg) { *tmp = _T('\0'); while((found = _tcsstr((statusmsg + i), _T("\n"))) != NULL && _tcslen(tmp) + 1 < 1024){ j = (int)(found - statusmsg); - if(lstrlen(tmp) + j - i + 2 < 1024){ + if (lstrlen(tmp) + j - i + 2 < 1024) tmp = _tcsncat(tmp, statusmsg + i, j - i); - } - else { + else break; - } - if(j == 0 || *(statusmsg + j - 1) != _T('\r')) { + + if (j == 0 || *(statusmsg + j - 1) != _T('\r')) tmp = lstrcat(tmp, _T("\r")); - } + tmp = lstrcat(tmp, _T("\n")); i = j + 1; } - if(lstrlen(tmp) + len - i + 1 < 1024){ + if (lstrlen(tmp) + len - i + 1 < 1024) tmp = lstrcat(tmp, statusmsg + i); - } return tmp; } -TCHAR* GetStr(STATUSMSGINFO *n, const TCHAR *tmplt) { +TCHAR* GetStr(STATUSMSGINFO *n, const TCHAR *tmplt) +{ TCHAR tmp[1024]; TCHAR *str; int i; @@ -458,77 +357,68 @@ TCHAR* GetStr(STATUSMSGINFO *n, const TCHAR *tmplt) { str[0] = _T('\0'); len = lstrlen(tmplt); - for (i = 0; i < len; i++) - { + for (i = 0; i < len; i++) { tmp[0] = _T('\0'); - if (tmplt[i] == _T('%')) - { + if (tmplt[i] == _T('%')) { i++; - switch (tmplt[i]) - { - case 'n': - if (n->compare == 2 || _tcscmp(n->newstatusmsg, TranslateT("<no status message>")) == 0) - lstrcpyn(tmp, TranslateT("<no status message>"), SIZEOF(tmp)); - else { - TCHAR *_tmp = AddCR(n->newstatusmsg); - lstrcpyn(tmp, _tmp, SIZEOF(tmp)); - mir_free(_tmp); - } - break; - case 'o': - if (n->oldstatusmsg == NULL || n->oldstatusmsg[0] == _T('\0') || _tcscmp(n->oldstatusmsg, TranslateT("<no status message>")) == 0) - lstrcpyn(tmp, TranslateT("<no status message>"), SIZEOF(tmp)); - else { - TCHAR *_tmp = AddCR(n->oldstatusmsg); - lstrcpyn(tmp, _tmp, SIZEOF(tmp)); - mir_free(_tmp); - } - break; - case 'c': - if (n->cust == NULL || n->cust[0] == _T('\0')) lstrcpyn(tmp, TranslateT("Contact"), SIZEOF(tmp)); - else lstrcpyn(tmp, n->cust, SIZEOF(tmp)); - break; - default: - //lstrcpyn(tmp, _T("%"), TMPMAX); - i--; - tmp[0] = tmplt[i]; tmp[1] = _T('\0'); - break; + switch (tmplt[i]) { + case 'n': + if (n->compare == 2 || _tcscmp(n->newstatusmsg, TranslateT("<no status message>")) == 0) + lstrcpyn(tmp, TranslateT("<no status message>"), SIZEOF(tmp)); + else { + TCHAR *_tmp = AddCR(n->newstatusmsg); + lstrcpyn(tmp, _tmp, SIZEOF(tmp)); + mir_free(_tmp); + } + break; + + case 'o': + if (n->oldstatusmsg == NULL || n->oldstatusmsg[0] == _T('\0') || _tcscmp(n->oldstatusmsg, TranslateT("<no status message>")) == 0) + lstrcpyn(tmp, TranslateT("<no status message>"), SIZEOF(tmp)); + else { + TCHAR *_tmp = AddCR(n->oldstatusmsg); + lstrcpyn(tmp, _tmp, SIZEOF(tmp)); + mir_free(_tmp); + } + break; + + case 'c': + if (n->cust == NULL || n->cust[0] == _T('\0')) lstrcpyn(tmp, TranslateT("Contact"), SIZEOF(tmp)); + else lstrcpyn(tmp, n->cust, SIZEOF(tmp)); + break; + + default: + //lstrcpyn(tmp, _T("%"), TMPMAX); + i--; + tmp[0] = tmplt[i], tmp[1] = _T('\0'); + break; } } - else if (tmplt[i] == _T('\\')) - { + else if (tmplt[i] == _T('\\')) { i++; - switch (tmplt[i]) - { - case 'n': - //_tcscat_s(tmp, TMPMAX, _T("\r\n")); - tmp[0] = _T('\r'); tmp[1] = _T('\n'); tmp[2] = _T('\0'); - break; - case 't': - //_tcscat_s(tmp, TMPMAX, _T("\t")); - tmp[0] = _T('\t'); tmp[1] = _T('\0'); - break; - default: - //lstrcpyn(tmp, _T("\\"), TMPMAX); - i--; - tmp[0] = tmplt[i]; tmp[1] = _T('\0'); - break; + switch (tmplt[i]) { + case 'n': + //_tcscat_s(tmp, TMPMAX, _T("\r\n")); + tmp[0] = _T('\r'), tmp[1] = _T('\n'), tmp[2] = _T('\0'); + break; + case 't': + //_tcscat_s(tmp, TMPMAX, _T("\t")); + tmp[0] = _T('\t'), tmp[1] = _T('\0'); + break; + default: + //lstrcpyn(tmp, _T("\\"), TMPMAX); + i--; + tmp[0] = tmplt[i], tmp[1] = _T('\0'); + break; } } - else - { - tmp[0] = tmplt[i]; tmp[1] = _T('\0'); - } + else tmp[0] = tmplt[i], tmp[1] = _T('\0'); - if (tmp[0] != _T('\0')) - { + if (tmp[0] != _T('\0')) { if (lstrlen(tmp) + lstrlen(str) < 2044) - { lstrcat(str, tmp); - } - else - { + else { lstrcat(str, _T("...")); break; } @@ -540,18 +430,17 @@ TCHAR* GetStr(STATUSMSGINFO *n, const TCHAR *tmplt) { int ProcessStatus(DBCONTACTWRITESETTING *cws, HANDLE hContact) { - if (strcmp(cws->szSetting, "Status") == 0) - { + if ( !strcmp(cws->szSetting, "Status")) { WORD newStatus = cws->value.wVal; if (newStatus < ID_STATUS_MIN || newStatus > ID_STATUS_MAX) return 0; DBVARIANT dbv; - if (!DBGetContactSettingString(hContact, "Protocol", "p", &dbv)) - { + if ( !DBGetContactSettingString(hContact, "Protocol", "p", &dbv)) { BOOL temp = strcmp(cws->szModule, dbv.pszVal) != 0; DBFreeVariant(&dbv); - if (temp) return 0; + if (temp) + return 0; } WORD oldStatus = DBGetContactSettingRangedWord(hContact, "UserOnline", "OldStatus", ID_STATUS_OFFLINE, ID_STATUS_MIN, ID_STATUS_MAX); @@ -570,8 +459,7 @@ int ProcessStatus(DBCONTACTWRITESETTING *cws, HANDLE hContact) return 1; } - if (!lstrcmpA(cws->szModule, "CList") && !lstrcmpA(cws->szSetting, "StatusMsg")) - { + if ( !strcmp(cws->szModule, "CList") && !strcmp(cws->szSetting, "StatusMsg")) { STATUSMSGINFO smi; BOOL retem = TRUE, rettime = TRUE; @@ -581,49 +469,33 @@ int ProcessStatus(DBCONTACTWRITESETTING *cws, HANDLE hContact) mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s_enabled", dbv.pszVal); db_free(&dbv); - if (!DBGetContactSettingByte(NULL, MODULE, dbSetting, 1)) + if (!db_get_b(NULL, MODULE, dbSetting, 1)) return 0; } smi.proto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); //don't show popup when mradio connecting and disconnecting - if (_stricmp(smi.proto, "mRadio") == 0 && !cws->value.type == DBVT_DELETED) - { + if (_stricmp(smi.proto, "mRadio") == 0 && !cws->value.type == DBVT_DELETED) { TCHAR buf[MAX_PATH]; mir_sntprintf(buf, SIZEOF(buf), _T(" (%s)"), TranslateT("connecting")); - char* pszUtf = mir_utf8encodeT(buf); + mir_ptr<char> pszUtf( mir_utf8encodeT(buf)); mir_sntprintf(buf, SIZEOF(buf), _T(" (%s)"), TranslateT("aborting")); - char* pszUtf2 = mir_utf8encodeT(buf); + mir_ptr<char> pszUtf2( mir_utf8encodeT(buf)); mir_sntprintf(buf, SIZEOF(buf), _T(" (%s)"), TranslateT("playing")); - char* pszUtf3 = mir_utf8encodeT(buf); + mir_ptr<char> pszUtf3( mir_utf8encodeT(buf)); if (_stricmp(cws->value.pszVal, pszUtf) == 0 || _stricmp(cws->value.pszVal, pszUtf2) == 0 || _stricmp(cws->value.pszVal, pszUtf3) == 0) - { - mir_free(pszUtf); - mir_free(pszUtf2); - mir_free(pszUtf3); return 0; - } - else - { - mir_free(pszUtf); - mir_free(pszUtf2); - mir_free(pszUtf3); - } } - if (smi.proto != NULL && CallProtoService(smi.proto, PS_GETSTATUS, 0, 0) != ID_STATUS_OFFLINE) - { + if (smi.proto != NULL && CallProtoService(smi.proto, PS_GETSTATUS, 0, 0) != ID_STATUS_OFFLINE) { smi.hContact = hContact; smi.compare = CompareStatusMsg(&smi, cws); if ((smi.compare == 0) || (opt.IgnoreEmpty && (smi.compare == 2))) return FreeSmiStr(&smi); if (cws->value.type == DBVT_DELETED) - { DBDeleteContactSetting(smi.hContact, "UserOnline", "OldStatusMsg"); - } - else - { + else { DBCONTACTWRITESETTING cws_old; cws_old.szModule = "UserOnline"; cws_old.szSetting = "OldStatusMsg"; @@ -639,8 +511,7 @@ int ProcessStatus(DBCONTACTWRITESETTING *cws, HANDLE hContact) char status[8]; mir_snprintf(status, SIZEOF(status), "%d", IDC_CHK_STATUS_MESSAGE); - if (DBGetContactSettingByte(hContact, MODULE, "EnablePopups", 1) && DBGetContactSettingByte(0, MODULE, status, 1) && retem && rettime) - { + if ( db_get_b(hContact, MODULE, "EnablePopups", 1) && db_get_b(0, MODULE, status, 1) && retem && rettime) { POPUPDATAT ppd = {0}; char* protoname = (char*)CallService(MS_PROTO_GETCONTACTBASEACCOUNT, (WPARAM)smi.hContact, 0); PROTOACCOUNT* pdescr = (PROTOACCOUNT*)CallService(MS_PROTO_GETACCOUNT, 0, (LPARAM)protoname); @@ -650,34 +521,29 @@ int ProcessStatus(DBCONTACTWRITESETTING *cws, HANDLE hContact) TCHAR *str; DBVARIANT dbVar = {0}; DBGetContactSettingTString(NULL, MODULE, protoname, &dbVar); - if (lstrcmp(dbVar.ptszVal, NULL) == 0) - { + if (lstrcmp(dbVar.ptszVal, NULL) == 0) { DBFreeVariant(&dbVar); str = GetStr(&smi, TranslateT(DEFAULT_POPUP_STATUSMESSAGE)); } - else - { - str = GetStr(&smi, dbVar.ptszVal); - } + else str = GetStr(&smi, dbVar.ptszVal); mir_free(protoname); ppd.lchContact = smi.hContact; ppd.lchIcon = LoadSkinnedProtoIcon(smi.proto, DBGetContactSettingWord(smi.hContact, smi.proto, "Status", ID_STATUS_ONLINE)); lstrcpyn(ppd.lptzContactName, smi.cust, MAX_CONTACTNAME); lstrcpyn(ppd.lptzText, str, MAX_SECONDLINE); - switch (opt.Colors) - { - case POPUP_COLOR_OWN: - ppd.colorBack = StatusList[Index(DBGetContactSettingWord(smi.hContact, smi.proto, "Status", ID_STATUS_ONLINE))].colorBack; - ppd.colorText = StatusList[Index(DBGetContactSettingWord(smi.hContact, smi.proto, "Status", ID_STATUS_ONLINE))].colorText; - break; - case POPUP_COLOR_WINDOWS: - ppd.colorBack = GetSysColor(COLOR_BTNFACE); - ppd.colorText = GetSysColor(COLOR_WINDOWTEXT); - break; - case POPUP_COLOR_POPUP: - ppd.colorBack = ppd.colorText = 0; - break; + switch (opt.Colors) { + case POPUP_COLOR_OWN: + ppd.colorBack = StatusList[Index(DBGetContactSettingWord(smi.hContact, smi.proto, "Status", ID_STATUS_ONLINE))].colorBack; + ppd.colorText = StatusList[Index(DBGetContactSettingWord(smi.hContact, smi.proto, "Status", ID_STATUS_ONLINE))].colorText; + break; + case POPUP_COLOR_WINDOWS: + ppd.colorBack = GetSysColor(COLOR_BTNFACE); + ppd.colorText = GetSysColor(COLOR_WINDOWTEXT); + break; + case POPUP_COLOR_POPUP: + ppd.colorBack = ppd.colorText = 0; + break; } ppd.PluginWindowProc = (WNDPROC)PopupDlgProc; ppd.PluginData = NULL; @@ -695,9 +561,7 @@ int ProcessStatus(DBCONTACTWRITESETTING *cws, HANDLE hContact) int ContactSettingChanged(WPARAM wParam, LPARAM lParam) { - DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *)lParam; HANDLE hContact = (HANDLE)wParam; - if (hContact == NULL) return 0; @@ -705,11 +569,10 @@ int ContactSettingChanged(WPARAM wParam, LPARAM lParam) if (szProto == NULL) return 0; + DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *)lParam; if (DBGetContactSettingWord(hContact, szProto, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) - { if (ProcessExtraStatus(cws, hContact)) return 0; - } ProcessStatus(cws, hContact); return 0; @@ -718,29 +581,23 @@ int ContactSettingChanged(WPARAM wParam, LPARAM lParam) int StatusModeChanged(WPARAM wParam, LPARAM lParam) { char *szProto = (char *)lParam; - if (opt.AutoDisable && (!opt.OnlyGlobalChanges || szProto == NULL)) - { - if (opt.DisablePopupGlobally && ServiceExists(MS_POPUP_QUERY)) - { + if (opt.AutoDisable && (!opt.OnlyGlobalChanges || szProto == NULL)) { + if (opt.DisablePopupGlobally && ServiceExists(MS_POPUP_QUERY)) { char szSetting[12]; wsprintfA(szSetting, "p%d", wParam); - BYTE hlpDisablePopup = DBGetContactSettingByte(0, MODULE, szSetting, 0); + BYTE hlpDisablePopup = db_get_b(0, MODULE, szSetting, 0); - if (hlpDisablePopup != opt.PopupAutoDisabled) - { + if (hlpDisablePopup != opt.PopupAutoDisabled) { BYTE hlpPopupStatus = (BYTE)CallService(MS_POPUP_QUERY, PUQS_GETSTATUS, 0); opt.PopupAutoDisabled = hlpDisablePopup; - if (hlpDisablePopup) - { + if (hlpDisablePopup) { DBWriteContactSettingByte(0, MODULE, "OldPopupStatus", hlpPopupStatus); CallService(MS_POPUP_QUERY, PUQS_DISABLEPOPUPS, 0); } - else - { - if (hlpPopupStatus == FALSE) - { - if (DBGetContactSettingByte(0, MODULE, "OldPopupStatus", TRUE) == TRUE) + else { + if (hlpPopupStatus == FALSE) { + if (db_get_b(0, MODULE, "OldPopupStatus", TRUE) == TRUE) CallService(MS_POPUP_QUERY, PUQS_ENABLEPOPUPS, 0); else CallService(MS_POPUP_QUERY, PUQS_DISABLEPOPUPS, 0); @@ -749,26 +606,22 @@ int StatusModeChanged(WPARAM wParam, LPARAM lParam) } } - if (opt.DisableSoundGlobally) - { + if (opt.DisableSoundGlobally) { char szSetting[12]; wsprintfA(szSetting, "s%d", wParam); - BYTE hlpDisableSound = DBGetContactSettingByte(0, MODULE, szSetting, 0); + BYTE hlpDisableSound = db_get_b(0, MODULE, szSetting, 0); - if (hlpDisableSound != opt.SoundAutoDisabled) - { - BYTE hlpUseSound = DBGetContactSettingByte(NULL, "Skin", "UseSound", 1); + if (hlpDisableSound != opt.SoundAutoDisabled) { + BYTE hlpUseSound = db_get_b(NULL, "Skin", "UseSound", 1); opt.SoundAutoDisabled = hlpDisableSound; - if (hlpDisableSound) - { + if (hlpDisableSound) { DBWriteContactSettingByte(0, MODULE, "OldUseSound", hlpUseSound); DBWriteContactSettingByte(0, "Skin", "UseSound", FALSE); } - else - { + else { if (hlpUseSound == FALSE) - DBWriteContactSettingByte(0, "Skin", "UseSound", DBGetContactSettingByte(0, MODULE, "OldUseSound", 1)); + DBWriteContactSettingByte(0, "Skin", "UseSound", db_get_b(0, MODULE, "OldUseSound", 1)); } } } @@ -787,11 +640,9 @@ void ShowStatusChangePopup(HANDLE hContact, char *szProto, WORD oldStatus, WORD ppd.lchIcon = LoadSkinnedProtoIcon(szProto, newStatus); _tcscpy(ppd.lptzContactName, (TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GSMDF_TCHAR)); - if (opt.ShowGroup) //add group name to popup title - { + if (opt.ShowGroup) { //add group name to popup title DBVARIANT dbv; - if (!DBGetContactSettingTString(hContact, "CList", "Group", &dbv)) - { + if (!DBGetContactSettingTString(hContact, "CList", "Group", &dbv)) { _tcscat(ppd.lptzContactName, _T(" (")); _tcscat(ppd.lptzContactName, dbv.ptszVal); _tcscat(ppd.lptzContactName, _T(")")); @@ -799,58 +650,46 @@ void ShowStatusChangePopup(HANDLE hContact, char *szProto, WORD oldStatus, WORD } } - if (opt.ShowStatus) - { - if (opt.UseAlternativeText) - { - switch (GetGender(hContact)) - { - case GENDER_MALE: - _tcsncpy(stzStatusText, StatusList[Index(newStatus)].lpzMStatusText, MAX_STATUSTEXT); - break; - case GENDER_FEMALE: - _tcsncpy(stzStatusText, StatusList[Index(newStatus)].lpzFStatusText, MAX_STATUSTEXT); - break; - case GENDER_UNSPECIFIED: - _tcsncpy(stzStatusText, StatusList[Index(newStatus)].lpzUStatusText, MAX_STATUSTEXT); - break; + if (opt.ShowStatus) { + if (opt.UseAlternativeText) { + switch (GetGender(hContact)) { + case GENDER_MALE: + _tcsncpy(stzStatusText, StatusList[Index(newStatus)].lpzMStatusText, MAX_STATUSTEXT); + break; + case GENDER_FEMALE: + _tcsncpy(stzStatusText, StatusList[Index(newStatus)].lpzFStatusText, MAX_STATUSTEXT); + break; + case GENDER_UNSPECIFIED: + _tcsncpy(stzStatusText, StatusList[Index(newStatus)].lpzUStatusText, MAX_STATUSTEXT); + break; } } - else - { - _tcsncpy(stzStatusText, StatusList[Index(newStatus)].lpzStandardText, MAX_STATUSTEXT); - } + else _tcsncpy(stzStatusText, StatusList[Index(newStatus)].lpzStandardText, MAX_STATUSTEXT); - if (opt.ShowPreviousStatus) - { + if (opt.ShowPreviousStatus) { TCHAR buff[MAX_STATUSTEXT]; wsprintf(buff, TranslateTS(STRING_SHOWPREVIOUSSTATUS), StatusList[Index(oldStatus)].lpzStandardText); _tcscat(_tcscat(stzStatusText, _T(" ")), buff); } } - if (opt.ReadAwayMsg && - myStatus != ID_STATUS_INVISIBLE && - StatusHasAwayMessage(szProto, newStatus)) - { - DBWriteContactSettingTString(hContact, MODULE, "LastPopupText", stzStatusText); - } + if (opt.ReadAwayMsg && myStatus != ID_STATUS_INVISIBLE && StatusHasAwayMessage(szProto, newStatus)) + db_set_ws(hContact, MODULE, "LastPopupText", stzStatusText); _tcscpy(ppd.lptzText, stzStatusText); - switch (opt.Colors) - { - case POPUP_COLOR_OWN: - ppd.colorBack = StatusList[Index(newStatus)].colorBack; - ppd.colorText = StatusList[Index(newStatus)].colorText; - break; - case POPUP_COLOR_WINDOWS: - ppd.colorBack = GetSysColor(COLOR_BTNFACE); - ppd.colorText = GetSysColor(COLOR_WINDOWTEXT); - break; - case POPUP_COLOR_POPUP: - ppd.colorBack = ppd.colorText = 0; - break; + switch (opt.Colors) { + case POPUP_COLOR_OWN: + ppd.colorBack = StatusList[Index(newStatus)].colorBack; + ppd.colorText = StatusList[Index(newStatus)].colorText; + break; + case POPUP_COLOR_WINDOWS: + ppd.colorBack = GetSysColor(COLOR_BTNFACE); + ppd.colorText = GetSysColor(COLOR_WINDOWTEXT); + break; + case POPUP_COLOR_POPUP: + ppd.colorBack = ppd.colorText = 0; + break; } ppd.PluginWindowProc = (WNDPROC)PopupDlgProc; @@ -889,23 +728,18 @@ void BlinkIcon(HANDLE hContact, char* szProto, WORD status) void PlayChangeSound(HANDLE hContact, WORD oldStatus, WORD newStatus) { DBVARIANT dbv; - if (opt.UseIndSnd) - { + if (opt.UseIndSnd) { TCHAR stzSoundFile[MAX_PATH] = {0}; - if (!DBGetContactSettingTString(hContact, MODULE, "UserFromOffline", &dbv) && - oldStatus == ID_STATUS_OFFLINE) - { + if (!DBGetContactSettingTString(hContact, MODULE, "UserFromOffline", &dbv) && oldStatus == ID_STATUS_OFFLINE) { _tcscpy(stzSoundFile, dbv.ptszVal); DBFreeVariant(&dbv); } - else if (!DBGetContactSettingTString(hContact, MODULE, StatusList[Index(newStatus)].lpzSkinSoundName, &dbv)) - { + else if (!DBGetContactSettingTString(hContact, MODULE, StatusList[Index(newStatus)].lpzSkinSoundName, &dbv)) { lstrcpy(stzSoundFile, dbv.ptszVal); DBFreeVariant(&dbv); } - if (stzSoundFile[0]) - { + if (stzSoundFile[0]) { //Now make path to IndSound absolute, as it isn't registered TCHAR stzSoundPath[MAX_PATH]; CallService(MS_UTILS_PATHTOABSOLUTET, (WPARAM)stzSoundFile, (LPARAM)stzSoundPath); @@ -916,14 +750,14 @@ void PlayChangeSound(HANDLE hContact, WORD oldStatus, WORD newStatus) char szSoundFile[MAX_PATH] = {0}; - if (!DBGetContactSettingByte(0, "SkinSoundsOff", "UserFromOffline", 0) && + if (!db_get_b(0, "SkinSoundsOff", "UserFromOffline", 0) && !DBGetContactSettingString(0,"SkinSounds", "UserFromOffline", &dbv) && - oldStatus == ID_STATUS_OFFLINE) + oldStatus == ID_STATUS_OFFLINE) { strcpy(szSoundFile, "UserFromOffline"); DBFreeVariant(&dbv); } - else if (!DBGetContactSettingByte(0, "SkinSoundsOff", StatusList[Index(newStatus)].lpzSkinSoundName, 0) && + else if (!db_get_b(0, "SkinSoundsOff", StatusList[Index(newStatus)].lpzSkinSoundName, 0) && !DBGetContactSetting(0, "SkinSounds", StatusList[Index(newStatus)].lpzSkinSoundName, &dbv)) { strcpy(szSoundFile, StatusList[Index(newStatus)].lpzSkinSoundName); @@ -949,75 +783,63 @@ int ContactStatusChanged(WPARAM wParam, LPARAM lParam) strcpy(szProto, hlpProto); WORD myStatus = (WORD)CallProtoService(szProto, PS_GETSTATUS, (WPARAM)0, (LPARAM)0); - if (strcmp(szProto, szMetaModuleName) == 0) //this contact is Meta - { + if (strcmp(szProto, szMetaModuleName) == 0) { //this contact is Meta HANDLE hSubContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0); strcpy(szSubProto, (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hSubContact,0)); - if (newStatus == ID_STATUS_OFFLINE) - { + if (newStatus == ID_STATUS_OFFLINE) { // read last online proto for metaconatct if exists, // to avoid notifying when meta went offline but default contact's proto still online DBVARIANT dbv; - if (!DBGetContactSettingString(hContact, szProto, "LastOnline", &dbv)) - { - strcpy(szSubProto, dbv.pszVal); + if (!DBGetContactSettingString(hContact, szProto, "LastOnline", &dbv)) { + strcpy(szSubProto, dbv.pszVal); DBFreeVariant(&dbv); } } - else - DBWriteContactSettingString(hContact, szProto, "LastOnline", szSubProto); + else DBWriteContactSettingString(hContact, szProto, "LastOnline", szSubProto); - if (!DBGetContactSettingByte(0, MODULE, szSubProto, 1)) + if (!db_get_b(0, MODULE, szSubProto, 1)) return 0; strcpy(szProto, szSubProto); } - else - { + else { if (myStatus == ID_STATUS_OFFLINE) return 0; } - if (!opt.FromOffline || oldStatus != ID_STATUS_OFFLINE) // Either it wasn't a change from Offline or we didn't enable that. - { + if (!opt.FromOffline || oldStatus != ID_STATUS_OFFLINE) { // Either it wasn't a change from Offline or we didn't enable that. wsprintfA(buff, "%d", newStatus); - if (DBGetContactSettingByte(0, MODULE, buff, 1) == 0) + if (db_get_b(0, MODULE, buff, 1) == 0) return 0; // "Notify when a contact changes to one of..." is unchecked } - if (!opt.HiddenContactsToo && (DBGetContactSettingByte(hContact, "CList", "Hidden", 0) == 1)) + if (!opt.HiddenContactsToo && (db_get_b(hContact, "CList", "Hidden", 0) == 1)) return 0; // we don't want to be notified if new chatroom comes online - if (DBGetContactSettingByte(hContact, szProto, "ChatRoom", 0) == 1) + if (db_get_b(hContact, szProto, "ChatRoom", 0) == 1) return 0; // check if that proto from which we received statuschange notification, isn't in autodisable list char statusIDs[12], statusIDp[12]; - if (opt.AutoDisable) - { + if (opt.AutoDisable) { wsprintfA(statusIDs, "s%d", myStatus); wsprintfA(statusIDp, "p%d", myStatus); - bEnableSound = DBGetContactSettingByte(0, MODULE, statusIDs, 1) ? FALSE : TRUE; - bEnablePopup = DBGetContactSettingByte(0, MODULE, statusIDp, 1) ? FALSE : TRUE; + bEnableSound = db_get_b(0, MODULE, statusIDs, 1) ? FALSE : TRUE; + bEnablePopup = db_get_b(0, MODULE, statusIDp, 1) ? FALSE : TRUE; } - if (bEnablePopup && DBGetContactSettingByte(hContact, MODULE, "EnablePopups", 1) && TimeoutCheck()) + if (bEnablePopup && db_get_b(hContact, MODULE, "EnablePopups", 1) && TimeoutCheck()) ShowStatusChangePopup(hContact, szProto, oldStatus, newStatus); if (opt.BlinkIcon) BlinkIcon(hContact, szProto, newStatus); - if (bEnableSound && - DBGetContactSettingByte(0, "Skin", "UseSound", TRUE) && - DBGetContactSettingByte(hContact, MODULE, "EnableSounds", 1)) - { + if (bEnableSound && db_get_b(0, "Skin", "UseSound", TRUE) && db_get_b(hContact, MODULE, "EnableSounds", 1)) PlayChangeSound(hContact, oldStatus, newStatus); - } - if (opt.Log) - { + if (opt.Log) { TCHAR stzName[64], stzStatus[MAX_STATUSTEXT], stzOldStatus[MAX_STATUSTEXT]; TCHAR stzDate[MAX_STATUSTEXT], stzTime[MAX_STATUSTEXT]; TCHAR stzText[1024]; @@ -1048,8 +870,8 @@ void InitStatusList() lstrcpynA(StatusList[index].lpzSkinSoundName, "UserOnline", MAX_SKINSOUNDNAME); lstrcpynA(StatusList[index].lpzSkinSoundDesc, Translate("User: Online"), MAX_SKINSOUNDDESC); lstrcpynA(StatusList[index].lpzSkinSoundFile, "global.wav", MAX_PATH); - StatusList[index].colorBack = DBGetContactSettingDword(NULL, MODULE, "40072bg", COLOR_BG_AVAILDEFAULT); - StatusList[index].colorText = DBGetContactSettingDword(NULL, MODULE, "40072tx", COLOR_TX_DEFAULT); + StatusList[index].colorBack = db_get_dw(NULL, MODULE, "40072bg", COLOR_BG_AVAILDEFAULT); + StatusList[index].colorText = db_get_dw(NULL, MODULE, "40072tx", COLOR_TX_DEFAULT); //Offline index = Index(ID_STATUS_OFFLINE); @@ -1062,8 +884,8 @@ void InitStatusList() lstrcpynA(StatusList[index].lpzSkinSoundName, "UserOffline", MAX_SKINSOUNDNAME); lstrcpynA(StatusList[index].lpzSkinSoundDesc, Translate("User: Offline"), MAX_SKINSOUNDDESC); lstrcpynA(StatusList[index].lpzSkinSoundFile, "offline.wav", MAX_PATH); - StatusList[index].colorBack = DBGetContactSettingDword(NULL, MODULE, "40071bg", COLOR_BG_NAVAILDEFAULT); - StatusList[index].colorText = DBGetContactSettingDword(NULL, MODULE, "40071tx", COLOR_TX_DEFAULT); + StatusList[index].colorBack = db_get_dw(NULL, MODULE, "40071bg", COLOR_BG_NAVAILDEFAULT); + StatusList[index].colorText = db_get_dw(NULL, MODULE, "40071tx", COLOR_TX_DEFAULT); //Invisible index = Index(ID_STATUS_INVISIBLE); @@ -1076,8 +898,8 @@ void InitStatusList() lstrcpynA(StatusList[index].lpzSkinSoundName, "UserInvisible", MAX_SKINSOUNDNAME); lstrcpynA(StatusList[index].lpzSkinSoundDesc, Translate("User: Invisible"), MAX_SKINSOUNDDESC); lstrcpynA(StatusList[index].lpzSkinSoundFile, "invisible.wav", MAX_PATH); - StatusList[index].colorBack = DBGetContactSettingDword(NULL, MODULE, "40078bg", COLOR_BG_AVAILDEFAULT); - StatusList[index].colorText = DBGetContactSettingDword(NULL, MODULE, "40078tx", COLOR_TX_DEFAULT); + StatusList[index].colorBack = db_get_dw(NULL, MODULE, "40078bg", COLOR_BG_AVAILDEFAULT); + StatusList[index].colorText = db_get_dw(NULL, MODULE, "40078tx", COLOR_TX_DEFAULT); //Free for chat index = Index(ID_STATUS_FREECHAT); @@ -1090,8 +912,8 @@ void InitStatusList() lstrcpynA(StatusList[index].lpzSkinSoundName, "UserFreeForChat", MAX_SKINSOUNDNAME); lstrcpynA(StatusList[index].lpzSkinSoundDesc, Translate("User: Free For Chat"), MAX_SKINSOUNDDESC); lstrcpynA(StatusList[index].lpzSkinSoundFile, "free4chat.wav", MAX_PATH); - StatusList[index].colorBack = DBGetContactSettingDword(NULL, MODULE, "40077bg", COLOR_BG_AVAILDEFAULT); - StatusList[index].colorText = DBGetContactSettingDword(NULL, MODULE, "40077tx", COLOR_TX_DEFAULT); + StatusList[index].colorBack = db_get_dw(NULL, MODULE, "40077bg", COLOR_BG_AVAILDEFAULT); + StatusList[index].colorText = db_get_dw(NULL, MODULE, "40077tx", COLOR_TX_DEFAULT); //Away index = Index(ID_STATUS_AWAY); @@ -1104,8 +926,8 @@ void InitStatusList() lstrcpynA(StatusList[index].lpzSkinSoundName, "UserAway", MAX_SKINSOUNDNAME); lstrcpynA(StatusList[index].lpzSkinSoundDesc, Translate("User: Away"), MAX_SKINSOUNDDESC); lstrcpynA(StatusList[index].lpzSkinSoundFile, "away.wav", MAX_PATH); - StatusList[index].colorBack = DBGetContactSettingDword(NULL, MODULE, "40073bg", COLOR_BG_NAVAILDEFAULT); - StatusList[index].colorText = DBGetContactSettingDword(NULL, MODULE, "40073tx", COLOR_TX_DEFAULT); + StatusList[index].colorBack = db_get_dw(NULL, MODULE, "40073bg", COLOR_BG_NAVAILDEFAULT); + StatusList[index].colorText = db_get_dw(NULL, MODULE, "40073tx", COLOR_TX_DEFAULT); //NA index = Index(ID_STATUS_NA); @@ -1118,8 +940,8 @@ void InitStatusList() lstrcpynA(StatusList[index].lpzSkinSoundName, "UserNA", MAX_SKINSOUNDNAME); lstrcpynA(StatusList[index].lpzSkinSoundDesc, Translate("User: Not Available"), MAX_SKINSOUNDDESC); lstrcpynA(StatusList[index].lpzSkinSoundFile, "na.wav", MAX_PATH); - StatusList[index].colorBack = DBGetContactSettingDword(NULL, MODULE, "40075bg", COLOR_BG_NAVAILDEFAULT); - StatusList[index].colorText = DBGetContactSettingDword(NULL, MODULE, "40075tx", COLOR_TX_DEFAULT); + StatusList[index].colorBack = db_get_dw(NULL, MODULE, "40075bg", COLOR_BG_NAVAILDEFAULT); + StatusList[index].colorText = db_get_dw(NULL, MODULE, "40075tx", COLOR_TX_DEFAULT); //Occupied index = Index(ID_STATUS_OCCUPIED); @@ -1132,8 +954,8 @@ void InitStatusList() lstrcpynA(StatusList[index].lpzSkinSoundName, "UserOccupied", MAX_SKINSOUNDNAME); lstrcpynA(StatusList[index].lpzSkinSoundDesc, Translate("User: Occupied"), MAX_SKINSOUNDDESC); lstrcpynA(StatusList[index].lpzSkinSoundFile, "occupied.wav", MAX_PATH); - StatusList[index].colorBack = DBGetContactSettingDword(NULL, MODULE, "40076bg", COLOR_BG_NAVAILDEFAULT); - StatusList[index].colorText = DBGetContactSettingDword(NULL, MODULE, "40076tx", COLOR_TX_DEFAULT); + StatusList[index].colorBack = db_get_dw(NULL, MODULE, "40076bg", COLOR_BG_NAVAILDEFAULT); + StatusList[index].colorText = db_get_dw(NULL, MODULE, "40076tx", COLOR_TX_DEFAULT); //DND index = Index(ID_STATUS_DND); @@ -1146,8 +968,8 @@ void InitStatusList() lstrcpynA(StatusList[index].lpzSkinSoundName, "UserDND", MAX_SKINSOUNDNAME); lstrcpynA(StatusList[index].lpzSkinSoundDesc, Translate("User: Do Not Disturb"), MAX_SKINSOUNDDESC); lstrcpynA(StatusList[index].lpzSkinSoundFile, "dnd.wav", MAX_PATH); - StatusList[index].colorBack = DBGetContactSettingDword(NULL, MODULE, "40074bg", COLOR_BG_NAVAILDEFAULT); - StatusList[index].colorText = DBGetContactSettingDword(NULL, MODULE, "40074tx", COLOR_TX_DEFAULT); + StatusList[index].colorBack = db_get_dw(NULL, MODULE, "40074bg", COLOR_BG_NAVAILDEFAULT); + StatusList[index].colorText = db_get_dw(NULL, MODULE, "40074tx", COLOR_TX_DEFAULT); //OutToLunch index = Index(ID_STATUS_OUTTOLUNCH); @@ -1160,8 +982,8 @@ void InitStatusList() lstrcpynA(StatusList[index].lpzSkinSoundName, "UserOutToLunch", MAX_SKINSOUNDNAME); lstrcpynA(StatusList[index].lpzSkinSoundDesc, Translate("User: Out To Lunch"), MAX_SKINSOUNDDESC); lstrcpynA(StatusList[index].lpzSkinSoundFile, "lunch.wav", MAX_PATH); - StatusList[index].colorBack = DBGetContactSettingDword(NULL, MODULE, "40080bg", COLOR_BG_NAVAILDEFAULT); - StatusList[index].colorText = DBGetContactSettingDword(NULL, MODULE, "40080tx", COLOR_TX_DEFAULT); + StatusList[index].colorBack = db_get_dw(NULL, MODULE, "40080bg", COLOR_BG_NAVAILDEFAULT); + StatusList[index].colorText = db_get_dw(NULL, MODULE, "40080tx", COLOR_TX_DEFAULT); //OnThePhone index = Index(ID_STATUS_ONTHEPHONE); @@ -1174,22 +996,21 @@ void InitStatusList() lstrcpynA(StatusList[index].lpzSkinSoundName, "UserOnThePhone", MAX_SKINSOUNDNAME); lstrcpynA(StatusList[index].lpzSkinSoundDesc, Translate("User: On The Phone"), MAX_SKINSOUNDDESC); lstrcpynA(StatusList[index].lpzSkinSoundFile, "phone.wav", MAX_PATH); - StatusList[index].colorBack = DBGetContactSettingDword(NULL, MODULE, "40079bg", COLOR_BG_NAVAILDEFAULT); - StatusList[index].colorText = DBGetContactSettingDword(NULL, MODULE, "40079tx", COLOR_TX_DEFAULT); + StatusList[index].colorBack = db_get_dw(NULL, MODULE, "40079bg", COLOR_BG_NAVAILDEFAULT); + StatusList[index].colorText = db_get_dw(NULL, MODULE, "40079tx", COLOR_TX_DEFAULT); //Extra status index = Index(ID_STATUS_EXTRASTATUS); StatusList[index].ID = ID_STATUS_EXTRASTATUS; - StatusList[index].colorBack = DBGetContactSettingDword(NULL, MODULE, "40081bg", COLOR_BG_AVAILDEFAULT); - StatusList[index].colorText = DBGetContactSettingDword(NULL, MODULE, "40081tx", COLOR_TX_DEFAULT); + StatusList[index].colorBack = db_get_dw(NULL, MODULE, "40081bg", COLOR_BG_AVAILDEFAULT); + StatusList[index].colorText = db_get_dw(NULL, MODULE, "40081tx", COLOR_TX_DEFAULT); } int ProtoAck(WPARAM wParam,LPARAM lParam) { ACKDATA *ack = (ACKDATA *)lParam; - if (ack->type == ACKTYPE_STATUS) - { + if (ack->type == ACKTYPE_STATUS) { WORD newStatus = (WORD)ack->lParam; WORD oldStatus = (WORD)ack->hProcess; char *szProto = (char *)ack->szModule; @@ -1197,13 +1018,11 @@ int ProtoAck(WPARAM wParam,LPARAM lParam) if (oldStatus == newStatus) return 0; - if (newStatus == ID_STATUS_OFFLINE) - { + if (newStatus == ID_STATUS_OFFLINE) { //The protocol switched to offline. Disable the popups for this protocol DBWriteContactSettingByte(NULL, MODULE, szProto, 0); } - else if (oldStatus < ID_STATUS_ONLINE && newStatus >= ID_STATUS_ONLINE) - { + else if (oldStatus < ID_STATUS_ONLINE && newStatus >= ID_STATUS_ONLINE) { //The protocol changed from a disconnected status to a connected status. //Enable the popups for this protocol. LoadTime = GetTickCount(); @@ -1221,13 +1040,11 @@ INT_PTR EnableDisableMenuCommand(WPARAM wParam, LPARAM lParam) CLISTMENUITEM mi = {0}; mi.cbSize = sizeof(mi); mi.flags = CMIM_ICON | CMIM_NAME | CMIF_TCHAR; - if (opt.TempDisabled) - { + if (opt.TempDisabled) { mi.ptszName = _T("Enable status notification"); mi.icolibItem = GetIconHandle(ICO_NOTIFICATION_OFF); } - else - { + else { mi.ptszName = _T("Disable status notification"); mi.icolibItem = GetIconHandle(ICO_NOTIFICATION_ON); } @@ -1278,8 +1095,7 @@ void InitIcolib() GetModuleFileNameA(hInst, szFile, MAX_PATH); - for (int i = 0; i < SIZEOF(iconList); i++) - { + for (int i = 0; i < SIZEOF(iconList); i++) { mir_snprintf(szSettingName, sizeof(szSettingName), "%s_%s", MODULE, iconList[i].szName); sid.pszDescription = Translate(iconList[i].szDescr); sid.iDefaultIndex = -iconList[i].iIconID; @@ -1365,6 +1181,5 @@ extern "C" int __declspec(dllexport) Unload(void) { DestroyHookableEvent(hHookContactStatusChanged); DestroyServiceFunction(hServiceMenu); - xstatusList.destroy(); return 0; -} \ No newline at end of file +} diff --git a/plugins/NewXstatusNotify/src/options.cpp b/plugins/NewXstatusNotify/src/options.cpp index 62fa290147..6fb0de5458 100644 --- a/plugins/NewXstatusNotify/src/options.cpp +++ b/plugins/NewXstatusNotify/src/options.cpp @@ -4,19 +4,19 @@ Copyright (c) 2005-2007 Vasilich Copyright (c) 2007-2011 yaho - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "common.h" @@ -50,51 +50,51 @@ void LoadTemplates() DBGetStringDefault(0, MODULE, "TLogChangeMsg", templates.LogNewMsg, SIZEOF(templates.LogNewMsg), DEFAULT_LOG_CHANGEMSG); DBGetStringDefault(0, MODULE, "TLogRemoval", templates.LogRemove, SIZEOF(templates.LogRemove), DEFAULT_LOG_REMOVE); DBGetStringDefault(0, MODULE, "TLogOpening", templates.LogOpening, SIZEOF(templates.LogOpening), DEFAULT_LOG_OPENING); - templates.PopupFlags = DBGetContactSettingByte(0, MODULE, "TPopupFlags", NOTIFY_NEW_XSTATUS | NOTIFY_NEW_MESSAGE); - templates.LogFlags = DBGetContactSettingByte(0, MODULE, "TLogFlags", NOTIFY_NEW_XSTATUS | NOTIFY_NEW_MESSAGE | NOTIFY_OPENING_ML); + templates.PopupFlags = db_get_b(0, MODULE, "TPopupFlags", NOTIFY_NEW_XSTATUS | NOTIFY_NEW_MESSAGE); + templates.LogFlags = db_get_b(0, MODULE, "TLogFlags", NOTIFY_NEW_XSTATUS | NOTIFY_NEW_MESSAGE | NOTIFY_OPENING_ML); } void LoadOptions() { // IDD_OPT_POPUP - opt.Colors = DBGetContactSettingByte(0,MODULE, "Colors", DEFAULT_COLORS); - opt.ShowGroup = DBGetContactSettingByte(0, MODULE, "ShowGroup", 0); - opt.ShowStatus = DBGetContactSettingByte(0, MODULE, "ShowStatus", 1); - opt.UseAlternativeText = DBGetContactSettingByte(0, MODULE, "UseAlternativeText", 0); - opt.ShowPreviousStatus = DBGetContactSettingByte(0, MODULE, "ShowPreviousStatus", 0); - opt.ReadAwayMsg = DBGetContactSettingByte(0, MODULE, "ReadAwayMsg", 0); - opt.PopupTimeout = DBGetContactSettingDword(0, MODULE, "PopupTimeout", 0); - opt.LeftClickAction= DBGetContactSettingByte(0, MODULE, "LeftClickAction", 5); - opt.RightClickAction = DBGetContactSettingByte(0, MODULE, "RightClickAction", 1); + opt.Colors = db_get_b(0,MODULE, "Colors", DEFAULT_COLORS); + opt.ShowGroup = db_get_b(0, MODULE, "ShowGroup", 0); + opt.ShowStatus = db_get_b(0, MODULE, "ShowStatus", 1); + opt.UseAlternativeText = db_get_b(0, MODULE, "UseAlternativeText", 0); + opt.ShowPreviousStatus = db_get_b(0, MODULE, "ShowPreviousStatus", 0); + opt.ReadAwayMsg = db_get_b(0, MODULE, "ReadAwayMsg", 0); + opt.PopupTimeout = db_get_dw(0, MODULE, "PopupTimeout", 0); + opt.LeftClickAction= db_get_b(0, MODULE, "LeftClickAction", 5); + opt.RightClickAction = db_get_b(0, MODULE, "RightClickAction", 1); // IDD_OPT_XPOPUP - opt.PDisableForMusic = DBGetContactSettingByte(0, MODULE, "PDisableForMusic", 1); - opt.PTruncateMsg = DBGetContactSettingByte(0, MODULE, "PTruncateMsg", 0); - opt.PMsgLen = DBGetContactSettingDword(0, MODULE, "PMsgLen", 64); + opt.PDisableForMusic = db_get_b(0, MODULE, "PDisableForMusic", 1); + opt.PTruncateMsg = db_get_b(0, MODULE, "PTruncateMsg", 0); + opt.PMsgLen = db_get_dw(0, MODULE, "PMsgLen", 64); // IDD_OPT_GENERAL - opt.FromOffline = DBGetContactSettingByte(0, MODULE, "FromOffline", 1); - opt.AutoDisable = DBGetContactSettingByte(0, MODULE, "AutoDisable", 1); - opt.HiddenContactsToo = DBGetContactSettingByte(0, MODULE, "HiddenContactsToo", 0); - opt.UseIndSnd = DBGetContactSettingByte(0, MODULE, "UseIndSounds", 1); - opt.BlinkIcon = DBGetContactSettingByte(0, MODULE, "BlinkIcon", 0); - opt.BlinkIcon_Status = DBGetContactSettingByte(0, MODULE, "BlinkIcon_Status", 0); - opt.Log = DBGetContactSettingByte(0, MODULE, "Log", 0); + opt.FromOffline = db_get_b(0, MODULE, "FromOffline", 1); + opt.AutoDisable = db_get_b(0, MODULE, "AutoDisable", 1); + opt.HiddenContactsToo = db_get_b(0, MODULE, "HiddenContactsToo", 0); + opt.UseIndSnd = db_get_b(0, MODULE, "UseIndSounds", 1); + opt.BlinkIcon = db_get_b(0, MODULE, "BlinkIcon", 0); + opt.BlinkIcon_Status = db_get_b(0, MODULE, "BlinkIcon_Status", 0); + opt.Log = db_get_b(0, MODULE, "Log", 0); DBGetStringDefault(0, MODULE, "LogFilePath", opt.LogFilePath, MAX_PATH, _T("")); // IDD_AUTODISABLE - opt.OnlyGlobalChanges = DBGetContactSettingByte(0, MODULE, "OnlyGlobalChanges", 1); - opt.DisablePopupGlobally = DBGetContactSettingByte(0, MODULE, "DisablePopupGlobally", 1); - opt.DisableSoundGlobally = DBGetContactSettingByte(0, MODULE, "DisableSoundGlobally", 1); + opt.OnlyGlobalChanges = db_get_b(0, MODULE, "OnlyGlobalChanges", 1); + opt.DisablePopupGlobally = db_get_b(0, MODULE, "DisablePopupGlobally", 1); + opt.DisableSoundGlobally = db_get_b(0, MODULE, "DisableSoundGlobally", 1); // IDD_OPT_XLOG - opt.EnableLogging = DBGetContactSettingByte(0, MODULE, "EnableLogging", 0); - opt.PreventIdentical = DBGetContactSettingByte(0, MODULE, "PreventIdentical", 1); - opt.KeepInHistory = DBGetContactSettingByte(0, MODULE, "KeepInHistory", 0); - opt.LDisableForMusic = DBGetContactSettingByte(0, MODULE, "LDisableForMusic", 1); - opt.LTruncateMsg = DBGetContactSettingByte(0, MODULE, "LTruncateMsg", 0); - opt.LMsgLen = DBGetContactSettingDword(0, MODULE, "LMsgLen", 128); + opt.EnableLogging = db_get_b(0, MODULE, "EnableLogging", 0); + opt.PreventIdentical = db_get_b(0, MODULE, "PreventIdentical", 1); + opt.KeepInHistory = db_get_b(0, MODULE, "KeepInHistory", 0); + opt.LDisableForMusic = db_get_b(0, MODULE, "LDisableForMusic", 1); + opt.LTruncateMsg = db_get_b(0, MODULE, "LTruncateMsg", 0); + opt.LMsgLen = db_get_dw(0, MODULE, "LMsgLen", 128); //IDD_OPT_SMPOPUP - opt.IgnoreEmpty = DBGetContactSettingByte(0, MODULE, "IgnoreEmpty", 1); - opt.PopupOnConnect = DBGetContactSettingByte(0, MODULE, "PopupOnConnect", 0); + opt.IgnoreEmpty = db_get_b(0, MODULE, "IgnoreEmpty", 1); + opt.PopupOnConnect = db_get_b(0, MODULE, "PopupOnConnect", 0); // OTHER - opt.TempDisabled = DBGetContactSettingByte(0, MODULE, "TempDisable", 0); + opt.TempDisabled = db_get_b(0, MODULE, "TempDisable", 0); LoadTemplates(); @@ -103,15 +103,15 @@ void LoadOptions() void SaveTemplates() { - DBWriteContactSettingTString(0, MODULE, "TPopupDelimiter", templates.PopupDelimiter); - DBWriteContactSettingTString(0, MODULE, "TPopupChange", templates.PopupNewXstatus); - DBWriteContactSettingTString(0, MODULE, "TPopupChangeMsg", templates.PopupNewMsg); - DBWriteContactSettingTString(0, MODULE, "TPopupRemoval", templates.PopupRemove); - DBWriteContactSettingTString(0, MODULE, "TLogDelimiter", templates.LogDelimiter); - DBWriteContactSettingTString(0, MODULE, "TLogChange", templates.LogNewXstatus); - DBWriteContactSettingTString(0, MODULE, "TLogChangeMsg", templates.LogNewMsg); - DBWriteContactSettingTString(0, MODULE, "TLogRemoval", templates.LogRemove); - DBWriteContactSettingTString(0, MODULE, "TLogOpening", templates.LogOpening); + db_set_ws(0, MODULE, "TPopupDelimiter", templates.PopupDelimiter); + db_set_ws(0, MODULE, "TPopupChange", templates.PopupNewXstatus); + db_set_ws(0, MODULE, "TPopupChangeMsg", templates.PopupNewMsg); + db_set_ws(0, MODULE, "TPopupRemoval", templates.PopupRemove); + db_set_ws(0, MODULE, "TLogDelimiter", templates.LogDelimiter); + db_set_ws(0, MODULE, "TLogChange", templates.LogNewXstatus); + db_set_ws(0, MODULE, "TLogChangeMsg", templates.LogNewMsg); + db_set_ws(0, MODULE, "TLogRemoval", templates.LogRemove); + db_set_ws(0, MODULE, "TLogOpening", templates.LogOpening); DBWriteContactSettingByte(0, MODULE, "TPopupFlags", templates.PopupFlags); DBWriteContactSettingByte(0, MODULE, "TLogFlags", templates.LogFlags); @@ -120,7 +120,7 @@ void SaveTemplates() TCHAR str[MAX_PATH]; mir_sntprintf(str, SIZEOF(str), _T("%s_TSMChange"), prototemplate->ProtoName); char *szstr = mir_t2a(str); - DBWriteContactSettingTString(0, MODULE, szstr, prototemplate->ProtoTemplate); + db_set_ws(0, MODULE, szstr, prototemplate->ProtoTemplate); } } @@ -148,7 +148,7 @@ void SaveOptions() DBWriteContactSettingByte(0, MODULE, "BlinkIcon", opt.BlinkIcon); DBWriteContactSettingByte(0, MODULE, "BlinkIcon_Status", opt.BlinkIcon_Status); DBWriteContactSettingByte(0, MODULE, "Log", opt.Log); - DBWriteContactSettingTString(0, MODULE, "LogFilePath", opt.LogFilePath); + db_set_ws(0, MODULE, "LogFilePath", opt.LogFilePath); // IDD_AUTODISABLE DBWriteContactSettingByte(0, MODULE, "OnlyGlobalChanges", opt.OnlyGlobalChanges); DBWriteContactSettingByte(0, MODULE, "DisablePopupGlobally", opt.DisablePopupGlobally); @@ -193,7 +193,7 @@ INT_PTR CALLBACK DlgProcGeneralOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA for (int i = ID_STATUS_MIN; i <= ID_STATUS_MAX2; i++) { wsprintfA(status, "%d", i); - CheckDlgButton(hwndDlg, i, DBGetContactSettingByte(0, MODULE, status, 1)); + CheckDlgButton(hwndDlg, i, db_get_b(0, MODULE, status, 1)); } CheckDlgButton(hwndDlg, IDC_CHK_FROMOFFLINE, opt.FromOffline); @@ -346,7 +346,7 @@ INT_PTR CALLBACK DlgProcPopUpOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM WORD idCtrl = LOWORD(wParam); if (HIWORD(wParam) == CPN_COLOURCHANGED) { - if(idCtrl > 40070) + if (idCtrl > 40070) { COLORREF colour = SendDlgItemMessage(hwndDlg, idCtrl, CPM_GETCOLOUR, 0, 0); if ((idCtrl > 41070) && (idCtrl < 42070)) //Text colour @@ -502,13 +502,13 @@ INT_PTR CALLBACK DlgProcAutoDisableOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L for (int i = ID_STATUS_MIN; i <= ID_STATUS_MAX; i++) { wsprintfA(str, "p%d", i); - CheckDlgButton(hwndDlg, i, DBGetContactSettingByte(0, MODULE, str, 0)); + CheckDlgButton(hwndDlg, i, db_get_b(0, MODULE, str, 0)); } for (int i = ID_STATUS_MIN; i <= ID_STATUS_MAX; i++) { wsprintfA(str, "s%d", i); - CheckDlgButton(hwndDlg, (i+2000),DBGetContactSettingByte(NULL, MODULE, str, 0)); + CheckDlgButton(hwndDlg, (i+2000),db_get_b(NULL, MODULE, str, 0)); } return TRUE; @@ -771,7 +771,7 @@ INT_PTR CALLBACK DlgProcSMPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA char dbSetting[128]; mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s_enabled", protos[i]->szModuleName); - ListView_SetCheckState(hList, lvItem.iItem, DBGetContactSettingByte(NULL, MODULE, dbSetting, TRUE)); + ListView_SetCheckState(hList, lvItem.iItem, db_get_b(NULL, MODULE, dbSetting, TRUE)); lvItem.iItem++; } if (lvItem.iItem) diff --git a/plugins/NewXstatusNotify/src/options.h b/plugins/NewXstatusNotify/src/options.h index 59c1bfff4f..7947401c31 100644 --- a/plugins/NewXstatusNotify/src/options.h +++ b/plugins/NewXstatusNotify/src/options.h @@ -4,19 +4,19 @@ Copyright (c) 2005-2007 Vasilich Copyright (c) 2007-2011 yaho - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef OPTIONS_H diff --git a/plugins/NewXstatusNotify/src/popup.cpp b/plugins/NewXstatusNotify/src/popup.cpp index c8e7d32e32..be7c39fd1c 100644 --- a/plugins/NewXstatusNotify/src/popup.cpp +++ b/plugins/NewXstatusNotify/src/popup.cpp @@ -4,19 +4,19 @@ Copyright (c) 2005-2007 Vasilich Copyright (c) 2007-2011 yaho - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "common.h" diff --git a/plugins/NewXstatusNotify/src/popup.h b/plugins/NewXstatusNotify/src/popup.h index e6e56f6c5b..13531388ae 100644 --- a/plugins/NewXstatusNotify/src/popup.h +++ b/plugins/NewXstatusNotify/src/popup.h @@ -4,36 +4,36 @@ Copyright (c) 2005-2007 Vasilich Copyright (c) 2007-2011 yaho - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef POPUP_H #define POPUP_H -#define POPUP_COLOR_OWN 1 -#define POPUP_COLOR_WINDOWS 2 -#define POPUP_COLOR_POPUP 3 -#define DEFAULT_COLORS POPUP_COLOR_POPUP +#define POPUP_COLOR_OWN 1 +#define POPUP_COLOR_WINDOWS 2 +#define POPUP_COLOR_POPUP 3 +#define DEFAULT_COLORS POPUP_COLOR_POPUP // Actions on popup click -#define PCA_OPENMESSAGEWND 0 // open message window -#define PCA_CLOSEPOPUP 1 // close popup -#define PCA_OPENDETAILS 2 // open contact details window -#define PCA_OPENMENU 3 // open contact menu -#define PCA_OPENHISTORY 4 // open contact history -#define PCA_DONOTHING 5 // do nothing +#define PCA_OPENMESSAGEWND 0 // open message window +#define PCA_CLOSEPOPUP 1 // close popup +#define PCA_OPENDETAILS 2 // open contact details window +#define PCA_OPENMENU 3 // open contact menu +#define PCA_OPENHISTORY 4 // open contact history +#define PCA_DONOTHING 5 // do nothing #define STRING_SHOWPREVIOUSSTATUS _T("(was %s)") diff --git a/plugins/NewXstatusNotify/src/utils.cpp b/plugins/NewXstatusNotify/src/utils.cpp index bfa8184ddf..ee8dbbc150 100644 --- a/plugins/NewXstatusNotify/src/utils.cpp +++ b/plugins/NewXstatusNotify/src/utils.cpp @@ -4,19 +4,19 @@ Copyright (c) 2005-2007 Vasilich Copyright (c) 2007-2011 yaho - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "common.h" @@ -28,16 +28,14 @@ extern STATUS StatusList[STATUS_COUNT]; TCHAR *db2t(DBVARIANT *dbv) { TCHAR *buff; - switch (dbv->type) - { + switch (dbv->type) { case DBVT_ASCIIZ: buff = mir_a2t(dbv->pszVal); break; case DBVT_WCHAR: buff = mir_tstrdup(dbv->ptszVal); break; case DBVT_UTF8: buff = mir_utf8decodeT(dbv->pszVal); break; - default: buff = mir_tstrdup(_T("")); + default: return NULL; } - if (buff[0] == 0) - { + if (buff[0] == 0) { mir_free(buff); buff = NULL; } @@ -48,8 +46,7 @@ TCHAR *db2t(DBVARIANT *dbv) int DBGetStringDefault(HANDLE hContact, const char *szModule, const char *szSetting, TCHAR *setting, int size, const TCHAR *defaultValue) { DBVARIANT dbv; - if (!DBGetContactSettingTString(hContact, szModule, szSetting, &dbv)) - { + if ( !DBGetContactSettingTString(hContact, szModule, szSetting, &dbv)) { _tcsncpy(setting, dbv.ptszVal, size); DBFreeVariant(&dbv); return 0; @@ -85,40 +82,35 @@ int ProtoServiceExists(const char *szModule, const char *szService) BOOL StatusHasAwayMessage(char *szProto, int status) { - if (szProto != NULL) - { + if (szProto != NULL) { unsigned long iSupportsSM = (unsigned long)CallProtoService(szProto, PS_GETCAPS, (WPARAM)PFLAGNUM_3, (LPARAM)0); return (iSupportsSM & Proto_Status2Flag(status)) ? TRUE : FALSE; } - else - { - switch (status) - { - case ID_STATUS_AWAY: - case ID_STATUS_NA: - case ID_STATUS_OCCUPIED: - case ID_STATUS_DND: - case ID_STATUS_FREECHAT: - case ID_STATUS_ONTHEPHONE: - case ID_STATUS_OUTTOLUNCH: - return TRUE; - default: - return FALSE; - } + + switch (status) { + case ID_STATUS_AWAY: + case ID_STATUS_NA: + case ID_STATUS_OCCUPIED: + case ID_STATUS_DND: + case ID_STATUS_FREECHAT: + case ID_STATUS_ONTHEPHONE: + case ID_STATUS_OUTTOLUNCH: + return TRUE; + + default: + return FALSE; } } void LogToFile(TCHAR *stzText) { FILE *fp = _tfopen(opt.LogFilePath, _T("a+b, ccs=UTF-8")); - if (fp) - { + if (fp) { char *encodedText = mir_utf8encodeT(stzText); - if (encodedText) - { + if (encodedText) { fprintf(fp, encodedText); mir_free(encodedText); } fclose(fp); } -} \ No newline at end of file +} diff --git a/plugins/NewXstatusNotify/src/utils.h b/plugins/NewXstatusNotify/src/utils.h index 0ff5c93e23..0c20662100 100644 --- a/plugins/NewXstatusNotify/src/utils.h +++ b/plugins/NewXstatusNotify/src/utils.h @@ -4,19 +4,19 @@ Copyright (c) 2005-2007 Vasilich Copyright (c) 2007-2011 yaho - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef UTILS_H diff --git a/plugins/NewXstatusNotify/src/xstatus.cpp b/plugins/NewXstatusNotify/src/xstatus.cpp index 4356af37fb..d99456abe9 100644 --- a/plugins/NewXstatusNotify/src/xstatus.cpp +++ b/plugins/NewXstatusNotify/src/xstatus.cpp @@ -2,19 +2,19 @@ NewXstatusNotify YM - Plugin for Miranda IM Copyright (c) 2007-2011 yaho - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "common.h" @@ -41,10 +41,9 @@ XSTATUSCHANGE *NewXSC(HANDLE hContact, char *szProto, int xstatusType, int actio void FreeXSC(XSTATUSCHANGE *xsc) { - if (xsc) - { - if (xsc->stzTitle) mir_free(xsc->stzTitle); - if (xsc->stzText) mir_free(xsc->stzText); + if (xsc) { + mir_free(xsc->stzTitle); + mir_free(xsc->stzText); mir_free(xsc); xsc = NULL; } @@ -52,11 +51,9 @@ void FreeXSC(XSTATUSCHANGE *xsc) void RemoveLoggedEvents(HANDLE hContact) { - for (int i = eventList.getCount()-1; i >= 0; i--) - { + for (int i = eventList.getCount()-1; i >= 0; i--) { DBEVENT *dbevent = eventList[i]; - if (dbevent->hContact == hContact) - { + if (dbevent->hContact == hContact) { CallService(MS_DB_EVENT_DELETE, (WPARAM)dbevent->hContact, (LPARAM)dbevent->hDBEvent); eventList.remove(i); mir_free(dbevent); @@ -84,60 +81,47 @@ void ReplaceVars(XSTATUSCHANGE *xsc , TCHAR *Template, TCHAR *delimiter, TCHAR * { buff[0] = 0; TCHAR *pch = _tcschr(Template, _T('%')); - while (pch != NULL) - { + while (pch != NULL) { size_t len = _tcslen(buff); _tcsncat(buff, Template, pch - Template); buff[len + pch - Template] = 0; - if (pch[1] == _T('N') || pch[1] == _T('T') || pch[1] == _T('I') || pch[1] == _T('D') || pch[1] == _T('B')) - { - switch (pch[1]) - { - case _T('N'): + if (pch[1] == _T('N') || pch[1] == _T('T') || pch[1] == _T('I') || pch[1] == _T('D') || pch[1] == _T('B')) { + switch (pch[1]) { + case _T('N'): { TCHAR stzType[32]; _tcscat(buff, GetStatusTypeAsString(xsc->type, stzType)); - break; } - case _T('T'): - { - if (xsc->stzTitle) - _tcscat(buff, xsc->stzTitle); - break; - } - case _T('I'): - { - if (xsc->stzText) - _tcscat(buff, xsc->stzText); - break; - } - case _T('D'): - { - if (xsc->stzText) - { - if (_tcscmp(delimiter, _T("%B")) == 0) - _tcscat(buff, _T("\r\n")); - else - _tcscat(buff, delimiter); - } - break; - } - case _T('B'): - { - _tcscat(buff, _T("\r\n")); - break; + break; + case _T('T'): + if (xsc->stzTitle) + _tcscat(buff, xsc->stzTitle); + break; + case _T('I'): + if (xsc->stzText) + _tcscat(buff, xsc->stzText); + break; + case _T('D'): + if (xsc->stzText) { + if (_tcscmp(delimiter, _T("%B")) == 0) + _tcscat(buff, _T("\r\n")); + else + _tcscat(buff, delimiter); } + break; + case _T('B'): + _tcscat(buff, _T("\r\n")); + break; } Template = pch + 2; } - else - { + else { _tcscat(buff, _T("%")); Template = pch + 1; } - + pch = _tcschr(Template, _T('%')); } @@ -154,22 +138,19 @@ void ShowPopup(XSTATUSCHANGE *xsc) POPUPDATAT ppd = {0}; ppd.lchContact = xsc->hContact; - switch(xsc->type) - { - case TYPE_JABBER_MOOD: - case TYPE_JABBER_ACTIVITY: - { - mir_snprintf(szSetting, SIZEOF(szSetting), "%s/%s/%s", xsc->szProto, (xsc->type == TYPE_JABBER_MOOD) ? "mood" : "activity", "icon"); - if (!DBGetContactSettingString(xsc->hContact, "AdvStatus", szSetting, &dbv)) - { - ppd.lchIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)dbv.pszVal); - DBFreeVariant(&dbv); - } - break; + switch(xsc->type) { + case TYPE_JABBER_MOOD: + case TYPE_JABBER_ACTIVITY: + mir_snprintf(szSetting, SIZEOF(szSetting), "%s/%s/%s", xsc->szProto, (xsc->type == TYPE_JABBER_MOOD) ? "mood" : "activity", "icon"); + if (!DBGetContactSettingString(xsc->hContact, "AdvStatus", szSetting, &dbv)) { + ppd.lchIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)dbv.pszVal); + DBFreeVariant(&dbv); } - case TYPE_ICQ_XSTATUS: + break; + + case TYPE_ICQ_XSTATUS: { - int statusId = DBGetContactSettingByte(xsc->hContact, xsc->szProto, "XStatusId", 0); + int statusId = db_get_b(xsc->hContact, xsc->szProto, "XStatusId", 0); ppd.lchIcon = (HICON)CallProtoService(xsc->szProto, PS_ICQ_GETCUSTOMSTATUSICON, statusId, LR_SHARED); } } @@ -177,19 +158,18 @@ void ShowPopup(XSTATUSCHANGE *xsc) if (ppd.lchIcon == NULL) ppd.lchIcon = LoadSkinnedProtoIcon(xsc->szProto, DBGetContactSettingWord(xsc->hContact, xsc->szProto, "Status", ID_STATUS_ONLINE)); - switch (opt.Colors) - { - case POPUP_COLOR_OWN: - ppd.colorBack = DBGetContactSettingDword(0, MODULE, "40081bg", COLOR_BG_AVAILDEFAULT); - ppd.colorText = DBGetContactSettingDword(0, MODULE, "40081tx", COLOR_TX_DEFAULT); - break; - case POPUP_COLOR_WINDOWS: - ppd.colorBack = GetSysColor(COLOR_BTNFACE); - ppd.colorText = GetSysColor(COLOR_WINDOWTEXT); - break; - case POPUP_COLOR_POPUP: - ppd.colorBack = ppd.colorText = 0; - break; + switch (opt.Colors) { + case POPUP_COLOR_OWN: + ppd.colorBack = db_get_dw(0, MODULE, "40081bg", COLOR_BG_AVAILDEFAULT); + ppd.colorText = db_get_dw(0, MODULE, "40081tx", COLOR_TX_DEFAULT); + break; + case POPUP_COLOR_WINDOWS: + ppd.colorBack = GetSysColor(COLOR_BTNFACE); + ppd.colorText = GetSysColor(COLOR_WINDOWTEXT); + break; + case POPUP_COLOR_POPUP: + ppd.colorBack = ppd.colorText = 0; + break; } TCHAR *ptszGroup = NULL, @@ -207,8 +187,7 @@ void ShowPopup(XSTATUSCHANGE *xsc) _tcsncpy(ppd.lptzContactName, ptszNick, SIZEOF(ppd.lptzContactName)); // cut message if needed - if (opt.PTruncateMsg && (opt.PMsgLen > 0) && xsc->stzText && (_tcslen(xsc->stzText) > opt.PMsgLen)) - { + if (opt.PTruncateMsg && (opt.PMsgLen > 0) && xsc->stzText && (_tcslen(xsc->stzText) > opt.PMsgLen)) { TCHAR buff[MAX_TEXT_LEN + 3]; _tcsncpy(buff, xsc->stzText, opt.PMsgLen); buff[opt.PMsgLen] = 0; @@ -218,16 +197,15 @@ void ShowPopup(XSTATUSCHANGE *xsc) } TCHAR *Template = _T(""); - switch (xsc->action) - { - case NOTIFY_NEW_XSTATUS: - Template = templates.PopupNewXstatus; break; - case NOTIFY_NEW_MESSAGE: - Template = templates.PopupNewMsg; break; - case NOTIFY_REMOVE: - Template = templates.PopupRemove; break; - case NOTIFY_OPENING_ML: - Template = templates.LogOpening; break; + switch (xsc->action) { + case NOTIFY_NEW_XSTATUS: + Template = templates.PopupNewXstatus; break; + case NOTIFY_NEW_MESSAGE: + Template = templates.PopupNewMsg; break; + case NOTIFY_REMOVE: + Template = templates.PopupRemove; break; + case NOTIFY_OPENING_ML: + Template = templates.LogOpening; break; } TCHAR stzPopupText[2*MAX_TEXT_LEN]; @@ -242,22 +220,20 @@ void ShowPopup(XSTATUSCHANGE *xsc) void PlayXStatusSound(int action) { - switch (action) - { - case NOTIFY_NEW_XSTATUS: - SkinPlaySound(XSTATUS_SOUND_CHANGED); break; - case NOTIFY_NEW_MESSAGE: - SkinPlaySound(XSTATUS_SOUND_MSGCHANGED); break; - case NOTIFY_REMOVE: - SkinPlaySound(XSTATUS_SOUND_REMOVED); break; + switch (action) { + case NOTIFY_NEW_XSTATUS: + SkinPlaySound(XSTATUS_SOUND_CHANGED); break; + case NOTIFY_NEW_MESSAGE: + SkinPlaySound(XSTATUS_SOUND_MSGCHANGED); break; + case NOTIFY_REMOVE: + SkinPlaySound(XSTATUS_SOUND_REMOVED); break; } } void LogToMessageWindow(XSTATUSCHANGE *xsc, BOOL opening) { // cut message if needed - if (opt.LTruncateMsg && (opt.LMsgLen > 0) && xsc->stzText && (_tcslen(xsc->stzText) > opt.LMsgLen)) - { + if (opt.LTruncateMsg && (opt.LMsgLen > 0) && xsc->stzText && (_tcslen(xsc->stzText) > opt.LMsgLen)) { TCHAR buff[MAX_TEXT_LEN + 3]; _tcsncpy(buff, xsc->stzText, opt.LMsgLen); buff[opt.LMsgLen] = 0; @@ -267,16 +243,15 @@ void LogToMessageWindow(XSTATUSCHANGE *xsc, BOOL opening) } TCHAR *Template = _T(""); - switch (xsc->action) - { - case NOTIFY_NEW_XSTATUS: - Template = templates.LogNewXstatus; break; - case NOTIFY_NEW_MESSAGE: - Template = templates.LogNewMsg; break; - case NOTIFY_REMOVE: - Template = templates.LogRemove; break; - case NOTIFY_OPENING_ML: - Template = templates.LogOpening; break; + switch (xsc->action) { + case NOTIFY_NEW_XSTATUS: + Template = templates.LogNewXstatus; break; + case NOTIFY_NEW_MESSAGE: + Template = templates.LogNewMsg; break; + case NOTIFY_REMOVE: + Template = templates.LogRemove; break; + case NOTIFY_OPENING_ML: + Template = templates.LogOpening; break; } TCHAR stzLogText[2*MAX_TEXT_LEN]; @@ -284,14 +259,10 @@ void LogToMessageWindow(XSTATUSCHANGE *xsc, BOOL opening) ReplaceVars(xsc, Template, templates.LogDelimiter, stzLogText); DBGetStringDefault(xsc->hContact, MODULE, DB_LASTLOG, stzLastLog, SIZEOF(stzLastLog), _T("")); - if (!opt.KeepInHistory || !(opt.PreventIdentical && _tcscmp(stzLastLog, stzLogText) == 0)) - { - DBWriteContactSettingTString(xsc->hContact, MODULE, DB_LASTLOG, stzLogText); - - char *blob; - - blob = mir_utf8encodeT(stzLogText); + if (!opt.KeepInHistory || !(opt.PreventIdentical && _tcscmp(stzLastLog, stzLogText) == 0)) { + db_set_ws(xsc->hContact, MODULE, DB_LASTLOG, stzLogText); + char *blob = mir_utf8encodeT(stzLogText); DBEVENTINFO dbei = {0}; dbei.cbSize = sizeof(dbei); @@ -307,8 +278,7 @@ void LogToMessageWindow(XSTATUSCHANGE *xsc, BOOL opening) HANDLE hDBEvent = (HANDLE)CallService(MS_DB_EVENT_ADD, (WPARAM)xsc->hContact, (LPARAM)&dbei); mir_free(blob); - if (!opt.KeepInHistory) - { + if (!opt.KeepInHistory) { DBEVENT *dbevent = (DBEVENT *)mir_alloc(sizeof(DBEVENT)); dbevent->hContact = xsc->hContact; dbevent->hDBEvent = hDBEvent; @@ -339,40 +309,40 @@ void LogChangeToFile(XSTATUSCHANGE *xsc) void ExtraStatusChanged(XSTATUSCHANGE *xsc) { + if (xsc == NULL) + return; + BOOL bEnablePopup = true, bEnableSound = true; char buff[12] = {0}; wsprintfA(buff, "%d", ID_STATUS_EXTRASTATUS); - if ((DBGetContactSettingByte(0, MODULE, buff, 1) == 0) || - (DBGetContactSettingWord(xsc->hContact, xsc->szProto, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE) || - (!opt.HiddenContactsToo && DBGetContactSettingByte(xsc->hContact, "CList", "Hidden", 0)) || - (opt.TempDisabled)) - { + if (( db_get_b(0, MODULE, buff, 1) == 0) + || (DBGetContactSettingWord(xsc->hContact, xsc->szProto, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE) + || (!opt.HiddenContactsToo && db_get_b(xsc->hContact, "CList", "Hidden", 0)) + || (opt.TempDisabled)) return; - } char statusIDs[12], statusIDp[12]; - if (opt.AutoDisable) - { + if (opt.AutoDisable) { WORD myStatus = (WORD)CallProtoService(xsc->szProto, PS_GETSTATUS, 0, 0); wsprintfA(statusIDs, "s%d", myStatus); wsprintfA(statusIDp, "p%d", myStatus); - bEnableSound = DBGetContactSettingByte(0, MODULE, statusIDs, 1) ? FALSE : TRUE; - bEnablePopup = DBGetContactSettingByte(0, MODULE, statusIDp, 1) ? FALSE : TRUE; + bEnableSound = db_get_b(0, MODULE, statusIDs, 1) ? FALSE : TRUE; + bEnablePopup = db_get_b(0, MODULE, statusIDp, 1) ? FALSE : TRUE; } if (!(templates.PopupFlags & xsc->action)) bEnableSound = bEnablePopup = false; - int xstatusID = DBGetContactSettingByte(xsc->hContact, xsc->szProto, "XStatusId", 0); + int xstatusID = db_get_b(xsc->hContact, xsc->szProto, "XStatusId", 0); if (opt.PDisableForMusic && xsc->type == TYPE_ICQ_XSTATUS && xstatusID == XSTATUS_MUSIC) bEnableSound = bEnablePopup = false; - if (bEnablePopup && DBGetContactSettingByte(xsc->hContact, MODULE, "EnableXStatusNotify", 1) && TimeoutCheck()) + if (bEnablePopup && db_get_b(xsc->hContact, MODULE, "EnableXStatusNotify", 1) && TimeoutCheck()) ShowPopup(xsc); - if (bEnableSound && DBGetContactSettingByte(xsc->hContact, MODULE, "EnableXStatusNotify", 1)) + if (bEnableSound && db_get_b(xsc->hContact, MODULE, "EnableXStatusNotify", 1)) PlayXStatusSound(xsc->action); BYTE enableLog = opt.EnableLogging; @@ -382,14 +352,14 @@ void ExtraStatusChanged(XSTATUSCHANGE *xsc) if (!(templates.LogFlags & xsc->action)) enableLog = FALSE; - if (enableLog && DBGetContactSettingByte(xsc->hContact, MODULE, "EnableLogging", 1) && - CallService(MS_MSG_MOD_MESSAGEDIALOGOPENED, (WPARAM)xsc->hContact, 0)) - { + if (enableLog && db_get_b(xsc->hContact, MODULE, "EnableLogging", 1) + && CallService(MS_MSG_MOD_MESSAGEDIALOGOPENED, (WPARAM)xsc->hContact, 0)) LogToMessageWindow(xsc, FALSE); - } if (opt.Log) LogChangeToFile(xsc); + + FreeXSC(xsc); } TCHAR *GetDefaultXstatusName(int statusID, char *szProto, TCHAR *buff, int bufflen) @@ -402,8 +372,7 @@ TCHAR *GetDefaultXstatusName(int statusID, char *szProto, TCHAR *buff, int buffl xstatus.flags = CSSF_MASK_NAME | CSSF_DEFAULT_NAME | CSSF_TCHAR; xstatus.ptszName = nameBuff; xstatus.wParam = (WPARAM *)&statusID; - if (!CallProtoService(szProto, PS_ICQ_GETCUSTOMSTATUSEX, 0, (LPARAM)&xstatus)) - { + if (!CallProtoService(szProto, PS_ICQ_GETCUSTOMSTATUSEX, 0, (LPARAM)&xstatus)) { _tcsncpy(buff, TranslateTS(nameBuff), bufflen); buff[bufflen - 1] = 0; } @@ -416,11 +385,9 @@ TCHAR *GetIcqXStatus(HANDLE hContact, char *szProto, char *szValue, TCHAR *buff, DBVARIANT dbv; buff[0] = 0; - int statusID = DBGetContactSettingByte(hContact, szProto, "XStatusId", -1); - if (statusID != -1) - { - if (!DBGetContactSettingTString(hContact, szProto, szValue, &dbv)) - { + int statusID = db_get_b(hContact, szProto, "XStatusId", -1); + if (statusID != -1) { + if (!DBGetContactSettingTString(hContact, szProto, szValue, &dbv)) { if ((strcmp(szValue, "XStatusName") == 0) && dbv.ptszVal[0] == 0) GetDefaultXstatusName(statusID, szProto, buff, bufflen); else @@ -441,8 +408,7 @@ TCHAR *GetJabberAdvStatusText(HANDLE hContact, char *szProto, char *szSlot, char buff[0] = 0; mir_snprintf(szSetting, SIZEOF(szSetting), "%s/%s/%s", szProto, szSlot, szValue); - if (!DBGetContactSettingTString(hContact, "AdvStatus", szSetting, &dbv)) - { + if ( !DBGetContactSettingTString(hContact, "AdvStatus", szSetting, &dbv)) { _tcsncpy(buff, dbv.ptszVal, bufflen); buff[bufflen - 1] = 0; DBFreeVariant(&dbv); @@ -473,29 +439,25 @@ void AddEventThread(void *arg) TCHAR stzTitle[MAX_TITLE_LEN], stzText[MAX_TEXT_LEN]; char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); - if (szProto == NULL) return; + if (szProto == NULL) + return; - if (ProtoServiceExists(szProto, JS_PARSE_XMPP_URI)) - { + if (ProtoServiceExists(szProto, JS_PARSE_XMPP_URI)) { GetJabberAdvStatusText(hContact, szProto, "mood", "title", stzTitle, SIZEOF(stzTitle)); - if (stzTitle[0]) - { + if (stzTitle[0]) { GetJabberAdvStatusText(hContact, szProto, "mood", "text", stzText, SIZEOF(stzText)); LogXstatusChange(hContact, szProto, TYPE_JABBER_MOOD, stzTitle, stzText); } GetJabberAdvStatusText(hContact, szProto, "activity", "title", stzTitle, SIZEOF(stzTitle)); - if (stzTitle[0]) - { + if (stzTitle[0]) { GetJabberAdvStatusText(hContact, szProto, "activity", "text", stzText, SIZEOF(stzText)); LogXstatusChange(hContact, szProto, TYPE_JABBER_ACTIVITY, stzTitle, stzText); } } - else - { + else { GetIcqXStatus(hContact, szProto, "XStatusName", stzTitle, SIZEOF(stzTitle)); - if (stzTitle[0]) - { + if (stzTitle[0]) { GetIcqXStatus(hContact, szProto, "XStatusMsg", stzText, SIZEOF(stzText)); LogXstatusChange(hContact, szProto, TYPE_ICQ_XSTATUS, stzTitle, stzText); } @@ -506,8 +468,7 @@ int OnWindowEvent(WPARAM wParam, LPARAM lParam) { MessageWindowEventData *mwed = (MessageWindowEventData *)lParam; - if (mwed->uType == MSG_WINDOW_EVT_CLOSE && !opt.KeepInHistory) - { + if (mwed->uType == MSG_WINDOW_EVT_CLOSE && !opt.KeepInHistory) { RemoveLoggedEvents(mwed->hContact); return 0; } @@ -515,7 +476,7 @@ int OnWindowEvent(WPARAM wParam, LPARAM lParam) if (opt.EnableLogging && (mwed->uType == MSG_WINDOW_EVT_OPEN) && (templates.LogFlags & NOTIFY_OPENING_ML) && - (DBGetContactSettingByte(mwed->hContact, MODULE, "EnableLogging", 1) == 1)) + (db_get_b(mwed->hContact, MODULE, "EnableLogging", 1) == 1)) { mir_forkthread(AddEventThread, mwed->hContact); } diff --git a/plugins/NewXstatusNotify/src/xstatus.h b/plugins/NewXstatusNotify/src/xstatus.h index d5a76acb52..5dfcdc346d 100644 --- a/plugins/NewXstatusNotify/src/xstatus.h +++ b/plugins/NewXstatusNotify/src/xstatus.h @@ -2,19 +2,19 @@ NewXstatusNotify YM - Plugin for Miranda IM Copyright (c) 2007-2011 yaho - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef XSTATUS_H @@ -98,9 +98,9 @@ typedef struct tagPROTOTEMPLATE TCHAR *GetDefaultXstatusName(int statusID, char *szProto, TCHAR *buff, int bufflen); XSTATUSCHANGE *NewXSC(HANDLE hContact, char *szProto, int xstatusType, int action, TCHAR *stzTitle, TCHAR *stzText); -void FreeXSC(XSTATUSCHANGE *xsc); void ExtraStatusChanged(XSTATUSCHANGE *xsc); -int OnWindowEvent(WPARAM wParam, LPARAM lParam); +void FreeXSC(XSTATUSCHANGE *xsc); +int OnWindowEvent(WPARAM wParam, LPARAM lParam); BOOL TimeoutCheck(); #endif \ No newline at end of file diff --git a/plugins/Popup/src/history.cpp b/plugins/Popup/src/history.cpp index 7da08ec60b..6775efe666 100644 --- a/plugins/Popup/src/history.cpp +++ b/plugins/Popup/src/history.cpp @@ -83,16 +83,9 @@ void PopupHistoryResize() } for(i = 0; i < toDelete; ++i){//free too old ones POPUPDATA2 *ppd = &oldPopupHistory[(oldStart + i)%oldBuffer]; - if (ppd->flags & PU2_UNICODE) - { - mir_free(ppd->lpwzTitle); - mir_free(ppd->lpwzText); - } else - { - mir_free(ppd->lpzTitle); - mir_free(ppd->lpzText); - } - if (ppd->lpzSkin) mir_free(ppd->lpzSkin); + mir_free(ppd->lpzTitle); + mir_free(ppd->lpzText); + mir_free(ppd->lpzSkin); } delete [] oldPopupHistory; } @@ -102,16 +95,9 @@ void PopupHistoryUnload() for (int i = 0; i < popupHistorySize; ++i) { POPUPDATA2 *ppd = &popupHistory[getHistoryIndex(i)]; - if (ppd->flags & PU2_UNICODE) - { - mir_free(ppd->lpwzTitle); - mir_free(ppd->lpwzText); - } else - { - mir_free(ppd->lpzTitle); - mir_free(ppd->lpzText); - } - if (ppd->lpzSkin) mir_free(ppd->lpzSkin); + mir_free(ppd->lpzTitle); + mir_free(ppd->lpzText); + mir_free(ppd->lpzSkin); } delete [] popupHistory; popupHistory = NULL; @@ -286,11 +272,11 @@ static INT_PTR CALLBACK HistoryDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA return TRUE; LPMEASUREITEMSTRUCT lpmis; - lpmis = (LPMEASUREITEMSTRUCT) lParam; + lpmis = (LPMEASUREITEMSTRUCT) lParam; if (lpmis->itemID == -1) return FALSE; lpmis->itemHeight = 50; - return TRUE; + return TRUE; } case WM_DRAWITEM: { -- cgit v1.2.3