From f12d8b56f2894e94491bd7424d69f595d285f01f Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 3 Nov 2012 20:16:42 +0000 Subject: no more MS_CLIST_EXTRA_ADD_ICON in the application code git-svn-id: http://svn.miranda-ng.org/main/trunk@2175 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/WhenWasIt/src/commonheaders.h | 1 - plugins/WhenWasIt/src/dlg_handlers.cpp | 568 +++++++++++++++----------------- plugins/WhenWasIt/src/hooked_events.cpp | 184 ++++------- plugins/WhenWasIt/src/hooked_events.h | 1 - plugins/WhenWasIt/src/icons.cpp | 31 +- plugins/WhenWasIt/src/icons.h | 2 - plugins/WhenWasIt/src/notifiers.cpp | 207 ++++-------- plugins/WhenWasIt/src/notifiers.h | 4 +- plugins/WhenWasIt/src/services.cpp | 1 - 9 files changed, 389 insertions(+), 610 deletions(-) (limited to 'plugins/WhenWasIt') diff --git a/plugins/WhenWasIt/src/commonheaders.h b/plugins/WhenWasIt/src/commonheaders.h index a231fafba8..e2421e91c8 100644 --- a/plugins/WhenWasIt/src/commonheaders.h +++ b/plugins/WhenWasIt/src/commonheaders.h @@ -81,7 +81,6 @@ struct CommonData{ int daysInAdvance; int popupTimeout; int popupTimeoutToday; - int clistIcon; int bUsePopups; int bUseClistIcon; int bUseDialog; diff --git a/plugins/WhenWasIt/src/dlg_handlers.cpp b/plugins/WhenWasIt/src/dlg_handlers.cpp index db617c4d4f..2c8114eca5 100644 --- a/plugins/WhenWasIt/src/dlg_handlers.cpp +++ b/plugins/WhenWasIt/src/dlg_handlers.cpp @@ -52,30 +52,21 @@ const int cNotifyFor = sizeof(szNotifyFor) / sizeof(szNotifyFor[0]); #include "commctrl.h" void CreateToolTip(HWND target, TCHAR* tooltip, LPARAM width) { - HWND hwndToolTip; - - hwndToolTip = CreateWindow(TOOLTIPS_CLASS, NULL, - WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, - CW_USEDEFAULT, CW_USEDEFAULT, - CW_USEDEFAULT, CW_USEDEFAULT, - target, - NULL, - NULL, - NULL); - if (hwndToolTip) - { - TOOLINFO ti = {0}; - ti.cbSize = sizeof(ti); - ti.uFlags = TTF_TRANSPARENT | TTF_SUBCLASS; - ti.hwnd = target; - ti.uId = 0; - ti.hinst = NULL; - ti.lpszText = tooltip; - GetClientRect(target, &ti.rect); - SendMessage(hwndToolTip, TTM_ADDTOOL, 0, (LPARAM) &ti ); - SendMessage(hwndToolTip, TTM_SETMAXTIPWIDTH, 0, width); - SendMessage(hwndToolTip, TTM_SETDELAYTIME, TTDT_AUTOPOP, 20000); - } + HWND hwndToolTip = CreateWindow(TOOLTIPS_CLASS, NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, + CW_USEDEFAULT, CW_USEDEFAULT, target, NULL, NULL, NULL); + if (hwndToolTip) { + TOOLINFO ti = {0}; + ti.cbSize = sizeof(ti); + ti.uFlags = TTF_TRANSPARENT | TTF_SUBCLASS; + ti.hwnd = target; + ti.uId = 0; + ti.hinst = NULL; + ti.lpszText = tooltip; + GetClientRect(target, &ti.rect); + SendMessage(hwndToolTip, TTM_ADDTOOL, 0, (LPARAM) &ti ); + SendMessage(hwndToolTip, TTM_SETMAXTIPWIDTH, 0, width); + SendMessage(hwndToolTip, TTM_SETDELAYTIME, TTDT_AUTOPOP, 20000); + } } int EnablePopupsGroup(HWND hWnd, int enable) @@ -112,33 +103,25 @@ int AddInfoToComboBoxes(HWND hWnd) { int i; TCHAR *buffer; - for (i = 0; i < cAdvancedIcons; i++) - { - buffer = TranslateTS(szAdvancedIcons[i]); - SendMessage(GetDlgItem(hWnd, IDC_ADVANCED_ICON), CB_ADDSTRING, 0, (LPARAM) buffer); - } - + for (i = 0; i < cAdvancedIcons; i++) { + buffer = TranslateTS(szAdvancedIcons[i]); + SendMessage(GetDlgItem(hWnd, IDC_ADVANCED_ICON), CB_ADDSTRING, 0, (LPARAM) buffer); + } + for (i = 0; i < cShowAgeMode; i++) - { - SendMessage(GetDlgItem(hWnd, IDC_AGE_COMBOBOX), CB_ADDSTRING, 0, (LPARAM) TranslateTS(szShowAgeMode[i])); - } - + SendMessage(GetDlgItem(hWnd, IDC_AGE_COMBOBOX), CB_ADDSTRING, 0, (LPARAM) TranslateTS(szShowAgeMode[i])); + for (i = 0; i < cSaveModule; i++) - { - SendMessage(GetDlgItem(hWnd, IDC_DEFAULT_MODULE), CB_ADDSTRING, 0, (LPARAM) TranslateTS(szSaveModule[i])); - } - - for (i = 0; i < cPopupClick; i++) - { - SendMessage(GetDlgItem(hWnd, IDC_LEFT_CLICK), CB_ADDSTRING, 0, (LPARAM) TranslateTS(szPopupClick[i])); - SendMessage(GetDlgItem(hWnd, IDC_RIGHT_CLICK), CB_ADDSTRING, 0, (LPARAM) TranslateTS(szPopupClick[i])); - } - + SendMessage(GetDlgItem(hWnd, IDC_DEFAULT_MODULE), CB_ADDSTRING, 0, (LPARAM) TranslateTS(szSaveModule[i])); + + for (i = 0; i < cPopupClick; i++) { + SendMessage(GetDlgItem(hWnd, IDC_LEFT_CLICK), CB_ADDSTRING, 0, (LPARAM) TranslateTS(szPopupClick[i])); + SendMessage(GetDlgItem(hWnd, IDC_RIGHT_CLICK), CB_ADDSTRING, 0, (LPARAM) TranslateTS(szPopupClick[i])); + } + for (i = 0; i < cNotifyFor; i++) - { SendMessage(GetDlgItem(hWnd, IDC_NOTIFYFOR), CB_ADDSTRING, 0, (LPARAM) TranslateTS(szNotifyFor[i])); - } - + return i; } @@ -176,13 +159,13 @@ TCHAR *strtrim(TCHAR *str) size_t i = 0; size_t len = _tcslen(str); while ((i < len) && (str[i] == _T(' '))) { i++; } - if (i) - { + if (i) { memmove(str, str + i, len - i + 1); len -= i; } - while ((len > 0) && (str[--len] == _T(' '))) { str[len] = 0; } + while ((len > 0) && (str[--len] == _T(' '))) + str[len] = 0; return str; } @@ -190,271 +173,236 @@ TCHAR *strtrim(TCHAR *str) INT_PTR CALLBACK DlgProcOptions(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { static int bInitializing = 0; - switch (msg) + switch (msg) { + case WM_INITDIALOG: { - case WM_INITDIALOG: - { - bInitializing = 1; - - SIZE oldPopupsSize = GetControlTextSize(GetDlgItem(hWnd, IDC_USE_POPUPS)); - SIZE oldClistIconSize = GetControlTextSize(GetDlgItem(hWnd, IDC_USE_CLISTICON)); - SIZE oldDialogSize = GetControlTextSize(GetDlgItem(hWnd, IDC_USE_DIALOG)); - - TranslateDialogDefault(hWnd); - - EnlargeControl(GetDlgItem(hWnd, IDC_USE_POPUPS), GetDlgItem(hWnd, IDC_POPUPS_STATIC), oldPopupsSize); - EnlargeControl(GetDlgItem(hWnd, IDC_USE_CLISTICON), GetDlgItem(hWnd, IDC_CLIST_STATIC), oldClistIconSize); - EnlargeControl(GetDlgItem(hWnd, IDC_USE_DIALOG), GetDlgItem(hWnd, IDC_DIALOG_STATIC), oldDialogSize); + bInitializing = 1; - AddInfoToComboBoxes(hWnd); - - SendMessage(GetDlgItem(hWnd, IDC_FOREGROUND), CPM_SETDEFAULTCOLOUR, 0, FOREGROUND_COLOR); - SendMessage(GetDlgItem(hWnd, IDC_BACKGROUND), CPM_SETDEFAULTCOLOUR, 0, BACKGROUND_COLOR); - - SendMessage(GetDlgItem(hWnd, IDC_FOREGROUND), CPM_SETCOLOUR, 0, commonData.foreground); - SendMessage(GetDlgItem(hWnd, IDC_BACKGROUND), CPM_SETCOLOUR, 0, commonData.background); - - SendMessage(GetDlgItem(hWnd, IDC_ADVANCED_ICON), CB_SETCURSEL, commonData.clistIcon, 0); - SendMessage(GetDlgItem(hWnd, IDC_DEFAULT_MODULE), CB_SETCURSEL, commonData.cDefaultModule, 0); - SendMessage(GetDlgItem(hWnd, IDC_LEFT_CLICK), CB_SETCURSEL, commonData.lPopupClick, 0); - SendMessage(GetDlgItem(hWnd, IDC_RIGHT_CLICK), CB_SETCURSEL, commonData.rPopupClick, 0); - SendMessage(GetDlgItem(hWnd, IDC_NOTIFYFOR), CB_SETCURSEL, commonData.notifyFor, 0); - - CreateToolTip(GetDlgItem(hWnd, IDC_POPUP_TIMEOUT), TranslateT("Set popup delay when notifying of upcoming birthdays.\nFormat: default delay [ | delay for birthdays occuring today]"), 400); - - TCHAR buffer[1024]; - _itot(commonData.daysInAdvance, buffer, 10); - SetWindowText(GetDlgItem(hWnd, IDC_DAYS_IN_ADVANCE), buffer); - _itot(commonData.checkInterval, buffer, 10); - SetWindowText(GetDlgItem(hWnd, IDC_CHECK_INTERVAL), buffer); - _sntprintf(buffer, 1024, _T("%d|%d"), commonData.popupTimeout, commonData.popupTimeoutToday); - SetWindowText(GetDlgItem(hWnd, IDC_POPUP_TIMEOUT), buffer); - _itot(commonData.cSoundNearDays, buffer, 10); - SetWindowText(GetDlgItem(hWnd, IDC_SOUND_NEAR_DAYS_EDIT), buffer); - _itot(commonData.cDlgTimeout, buffer, 10); - SetWindowText(GetDlgItem(hWnd, IDC_DLG_TIMEOUT), buffer); - _itot(commonData.daysAfter, buffer, 10); - SetWindowText(GetDlgItem(hWnd, IDC_DAYS_AFTER), buffer); - - CheckDlgButton(hWnd, IDC_OPENINBACKGROUND, (commonData.bOpenInBackground) ? BST_CHECKED : BST_UNCHECKED); - - CheckDlgButton(hWnd, IDC_NOBIRTHDAYS_POPUP, (commonData.bNoBirthdaysPopup) ? BST_CHECKED : BST_UNCHECKED); - //CheckDlgButton(hWnd, IDC_SHOW_CURRENT_AGE, (bShowCurrentAge) ? BST_CHECKED : BST_UNCHECKED); - SendMessage(GetDlgItem(hWnd, IDC_AGE_COMBOBOX), CB_SETCURSEL, commonData.cShowAgeMode, 0); - - CheckDlgButton(hWnd, IDC_IGNORE_SUBCONTACTS, (commonData.bIgnoreSubcontacts) ? BST_CHECKED : BST_UNCHECKED); - - CheckDlgButton(hWnd, IDC_ONCE_PER_DAY, (commonData.bOncePerDay) ? BST_CHECKED : BST_UNCHECKED); - EnableWindow(GetDlgItem(hWnd, IDC_CHECK_INTERVAL), !commonData.bOncePerDay); - - CheckDlgButton(hWnd, IDC_USE_DIALOG, (commonData.bUseDialog) ? BST_CHECKED : BST_UNCHECKED); - EnableDialogGroup(hWnd, commonData.bUseDialog); - - if (ServiceExists(MS_POPUP_ADDPOPUPEX)) - { - CheckDlgButton(hWnd, IDC_USE_POPUPS, commonData.bUsePopups ? BST_CHECKED : BST_UNCHECKED); - EnablePopupsGroup(hWnd, commonData.bUsePopups); - } - else{ - EnableWindow(GetDlgItem(hWnd, IDC_USE_POPUPS), FALSE); - EnablePopupsGroup(hWnd, FALSE); - } - - if (ServiceExists(MS_CLIST_EXTRA_SET_ICON) && (!ServiceExists(MS_EXTRAICON_REGISTER))) - { - CheckDlgButton(hWnd, IDC_USE_CLISTICON, commonData.bUseClistIcon ? BST_CHECKED : BST_UNCHECKED); - EnableClistGroup(hWnd, commonData.bUseClistIcon); - } - else{ - CheckDlgButton(hWnd, IDC_USE_CLISTICON, BST_CHECKED); - EnableWindow(GetDlgItem(hWnd, IDC_USE_CLISTICON), FALSE); - EnableClistGroup(hWnd, FALSE); - } - bInitializing = 0; - - return TRUE; - } - case WM_COMMAND: - { - switch (LOWORD(wParam)) - { - case IDC_CHECK_INTERVAL: - case IDC_POPUP_TIMEOUT: - case IDC_DAYS_IN_ADVANCE: - case IDC_DLG_TIMEOUT: - case IDC_SOUND_NEAR_DAYS_EDIT: - case IDC_DAYS_AFTER: - { - if ((HIWORD(wParam) == EN_CHANGE) && (!bInitializing))// || (HIWORD(wParam) == CBN_SELENDOK)) - { - SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0); - } - - break; - } - - case IDC_USE_POPUPS: - case IDC_USE_CLISTICON: - case IDC_USE_DIALOG: - { - EnablePopupsGroup(hWnd, IsDlgButtonChecked(hWnd, IDC_USE_POPUPS)); - EnableClistGroup(hWnd, IsDlgButtonChecked(hWnd, IDC_USE_CLISTICON)); - EnableDialogGroup(hWnd, IsDlgButtonChecked(hWnd, IDC_USE_DIALOG)); - RedrawWindow(GetDlgItem(hWnd, IDC_USE_POPUPS), NULL, NULL, RDW_ERASE | RDW_INVALIDATE); - RedrawWindow(GetDlgItem(hWnd, IDC_USE_CLISTICON), NULL, NULL, RDW_ERASE | RDW_INVALIDATE); - RedrawWindow(GetDlgItem(hWnd, IDC_USE_DIALOG), NULL, NULL, RDW_ERASE | RDW_INVALIDATE); - }//fallthrough - - case IDC_FOREGROUND: - case IDC_BACKGROUND: - case IDC_ADVANCED_ICON: - case IDC_IGNORE_SUBCONTACTS: - case IDC_AGE_COMBOBOX: - case IDC_NOBIRTHDAYS_POPUP: - case IDC_DEFAULT_MODULE: - case IDC_LEFT_CLICK: - case IDC_RIGHT_CLICK: - case IDC_ONCE_PER_DAY: - case IDC_NOTIFYFOR: - { - SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0); - EnableWindow(GetDlgItem(hWnd, IDC_CHECK_INTERVAL), !IsDlgButtonChecked(hWnd, IDC_ONCE_PER_DAY)); - - break; - } - - case IDC_PREVIEW: - { - HANDLE hContact = db_find_first(); - int dtb, age; - dtb = rand() % 11; //0..10 - age = rand() % 50 + 1; //1..50 - PopupNotifyBirthday(hContact, dtb, age); - - break; - } - } - break; - } - case WM_NOTIFY: + SIZE oldPopupsSize = GetControlTextSize(GetDlgItem(hWnd, IDC_USE_POPUPS)); + SIZE oldClistIconSize = GetControlTextSize(GetDlgItem(hWnd, IDC_USE_CLISTICON)); + SIZE oldDialogSize = GetControlTextSize(GetDlgItem(hWnd, IDC_USE_DIALOG)); + + TranslateDialogDefault(hWnd); + + EnlargeControl(GetDlgItem(hWnd, IDC_USE_POPUPS), GetDlgItem(hWnd, IDC_POPUPS_STATIC), oldPopupsSize); + EnlargeControl(GetDlgItem(hWnd, IDC_USE_CLISTICON), GetDlgItem(hWnd, IDC_CLIST_STATIC), oldClistIconSize); + EnlargeControl(GetDlgItem(hWnd, IDC_USE_DIALOG), GetDlgItem(hWnd, IDC_DIALOG_STATIC), oldDialogSize); + + AddInfoToComboBoxes(hWnd); + + SendMessage(GetDlgItem(hWnd, IDC_FOREGROUND), CPM_SETDEFAULTCOLOUR, 0, FOREGROUND_COLOR); + SendMessage(GetDlgItem(hWnd, IDC_BACKGROUND), CPM_SETDEFAULTCOLOUR, 0, BACKGROUND_COLOR); + + SendMessage(GetDlgItem(hWnd, IDC_FOREGROUND), CPM_SETCOLOUR, 0, commonData.foreground); + SendMessage(GetDlgItem(hWnd, IDC_BACKGROUND), CPM_SETCOLOUR, 0, commonData.background); + + SendMessage(GetDlgItem(hWnd, IDC_DEFAULT_MODULE), CB_SETCURSEL, commonData.cDefaultModule, 0); + SendMessage(GetDlgItem(hWnd, IDC_LEFT_CLICK), CB_SETCURSEL, commonData.lPopupClick, 0); + SendMessage(GetDlgItem(hWnd, IDC_RIGHT_CLICK), CB_SETCURSEL, commonData.rPopupClick, 0); + SendMessage(GetDlgItem(hWnd, IDC_NOTIFYFOR), CB_SETCURSEL, commonData.notifyFor, 0); + + CreateToolTip(GetDlgItem(hWnd, IDC_POPUP_TIMEOUT), TranslateT("Set popup delay when notifying of upcoming birthdays.\nFormat: default delay [ | delay for birthdays occuring today]"), 400); + + TCHAR buffer[1024]; + _itot(commonData.daysInAdvance, buffer, 10); + SetWindowText(GetDlgItem(hWnd, IDC_DAYS_IN_ADVANCE), buffer); + _itot(commonData.checkInterval, buffer, 10); + SetWindowText(GetDlgItem(hWnd, IDC_CHECK_INTERVAL), buffer); + _sntprintf(buffer, 1024, _T("%d|%d"), commonData.popupTimeout, commonData.popupTimeoutToday); + SetWindowText(GetDlgItem(hWnd, IDC_POPUP_TIMEOUT), buffer); + _itot(commonData.cSoundNearDays, buffer, 10); + SetWindowText(GetDlgItem(hWnd, IDC_SOUND_NEAR_DAYS_EDIT), buffer); + _itot(commonData.cDlgTimeout, buffer, 10); + SetWindowText(GetDlgItem(hWnd, IDC_DLG_TIMEOUT), buffer); + _itot(commonData.daysAfter, buffer, 10); + SetWindowText(GetDlgItem(hWnd, IDC_DAYS_AFTER), buffer); + + CheckDlgButton(hWnd, IDC_OPENINBACKGROUND, (commonData.bOpenInBackground) ? BST_CHECKED : BST_UNCHECKED); + + CheckDlgButton(hWnd, IDC_NOBIRTHDAYS_POPUP, (commonData.bNoBirthdaysPopup) ? BST_CHECKED : BST_UNCHECKED); + //CheckDlgButton(hWnd, IDC_SHOW_CURRENT_AGE, (bShowCurrentAge) ? BST_CHECKED : BST_UNCHECKED); + SendMessage(GetDlgItem(hWnd, IDC_AGE_COMBOBOX), CB_SETCURSEL, commonData.cShowAgeMode, 0); + + CheckDlgButton(hWnd, IDC_IGNORE_SUBCONTACTS, (commonData.bIgnoreSubcontacts) ? BST_CHECKED : BST_UNCHECKED); + + CheckDlgButton(hWnd, IDC_ONCE_PER_DAY, (commonData.bOncePerDay) ? BST_CHECKED : BST_UNCHECKED); + EnableWindow(GetDlgItem(hWnd, IDC_CHECK_INTERVAL), !commonData.bOncePerDay); + + CheckDlgButton(hWnd, IDC_USE_DIALOG, (commonData.bUseDialog) ? BST_CHECKED : BST_UNCHECKED); + EnableDialogGroup(hWnd, commonData.bUseDialog); + + if (ServiceExists(MS_POPUP_ADDPOPUPEX)) { - switch(((LPNMHDR)lParam)->idFrom) - { - case 0: - { - switch (((LPNMHDR)lParam)->code) - { - case PSN_APPLY: - { - commonData.foreground = SendMessage(GetDlgItem(hWnd, IDC_FOREGROUND), CPM_GETCOLOUR, 0, 0); - commonData.background = SendMessage(GetDlgItem(hWnd, IDC_BACKGROUND), CPM_GETCOLOUR, 0, 0); - commonData.popupTimeout = POPUP_TIMEOUT; - commonData.popupTimeoutToday = POPUP_TIMEOUT; - commonData.clistIcon = SendMessage(GetDlgItem(hWnd, IDC_ADVANCED_ICON), CB_GETCURSEL, 0, 0); - int oldClistIcon = DBGetContactSettingByte(NULL, ModuleName, "AdvancedIcon", -1); - commonData.bUsePopups = IsDlgButtonChecked(hWnd, IDC_USE_POPUPS); - commonData.bUseClistIcon = IsDlgButtonChecked(hWnd, IDC_USE_CLISTICON); - commonData.bUseDialog = IsDlgButtonChecked(hWnd, IDC_USE_DIALOG); - commonData.bIgnoreSubcontacts = IsDlgButtonChecked(hWnd, IDC_IGNORE_SUBCONTACTS); - commonData.bNoBirthdaysPopup = IsDlgButtonChecked(hWnd, IDC_NOBIRTHDAYS_POPUP); - commonData.cShowAgeMode = SendMessage(GetDlgItem(hWnd, IDC_AGE_COMBOBOX), CB_GETCURSEL, 0, 0); - commonData.cDefaultModule = SendMessage(GetDlgItem(hWnd, IDC_DEFAULT_MODULE), CB_GETCURSEL, 0, 0); - commonData.lPopupClick = SendMessage(GetDlgItem(hWnd, IDC_LEFT_CLICK), CB_GETCURSEL, 0, 0); - commonData.rPopupClick = SendMessage(GetDlgItem(hWnd, IDC_RIGHT_CLICK), CB_GETCURSEL, 0, 0); - commonData.bOncePerDay = IsDlgButtonChecked(hWnd, IDC_ONCE_PER_DAY); - commonData.notifyFor = SendMessage(GetDlgItem(hWnd, IDC_NOTIFYFOR), CB_GETCURSEL, 0, 0); - commonData.bOpenInBackground = IsDlgButtonChecked(hWnd, IDC_OPENINBACKGROUND); - - const int maxSize = 1024; - TCHAR buffer[maxSize]; - - GetWindowText(GetDlgItem(hWnd, IDC_DAYS_IN_ADVANCE), buffer, maxSize); - TCHAR *stop = NULL; - commonData.daysInAdvance = _tcstol(buffer, &stop, 10); - - if (*stop) { commonData.daysInAdvance = DAYS_TO_NOTIFY; } - - GetWindowText(GetDlgItem(hWnd, IDC_DAYS_AFTER), buffer, maxSize); - commonData.daysAfter = _tcstol(buffer, &stop, 10); - - if (*stop) { commonData.daysAfter = DAYS_TO_NOTIFY_AFTER; } - - GetWindowText(GetDlgItem(hWnd, IDC_CHECK_INTERVAL), buffer, maxSize); - commonData.checkInterval = _ttol(buffer); - if (!commonData.checkInterval) { commonData.checkInterval = CHECK_INTERVAL; } - - GetWindowText(GetDlgItem(hWnd, IDC_POPUP_TIMEOUT), buffer, maxSize); - TCHAR *pos; - pos = _tcschr(buffer, _T('|')); - if (pos) - { - TCHAR tmp[128]; - *pos = 0; - _tcscpy(tmp, buffer); - strtrim(tmp); - commonData.popupTimeout = _ttol(tmp); - - _tcscpy(tmp, pos + 1); - strtrim(tmp); - commonData.popupTimeoutToday = _ttol(tmp); - - } - else{ - commonData.popupTimeout = commonData.popupTimeoutToday = _ttol(buffer); - } - - GetWindowText(GetDlgItem(hWnd, IDC_SOUND_NEAR_DAYS_EDIT), buffer, maxSize); - //cSoundNearDays = _ttol(buffer); - commonData.cSoundNearDays = _tcstol(buffer, &stop, 10); - if (*stop) { commonData.cSoundNearDays = BIRTHDAY_NEAR_DEFAULT_DAYS; } - - GetWindowText(GetDlgItem(hWnd, IDC_DLG_TIMEOUT), buffer, maxSize); - commonData.cDlgTimeout = _tcstol(buffer, &stop, 10); - if (*stop) { commonData.cDlgTimeout = POPUP_TIMEOUT; } - - DBWriteContactSettingByte(NULL, ModuleName, "IgnoreSubcontacts", commonData.bIgnoreSubcontacts); - DBWriteContactSettingByte(NULL, ModuleName, "UsePopups", commonData.bUsePopups); - DBWriteContactSettingByte(NULL, ModuleName, "UseClistIcon", commonData.bUseClistIcon); - DBWriteContactSettingByte(NULL, ModuleName, "UseDialog", commonData.bUseDialog); - DBWriteContactSettingByte(NULL, ModuleName, "AdvancedIcon", commonData.clistIcon); - DBWriteContactSettingWord(NULL, ModuleName, "CheckInterval", commonData.checkInterval); - DBWriteContactSettingWord(NULL, ModuleName, "DaysInAdvance", commonData.daysInAdvance); - DBWriteContactSettingWord(NULL, ModuleName, "DaysAfter", commonData.daysAfter); - DBWriteContactSettingWord(NULL, ModuleName, "PopupTimeout", commonData.popupTimeout); - DBWriteContactSettingWord(NULL, ModuleName, "PopupTimeoutToday", commonData.popupTimeoutToday); - - DBWriteContactSettingByte(NULL, ModuleName, "ShowCurrentAge", commonData.cShowAgeMode); - DBWriteContactSettingByte(NULL, ModuleName, "NoBirthdaysPopup", commonData.bNoBirthdaysPopup); - - DBWriteContactSettingByte(NULL, ModuleName, "OpenInBackground", commonData.bOpenInBackground); - - DBWriteContactSettingByte(NULL, ModuleName, "SoundNearDays", commonData.cSoundNearDays); - - DBWriteContactSettingByte(NULL, ModuleName, "DefaultModule", commonData.cDefaultModule); - - DBWriteContactSettingByte(NULL, ModuleName, "PopupLeftClick", commonData.lPopupClick); - DBWriteContactSettingByte(NULL, ModuleName, "PopupRightClick", commonData.rPopupClick); - - DBWriteContactSettingDword(NULL, ModuleName, "Foreground", commonData.foreground); - DBWriteContactSettingDword(NULL, ModuleName, "Background", commonData.background); - - DBWriteContactSettingByte(NULL, ModuleName, "OncePerDay", commonData.bOncePerDay); - - DBWriteContactSettingWord(NULL, ModuleName, "DlgTimeout", commonData.cDlgTimeout); - - DBWriteContactSettingByte(NULL, ModuleName, "NotifyFor", commonData.notifyFor); - - RefreshAllContactListIcons(oldClistIcon); - - UpdateTimers(); //interval might get changed - break; - } - } - break; - } - } + CheckDlgButton(hWnd, IDC_USE_POPUPS, commonData.bUsePopups ? BST_CHECKED : BST_UNCHECKED); + EnablePopupsGroup(hWnd, commonData.bUsePopups); + } + else { + EnableWindow(GetDlgItem(hWnd, IDC_USE_POPUPS), FALSE); + EnablePopupsGroup(hWnd, FALSE); + } + + CheckDlgButton(hWnd, IDC_USE_CLISTICON, BST_CHECKED); + EnableWindow(GetDlgItem(hWnd, IDC_USE_CLISTICON), FALSE); + EnableClistGroup(hWnd, FALSE); + } + bInitializing = 0; + return TRUE; + + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDC_CHECK_INTERVAL: + case IDC_POPUP_TIMEOUT: + case IDC_DAYS_IN_ADVANCE: + case IDC_DLG_TIMEOUT: + case IDC_SOUND_NEAR_DAYS_EDIT: + case IDC_DAYS_AFTER: + if ((HIWORD(wParam) == EN_CHANGE) && (!bInitializing))// || (HIWORD(wParam) == CBN_SELENDOK)) + SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0); + break; + + case IDC_USE_POPUPS: + case IDC_USE_CLISTICON: + case IDC_USE_DIALOG: + EnablePopupsGroup(hWnd, IsDlgButtonChecked(hWnd, IDC_USE_POPUPS)); + EnableClistGroup(hWnd, IsDlgButtonChecked(hWnd, IDC_USE_CLISTICON)); + EnableDialogGroup(hWnd, IsDlgButtonChecked(hWnd, IDC_USE_DIALOG)); + RedrawWindow(GetDlgItem(hWnd, IDC_USE_POPUPS), NULL, NULL, RDW_ERASE | RDW_INVALIDATE); + RedrawWindow(GetDlgItem(hWnd, IDC_USE_CLISTICON), NULL, NULL, RDW_ERASE | RDW_INVALIDATE); + RedrawWindow(GetDlgItem(hWnd, IDC_USE_DIALOG), NULL, NULL, RDW_ERASE | RDW_INVALIDATE); + //fallthrough + + case IDC_FOREGROUND: + case IDC_BACKGROUND: + case IDC_ADVANCED_ICON: + case IDC_IGNORE_SUBCONTACTS: + case IDC_AGE_COMBOBOX: + case IDC_NOBIRTHDAYS_POPUP: + case IDC_DEFAULT_MODULE: + case IDC_LEFT_CLICK: + case IDC_RIGHT_CLICK: + case IDC_ONCE_PER_DAY: + case IDC_NOTIFYFOR: + SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0); + EnableWindow(GetDlgItem(hWnd, IDC_CHECK_INTERVAL), !IsDlgButtonChecked(hWnd, IDC_ONCE_PER_DAY)); + break; + + case IDC_PREVIEW: + { + HANDLE hContact = db_find_first(); + int dtb = rand() % 11; //0..10 + int age = rand() % 50 + 1; //1..50 + PopupNotifyBirthday(hContact, dtb, age); break; } + } + break; + + case WM_NOTIFY: + switch(((LPNMHDR)lParam)->idFrom) { + case 0: + switch (((LPNMHDR)lParam)->code) { + case PSN_APPLY: + commonData.foreground = SendMessage(GetDlgItem(hWnd, IDC_FOREGROUND), CPM_GETCOLOUR, 0, 0); + commonData.background = SendMessage(GetDlgItem(hWnd, IDC_BACKGROUND), CPM_GETCOLOUR, 0, 0); + commonData.popupTimeout = POPUP_TIMEOUT; + commonData.popupTimeoutToday = POPUP_TIMEOUT; + commonData.bUsePopups = IsDlgButtonChecked(hWnd, IDC_USE_POPUPS); + commonData.bUseClistIcon = IsDlgButtonChecked(hWnd, IDC_USE_CLISTICON); + commonData.bUseDialog = IsDlgButtonChecked(hWnd, IDC_USE_DIALOG); + commonData.bIgnoreSubcontacts = IsDlgButtonChecked(hWnd, IDC_IGNORE_SUBCONTACTS); + commonData.bNoBirthdaysPopup = IsDlgButtonChecked(hWnd, IDC_NOBIRTHDAYS_POPUP); + commonData.cShowAgeMode = SendMessage(GetDlgItem(hWnd, IDC_AGE_COMBOBOX), CB_GETCURSEL, 0, 0); + commonData.cDefaultModule = SendMessage(GetDlgItem(hWnd, IDC_DEFAULT_MODULE), CB_GETCURSEL, 0, 0); + commonData.lPopupClick = SendMessage(GetDlgItem(hWnd, IDC_LEFT_CLICK), CB_GETCURSEL, 0, 0); + commonData.rPopupClick = SendMessage(GetDlgItem(hWnd, IDC_RIGHT_CLICK), CB_GETCURSEL, 0, 0); + commonData.bOncePerDay = IsDlgButtonChecked(hWnd, IDC_ONCE_PER_DAY); + commonData.notifyFor = SendMessage(GetDlgItem(hWnd, IDC_NOTIFYFOR), CB_GETCURSEL, 0, 0); + commonData.bOpenInBackground = IsDlgButtonChecked(hWnd, IDC_OPENINBACKGROUND); + { + const int maxSize = 1024; + TCHAR buffer[maxSize]; + + GetWindowText(GetDlgItem(hWnd, IDC_DAYS_IN_ADVANCE), buffer, maxSize); + TCHAR *stop = NULL; + commonData.daysInAdvance = _tcstol(buffer, &stop, 10); + + if (*stop) { commonData.daysInAdvance = DAYS_TO_NOTIFY; } + + GetWindowText(GetDlgItem(hWnd, IDC_DAYS_AFTER), buffer, maxSize); + commonData.daysAfter = _tcstol(buffer, &stop, 10); + + if (*stop) { commonData.daysAfter = DAYS_TO_NOTIFY_AFTER; } + + GetWindowText(GetDlgItem(hWnd, IDC_CHECK_INTERVAL), buffer, maxSize); + commonData.checkInterval = _ttol(buffer); + if (!commonData.checkInterval) { commonData.checkInterval = CHECK_INTERVAL; } + + GetWindowText(GetDlgItem(hWnd, IDC_POPUP_TIMEOUT), buffer, maxSize); + TCHAR *pos; + pos = _tcschr(buffer, _T('|')); + if (pos) { + TCHAR tmp[128]; + *pos = 0; + _tcscpy(tmp, buffer); + strtrim(tmp); + commonData.popupTimeout = _ttol(tmp); + + _tcscpy(tmp, pos + 1); + strtrim(tmp); + commonData.popupTimeoutToday = _ttol(tmp); + + } + else commonData.popupTimeout = commonData.popupTimeoutToday = _ttol(buffer); + + GetWindowText(GetDlgItem(hWnd, IDC_SOUND_NEAR_DAYS_EDIT), buffer, maxSize); + //cSoundNearDays = _ttol(buffer); + commonData.cSoundNearDays = _tcstol(buffer, &stop, 10); + if (*stop) { commonData.cSoundNearDays = BIRTHDAY_NEAR_DEFAULT_DAYS; } + + GetWindowText(GetDlgItem(hWnd, IDC_DLG_TIMEOUT), buffer, maxSize); + commonData.cDlgTimeout = _tcstol(buffer, &stop, 10); + if (*stop) { commonData.cDlgTimeout = POPUP_TIMEOUT; } + + DBWriteContactSettingByte(NULL, ModuleName, "IgnoreSubcontacts", commonData.bIgnoreSubcontacts); + DBWriteContactSettingByte(NULL, ModuleName, "UsePopups", commonData.bUsePopups); + DBWriteContactSettingByte(NULL, ModuleName, "UseClistIcon", commonData.bUseClistIcon); + DBWriteContactSettingByte(NULL, ModuleName, "UseDialog", commonData.bUseDialog); + DBWriteContactSettingWord(NULL, ModuleName, "CheckInterval", commonData.checkInterval); + DBWriteContactSettingWord(NULL, ModuleName, "DaysInAdvance", commonData.daysInAdvance); + DBWriteContactSettingWord(NULL, ModuleName, "DaysAfter", commonData.daysAfter); + DBWriteContactSettingWord(NULL, ModuleName, "PopupTimeout", commonData.popupTimeout); + DBWriteContactSettingWord(NULL, ModuleName, "PopupTimeoutToday", commonData.popupTimeoutToday); + + DBWriteContactSettingByte(NULL, ModuleName, "ShowCurrentAge", commonData.cShowAgeMode); + DBWriteContactSettingByte(NULL, ModuleName, "NoBirthdaysPopup", commonData.bNoBirthdaysPopup); + + DBWriteContactSettingByte(NULL, ModuleName, "OpenInBackground", commonData.bOpenInBackground); + + DBWriteContactSettingByte(NULL, ModuleName, "SoundNearDays", commonData.cSoundNearDays); + + DBWriteContactSettingByte(NULL, ModuleName, "DefaultModule", commonData.cDefaultModule); + + DBWriteContactSettingByte(NULL, ModuleName, "PopupLeftClick", commonData.lPopupClick); + DBWriteContactSettingByte(NULL, ModuleName, "PopupRightClick", commonData.rPopupClick); + + DBWriteContactSettingDword(NULL, ModuleName, "Foreground", commonData.foreground); + DBWriteContactSettingDword(NULL, ModuleName, "Background", commonData.background); + + DBWriteContactSettingByte(NULL, ModuleName, "OncePerDay", commonData.bOncePerDay); + + DBWriteContactSettingWord(NULL, ModuleName, "DlgTimeout", commonData.cDlgTimeout); + + DBWriteContactSettingByte(NULL, ModuleName, "NotifyFor", commonData.notifyFor); + + RefreshAllContactListIcons(); + + UpdateTimers(); //interval might get changed + } + bInitializing = 0; + } + break; + } + break; } return 0; } diff --git a/plugins/WhenWasIt/src/hooked_events.cpp b/plugins/WhenWasIt/src/hooked_events.cpp index fda21c0aea..bb2d44dd9b 100644 --- a/plugins/WhenWasIt/src/hooked_events.cpp +++ b/plugins/WhenWasIt/src/hooked_events.cpp @@ -93,16 +93,12 @@ int UnhookEvents() int OnModulesLoaded(WPARAM wParam, LPARAM lParam) { hIconsChanged = HookEvent(ME_SKIN2_ICONSCHANGED, OnIconsChanged); - hExtraIconListRebuild = HookEvent(ME_CLIST_EXTRA_LIST_REBUILD, OnExtraIconListRebuild); - hExtraImageApply = HookEvent(ME_CLIST_EXTRA_IMAGE_APPLY, OnExtraImageApply); hContactSettingChanged = HookEvent(ME_DB_CONTACT_SETTINGCHANGED, OnContactSettingChanged); hTopToolBarModuleLoaded = HookEvent(ME_TTB_MODULELOADED, OnTopToolBarModuleLoaded); SkinAddNewSoundEx(BIRTHDAY_NEAR_SOUND, LPGEN("WhenWasIt"), LPGEN("Birthday near")); SkinAddNewSoundEx(BIRTHDAY_TODAY_SOUND, LPGEN("WhenWasIt"), LPGEN("Birthday today")); - RebuildAdvIconList(); - UpdateTimers(); CLISTMENUITEM cl = {0}; cl.cbSize = sizeof(CLISTMENUITEM); @@ -224,20 +220,9 @@ int OnIconsChanged(WPARAM wParam, LPARAM lParam) int OnContactSettingChanged(WPARAM wParam, LPARAM lParam) { DBCONTACTWRITESETTING *dw = (DBCONTACTWRITESETTING *) lParam; - //static HANDLE oldContact = NULL; DBVARIANT dv = dw->value; if ((strcmp(dw->szModule, DUMMY_MODULE) == 0) && (strcmp(dw->szSetting, DUMMY_SETTING) == 0)) - { - OnExtraImageApply(wParam, 0); - } - //oldContact = (HANDLE) wParam; - - return 0; -} - -int OnExtraIconListRebuild(WPARAM wParam, LPARAM lParam) -{ - RebuildAdvIconList(); + OnExtraImageApply(wParam, 0); return 0; } @@ -245,109 +230,71 @@ int OnExtraIconListRebuild(WPARAM wParam, LPARAM lParam) int OnExtraImageApply(WPARAM wParam, LPARAM lParam) { HANDLE hContact = (HANDLE) wParam; - if ((hContact)) + if (hContact == 0) + return 0; + + int count = CallService(MS_DB_CONTACT_GETCOUNT, 0, 0); + int hidden = DBGetContactSettingByte(hContact, "CList", "Hidden", 0); + int ignored = DBGetContactSettingDword(hContact, "Ignore", "Mask1", 0); + ignored = ((ignored & 0x3f) != 0) ? 1 : 0; + int ok = 1; + if (commonData.notifyFor & EXCLUDE_HIDDEN) + ok &= (hidden == 0); + + if (commonData.notifyFor & EXCLUDE_IGNORED) + ok &= (ignored == 0); + + time_t today = Today(); + + int dtb = NotifyContactBirthday(hContact, today, commonData.daysInAdvance); + int dab = NotifyMissedContactBirthday(hContact, today, commonData.daysAfter); + + if (ok && (dtb >= 0 || dab > 0)) { + int age = GetContactAge(hContact); + DBWriteContactSettingByte(hContact, "UserInfo", "Age", age); + + if ((bShouldCheckBirthdays) && (commonData.bUsePopups)) { - int count = CallService(MS_DB_CONTACT_GETCOUNT, 0, 0); - //int daysInAdvance = DBGetContactSettingWord(NULL, ModuleName, "DaysInAdvance", DAYS_TO_NOTIFY); - //int popupTimeout = DBGetContactSettingWord(NULL, ModuleName, "PopupTimeout", POPUP_TIMEOUT); - //DWORD foreground = DBGetContactSettingDword(NULL, ModuleName, "Foreground", FOREGROUND_COLOR); - //DWORD background = DBGetContactSettingDword(NULL, ModuleName, "Background", BACKGROUND_COLOR); - //int bUsePopups = DBGetContactSettingByte(NULL, ModuleName, "UsePopups", TRUE); - //int bUseClistIcon = DBGetContactSettingByte(NULL, ModuleName, "UseClistIcon", TRUE); - //int bUseDialog = DBGetContactSettingByte(NULL, ModuleName, "UseDialog", TRUE); - //int clistIcon = DBGetContactSettingByte(NULL, ModuleName, "AdvancedIcon", CLIST_ICON); - //int notifyFor = DBGetContactSettingByte(NULL, ModuleName, "NotifyFor", 0); - int hidden = DBGetContactSettingByte(hContact, "CList", "Hidden", 0); - int ignored = DBGetContactSettingDword(hContact, "Ignore", "Mask1", 0); - ignored = ((ignored & 0x3f) != 0) ? 1 : 0; - int ok = 1; - if (commonData.notifyFor & EXCLUDE_HIDDEN) - { - ok &= (hidden == 0); - } - if (commonData.notifyFor & EXCLUDE_IGNORED) - { - ok &= (ignored == 0); - } - - int dtb; - int dab; - int caps = ServiceExists(MS_CLIST_EXTRA_ADD_ICON); // CallService(MS_CLUI_GETCAPS, 0, 0); - - time_t today = Today(); - - if ((ok) && (((dtb = NotifyContactBirthday(hContact, today, commonData.daysInAdvance)) >= 0) || ((dab = NotifyMissedContactBirthday(hContact, today, commonData.daysAfter)) > 0))) - { - int age = GetContactAge(hContact); - DBWriteContactSettingByte(hContact, "UserInfo", "Age", age); - - if ((bShouldCheckBirthdays) && (commonData.bUsePopups)) - { - if (dtb >= 0) - { - bBirthdayFound = 1; //only set it if we're called from our CheckBirthdays service - PopupNotifyBirthday(hContact, dtb, age); - } - else if (dab > 0) - { - PopupNotifyMissedBirthday(hContact, dab, age); - } - } - - if (bShouldCheckBirthdays) - { - if (dtb >= 0) - { - SoundNotifyBirthday(dtb); - } - } - - if ((bShouldCheckBirthdays) && (commonData.bUseDialog)) - { - if (dtb >= 0) - { - DialogNotifyBirthday(hContact, dtb, age); - } - else if (dab > 0) - { - DialogNotifyMissedBirthday(hContact, dab, age); - } - } - - if ((caps > 0) && (commonData.bUseClistIcon)) //TODO - { - if (dtb >= 0) - { - ClistIconNotifyBirthday(hContact, dtb, commonData.clistIcon); - } - } - } - else{ - if (caps > 0) //TODO - { //clear the icon - ClearClistIcon(hContact, commonData.clistIcon); - } + if (dtb >= 0) { + bBirthdayFound = 1; //only set it if we're called from our CheckBirthdays service + PopupNotifyBirthday(hContact, dtb, age); } + else if (dab > 0) + PopupNotifyMissedBirthday(hContact, dab, age); } - + + if (bShouldCheckBirthdays) + if (dtb >= 0) + SoundNotifyBirthday(dtb); + + if ((bShouldCheckBirthdays) && (commonData.bUseDialog)) { + if (dtb >= 0) + DialogNotifyBirthday(hContact, dtb, age); + else if (dab > 0) + DialogNotifyMissedBirthday(hContact, dab, age); + } + + if (commonData.bUseClistIcon) //TODO + if (dtb >= 0) + ClistIconNotifyBirthday(hContact, dtb); + } + else ClearClistIcon(hContact); + return 0; } int UpdateTimers() { - if (hCheckTimer) - { - KillTimer(NULL, hCheckTimer); - hCheckTimer = NULL; - } - long interval; - interval = DBGetContactSettingDword(NULL, ModuleName, "Interval", CHECK_INTERVAL); + if (hCheckTimer) { + KillTimer(NULL, hCheckTimer); + hCheckTimer = NULL; + } + + long interval = DBGetContactSettingDword(NULL, ModuleName, "Interval", CHECK_INTERVAL); interval *= 1000 * 60 * 60; //go from miliseconds to hours hCheckTimer = SetTimer(NULL, 0, interval, (TIMERPROC) OnCheckTimer); if (!hDateChangeTimer) - { - hDateChangeTimer = SetTimer(NULL, 0, 1000 * DATE_CHANGE_CHECK_INTERVAL, (TIMERPROC) OnDateChangeTimer); - } + hDateChangeTimer = SetTimer(NULL, 0, 1000 * DATE_CHANGE_CHECK_INTERVAL, (TIMERPROC) OnDateChangeTimer); return 0; } @@ -355,18 +302,17 @@ int UpdateTimers() int KillTimers() { Log("%s", "Entering function " __FUNCTION__); - if (hCheckTimer) - { - KillTimer(NULL, hCheckTimer); - hCheckTimer = NULL; - } - if (hDateChangeTimer) - { - KillTimer(NULL, hDateChangeTimer); - hDateChangeTimer = NULL; - } + if (hCheckTimer) { + KillTimer(NULL, hCheckTimer); + hCheckTimer = NULL; + } + + if (hDateChangeTimer) { + KillTimer(NULL, hDateChangeTimer); + hDateChangeTimer = NULL; + } + Log("%s", "Leaving function " __FUNCTION__); - return 0; } diff --git a/plugins/WhenWasIt/src/hooked_events.h b/plugins/WhenWasIt/src/hooked_events.h index 69c75f0531..30e2c2455a 100644 --- a/plugins/WhenWasIt/src/hooked_events.h +++ b/plugins/WhenWasIt/src/hooked_events.h @@ -36,7 +36,6 @@ int OnModulesLoaded(WPARAM wParam, LPARAM lParam); int OnTopToolBarModuleLoaded(WPARAM wParam, LPARAM lParam); int OnOptionsInitialise(WPARAM wParam, LPARAM lParam); int OnIconsChanged(WPARAM wParam, LPARAM lParam); -int OnExtraIconListRebuild(WPARAM wParam, LPARAM lParam); int OnExtraImageApply(WPARAM wParam, LPARAM lParam); int OnContactSettingChanged(WPARAM wParam, LPARAM lParam); diff --git a/plugins/WhenWasIt/src/icons.cpp b/plugins/WhenWasIt/src/icons.cpp index ffa5e1e9ee..6ac1627e97 100644 --- a/plugins/WhenWasIt/src/icons.cpp +++ b/plugins/WhenWasIt/src/icons.cpp @@ -67,9 +67,7 @@ int LoadIcons() AddIcons(); GetIcons(); - if (ServiceExists(MS_EXTRAICON_REGISTER)) - hWWIExtraIcons = ExtraIcon_Register("WhenWasIt", Translate("WhenWasIt birthday reminder"), "MenuCheck", OnExtraIconListRebuild, OnExtraImageApply); - + hWWIExtraIcons = ExtraIcon_Register("WhenWasIt", Translate("WhenWasIt birthday reminder"), "MenuCheck"); return 0; } @@ -123,8 +121,7 @@ void FreeIcon(HICON &icon) void FreeIcons() { static int bFreed = 0; - if (!bFreed) - { + if (!bFreed) { FreeIcon(hiCheckMenu); FreeIcon(hiListMenu); FreeIcon(hiAddBirthdayContact); @@ -133,11 +130,9 @@ void FreeIcons() FreeIcon(hiImportBirthdays); FreeIcon(hiExportBirthdays); - int i; - for (i = 0; i < cDTB; i++) - { + for (int i = 0; i < cDTB; i++) FreeIcon(hiDTB[i]); - } + FreeIcon(hiDTBMore); } bFreed = 1; //only free them once (ours). @@ -183,21 +178,3 @@ HANDLE GetClistIcon(int dtb) return hClistImages[dtb]; } - -HANDLE RebuildCListIcon(HICON icon) -{ - INT_PTR tmp = CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM) icon, 0); - if (tmp != CALLSERVICE_NOTFOUND) - return (HANDLE) tmp; - - return (HANDLE) -1; -} - -int RebuildAdvIconList() -{ - for (int i = 0; i < cDTB; i++) - hClistImages[i] = RebuildCListIcon(hiDTB[i]); - - hClistImages[cDTB] = RebuildCListIcon(hiDTBMore); - return 0; -} diff --git a/plugins/WhenWasIt/src/icons.h b/plugins/WhenWasIt/src/icons.h index f9d85ce7a4..d3f312fe46 100644 --- a/plugins/WhenWasIt/src/icons.h +++ b/plugins/WhenWasIt/src/icons.h @@ -41,8 +41,6 @@ int LoadIcons(); int AddIcons(); int GetIcons(); -int RebuildAdvIconList(); - HICON GetDTBIcon(int dtb); HICON GetDABIcon(int dtb); HANDLE GetClistIcon(int dtb); diff --git a/plugins/WhenWasIt/src/notifiers.cpp b/plugins/WhenWasIt/src/notifiers.cpp index 5b1e569ea2..2cc37e28a8 100644 --- a/plugins/WhenWasIt/src/notifiers.cpp +++ b/plugins/WhenWasIt/src/notifiers.cpp @@ -23,8 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. void FillPopupData(POPUPDATAT &pd, int dtb) { - //DWORD foreground = DBGetContactSettingDword(NULL, ModuleName, "Foreground", FOREGROUND_COLOR); - //DWORD background = DBGetContactSettingDword(NULL, ModuleName, "Background", BACKGROUND_COLOR); int popupTimeout = (dtb == 0) ? commonData.popupTimeoutToday : commonData.popupTimeout; pd.colorBack = commonData.background; @@ -40,26 +38,17 @@ int PopupNotifyNoBirthdays() _tcscpy(pd.lptzContactName, TranslateT("WhenWasIt")); _tcscpy(pd.lptzText, TranslateT("No upcoming birthdays.")); - - return PUAddPopUpT(&pd); } TCHAR *BuildDTBText(int dtb, TCHAR *name, TCHAR *text, int size) { if (dtb > 1) - { mir_sntprintf(text, size, TranslateT("%s has birthday in %d days."), name, dtb); - } - else{ - if (dtb == 1) - { - mir_sntprintf(text, size, TranslateT("%s has birthday tomorrow."), name); - } - else{ - mir_sntprintf(text, size, TranslateT("%s has birthday today."), name); - } - } + else if (dtb == 1) + mir_sntprintf(text, size, TranslateT("%s has birthday tomorrow."), name); + else + mir_sntprintf(text, size, TranslateT("%s has birthday today."), name); return text; } @@ -67,18 +56,11 @@ TCHAR *BuildDTBText(int dtb, TCHAR *name, TCHAR *text, int size) TCHAR *BuildDABText(int dab, TCHAR *name, TCHAR *text, int size) { if (dab > 1) - { mir_sntprintf(text, size, TranslateT("%s had birthday %d days ago."), name, dab); - } - else{ - if (dab == 1) - { - mir_sntprintf(text, size, TranslateT("%s had birthday yesterday."), name); - } - else{ - mir_sntprintf(text, size, TranslateT("%s has birthday today (Should not happen, please report)."), name); - } - } + else if (dab == 1) + mir_sntprintf(text, size, TranslateT("%s had birthday yesterday."), name); + else + mir_sntprintf(text, size, TranslateT("%s has birthday today (Should not happen, please report)."), name); return text; } @@ -113,32 +95,22 @@ int PopupNotifyBirthday(HANDLE hContact, int dtb, int age) //strcpy(pd.lpzContactName, text); _stprintf(pd.lptzContactName, TranslateT("Birthday - %s"), name); TCHAR *sex; - switch (toupper(gender)) - { - case _T('M'): - { - sex = TranslateT("He"); - break; - } - case _T('F'): - { - sex = TranslateT("She"); - break; - } - default: - { - sex = TranslateT("He/She"); - break; - } - } + switch (toupper(gender)) { + case _T('M'): + sex = TranslateT("He"); + break; + case _T('F'): + sex = TranslateT("She"); + break; + default: + sex = TranslateT("He/She"); + break; + } if (dtb > 0) - { - _stprintf(pd.lptzText, TranslateT("%s\n%s will be %d years old."), text, sex, age); - } - else{ - _stprintf(pd.lptzText, TranslateT("%s\n%s just turned %d."), text, sex, age); - } - + _stprintf(pd.lptzText, TranslateT("%s\n%s will be %d years old."), text, sex, age); + else + _stprintf(pd.lptzText, TranslateT("%s\n%s just turned %d."), text, sex, age); + PUAddPopUpT(&pd); free(name); @@ -151,14 +123,11 @@ int PopupNotifyMissedBirthday(HANDLE hContact, int dab, int age) const int MAX_SIZE = 1024; TCHAR text[MAX_SIZE]; //int bIgnoreSubcontacts = DBGetContactSettingByte(NULL, ModuleName, "IgnoreSubcontacts", FALSE); - if (commonData.bIgnoreSubcontacts) - { - HANDLE hMetacontact = (HANDLE) CallService(MS_MC_GETMETACONTACT, (WPARAM) hContact, 0); - if ((hMetacontact) && (hMetacontact != hContact)) //not main metacontact - { - return 0; - } - } + if (commonData.bIgnoreSubcontacts) { + HANDLE hMetacontact = (HANDLE) CallService(MS_MC_GETMETACONTACT, (WPARAM) hContact, 0); + if (hMetacontact && hMetacontact != hContact) //not main metacontact + return 0; + } BuildDABText(dab, name, text, MAX_SIZE); int gender = GetContactGender(hContact); @@ -166,40 +135,25 @@ int PopupNotifyMissedBirthday(HANDLE hContact, int dab, int age) FillPopupData(pd, dab); pd.lchContact = hContact; pd.PluginWindowProc = (WNDPROC) DlgProcPopup; - //pd.PluginData = (void *) hContact; - //pd.colorBack = background; - //pd.colorText = foreground; - //pd.iSeconds = popupTimeout; pd.lchIcon = GetDABIcon(dab); - //strcpy(pd.lpzContactName, text); _stprintf(pd.lptzContactName, TranslateT("Birthday - %s"), name); TCHAR *sex; - switch (toupper(gender)) - { - case _T('M'): - { - sex = TranslateT("He"); - break; - } - case _T('F'): - { - sex = TranslateT("She"); - break; - } - default: - { - sex = TranslateT("He/She"); - break; - } - } + switch (toupper(gender)) { + case _T('M'): + sex = TranslateT("He"); + break; + case _T('F'): + sex = TranslateT("She"); + break; + default: + sex = TranslateT("He/She"); + break; + } if (dab > 0) - { - _stprintf(pd.lptzText, TranslateT("%s\n%s just turned %d."), text, sex, age); - } - else{ - _stprintf(pd.lptzText, TranslateT("%s\n%s just turned %d."), text, sex, age); - } + _stprintf(pd.lptzText, TranslateT("%s\n%s just turned %d."), text, sex, age); + else + _stprintf(pd.lptzText, TranslateT("%s\n%s just turned %d."), text, sex, age); PUAddPopUpT(&pd); free(name); @@ -207,20 +161,9 @@ int PopupNotifyMissedBirthday(HANDLE hContact, int dab, int age) return 0; } -int ClistIconNotifyBirthday(HANDLE hContact, int dtb, int advancedIcon) +int ClistIconNotifyBirthday(HANDLE hContact, int dtb) { - if (ServiceExists(MS_EXTRAICON_SET_ICON)) - { - ExtraIcon_SetIcon(hWWIExtraIcons, hContact, GetClistIcon(dtb)); - } - else { - IconExtraColumn iec = {0}; - iec.cbSize = sizeof(IconExtraColumn); - iec.ColumnType = advancedIcon; - iec.hImage = GetClistIcon(dtb); - CallService(MS_CLIST_EXTRA_SET_ICON, (WPARAM) hContact, (LPARAM) &iec); - } - + ExtraIcon_SetIcon(hWWIExtraIcons, hContact, GetClistIcon(dtb)); return 0; } @@ -231,8 +174,7 @@ int DialogNotifyBirthday(HANDLE hContact, int dtb, int age) TCHAR text[MAX_SIZE]; BuildDTBText(dtb, name, text, MAX_SIZE); - if (!hUpcomingDlg) - { + if (!hUpcomingDlg) { hUpcomingDlg = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_UPCOMING), NULL, DlgProcUpcoming); ShowWindow(hUpcomingDlg, commonData.bOpenInBackground ? SW_SHOWNOACTIVATE : SW_SHOW); } @@ -258,8 +200,7 @@ int DialogNotifyMissedBirthday(HANDLE hContact, int dab, int age) TCHAR text[MAX_SIZE]; BuildDABText(dab, name, text, MAX_SIZE); - if (!hUpcomingDlg) - { + if (!hUpcomingDlg) { hUpcomingDlg = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_UPCOMING), NULL, DlgProcUpcoming); ShowWindow(hUpcomingDlg, commonData.bOpenInBackground ? SW_SHOWNOACTIVATE : SW_SHOW); } @@ -280,48 +221,22 @@ int DialogNotifyMissedBirthday(HANDLE hContact, int dab, int age) int SoundNotifyBirthday(int dtb) { - //int daysToPlay = DBGetContactSettingByte(NULL, ModuleName, "SoundNearDays", BIRTHDAY_NEAR_DEFAULT_DAYS); if (dtb == 0) - { - SkinPlaySound(BIRTHDAY_TODAY_SOUND); - } - else{ - if (dtb <= commonData.cSoundNearDays) - { - SkinPlaySound(BIRTHDAY_NEAR_SOUND); - } - } - + SkinPlaySound(BIRTHDAY_TODAY_SOUND); + else if (dtb <= commonData.cSoundNearDays) + SkinPlaySound(BIRTHDAY_NEAR_SOUND); + return 0; } -int ClearClistIcon(HANDLE hContact, int advancedIcon) +int ClearClistIcon(HANDLE hContact) { - if (ServiceExists(MS_EXTRAICON_SET_ICON)) - { - return ExtraIcon_SetIcon(hWWIExtraIcons, hContact, (HANDLE) -1); - } - else { - IconExtraColumn iec = {0}; - iec.cbSize = sizeof(IconExtraColumn); - iec.ColumnType = advancedIcon; - iec.hImage = (HANDLE) -1; - - return CallService(MS_CLIST_EXTRA_SET_ICON, (WPARAM) hContact, (LPARAM) &iec); - } + return ExtraIcon_SetIcon(hWWIExtraIcons, hContact, INVALID_HANDLE_VALUE); } int RefreshContactListIcons(HANDLE hContact) { - //if (DBGetContactSettingWord(hContact, DUMMY_MODULE, DUMMY_SETTING, 0) != 0) - // { - // DBDeleteContactSetting(hContact, DUMMY_MODULE, DUMMY_SETTING); - // } - // else{ - // DBWriteContactSettingWord(hContact, DUMMY_MODULE, DUMMY_SETTING, 101); - // } OnExtraImageApply((WPARAM) hContact, 0); - return 0; } @@ -330,14 +245,12 @@ int RefreshContactListIcons(HANDLE hContact) int RefreshAllContactListIcons(int oldClistIcon) { HANDLE hContact = db_find_first(); - while (hContact != NULL) - { - if (oldClistIcon != -1) - { - ClearClistIcon(hContact, oldClistIcon); - } - RefreshContactListIcons(hContact); //will change bBirthdayFound if needed - hContact = db_find_next(hContact); - } + while (hContact != NULL) { + if (oldClistIcon != -1) + ClearClistIcon(hContact); + + RefreshContactListIcons(hContact); //will change bBirthdayFound if needed + hContact = db_find_next(hContact); + } return 0; -} \ No newline at end of file +} diff --git a/plugins/WhenWasIt/src/notifiers.h b/plugins/WhenWasIt/src/notifiers.h index db43ca55e1..149cd6a3bb 100644 --- a/plugins/WhenWasIt/src/notifiers.h +++ b/plugins/WhenWasIt/src/notifiers.h @@ -47,12 +47,12 @@ typedef TUpcomingBirthday *PUpcomingBirthday; int PopupNotifyNoBirthdays(); int PopupNotifyBirthday(HANDLE hContact, int dtb, int age); int PopupNotifyMissedBirthday(HANDLE hContact, int dab, int age); -int ClistIconNotifyBirthday(HANDLE hContact, int dtb, int advancedIcon); int DialogNotifyBirthday(HANDLE hContact, int dtb, int age); int DialogNotifyMissedBirthday(HANDLE hContact, int dab, int age); int SoundNotifyBirthday(int dtb); -int ClearClistIcon(HANDLE hContact, int advancedIcon); +int ClistIconNotifyBirthday(HANDLE hContact, int dtb); +int ClearClistIcon(HANDLE hContact); int RefreshContactListIcons(HANDLE hContact); int RefreshAllContactListIcons(int oldClistIcon = -1); diff --git a/plugins/WhenWasIt/src/services.cpp b/plugins/WhenWasIt/src/services.cpp index 7fc5d22d52..6da69a5a23 100644 --- a/plugins/WhenWasIt/src/services.cpp +++ b/plugins/WhenWasIt/src/services.cpp @@ -47,7 +47,6 @@ int InitServices() commonData.bUsePopups = DBGetContactSettingByte(NULL, ModuleName, "UsePopups", TRUE); commonData.bUseClistIcon = DBGetContactSettingByte(NULL, ModuleName, "UseClistIcon", TRUE); commonData.bUseDialog = DBGetContactSettingByte(NULL, ModuleName, "UseDialog", TRUE); - commonData.clistIcon= DBGetContactSettingByte(NULL, ModuleName, "AdvancedIcon", CLIST_ICON); commonData.bIgnoreSubcontacts = DBGetContactSettingByte(NULL, ModuleName, "IgnoreSubcontacts", FALSE); commonData.cShowAgeMode = DBGetContactSettingByte(NULL, ModuleName, "ShowCurrentAge", FALSE); commonData.bNoBirthdaysPopup = DBGetContactSettingByte(NULL, ModuleName, "NoBirthdaysPopup", FALSE); -- cgit v1.2.3