diff options
Diffstat (limited to 'plugins/Scriver/src/msgs.cpp')
-rw-r--r-- | plugins/Scriver/src/msgs.cpp | 474 |
1 files changed, 218 insertions, 256 deletions
diff --git a/plugins/Scriver/src/msgs.cpp b/plugins/Scriver/src/msgs.cpp index fe1a050430..0f3eb1f6f2 100644 --- a/plugins/Scriver/src/msgs.cpp +++ b/plugins/Scriver/src/msgs.cpp @@ -23,9 +23,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "commonheaders.h"
-HCURSOR hCurSplitNS, hCurSplitWE, hCurHyperlinkHand, hDragCursor;
-
-HANDLE hMsgMenuItem, hHookWinEvt=NULL, hHookWinPopup=NULL;;
+HCURSOR hCurSplitNS, hCurSplitWE, hCurHyperlinkHand, hDragCursor;
+HANDLE hHookWinEvt=NULL, hHookWinPopup=NULL;
+HGENMENU hMsgMenuItem;
extern HWND GetParentWindow(HANDLE hContact, BOOL bChat);
@@ -36,29 +36,29 @@ PSLWA pSetLayeredWindowAttributes; static int SRMMStatusToPf2(int status)
{
- switch (status) {
- case ID_STATUS_ONLINE:
- return PF2_ONLINE;
- case ID_STATUS_AWAY:
- return PF2_SHORTAWAY;
- case ID_STATUS_DND:
- return PF2_HEAVYDND;
- case ID_STATUS_NA:
- return PF2_LONGAWAY;
- case ID_STATUS_OCCUPIED:
- return PF2_LIGHTDND;
- case ID_STATUS_FREECHAT:
- return PF2_FREECHAT;
- case ID_STATUS_INVISIBLE:
- return PF2_INVISIBLE;
- case ID_STATUS_ONTHEPHONE:
- return PF2_ONTHEPHONE;
- case ID_STATUS_OUTTOLUNCH:
- return PF2_OUTTOLUNCH;
- case ID_STATUS_OFFLINE:
- return MODEF_OFFLINE;
- }
- return 0;
+ switch (status) {
+ case ID_STATUS_ONLINE:
+ return PF2_ONLINE;
+ case ID_STATUS_AWAY:
+ return PF2_SHORTAWAY;
+ case ID_STATUS_DND:
+ return PF2_HEAVYDND;
+ case ID_STATUS_NA:
+ return PF2_LONGAWAY;
+ case ID_STATUS_OCCUPIED:
+ return PF2_LIGHTDND;
+ case ID_STATUS_FREECHAT:
+ return PF2_FREECHAT;
+ case ID_STATUS_INVISIBLE:
+ return PF2_INVISIBLE;
+ case ID_STATUS_ONTHEPHONE:
+ return PF2_ONTHEPHONE;
+ case ID_STATUS_OUTTOLUNCH:
+ return PF2_OUTTOLUNCH;
+ case ID_STATUS_OFFLINE:
+ return MODEF_OFFLINE;
+ }
+ return 0;
}
int IsAutoPopup(HANDLE hContact) {
@@ -69,9 +69,8 @@ int IsAutoPopup(HANDLE hContact) { 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;
- }
}
return 0;
}
@@ -86,10 +85,9 @@ static INT_PTR ReadMessageCommand(WPARAM wParam, LPARAM lParam) if (hwndExisting == NULL) {
newData.hContact = ((CLISTEVENT *) lParam)->hContact;
hParent = GetParentWindow(newData.hContact, FALSE);
- CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSG), hParent, DlgProcMessage, (LPARAM) & newData);
- } else {
- SendMessage(GetParent(hwndExisting), CM_POPUPWINDOW, 0, (LPARAM) hwndExisting);
+ CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSG), hParent, DlgProcMessage, (LPARAM)& newData);
}
+ else SendMessage(GetParent(hwndExisting), CM_POPUPWINDOW, 0, (LPARAM)hwndExisting);
return 0;
}
@@ -100,53 +98,46 @@ static int MessageEventAdded(WPARAM wParam, LPARAM lParam) if (dbei.eventType == EVENTTYPE_MESSAGE && (dbei.flags & DBEF_READ))
return 0;
- HWND hwnd = WindowList_Find(g_dat.hMessageWindowList, (HANDLE) wParam);
+ HWND hwnd = WindowList_Find(g_dat.hMessageWindowList, (HANDLE)wParam);
if (hwnd)
SendMessage(hwnd, HM_DBEVENTADDED, wParam, lParam);
if (dbei.flags & DBEF_SENT || !DbEventIsMessageOrCustom(&dbei))
return 0;
- CallServiceSync(MS_CLIST_REMOVEEVENT, wParam, (LPARAM) 1);
+ CallServiceSync(MS_CLIST_REMOVEEVENT, wParam, (LPARAM)1);
/* does a window for the contact exist? */
if (hwnd == NULL) {
/* new message */
SkinPlaySound("AlertMsg");
- if (IsAutoPopup((HANDLE) wParam)) {
- HWND hParent;
+ if (IsAutoPopup((HANDLE)wParam)) {
NewMessageWindowLParam newData = { 0 };
- newData.hContact = (HANDLE) wParam;
- hParent = GetParentWindow(newData.hContact, FALSE);
+ newData.hContact = (HANDLE)wParam;
+ HWND hParent = GetParentWindow(newData.hContact, FALSE);
newData.flags = NMWLP_INCOMING;
- CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSG), hParent, DlgProcMessage, (LPARAM) & newData);
+ CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSG), hParent, DlgProcMessage, (LPARAM)&newData);
return 0;
}
}
- if (hwnd == NULL || !IsWindowVisible(GetParent(hwnd)))
- {
- CLISTEVENT cle = {0};
- TCHAR *contactName;
+ if (hwnd == NULL || !IsWindowVisible(GetParent(hwnd))) {
+ TCHAR *contactName = (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, wParam, GCDNF_TCHAR);
TCHAR toolTip[256];
- cle.cbSize = sizeof(cle);
+ CLISTEVENT cle = { sizeof(cle) };
cle.flags = CLEF_TCHAR;
- cle.hContact = (HANDLE) wParam;
- cle.hDbEvent = (HANDLE) lParam;
+ cle.hContact = (HANDLE)wParam;
+ cle.hDbEvent = (HANDLE)lParam;
cle.hIcon = LoadSkinnedIcon(SKINICON_EVENT_MESSAGE);
cle.pszService = "SRMsg/ReadMessage";
- contactName = (TCHAR *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, wParam, GCDNF_TCHAR);
mir_sntprintf(toolTip, SIZEOF(toolTip), TranslateT("Message from %s"), contactName);
cle.ptszTooltip = toolTip;
- CallService(MS_CLIST_ADDEVENT, 0, (LPARAM) & cle);
+ CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)& cle);
}
return 0;
}
static INT_PTR SendMessageCommandW(WPARAM wParam, LPARAM lParam)
{
- HWND hwnd;
- NewMessageWindowLParam newData = { 0 };
-
/* does the HCONTACT's protocol support IM messages? */
char *szProto = GetContactProto((HANDLE)wParam);
if (szProto == NULL)
@@ -155,205 +146,185 @@ 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 (lParam) {
- HWND hEdit;
- hEdit = GetDlgItem(hwnd, IDC_MESSAGE);
- SendMessage(hEdit, EM_SETSEL, -1, SendMessage(hEdit, WM_GETTEXTLENGTH, 0, 0));
-/*
- SETTEXTEX st;
- st.flags = ST_SELECTION;
- st.codepage = 1200;
- SendMessage(hEdit, EM_SETTEXTEX, (WPARAM) &st, (LPARAM)lParam);
-*/
- SendMessage(hEdit, EM_REPLACESEL, FALSE, (LPARAM) (TCHAR *) lParam);
- }
- SendMessage(GetParent(hwnd), CM_POPUPWINDOW, 0, (LPARAM) hwnd);
- } else {
- HWND hParent;
- newData.hContact = (HANDLE) wParam;
- newData.szInitialText = (const char *) lParam;
- newData.isWchar = 1;
- hParent = GetParentWindow(newData.hContact, FALSE);
- CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSG), hParent, DlgProcMessage, (LPARAM) & newData);
- }
- return 0;
+ HWND hwnd = WindowList_Find(g_dat.hMessageWindowList, (HANDLE)wParam);
+ if (hwnd != NULL) {
+ if (lParam) {
+ HWND hEdit = GetDlgItem(hwnd, IDC_MESSAGE);
+ SendMessage(hEdit, EM_SETSEL, -1, SendMessage(hEdit, WM_GETTEXTLENGTH, 0, 0));
+ SendMessage(hEdit, EM_REPLACESEL, FALSE, (LPARAM)(TCHAR *) lParam);
+ }
+ SendMessage(GetParent(hwnd), CM_POPUPWINDOW, 0, (LPARAM)hwnd);
+ }
+ else {
+ NewMessageWindowLParam newData = { 0 };
+ newData.hContact = (HANDLE)wParam;
+ newData.szInitialText = (const char *) lParam;
+ newData.isWchar = 1;
+ HWND hParent = GetParentWindow(newData.hContact, FALSE);
+ CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSG), hParent, DlgProcMessage, (LPARAM)& newData);
+ }
+ return 0;
}
static INT_PTR SendMessageCommand(WPARAM wParam, LPARAM lParam)
{
- HWND hwnd;
- NewMessageWindowLParam newData = { 0 };
-
- {
- char *szProto = GetContactProto((HANDLE)wParam);
- //logInfo("Show message window for: %s (%s)", CallService(MS_CLIST_GETCONTACTDISPLAYNAME, wParam, 0), szProto);
- if (szProto) {
- /* does the HCONTACT's protocol support IM messages? */
- if (!CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND)
- return 1;
- }
- else {
- /* unknown contact */
- return 1;
- } //if
- }
-
- if ((hwnd = WindowList_Find(g_dat.hMessageWindowList, (HANDLE) wParam))) {
- if (lParam) {
- HWND hEdit;
- hEdit = GetDlgItem(hwnd, IDC_MESSAGE);
- SendMessage(hEdit, EM_SETSEL, -1, SendMessage(hEdit, WM_GETTEXTLENGTH, 0, 0));
-/*
- SETTEXTEX st;
- st.flags = ST_SELECTION;
- st.codepage = CP_ACP;
- SendMessage(hEdit, EM_SETTEXTEX, (WPARAM) &st, (LPARAM)lParam);
-*/
- SendMessageA(hEdit, EM_REPLACESEL, FALSE, (LPARAM) (char *) lParam);
- }
- SendMessage(GetParent(hwnd), CM_POPUPWINDOW, 0, (LPARAM) hwnd);
- } else {
- HWND hParent;
- newData.hContact = (HANDLE) wParam;
- newData.szInitialText = (const char *) lParam;
- newData.isWchar = 0;
- hParent = GetParentWindow(newData.hContact, FALSE);
- CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSG), hParent, DlgProcMessage, (LPARAM) & newData);
- }
- return 0;
+ char *szProto = GetContactProto((HANDLE)wParam);
+ //logInfo("Show message window for: %s (%s)", CallService(MS_CLIST_GETCONTACTDISPLAYNAME, wParam, 0), szProto);
+ if (szProto) {
+ /* does the HCONTACT's protocol support IM messages? */
+ if (!CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND)
+ return 1;
+ }
+ else /* unknown contact */
+ return 1;
+
+ HWND hwnd = WindowList_Find(g_dat.hMessageWindowList, (HANDLE)wParam);
+ if (hwnd != NULL) {
+ if (lParam) {
+ HWND hEdit = GetDlgItem(hwnd, IDC_MESSAGE);
+ SendMessage(hEdit, EM_SETSEL, -1, SendMessage(hEdit, WM_GETTEXTLENGTH, 0, 0));
+ SendMessageA(hEdit, EM_REPLACESEL, FALSE, (LPARAM)(char *) lParam);
+ }
+ SendMessage(GetParent(hwnd), CM_POPUPWINDOW, 0, (LPARAM)hwnd);
+ }
+ else {
+ NewMessageWindowLParam newData = { 0 };
+ newData.hContact = (HANDLE)wParam;
+ newData.szInitialText = (const char *)lParam;
+ HWND hParent = GetParentWindow(newData.hContact, FALSE);
+ CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSG), hParent, DlgProcMessage, (LPARAM)& newData);
+ }
+ return 0;
}
static INT_PTR TypingMessageCommand(WPARAM wParam, LPARAM lParam)
{
- CLISTEVENT *cle = (CLISTEVENT *) lParam;
-
- if (!cle)
- return 0;
- SendMessageCommand((WPARAM) cle->hContact, 0);
- return 0;
+ CLISTEVENT *cle = (CLISTEVENT*)lParam;
+ if (cle)
+ SendMessageCommand((WPARAM)cle->hContact, 0);
+ return 0;
}
static int TypingMessage(WPARAM wParam, LPARAM lParam)
{
- HWND hwnd;
-
- if (!(g_dat.flags2&SMF2_SHOWTYPING))
- return 0;
- if ((hwnd = WindowList_Find(g_dat.hMessageWindowList, (HANDLE) wParam))) {
- SendMessage(hwnd, DM_TYPING, 0, lParam);
- } 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)) {
- MIRANDASYSTRAYNOTIFY tn;
- tn.szProto = NULL;
- tn.cbSize = sizeof(tn);
- tn.tszInfoTitle = TranslateT("Typing Notification");
- tn.tszInfo = szTip;
- tn.dwInfoFlags = NIIF_INFO | NIIF_INTERN_UNICODE;
- tn.uTimeout = 1000 * 4;
- CallService(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM) & tn);
- }
- else {
- CLISTEVENT cle = {0};
-
- cle.cbSize = sizeof(cle);
- cle.hContact = (HANDLE) wParam;
- cle.hDbEvent = (HANDLE) 1;
- cle.flags = CLEF_ONLYAFEW | CLEF_TCHAR;
- cle.hIcon = GetCachedIcon("scriver_TYPING");
- cle.pszService = "SRMsg/TypingMessage";
- cle.ptszTooltip = szTip;
- CallServiceSync(MS_CLIST_REMOVEEVENT, wParam, (LPARAM) 1);
- CallServiceSync(MS_CLIST_ADDEVENT, wParam, (LPARAM) & cle);
- }
- }
- return 0;
+ HWND hwnd;
+
+ if (!(g_dat.flags2&SMF2_SHOWTYPING))
+ return 0;
+ if ((hwnd = WindowList_Find(g_dat.hMessageWindowList, (HANDLE)wParam))) {
+ SendMessage(hwnd, DM_TYPING, 0, lParam);
+ } 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)) {
+ MIRANDASYSTRAYNOTIFY tn;
+ tn.szProto = NULL;
+ tn.cbSize = sizeof(tn);
+ tn.tszInfoTitle = TranslateT("Typing Notification");
+ tn.tszInfo = szTip;
+ tn.dwInfoFlags = NIIF_INFO | NIIF_INTERN_UNICODE;
+ tn.uTimeout = 1000 * 4;
+ CallService(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM)& tn);
+ }
+ else {
+ CLISTEVENT cle = {0};
+
+ cle.cbSize = sizeof(cle);
+ cle.hContact = (HANDLE)wParam;
+ cle.hDbEvent = (HANDLE)1;
+ cle.flags = CLEF_ONLYAFEW | CLEF_TCHAR;
+ cle.hIcon = GetCachedIcon("scriver_TYPING");
+ cle.pszService = "SRMsg/TypingMessage";
+ cle.ptszTooltip = szTip;
+ CallServiceSync(MS_CLIST_REMOVEEVENT, wParam, (LPARAM)1);
+ CallServiceSync(MS_CLIST_ADDEVENT, wParam, (LPARAM)& cle);
+ }
+ }
+ return 0;
}
static int MessageSettingChanged(WPARAM wParam, LPARAM lParam)
{
- DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *) 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);
- return 0;
+ DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *) 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);
+ return 0;
}
static int ContactDeleted(WPARAM wParam, LPARAM lParam)
{
- HWND hwnd;
+ HWND hwnd;
- if ((hwnd = WindowList_Find(g_dat.hMessageWindowList, (HANDLE) wParam))) {
- SendMessage(hwnd, WM_CLOSE, 0, 0);
- }
- return 0;
+ if ((hwnd = WindowList_Find(g_dat.hMessageWindowList, (HANDLE)wParam))) {
+ SendMessage(hwnd, WM_CLOSE, 0, 0);
+ }
+ return 0;
}
static void RestoreUnreadMessageAlerts(void)
{
- TCHAR toolTip[256];
+ TCHAR toolTip[256];
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;
-
- HANDLE hContact = db_find_first();
- while (hContact) {
- HANDLE hDbEvent = db_event_firstUnread(hContact);
- while (hDbEvent) {
- dbei.cbBlob = 0;
- db_event_get(hDbEvent, &dbei);
- if (!(dbei.flags & (DBEF_SENT | DBEF_READ)) && DbEventIsMessageOrCustom(&dbei)) {
- int windowAlreadyExists = WindowList_Find(g_dat.hMessageWindowList, hContact) != NULL;
- if (windowAlreadyExists)
- continue;
+ cle.hIcon = LoadSkinnedIcon(SKINICON_EVENT_MESSAGE);
+ cle.pszService = "SRMsg/ReadMessage";
+ cle.flags = CLEF_TCHAR;
+ cle.ptszTooltip = toolTip;
+
+ HANDLE hContact = db_find_first();
+ while (hContact) {
+ HANDLE hDbEvent = db_event_firstUnread(hContact);
+ while (hDbEvent) {
+ dbei.cbBlob = 0;
+ db_event_get(hDbEvent, &dbei);
+ if (!(dbei.flags & (DBEF_SENT | DBEF_READ)) && DbEventIsMessageOrCustom(&dbei)) {
+ int windowAlreadyExists = WindowList_Find(g_dat.hMessageWindowList, hContact) != NULL;
+ if (windowAlreadyExists)
+ continue;
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);
+ 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);
+ CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)& cle);
}
}
hDbEvent = db_event_next(hDbEvent);
- }
- hContact = db_find_next(hContact);
- }
+ }
+ hContact = db_find_next(hContact);
+ }
}
static INT_PTR GetWindowAPI(WPARAM wParam, LPARAM lParam)
{
- return PLUGIN_MAKE_VERSION(0,0,0,3);
+ return PLUGIN_MAKE_VERSION(0,0,0,3);
}
static INT_PTR GetWindowClass(WPARAM wParam, LPARAM lParam)
{
- char *szBuf = (char*)wParam;
- int size = (int)lParam;
- mir_snprintf(szBuf, size, "Scriver");
- return 0;
+ char *szBuf = (char*)wParam;
+ int size = (int)lParam;
+ mir_snprintf(szBuf, size, "Scriver");
+ return 0;
}
static INT_PTR GetWindowData(WPARAM wParam, LPARAM lParam)
{
- MessageWindowInputData *mwid = (MessageWindowInputData*)wParam;
- MessageWindowData *mwd = (MessageWindowData*)lParam;
- HWND hwnd;
+ MessageWindowInputData *mwid = (MessageWindowInputData*)wParam;
+ MessageWindowData *mwd = (MessageWindowData*)lParam;
+ HWND hwnd;
if (mwid == NULL || mwd == NULL) return 1;
if (mwid->cbSize != sizeof(MessageWindowInputData) || mwd->cbSize != sizeof(SrmmWindowData)) return 1;
@@ -369,101 +340,93 @@ static INT_PTR GetWindowData(WPARAM wParam, LPARAM lParam) return 0;
}
-static int PrebuildContactMenu(WPARAM wParam, LPARAM lParam) {
+static int PrebuildContactMenu(WPARAM wParam, LPARAM lParam)
+{
HANDLE hContact = (HANDLE)wParam;
- if ( hContact ) {
- char* szProto = GetContactProto(hContact);
-
- CLISTMENUITEM clmi = { sizeof(clmi) };
- clmi.flags = CMIM_FLAGS | CMIF_DEFAULT | CMIF_HIDDEN;
-
- if ( szProto ) {
- // leave this menu item hidden for chats
- if ( !db_get_b( hContact, szProto, "ChatRoom", 0 ))
- if ( CallProtoService( szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND )
- clmi.flags &= ~CMIF_HIDDEN;
- }
+ if (hContact == 0)
+ return 0;
- CallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM )hMsgMenuItem, ( LPARAM )&clmi );
+ bool bEnabled = false;
+ char *szProto = GetContactProto(hContact);
+ if ( szProto ) {
+ // leave this menu item hidden for chats
+ if ( !db_get_b(hContact, szProto, "ChatRoom", 0))
+ if ( CallProtoService( szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND)
+ bEnabled = true;
}
+
+ Menu_ShowItem(hMsgMenuItem, bEnabled);
return 0;
}
-static int AvatarChanged(WPARAM wParam, LPARAM lParam) {
- if (wParam == 0) { // protocol picture has changed...
- WindowList_Broadcast(g_dat.hMessageWindowList, DM_AVATARCHANGED, wParam, lParam);
- } else {
- HWND hwnd = WindowList_Find(g_dat.hMessageWindowList, (HANDLE)wParam);
- SendMessage(hwnd, DM_AVATARCHANGED, wParam, lParam);
- }
- return 0;
+static int AvatarChanged(WPARAM wParam, LPARAM lParam)
+{
+ if (wParam == 0) // protocol picture has changed...
+ WindowList_Broadcast(g_dat.hMessageWindowList, DM_AVATARCHANGED, wParam, lParam);
+ else {
+ HWND hwnd = WindowList_Find(g_dat.hMessageWindowList, (HANDLE)wParam);
+ SendMessage(hwnd, DM_AVATARCHANGED, wParam, lParam);
+ }
+ return 0;
}
-static void RegisterStatusIcons() {
- StatusIconData sid;
- sid.cbSize = sizeof(sid);
+static void RegisterStatusIcons()
+{
+ StatusIconData sid = { sizeof(sid) };
sid.szModule = SRMMMOD;
-
sid.dwId = 1;
sid.hIcon = CopyIcon(GetCachedIcon("scriver_TYPING"));
sid.hIconDisabled = CopyIcon(GetCachedIcon("scriver_TYPINGOFF"));
sid.flags = MBF_HIDDEN;
sid.szTooltip = NULL;
- AddStickyStatusIcon((WPARAM) 0, (LPARAM) &sid);
+ AddStickyStatusIcon((WPARAM) 0, (LPARAM)&sid);
}
-void ChangeStatusIcons() {
- StatusIconData sid;
- sid.cbSize = sizeof(sid);
+void ChangeStatusIcons()
+{
+ StatusIconData sid = { sizeof(sid) };
sid.szModule = SRMMMOD;
- sid.dwId = 0;
sid.hIcon = CopyIcon(GetCachedIcon("scriver_UNICODEON"));
sid.hIconDisabled = CopyIcon(GetCachedIcon("scriver_UNICODEOFF"));
- sid.flags = 0;
- sid.szTooltip = NULL;
- ModifyStatusIcon(0, (LPARAM) &sid);
+ ModifyStatusIcon(0, (LPARAM)&sid);
sid.dwId = 1;
sid.hIcon = CopyIcon(GetCachedIcon("scriver_TYPING"));
sid.hIconDisabled = CopyIcon(GetCachedIcon("scriver_TYPINGOFF"));
sid.flags = MBF_HIDDEN;
- sid.szTooltip = NULL;
- ModifyStatusIcon(0, (LPARAM) &sid);
+ ModifyStatusIcon(0, (LPARAM)&sid);
}
-int StatusIconPressed(WPARAM wParam, LPARAM lParam) {
-// HANDLE hContact = (HANDLE) wParam;
+int StatusIconPressed(WPARAM wParam, LPARAM lParam)
+{
StatusIconClickData *sicd = (StatusIconClickData *) lParam;
HWND hwnd = WindowList_Find(g_dat.hMessageWindowList, (HANDLE)wParam);
- if (hwnd == NULL) {
+ 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->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++) {
+ for (int i = 0; i < GetMenuItemCount(g_dat.hMenuANSIEncoding); i++)
CheckMenuItem (g_dat.hMenuANSIEncoding, i, MF_BYPOSITION | MF_UNCHECKED);
- }
- if (codePage == CP_ACP) {
+
+ if (codePage == CP_ACP)
CheckMenuItem(g_dat.hMenuANSIEncoding, 0, MF_BYPOSITION | MF_CHECKED);
- } else {
+ else
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);
+
+ int 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);
}
}
}
- } else {
- SendMessage(hwnd, DM_SWITCHTYPING, 0, 0);
}
+ else SendMessage(hwnd, DM_SWITCHTYPING, 0, 0);
}
}
return 0;
@@ -535,18 +498,18 @@ int OnUnloadModule(void) return 0;
}
-int OnLoadModule(void) {
- HMODULE hDLL = 0;
+int OnLoadModule(void)
+{
if (LoadLibraryA("riched20.dll") == NULL) {
- if (IDYES !=
- MessageBox(0,
- TranslateT
- ("Miranda could not load the built-in message module, riched20.dll is missing. If you are using Windows 95 or WINE please make sure you have riched20.dll installed. Press 'Yes' to continue loading Miranda."),
- TranslateT("Information"), MB_YESNO | MB_ICONINFORMATION))
+ if (IDYES != MessageBox(0,
+ TranslateT
+ ("Miranda could not load the built-in message module, riched20.dll is missing. If you are using Windows 95 or WINE please make sure you have riched20.dll installed. Press 'Yes' to continue loading Miranda."),
+ TranslateT("Information"), MB_YESNO | MB_ICONINFORMATION))
return 1;
return 0;
}
- hDLL = GetModuleHandle(_T("user32"));
+
+ HMODULE hDLL = GetModuleHandle(_T("user32"));
pSetLayeredWindowAttributes = (PSLWA) GetProcAddress(hDLL,"SetLayeredWindowAttributes");
InitGlobals();
@@ -587,7 +550,6 @@ int OnLoadModule(void) { hCurHyperlinkHand = LoadCursor(g_hInst, MAKEINTRESOURCE(IDC_HYPERLINKHAND));
hDragCursor = LoadCursor(g_hInst, MAKEINTRESOURCE(IDC_DRAGCURSOR));
-
Chat_Load();
return 0;
}
@@ -602,9 +564,9 @@ STDMETHODIMP CREOleCallback::QueryInterface(REFIID riid, LPVOID * ppvObj) *ppvObj = this;
AddRef();
return S_OK;
- }
- *ppvObj = NULL;
- return E_NOINTERFACE;
+ }
+ *ppvObj = NULL;
+ return E_NOINTERFACE;
}
STDMETHODIMP_(ULONG) CREOleCallback::AddRef()
@@ -680,4 +642,4 @@ STDMETHODIMP CREOleCallback::QueryInsertObject(LPCLSID lpclsid, LPSTORAGE lpstg, STDMETHODIMP CREOleCallback::ShowContainerUI(BOOL fShow)
{
return S_OK;
-}
\ No newline at end of file +}
|