diff options
author | Tobias Weimer <wishmaster51@googlemail.com> | 2014-03-09 12:59:20 +0000 |
---|---|---|
committer | Tobias Weimer <wishmaster51@googlemail.com> | 2014-03-09 12:59:20 +0000 |
commit | db96bee8b5d8849bc8af7c47c162ba6b461a4177 (patch) | |
tree | fb1cb7bc1b737ee5d38ec876a58f61f75741c208 /plugins/NewXstatusNotify/src | |
parent | e01f0a233002645f505d828d0698a0f1829fd2cb (diff) |
First version of NewXStatusNotify that can log status changes in db and display them in the message window. (fixes #553)
git-svn-id: http://svn.miranda-ng.org/main/trunk@8494 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/NewXstatusNotify/src')
-rw-r--r-- | plugins/NewXstatusNotify/src/common.h | 1 | ||||
-rw-r--r-- | plugins/NewXstatusNotify/src/main.cpp | 148 | ||||
-rw-r--r-- | plugins/NewXstatusNotify/src/options.cpp | 52 | ||||
-rw-r--r-- | plugins/NewXstatusNotify/src/options.h | 1 | ||||
-rw-r--r-- | plugins/NewXstatusNotify/src/resource.h | 6 | ||||
-rw-r--r-- | plugins/NewXstatusNotify/src/utils.cpp | 23 | ||||
-rw-r--r-- | plugins/NewXstatusNotify/src/xstatus.cpp | 43 | ||||
-rw-r--r-- | plugins/NewXstatusNotify/src/xstatus.h | 2 |
8 files changed, 163 insertions, 113 deletions
diff --git a/plugins/NewXstatusNotify/src/common.h b/plugins/NewXstatusNotify/src/common.h index 544e7ca667..bd83b6b609 100644 --- a/plugins/NewXstatusNotify/src/common.h +++ b/plugins/NewXstatusNotify/src/common.h @@ -149,4 +149,5 @@ extern HINSTANCE hInst; extern HGENMENU hEnableDisableMenu;
extern STATUS StatusList[STATUS_COUNT];
+bool CheckMsgWnd(MCONTACT hContact);
#endif //COMMON_H
diff --git a/plugins/NewXstatusNotify/src/main.cpp b/plugins/NewXstatusNotify/src/main.cpp index bcdfbaad92..daa4fe4c37 100644 --- a/plugins/NewXstatusNotify/src/main.cpp +++ b/plugins/NewXstatusNotify/src/main.cpp @@ -32,6 +32,10 @@ STATUS StatusList[STATUS_COUNT]; HWND SecretWnd;
int hLangpack;
+
+int ContactStatusChanged(MCONTACT hContact, WORD oldStatus,WORD newStatus);
+
+
PLUGININFOEX pluginInfoEx = {
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
@@ -437,6 +441,7 @@ int ProcessStatus(DBCONTACTWRITESETTING *cws, MCONTACT hContact) return 0;
//If we get here, we have to notify the Hooks.
+ ContactStatusChanged(hContact,oldStatus, newStatus);
NotifyEventHooks(hHookContactStatusChanged, hContact, (LPARAM)MAKELPARAM(oldStatus, newStatus));
return 1;
}
@@ -610,26 +615,7 @@ int StatusModeChanged(WPARAM wParam, LPARAM lParam) return 0;
}
-void ShowStatusChangePopup(MCONTACT hContact, char *szProto, WORD oldStatus, WORD newStatus)
-{
- TCHAR stzStatusText[MAX_SECONDLINE] = {0};
- WORD myStatus = (WORD)CallProtoService(szProto, PS_GETSTATUS, 0, 0);
-
- POPUPDATAT ppd = {0};
- ppd.lchContact = hContact;
- ppd.lchIcon = LoadSkinnedProtoIcon(szProto, newStatus);
- _tcsncpy(ppd.lptzContactName, (TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GSMDF_TCHAR), MAX_CONTACTNAME);
-
- if (opt.ShowGroup) { //add group name to popup title
- DBVARIANT dbv;
- if (!db_get_ts(hContact, "CList", "Group", &dbv)) {
- _tcscat(ppd.lptzContactName, _T(" ("));
- _tcscat(ppd.lptzContactName, dbv.ptszVal);
- _tcscat(ppd.lptzContactName, _T(")"));
- db_free(&dbv);
- }
- }
-
+void GetStatusText(MCONTACT hContact, WORD newStatus, WORD oldStatus, TCHAR *stzStatusText) {
if (opt.ShowStatus) {
if (opt.UseAlternativeText) {
switch (GetGender(hContact)) {
@@ -652,11 +638,35 @@ void ShowStatusChangePopup(MCONTACT hContact, char *szProto, WORD oldStatus, WOR _tcscat(_tcscat(stzStatusText, _T(" ")), buff);
}
}
+}
+
+
+void ShowStatusChangePopup(MCONTACT hContact, char *szProto, WORD oldStatus, WORD newStatus)
+{
+ WORD myStatus = (WORD)CallProtoService(szProto, PS_GETSTATUS, 0, 0);
+
+ POPUPDATAT ppd = {0};
+ ppd.lchContact = hContact;
+ ppd.lchIcon = LoadSkinnedProtoIcon(szProto, newStatus);
+ _tcsncpy(ppd.lptzContactName, (TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GSMDF_TCHAR), MAX_CONTACTNAME);
+
+ if (opt.ShowGroup) { //add group name to popup title
+ DBVARIANT dbv;
+ if (!db_get_ts(hContact, "CList", "Group", &dbv)) {
+ _tcsncat(ppd.lptzContactName, _T(" ("), MAX_CONTACTNAME);
+ _tcsncat(ppd.lptzContactName, dbv.ptszVal, MAX_CONTACTNAME);
+ _tcsncat(ppd.lptzContactName, _T(")"), MAX_CONTACTNAME);
+ db_free(&dbv);
+ }
+ }
+
+ TCHAR stzStatusText[MAX_SECONDLINE] = {0};
+ GetStatusText(hContact,newStatus,oldStatus,stzStatusText);
if (opt.ReadAwayMsg && myStatus != ID_STATUS_INVISIBLE && StatusHasAwayMessage(szProto, newStatus))
db_set_ws(hContact, MODULE, "LastPopupText", stzStatusText);
- _tcscpy(ppd.lptzText, stzStatusText);
+ _tcsncpy(ppd.lptzText, stzStatusText, MAX_SECONDLINE);
switch (opt.Colors) {
case POPUP_COLOR_OWN:
@@ -697,8 +707,8 @@ void BlinkIcon(MCONTACT hContact, char* szProto, WORD status) cle.pszService = "UserOnline/Description";
cle.ptszTooltip = stzTooltip;
- TCHAR *hlpName = (TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GCDNF_TCHAR);
- mir_sntprintf(stzTooltip, SIZEOF(stzTooltip), TranslateT("%s is now %s"), hlpName, StatusList[Index(status)].lpzStandardText);
+ mir_sntprintf(stzTooltip, SIZEOF(stzTooltip), TranslateT("%s is now %s"),
+ CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GCDNF_TCHAR), StatusList[Index(status)].lpzStandardText);
CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle);
}
@@ -725,39 +735,20 @@ void PlayChangeSound(MCONTACT hContact, WORD oldStatus, WORD newStatus) }
}
- char szSoundFile[MAX_PATH] = {0};
-
- if (!db_get_b(0, "SkinSoundsOff", "UserFromOffline", 0) &&
- !db_get_s(0,"SkinSounds", "UserFromOffline", &dbv) &&
- oldStatus == ID_STATUS_OFFLINE)
- {
- strcpy(szSoundFile, "UserFromOffline");
- db_free(&dbv);
- }
- else if (!db_get_b(0, "SkinSoundsOff", StatusList[Index(newStatus)].lpzSkinSoundName, 0) &&
- !db_get(0, "SkinSounds", StatusList[Index(newStatus)].lpzSkinSoundName, &dbv))
- {
- strcpy(szSoundFile, StatusList[Index(newStatus)].lpzSkinSoundName);
- db_free(&dbv);
- }
-
- if (szSoundFile[0])
- SkinPlaySound(szSoundFile);
+ if (!db_get_b(0, "SkinSoundsOff", "UserFromOffline", 0) && oldStatus == ID_STATUS_OFFLINE)
+ SkinPlaySound("UserFromOffline");
+ else if (!db_get_b(0, "SkinSoundsOff", StatusList[Index(newStatus)].lpzSkinSoundName, 0))
+ SkinPlaySound(StatusList[Index(newStatus)].lpzSkinSoundName);
}
-int ContactStatusChanged(WPARAM hContact, LPARAM lParam)
+int ContactStatusChanged(MCONTACT hContact, WORD oldStatus,WORD newStatus)
{
- WORD oldStatus = LOWORD(lParam);
- WORD newStatus = HIWORD(lParam);
-
bool bEnablePopup = true, bEnableSound = true;
- char *hlpProto = GetContactProto(hContact);
- if (hlpProto == NULL || opt.TempDisabled)
+ char *szProto = GetContactProto(hContact);
+ if (szProto == NULL || opt.TempDisabled)
return 0;
- char szProto[64];
- strcpy(szProto, hlpProto);
WORD myStatus = (WORD)CallProtoService(szProto, PS_GETSTATUS, 0, 0);
if (opt.EnableLastSeen && newStatus == ID_STATUS_OFFLINE && oldStatus > ID_STATUS_OFFLINE) {
@@ -776,13 +767,10 @@ int ContactStatusChanged(WPARAM hContact, LPARAM lParam) if (!strcmp(szProto, META_PROTO)) { //this contact is Meta
MCONTACT hSubContact = (MCONTACT)CallService(MS_MC_GETMOSTONLINECONTACT, hContact, 0);
- hlpProto = GetContactProto(hSubContact);
- if (hlpProto == NULL)
+ char *szSubProto = GetContactProto(hSubContact);
+ if (szSubProto == NULL)
return 0;
- char szSubProto[64];
- strcpy(szSubProto, hlpProto);
-
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
@@ -797,7 +785,7 @@ int ContactStatusChanged(WPARAM hContact, LPARAM lParam) if (!db_get_b(0, MODULE, szSubProto, 1))
return 0;
- strcpy(szProto, szSubProto);
+ szProto = szSubProto;
}
else {
if (myStatus == ID_STATUS_OFFLINE || !db_get_b(0, MODULE, szProto, 1))
@@ -836,17 +824,32 @@ int ContactStatusChanged(WPARAM hContact, LPARAM lParam) if (bEnableSound && db_get_b(0, "Skin", "UseSound", TRUE) && db_get_b(hContact, MODULE, "EnableSounds", 1))
PlayChangeSound(hContact, oldStatus, newStatus);
+ if(opt.LogToDB && (!opt.CheckMessageWindow || CheckMsgWnd(hContact))) {
+ TCHAR stzStatusText[MAX_SECONDLINE] = {0};
+ GetStatusText(hContact,newStatus,oldStatus,stzStatusText);
+ char *blob = mir_utf8encodeT(stzStatusText);
+
+ DBEVENTINFO dbei = {0};
+ dbei.cbSize = sizeof(dbei);
+ dbei.cbBlob = (DWORD)strlen(blob) + 1;
+ dbei.pBlob = (PBYTE) blob;
+ dbei.eventType = EVENTTYPE_STATUSCHANGE;
+ dbei.flags = DBEF_READ | DBEF_UTF;
+
+ dbei.timestamp = (DWORD)time(NULL);
+ dbei.szModule = szProto;
+ HANDLE hDBEvent = db_event_add(hContact, &dbei);
+ mir_free(blob);
+ }
+
if (opt.Log) {
- TCHAR stzName[64], stzStatus[MAX_STATUSTEXT], stzOldStatus[MAX_STATUSTEXT];
- TCHAR stzDate[MAX_STATUSTEXT], stzTime[MAX_STATUSTEXT];
- TCHAR stzText[1024];
+ TCHAR stzDate[MAX_STATUSTEXT], stzTime[MAX_STATUSTEXT], stzText[1024];
- _tcscpy(stzName, (TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GCDNF_TCHAR));
- _tcsncpy(stzStatus, StatusList[Index(newStatus)].lpzStandardText, MAX_STATUSTEXT);
- _tcsncpy(stzOldStatus, StatusList[Index(oldStatus)].lpzStandardText, MAX_STATUSTEXT);
GetTimeFormat(LOCALE_USER_DEFAULT, 0, NULL,_T("HH':'mm"), stzTime, SIZEOF(stzTime));
GetDateFormat(LOCALE_USER_DEFAULT, 0, NULL,_T("dd/MM/yyyy"), stzDate, SIZEOF(stzDate));
- mir_sntprintf(stzText, SIZEOF(stzText), TranslateT("%s, %s. %s changed to: %s (was: %s).\r\n"), stzDate, stzTime, stzName, stzStatus, stzOldStatus);
+ mir_sntprintf(stzText, SIZEOF(stzText), TranslateT("%s, %s. %s changed to: %s (was: %s).\r\n"),
+ stzDate, stzTime, CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GCDNF_TCHAR), StatusList[Index(newStatus)].lpzStandardText,
+ StatusList[Index(oldStatus)].lpzStandardText);
LogToFile(stzText);
}
@@ -1076,8 +1079,6 @@ void InitMainMenuItem() opt.TempDisabled = !opt.TempDisabled;
EnableDisableMenuCommand(0, 0);
-
- hServiceMenu = (HANDLE)CreateServiceFunction(MS_STATUSCHANGE_MENUCOMMAND, EnableDisableMenuCommand);
}
static IconItem iconList[] =
@@ -1108,8 +1109,8 @@ int InitTopToolbar(WPARAM, LPARAM) tbb.pszService = MS_STATUSCHANGE_MENUCOMMAND;
tbb.dwFlags = (opt.TempDisabled ? 0 : TTBBF_PUSHED) | TTBBF_ASPUSHBUTTON;
tbb.name = LPGEN("Toggle status notification");
- tbb.hIconHandleUp = GetIconHandle(ICO_NOTIFICATION_OFF);
- tbb.hIconHandleDn = GetIconHandle(ICO_NOTIFICATION_ON);
+ tbb.hIconHandleUp = iconList[0].hIcolib;
+ tbb.hIconHandleDn = iconList[1].hIcolib;
tbb.pszTooltipUp = LPGEN("Enable status notification");
tbb.pszTooltipDn = LPGEN("Disable status notification");
hToolbarButton = TopToolbar_AddButton(&tbb);
@@ -1122,7 +1123,6 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) InitMainMenuItem();
HookEvent(ME_USERINFO_INITIALISE, UserInfoInitialise);
- HookEvent(ME_STATUSCHANGE_CONTACTSTATUSCHANGED, ContactStatusChanged);
HookEvent(ME_MSG_WINDOWEVENT, OnWindowEvent);
HookEvent(ME_TTB_MODULELOADED, InitTopToolbar);
@@ -1169,6 +1169,20 @@ extern "C" int __declspec(dllexport) Load(void) db_set_resident("MetaContacts", "LastOnline");
db_set_resident("NewStatusNotify", "LastPopupText");
+
+ // register special type of event
+ // there's no need to declare the special service for getting text
+ // because a blob contains only text
+ DBEVENTTYPEDESCR evtype = { sizeof(evtype) };
+ evtype.module = MODULE;
+ evtype.eventType = EVENTTYPE_STATUSCHANGE;
+ evtype.descr = LPGEN("Status change");
+ evtype.eventIcon = iconList[0].hIcolib;
+ evtype.flags = DETF_HISTORY | DETF_MSGWINDOW;
+ CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&evtype);
+
+ hServiceMenu = CreateServiceFunction(MS_STATUSCHANGE_MENUCOMMAND, EnableDisableMenuCommand);
+
return 0;
}
diff --git a/plugins/NewXstatusNotify/src/options.cpp b/plugins/NewXstatusNotify/src/options.cpp index 4b840f726b..f1693ab8be 100644 --- a/plugins/NewXstatusNotify/src/options.cpp +++ b/plugins/NewXstatusNotify/src/options.cpp @@ -71,6 +71,8 @@ void LoadOptions() 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);
+ opt.LogToDB = db_get_b(0, MODULE, "LogToDB", 0);
+ opt.CheckMessageWindow = db_get_b(0, MODULE, "CheckMessageWindow", 1);
DBGetStringDefault(0, MODULE, "LogFilePath", opt.LogFilePath, MAX_PATH, _T(""));
// IDD_AUTODISABLE
opt.OnlyGlobalChanges = db_get_b(0, MODULE, "OnlyGlobalChanges", 0);
@@ -90,8 +92,6 @@ void LoadOptions() opt.EnableLastSeen = db_get_b(0, MODULE, "EnableLastSeen", 0);
LoadTemplates();
-
- return;
}
void SaveTemplates()
@@ -143,6 +143,8 @@ void SaveOptions() db_set_b(0, MODULE, "BlinkIcon", opt.BlinkIcon);
db_set_b(0, MODULE, "BlinkIcon_Status", opt.BlinkIcon_Status);
db_set_b(0, MODULE, "Log", opt.Log);
+ db_set_b(0, MODULE, "LogToDB", opt.LogToDB);
+ db_set_b(0, MODULE, "CheckMessageWindow", opt.CheckMessageWindow);
db_set_ws(0, MODULE, "LogFilePath", opt.LogFilePath);
// IDD_AUTODISABLE
db_set_b(0, MODULE, "OnlyGlobalChanges", opt.OnlyGlobalChanges);
@@ -164,7 +166,6 @@ INT_PTR CALLBACK DlgProcGeneralOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA switch (msg)
{
case WM_INITDIALOG:
- {
TranslateDialogDefault(hwndDlg);
CheckDlgButton(hwndDlg, IDC_AUTODISABLE, opt.AutoDisable);
@@ -182,17 +183,20 @@ INT_PTR CALLBACK DlgProcGeneralOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA EnableWindow(GetDlgItem(hwndDlg, IDC_BT_CHOOSELOGFILE), opt.Log);
EnableWindow(GetDlgItem(hwndDlg, IDC_BT_VIEWLOG), opt.Log);
- //Statuses notified
- char status[8];
+ CheckDlgButton(hwndDlg, IDC_LOGTODB, opt.LogToDB);
+ CheckDlgButton(hwndDlg, IDC_CHECKMESSAGEWINDOW, opt.CheckMessageWindow);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHECKMESSAGEWINDOW), opt.LogToDB);
+
for (int i = ID_STATUS_MIN; i <= ID_STATUS_MAX2; i++)
{
+ //Statuses notified
+ char status[8];
mir_snprintf(status, SIZEOF(status), "%d", i);
CheckDlgButton(hwndDlg, i, db_get_b(0, MODULE, status, 1));
}
CheckDlgButton(hwndDlg, IDC_CHK_FROMOFFLINE, opt.FromOffline);
return TRUE;
- }
case WM_COMMAND:
{
switch(LOWORD(wParam))
@@ -236,15 +240,9 @@ INT_PTR CALLBACK DlgProcGeneralOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA EnableWindow(GetDlgItem(hwndDlg, IDC_BT_CHOOSELOGFILE), IsDlgButtonChecked(hwndDlg, IDC_LOG));
EnableWindow(GetDlgItem(hwndDlg, IDC_BT_VIEWLOG), IsDlgButtonChecked(hwndDlg, IDC_LOG));
break;
- case IDC_HYPERLINK:
- {
- OPENOPTIONSDIALOG ood = {0};
- ood.cbSize = sizeof(ood);
- //ood.pszGroup = "Customize";
- ood.pszPage = "Sounds";
- Options_Open(&ood);
- return FALSE;
- }
+ case IDC_LOGTODB:
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHECKMESSAGEWINDOW), IsDlgButtonChecked(hwndDlg, IDC_LOGTODB));
+ break;
}
if (HIWORD(wParam) == BN_CLICKED || (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus()))
@@ -253,7 +251,6 @@ INT_PTR CALLBACK DlgProcGeneralOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA break;
}
case WM_NOTIFY:
- {
if (((LPNMHDR)lParam)->code == PSN_APPLY)
{
opt.AutoDisable = IsDlgButtonChecked(hwndDlg, IDC_AUTODISABLE);
@@ -265,10 +262,13 @@ INT_PTR CALLBACK DlgProcGeneralOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA opt.Log = IsDlgButtonChecked(hwndDlg, IDC_LOG);
GetDlgItemText(hwndDlg, IDC_LOGFILE, opt.LogFilePath, SIZEOF(opt.LogFilePath));
+ opt.LogToDB = IsDlgButtonChecked(hwndDlg, IDC_LOGTODB);
+ opt.CheckMessageWindow = IsDlgButtonChecked(hwndDlg, IDC_CHECKMESSAGEWINDOW);
+
//Notified statuses
- char status[8];
for (int i = ID_STATUS_MIN; i <= ID_STATUS_MAX2; i++)
{
+ char status[8];
mir_snprintf(status, SIZEOF(status), "%d", i);
db_set_b(NULL, MODULE, status, (BYTE)IsDlgButtonChecked(hwndDlg, i));
}
@@ -277,7 +277,6 @@ INT_PTR CALLBACK DlgProcGeneralOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA SaveOptions();
return TRUE;
}
- }
}
return FALSE;
@@ -606,12 +605,12 @@ INT_PTR CALLBACK DlgProcXPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM EnableWindow(GetDlgItem(hwndDlg, IDC_ED_TREMOVE), templates.PopupFlags & NOTIFY_REMOVE);
// Buttons
- SendDlgItemMessage(hwndDlg, IDC_BT_VARIABLES, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Show available variables"), BATF_TCHAR);
+ SendDlgItemMessage(hwndDlg, IDC_BT_VARIABLES, BUTTONADDTOOLTIP, (WPARAM)LPGENT("Show available variables"), BATF_TCHAR);
HICON hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_VARIABLES));
SendDlgItemMessage(hwndDlg, IDC_BT_VARIABLES, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
DestroyIcon(hIcon);
- SendDlgItemMessage(hwndDlg, IDC_BT_RESET, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Reset all templates to default"), BATF_TCHAR);
+ SendDlgItemMessage(hwndDlg, IDC_BT_RESET, BUTTONADDTOOLTIP, (WPARAM)LPGENT("Reset all templates to default"), BATF_TCHAR);
hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_RESET));
SendDlgItemMessage(hwndDlg, IDC_BT_RESET, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
DestroyIcon(hIcon);
@@ -695,16 +694,7 @@ INT_PTR CALLBACK DlgProcXPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM bool IsSuitableProto(PROTOACCOUNT *pa)
{
- if ( pa == NULL )
- return false;
-
- if ( pa->bDynDisabled || !pa->bIsEnabled )
- return false;
-
- if ( CallProtoService( pa->szProtoName, PS_GETCAPS, PFLAGNUM_2, 0 ) == 0 )
- return false;
-
- return true;
+ return ( pa != NULL && !pa->bDynDisabled && pa->bIsEnabled && CallProtoService( pa->szProtoName, PS_GETCAPS, PFLAGNUM_2, 0 ) != 0 );
}
INT_PTR CALLBACK DlgProcSMPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -1030,7 +1020,7 @@ INT_PTR CALLBACK DlgProcXLogOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l return FALSE;
}
-int OptionsInitialize(WPARAM wParam, LPARAM lParam)
+int OptionsInitialize(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { sizeof(odp) };
odp.position = -100000000;
diff --git a/plugins/NewXstatusNotify/src/options.h b/plugins/NewXstatusNotify/src/options.h index dc62e034e7..c0ebc30a29 100644 --- a/plugins/NewXstatusNotify/src/options.h +++ b/plugins/NewXstatusNotify/src/options.h @@ -48,6 +48,7 @@ typedef struct tagOPTIONS { BYTE BlinkIcon;
BYTE BlinkIcon_Status;
BYTE Log;
+ BYTE LogToDB, CheckMessageWindow;
TCHAR LogFilePath[MAX_PATH];
// IDD_AUTODISABLE
BYTE OnlyGlobalChanges;
diff --git a/plugins/NewXstatusNotify/src/resource.h b/plugins/NewXstatusNotify/src/resource.h index 58a41599b1..3e2cfe9fd3 100644 --- a/plugins/NewXstatusNotify/src/resource.h +++ b/plugins/NewXstatusNotify/src/resource.h @@ -1,6 +1,6 @@ //{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
-// Used by resource.rc
+// Used by ..\res\resource.rc
//
#define IDD_OPT_XPOPUP 101
#define IDD_INFO_SOUNDS 102
@@ -56,6 +56,8 @@ #define IDC_ED_TREMOVE 1040
#define IDC_ED_TDELIMITER 1042
#define IDC_INDSNDLIST 1044
+#define IDC_LOGTODB 1044
+#define IDC_CHECKMESSAGEWINDOW 1045
#define IDC_HIDDENCONTACTSTOO 1052
#define IDC_USEINDIVSOUNDS 1053
#define IDC_OK 1055
@@ -144,7 +146,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 111
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1044
+#define _APS_NEXT_CONTROL_VALUE 1046
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/plugins/NewXstatusNotify/src/utils.cpp b/plugins/NewXstatusNotify/src/utils.cpp index a86f7e80bc..08e61f1dd2 100644 --- a/plugins/NewXstatusNotify/src/utils.cpp +++ b/plugins/NewXstatusNotify/src/utils.cpp @@ -21,6 +21,29 @@ #include "common.h"
+
+// From NewEventNotify :-)
+bool CheckMsgWnd(MCONTACT hContact)
+{
+ MessageWindowInputData mwid;
+ mwid.cbSize = sizeof(MessageWindowInputData);
+ mwid.hContact = hContact;
+ mwid.uFlags = MSG_WINDOW_UFLAG_MSG_BOTH;
+
+ MessageWindowData mwd;
+ mwd.cbSize = sizeof(MessageWindowData);
+ mwd.hContact = hContact;
+ if (CallService(MS_MSG_GETWINDOWDATA, (WPARAM) &mwid, (LPARAM) &mwd) != NULL)
+ return false;
+
+ if (mwd.hwndWindow != NULL && (mwd.uState & MSG_WINDOW_STATE_EXISTS))
+ return true;
+
+ return false;
+}
+
+
+
TCHAR *db2t(DBVARIANT *dbv)
{
TCHAR *buff;
diff --git a/plugins/NewXstatusNotify/src/xstatus.cpp b/plugins/NewXstatusNotify/src/xstatus.cpp index 4930aaac08..e5e070ac62 100644 --- a/plugins/NewXstatusNotify/src/xstatus.cpp +++ b/plugins/NewXstatusNotify/src/xstatus.cpp @@ -174,9 +174,9 @@ void ShowPopup(XSTATUSCHANGE *xsc) }
if (ptszGroup)
- mir_sntprintf(ppd.lptzContactName, SIZEOF(ppd.lptzContactName),_T("%s (%s)"), ptszNick, ptszGroup);
+ mir_sntprintf(ppd.lptzContactName, MAX_CONTACTNAME,_T("%s (%s)"), ptszNick, ptszGroup);
else
- _tcsncpy(ppd.lptzContactName, ptszNick, SIZEOF(ppd.lptzContactName));
+ _tcsncpy(ppd.lptzContactName, ptszNick, MAX_CONTACTNAME);
// cut message if needed
if (opt.PTruncateMsg && (opt.PMsgLen > 0) && xsc->stzText && (_tcslen(xsc->stzText) > opt.PMsgLen)) {
@@ -205,7 +205,7 @@ void ShowPopup(XSTATUSCHANGE *xsc) _tcsncpy(ppd.lptzText, stzPopupText, SIZEOF(ppd.lptzText));
ppd.lptzText[SIZEOF(ppd.lptzText) - 1] = 0;
- ppd.PluginWindowProc = (WNDPROC)PopupDlgProc;
+ ppd.PluginWindowProc = PopupDlgProc;
ppd.iSeconds = opt.PopupTimeout;
PUAddPopupT(&ppd);
}
@@ -246,24 +246,44 @@ void LogToMessageWindow(XSTATUSCHANGE *xsc, BOOL opening) Template = templates.LogOpening; break;
}
- TCHAR stzLogText[2*MAX_TEXT_LEN];
- TCHAR stzLastLog[2*MAX_TEXT_LEN];
+ TCHAR stzLogText[2*MAX_TEXT_LEN], stzLastLog[2*MAX_TEXT_LEN];
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))
+ 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);
+ dbei.cbBlob = (DWORD)strlen(blob) + 1;
+ dbei.pBlob = (PBYTE) blob;
+ dbei.eventType = EVENTTYPE_STATUSCHANGE;
+ dbei.flags = DBEF_READ | DBEF_UTF;
+
+ dbei.timestamp = (DWORD)time(NULL);
+ dbei.szModule = xsc->szProto;
+ HANDLE hDBEvent = db_event_add(xsc->hContact, &dbei);
+ mir_free(blob);
+
+ if (!opt.KeepInHistory) {
+ DBEVENT *dbevent = (DBEVENT *)mir_alloc(sizeof(DBEVENT));
+ dbevent->hContact = xsc->hContact;
+ dbevent->hDBEvent = hDBEvent;
+ eventList.insert(dbevent);
+ }
+ }
}
void LogChangeToFile(XSTATUSCHANGE *xsc)
{
- TCHAR stzName[256], stzType[32];
- TCHAR stzDate[32], stzTime[32];
- TCHAR stzText[MAX_TEXT_LEN];
+ TCHAR stzType[32], stzDate[32], stzTime[32], stzText[MAX_TEXT_LEN];
GetStatusTypeAsString(xsc->type, stzType);
- _tcscpy(stzName, (TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)xsc->hContact, GCDNF_TCHAR));
+ INT_PTR stzName = CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)xsc->hContact, GCDNF_TCHAR);
+
GetTimeFormat(LOCALE_USER_DEFAULT, 0, NULL,_T("HH':'mm"), stzTime, SIZEOF(stzTime));
GetDateFormat(LOCALE_USER_DEFAULT, 0, NULL,_T("dd/MM/yyyy"), stzDate, SIZEOF(stzDate));
@@ -323,8 +343,7 @@ void ExtraStatusChanged(XSTATUSCHANGE *xsc) if (!(templates.LogFlags & xsc->action))
enableLog = FALSE;
- if (enableLog && db_get_b(xsc->hContact, MODULE, "EnableLogging", 1)
- && CallService(MS_MSG_MOD_MESSAGEDIALOGOPENED, (WPARAM)xsc->hContact, 0))
+ if (enableLog && db_get_b(xsc->hContact, MODULE, "EnableLogging", 1) && CheckMsgWnd(xsc->hContact))
LogToMessageWindow(xsc, FALSE);
if (opt.Log)
diff --git a/plugins/NewXstatusNotify/src/xstatus.h b/plugins/NewXstatusNotify/src/xstatus.h index c2d4d46113..9ee53fae30 100644 --- a/plugins/NewXstatusNotify/src/xstatus.h +++ b/plugins/NewXstatusNotify/src/xstatus.h @@ -43,7 +43,7 @@ #define XSTATUS_SOUND_REMOVED "XStatusRemove"
// tabSRMM stuff (logging to message window)
-#define MS_MSG_MOD_MESSAGEDIALOGOPENED "SRMsg_MOD/MessageDialogOpened"
+#define EVENTTYPE_STATUSCHANGE 25368
// Default templates
#define DEFAULT_POPUP_DELIMITER _T("%B")
|