diff options
Diffstat (limited to 'plugins/Scriver/src/msgs.cpp')
-rw-r--r-- | plugins/Scriver/src/msgs.cpp | 152 |
1 files changed, 73 insertions, 79 deletions
diff --git a/plugins/Scriver/src/msgs.cpp b/plugins/Scriver/src/msgs.cpp index c68a2397b7..93aca689e1 100644 --- a/plugins/Scriver/src/msgs.cpp +++ b/plugins/Scriver/src/msgs.cpp @@ -62,14 +62,14 @@ static int SRMMStatusToPf2(int status) }
int IsAutoPopup(HANDLE hContact) {
- if (g_dat->flags & SMF_AUTOPOPUP) {
+ if (g_dat.flags & SMF_AUTOPOPUP) {
char *szProto = GetContactProto(hContact);
if (strcmp(szProto, "MetaContacts") == 0 ) {
hContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT,(WPARAM)hContact, 0);
if (hContact != NULL)
szProto = GetContactProto(hContact);
}
- if (szProto && (g_dat->openFlags & SRMMStatusToPf2(CallProtoService(szProto, PS_GETSTATUS, 0, 0)))) {
+ if (szProto && (g_dat.openFlags & SRMMStatusToPf2(CallProtoService(szProto, PS_GETSTATUS, 0, 0)))) {
return 1;
}
}
@@ -82,7 +82,7 @@ static INT_PTR ReadMessageCommand(WPARAM wParam, LPARAM lParam) HWND hwndExisting;
HWND hParent;
- hwndExisting = WindowList_Find(g_dat->hMessageWindowList, ((CLISTEVENT *) lParam)->hContact);
+ hwndExisting = WindowList_Find(g_dat.hMessageWindowList, ((CLISTEVENT *) lParam)->hContact);
if (hwndExisting == NULL) {
newData.hContact = ((CLISTEVENT *) lParam)->hContact;
hParent = GetParentWindow(newData.hContact, FALSE);
@@ -102,7 +102,7 @@ static int MessageEventAdded(WPARAM wParam, LPARAM lParam) CallService(MS_DB_EVENT_GET, lParam, (LPARAM) & dbei);
if (dbei.eventType == EVENTTYPE_MESSAGE && (dbei.flags & DBEF_READ))
return 0;
- hwnd = WindowList_Find(g_dat->hMessageWindowList, (HANDLE) wParam);
+ hwnd = WindowList_Find(g_dat.hMessageWindowList, (HANDLE) wParam);
if (hwnd) {
SendMessage(hwnd, HM_DBEVENTADDED, wParam, lParam);
}
@@ -157,7 +157,7 @@ static INT_PTR SendMessageCommandW(WPARAM wParam, LPARAM lParam) if (!CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND)
return 1;
- if ((hwnd = WindowList_Find(g_dat->hMessageWindowList, (HANDLE) wParam))) {
+ if ((hwnd = WindowList_Find(g_dat.hMessageWindowList, (HANDLE) wParam))) {
if (lParam) {
HWND hEdit;
hEdit = GetDlgItem(hwnd, IDC_MESSAGE);
@@ -201,7 +201,7 @@ static INT_PTR SendMessageCommand(WPARAM wParam, LPARAM lParam) } //if
}
- if ((hwnd = WindowList_Find(g_dat->hMessageWindowList, (HANDLE) wParam))) {
+ if ((hwnd = WindowList_Find(g_dat.hMessageWindowList, (HANDLE) wParam))) {
if (lParam) {
HWND hEdit;
hEdit = GetDlgItem(hwnd, IDC_MESSAGE);
@@ -240,15 +240,15 @@ static int TypingMessage(WPARAM wParam, LPARAM lParam) {
HWND hwnd;
- if (!(g_dat->flags2&SMF2_SHOWTYPING))
+ if (!(g_dat.flags2&SMF2_SHOWTYPING))
return 0;
- if ((hwnd = WindowList_Find(g_dat->hMessageWindowList, (HANDLE) wParam))) {
+ if ((hwnd = WindowList_Find(g_dat.hMessageWindowList, (HANDLE) wParam))) {
SendMessage(hwnd, DM_TYPING, 0, lParam);
- } else if ((int) lParam && (g_dat->flags2&SMF2_SHOWTYPINGTRAY)) {
+ } else if ((int) lParam && (g_dat.flags2&SMF2_SHOWTYPINGTRAY)) {
TCHAR szTip[256];
mir_sntprintf(szTip, SIZEOF(szTip), TranslateT("%s is typing a message"), (TCHAR *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, wParam, GCDNF_TCHAR));
- if (ServiceExists(MS_CLIST_SYSTRAY_NOTIFY) && !(g_dat->flags2&SMF2_SHOWTYPINGCLIST)) {
+ if (ServiceExists(MS_CLIST_SYSTRAY_NOTIFY) && !(g_dat.flags2&SMF2_SHOWTYPINGCLIST)) {
MIRANDASYSTRAYNOTIFY tn;
tn.szProto = NULL;
tn.cbSize = sizeof(tn);
@@ -281,7 +281,7 @@ static int MessageSettingChanged(WPARAM wParam, LPARAM lParam) char *szProto = GetContactProto((HANDLE)wParam);
if (lstrcmpA(cws->szModule, "CList") && (szProto == NULL || lstrcmpA(cws->szModule, szProto)))
return 0;
- WindowList_Broadcast(g_dat->hMessageWindowList, DM_CLISTSETTINGSCHANGED, wParam, lParam);
+ WindowList_Broadcast(g_dat.hMessageWindowList, DM_CLISTSETTINGSCHANGED, wParam, lParam);
return 0;
}
@@ -289,7 +289,7 @@ static int ContactDeleted(WPARAM wParam, LPARAM lParam) {
HWND hwnd;
- if ((hwnd = WindowList_Find(g_dat->hMessageWindowList, (HANDLE) wParam))) {
+ if ((hwnd = WindowList_Find(g_dat.hMessageWindowList, (HANDLE) wParam))) {
SendMessage(hwnd, WM_CLOSE, 0, 0);
}
return 0;
@@ -297,47 +297,42 @@ static int ContactDeleted(WPARAM wParam, LPARAM lParam) static void RestoreUnreadMessageAlerts(void)
{
- CLISTEVENT cle = { 0 };
- DBEVENTINFO dbei = { 0 };
TCHAR toolTip[256];
- int windowAlreadyExists;
- HANDLE hDbEvent, hContact;
- dbei.cbSize = sizeof(dbei);
- cle.cbSize = sizeof(cle);
+ DBEVENTINFO dbei = { sizeof(dbei) };
+
+ CLISTEVENT cle = { sizeof(cle) };
cle.hIcon = LoadSkinnedIcon(SKINICON_EVENT_MESSAGE);
cle.pszService = "SRMsg/ReadMessage";
cle.flags = CLEF_TCHAR;
cle.ptszTooltip = toolTip;
- hContact = db_find_first();
+ HANDLE hContact = db_find_first();
while (hContact) {
- hDbEvent = (HANDLE) CallService(MS_DB_EVENT_FINDFIRSTUNREAD, (WPARAM) hContact, 0);
+ HANDLE hDbEvent = (HANDLE) CallService(MS_DB_EVENT_FINDFIRSTUNREAD, (WPARAM) hContact, 0);
while (hDbEvent) {
dbei.cbBlob = 0;
- CallService(MS_DB_EVENT_GET, (WPARAM) hDbEvent, (LPARAM) & dbei);
+ CallService(MS_DB_EVENT_GET, (WPARAM) hDbEvent, (LPARAM) &dbei);
if (!(dbei.flags & (DBEF_SENT | DBEF_READ)) && DbEventIsMessageOrCustom(&dbei)) {
- windowAlreadyExists = WindowList_Find(g_dat->hMessageWindowList, hContact) != NULL;
+ int windowAlreadyExists = WindowList_Find(g_dat.hMessageWindowList, hContact) != NULL;
if (windowAlreadyExists)
continue;
- if (IsAutoPopup(hContact) && !windowAlreadyExists) {
- HWND hParent;
- NewMessageWindowLParam newData = { 0 };
- newData.hContact = hContact;
- newData.flags = NMWLP_INCOMING;
- hParent = GetParentWindow(newData.hContact, FALSE);
- CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSG), hParent, DlgProcMessage, (LPARAM) & newData);
-// CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSG), NULL, DlgProcMessage, (LPARAM) & newData);
- }
- else {
- cle.hContact = hContact;
- cle.hDbEvent = hDbEvent;
- mir_sntprintf(toolTip, SIZEOF(toolTip), TranslateT("Message from %s"), (char *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) hContact, GCDNF_TCHAR));
- CallService(MS_CLIST_ADDEVENT, 0, (LPARAM) & cle);
- }
- }
- hDbEvent = (HANDLE) CallService(MS_DB_EVENT_FINDNEXT, (WPARAM) hDbEvent, 0);
+ if (IsAutoPopup(hContact) && !windowAlreadyExists) {
+ NewMessageWindowLParam newData = { 0 };
+ newData.hContact = hContact;
+ newData.flags = NMWLP_INCOMING;
+ HWND hParent = GetParentWindow(newData.hContact, FALSE);
+ CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSG), hParent, DlgProcMessage, (LPARAM) & newData);
+ }
+ else {
+ cle.hContact = hContact;
+ cle.hDbEvent = hDbEvent;
+ mir_sntprintf(toolTip, SIZEOF(toolTip), TranslateT("Message from %s"), (char *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) hContact, GCDNF_TCHAR));
+ CallService(MS_CLIST_ADDEVENT, 0, (LPARAM) & cle);
+ }
+ }
+ hDbEvent = (HANDLE) CallService(MS_DB_EVENT_FINDNEXT, (WPARAM) hDbEvent, 0);
}
hContact = db_find_next(hContact);
}
@@ -366,7 +361,7 @@ static INT_PTR GetWindowData(WPARAM wParam, LPARAM lParam) if (mwid->cbSize != sizeof(MessageWindowInputData) || mwd->cbSize != sizeof(SrmmWindowData)) return 1;
if (mwid->hContact == NULL) return 1;
if (mwid->uFlags != MSG_WINDOW_UFLAG_MSG_BOTH) return 1;
- hwnd = WindowList_Find(g_dat->hMessageWindowList, mwid->hContact);
+ hwnd = WindowList_Find(g_dat.hMessageWindowList, mwid->hContact);
if (hwnd == NULL)
hwnd = SM_FindWindowByContact(mwid->hContact);
mwd->uFlags = MSG_WINDOW_UFLAG_MSG_BOTH;
@@ -398,9 +393,9 @@ static int PrebuildContactMenu(WPARAM wParam, LPARAM lParam) { static int AvatarChanged(WPARAM wParam, LPARAM lParam) {
if (wParam == 0) { // protocol picture has changed...
- WindowList_Broadcast(g_dat->hMessageWindowList, DM_AVATARCHANGED, wParam, lParam);
+ WindowList_Broadcast(g_dat.hMessageWindowList, DM_AVATARCHANGED, wParam, lParam);
} else {
- HWND hwnd = WindowList_Find(g_dat->hMessageWindowList, (HANDLE)wParam);
+ HWND hwnd = WindowList_Find(g_dat.hMessageWindowList, (HANDLE)wParam);
SendMessage(hwnd, DM_AVATARCHANGED, wParam, lParam);
}
return 0;
@@ -441,27 +436,27 @@ void ChangeStatusIcons() { int StatusIconPressed(WPARAM wParam, LPARAM lParam) {
// HANDLE hContact = (HANDLE) wParam;
StatusIconClickData *sicd = (StatusIconClickData *) lParam;
- HWND hwnd = WindowList_Find(g_dat->hMessageWindowList, (HANDLE)wParam);
+ HWND hwnd = WindowList_Find(g_dat.hMessageWindowList, (HANDLE)wParam);
if (hwnd == NULL) {
hwnd = SM_FindWindowByContact((HANDLE)wParam);
}
if (hwnd != NULL) {
if (!strcmp(SRMMMOD, sicd->szModule)) {
- if (sicd->dwId == 0 && g_dat->hMenuANSIEncoding) {
+ if (sicd->dwId == 0 && g_dat.hMenuANSIEncoding) {
if (sicd->flags & MBCF_RIGHTBUTTON) {
int codePage = (int) SendMessage(hwnd, DM_GETCODEPAGE, 0, 0);
if (codePage != 1200) {
int i, iSel;
- for (i = 0; i < GetMenuItemCount(g_dat->hMenuANSIEncoding); i++) {
- CheckMenuItem (g_dat->hMenuANSIEncoding, i, MF_BYPOSITION | MF_UNCHECKED);
+ for (i = 0; i < GetMenuItemCount(g_dat.hMenuANSIEncoding); i++) {
+ CheckMenuItem (g_dat.hMenuANSIEncoding, i, MF_BYPOSITION | MF_UNCHECKED);
}
if (codePage == CP_ACP) {
- CheckMenuItem(g_dat->hMenuANSIEncoding, 0, MF_BYPOSITION | MF_CHECKED);
+ CheckMenuItem(g_dat.hMenuANSIEncoding, 0, MF_BYPOSITION | MF_CHECKED);
} else {
- CheckMenuItem(g_dat->hMenuANSIEncoding, codePage, MF_BYCOMMAND | MF_CHECKED);
+ CheckMenuItem(g_dat.hMenuANSIEncoding, codePage, MF_BYCOMMAND | MF_CHECKED);
}
- iSel = TrackPopupMenu(g_dat->hMenuANSIEncoding, TPM_RETURNCMD, sicd->clickLocation.x, sicd->clickLocation.y, 0, GetParent(hwnd), NULL);
+ iSel = TrackPopupMenu(g_dat.hMenuANSIEncoding, TPM_RETURNCMD, sicd->clickLocation.x, sicd->clickLocation.y, 0, GetParent(hwnd), NULL);
if (iSel >= 500) {
if (iSel == 500) iSel = CP_ACP;
SendMessage(hwnd, DM_SETCODEPAGE, 0, iSel);
@@ -478,9 +473,9 @@ int StatusIconPressed(WPARAM wParam, LPARAM lParam) { static int ModuleLoad(WPARAM wParam, LPARAM lParam)
{
- g_dat->smileyAddInstalled = ServiceExists(MS_SMILEYADD_SHOWSELECTION) && ServiceExists(MS_SMILEYADD_REPLACESMILEYS) != 0;
- g_dat->popupInstalled = ServiceExists(MS_POPUP_ADDPOPUPEX) != 0;
- g_dat->ieviewInstalled = ServiceExists(MS_IEVIEW_WINDOW) != 0;
+ g_dat.smileyAddInstalled = ServiceExists(MS_SMILEYADD_SHOWSELECTION) && ServiceExists(MS_SMILEYADD_REPLACESMILEYS) != 0;
+ g_dat.popupInstalled = ServiceExists(MS_POPUP_ADDPOPUPEX) != 0;
+ g_dat.ieviewInstalled = ServiceExists(MS_IEVIEW_WINDOW) != 0;
return 0;
}
@@ -503,11 +498,11 @@ static int OnModulesLoaded(WPARAM wParam, LPARAM lParam) hMsgMenuItem = Menu_AddContactMenuItem(&mi);
Skin_ReleaseIcon(mi.hIcon);
- HookEvent_Ex(ME_SMILEYADD_OPTIONSCHANGED, SmileySettingsChanged);
- HookEvent_Ex(ME_IEVIEW_OPTIONSCHANGED, SmileySettingsChanged);
- HookEvent_Ex(ME_AV_AVATARCHANGED, AvatarChanged);
- HookEvent_Ex(ME_FONT_RELOAD, FontServiceFontsChanged);
- HookEvent_Ex(ME_MSG_ICONPRESSED, StatusIconPressed);
+ HookEvent(ME_SMILEYADD_OPTIONSCHANGED, SmileySettingsChanged);
+ HookEvent(ME_IEVIEW_OPTIONSCHANGED, SmileySettingsChanged);
+ HookEvent(ME_AV_AVATARCHANGED, AvatarChanged);
+ HookEvent(ME_FONT_RELOAD, FontServiceFontsChanged);
+ HookEvent(ME_MSG_ICONPRESSED, StatusIconPressed);
RestoreUnreadMessageAlerts();
Chat_ModulesLoaded(wParam, lParam);
@@ -518,7 +513,8 @@ static int OnModulesLoaded(WPARAM wParam, LPARAM lParam) int OnSystemPreshutdown(WPARAM wParam, LPARAM lParam)
{
Chat_PreShutdown(wParam, lParam);
- WindowList_BroadcastAsync(g_dat->hMessageWindowList, WM_CLOSE, 0, 0);
+ WindowList_Broadcast(g_dat.hMessageWindowList, WM_CLOSE, 0, 0);
+ WindowList_Broadcast(g_dat.hParentWindowList, WM_CLOSE, 0, 0);
DeinitStatusIcons();
return 0;
}
@@ -530,8 +526,6 @@ int OnUnloadModule(void) DestroyCursor(hCurHyperlinkHand);
DestroyCursor(hCurSplitWE);
DestroyCursor(hDragCursor);
- UnhookEvents_Ex();
- DestroyServices_Ex();
DestroyHookableEvent(hHookWinEvt);
DestroyHookableEvent(hHookWinPopup);
ReleaseIcons();
@@ -562,25 +556,25 @@ int OnLoadModule(void) { OleInitialize(NULL);
InitStatusIcons();
- HookEvent_Ex(ME_OPT_INITIALISE, OptInitialise);
- HookEvent_Ex(ME_DB_EVENT_ADDED, MessageEventAdded);
- HookEvent_Ex(ME_DB_CONTACT_SETTINGCHANGED, MessageSettingChanged);
- HookEvent_Ex(ME_DB_CONTACT_DELETED, ContactDeleted);
- HookEvent_Ex(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
- HookEvent_Ex(ME_SKIN_ICONSCHANGED, IconsChanged);
- HookEvent_Ex(ME_PROTO_CONTACTISTYPING, TypingMessage);
- HookEvent_Ex(ME_SYSTEM_PRESHUTDOWN, OnSystemPreshutdown);
- HookEvent_Ex(ME_CLIST_PREBUILDCONTACTMENU, PrebuildContactMenu);
- HookEvent_Ex(ME_SYSTEM_MODULELOAD, ModuleLoad);
- HookEvent_Ex(ME_SYSTEM_MODULEUNLOAD, ModuleLoad);
-
- CreateServiceFunction_Ex(MS_MSG_SENDMESSAGE, SendMessageCommand);
- CreateServiceFunction_Ex(MS_MSG_SENDMESSAGEW, SendMessageCommandW);
- CreateServiceFunction_Ex(MS_MSG_GETWINDOWAPI, GetWindowAPI);
- CreateServiceFunction_Ex(MS_MSG_GETWINDOWCLASS, GetWindowClass);
- CreateServiceFunction_Ex(MS_MSG_GETWINDOWDATA, GetWindowData);
- CreateServiceFunction_Ex("SRMsg/ReadMessage", ReadMessageCommand);
- CreateServiceFunction_Ex("SRMsg/TypingMessage", TypingMessageCommand);
+ HookEvent(ME_OPT_INITIALISE, OptInitialise);
+ HookEvent(ME_DB_EVENT_ADDED, MessageEventAdded);
+ HookEvent(ME_DB_CONTACT_SETTINGCHANGED, MessageSettingChanged);
+ HookEvent(ME_DB_CONTACT_DELETED, ContactDeleted);
+ HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
+ HookEvent(ME_SKIN_ICONSCHANGED, IconsChanged);
+ HookEvent(ME_PROTO_CONTACTISTYPING, TypingMessage);
+ HookEvent(ME_SYSTEM_PRESHUTDOWN, OnSystemPreshutdown);
+ HookEvent(ME_CLIST_PREBUILDCONTACTMENU, PrebuildContactMenu);
+ HookEvent(ME_SYSTEM_MODULELOAD, ModuleLoad);
+ HookEvent(ME_SYSTEM_MODULEUNLOAD, ModuleLoad);
+
+ CreateServiceFunction(MS_MSG_SENDMESSAGE, SendMessageCommand);
+ CreateServiceFunction(MS_MSG_SENDMESSAGEW, SendMessageCommandW);
+ CreateServiceFunction(MS_MSG_GETWINDOWAPI, GetWindowAPI);
+ CreateServiceFunction(MS_MSG_GETWINDOWCLASS, GetWindowClass);
+ CreateServiceFunction(MS_MSG_GETWINDOWDATA, GetWindowData);
+ CreateServiceFunction("SRMsg/ReadMessage", ReadMessageCommand);
+ CreateServiceFunction("SRMsg/TypingMessage", TypingMessageCommand);
hHookWinEvt = CreateHookableEvent(ME_MSG_WINDOWEVENT);
hHookWinPopup = CreateHookableEvent(ME_MSG_WINDOWPOPUP);
|