From 046a82ec1d9982a0beb8d19b6f31c279eeb02b50 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 5 Mar 2014 14:50:06 +0000 Subject: - "Add to metacontact" dialog fixed; - "Remove from metacontact" menu item sometimes got hidden; - code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@8412 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/metacontacts/meta_addto.cpp | 64 +++---- src/modules/metacontacts/meta_api.cpp | 82 ++++----- src/modules/metacontacts/meta_edit.cpp | 266 +++++++++++++++-------------- src/modules/metacontacts/meta_menu.cpp | 36 +--- src/modules/metacontacts/meta_options.cpp | 30 ++-- src/modules/metacontacts/meta_services.cpp | 8 +- src/modules/metacontacts/meta_utils.cpp | 18 +- src/modules/metacontacts/metacontacts.h | 3 - 8 files changed, 243 insertions(+), 264 deletions(-) (limited to 'src/modules') diff --git a/src/modules/metacontacts/meta_addto.cpp b/src/modules/metacontacts/meta_addto.cpp index f2f03eb581..4c79f3f268 100644 --- a/src/modules/metacontacts/meta_addto.cpp +++ b/src/modules/metacontacts/meta_addto.cpp @@ -24,19 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "metacontacts.h" -//! Holds information about a contact. -struct METAUSERINFO -{ - char *name; //!< Name of the contact - char *proto; //!< Protocol under which the contact has been registered - HANDLE hUser; //!< Identifier of the contact in the DB. -}; - -//! Holds information for the callback function. -typedef struct { - METAUSERINFO uInfo; //!< Information about the contact to add -}ADDTO_INFO; - /** Adds all the metacontacts desired in the listview. * * Adds all the metacontacts present in the database in the list, @@ -51,9 +38,9 @@ typedef struct { * @return An integer specifying the number of rows added in the list. */ -int FillList(HWND list, BOOL sort) +static int FillList(HWND list, BOOL sort) { - int i=0; + int i = 0; // The DB is searched through, to get all the metacontacts for (MCONTACT hMetaUser = db_find_first(); hMetaUser; hMetaUser = db_find_next(hMetaUser)) { @@ -95,7 +82,7 @@ int FillList(HWND list, BOOL sort) * @returns An integer specifying the number of rows inserted or -1 if there was a problem */ -int BuildList(HWND list, BOOL sort) +static int BuildList(HWND list, BOOL sort) { SendMessage(list, LB_RESETCONTENT, 0, 0); return FillList(list, sort); @@ -117,13 +104,13 @@ int BuildList(HWND list, BOOL sort) or there is none that can host this contact.\n\ Another solution could be to convert this contact into a new MetaContact.\n\nConvert this contact into a new MetaContact?") -INT_PTR CALLBACK Meta_SelectDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +static INT_PTR CALLBACK Meta_SelectDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - switch(msg) { + switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); { - DBCachedContact *cc = CheckMeta(lParam); + DBCachedContact *cc = currDb->m_cache->GetCachedContact(lParam); if (cc == NULL) { DestroyWindow(hwndDlg); return TRUE; @@ -155,7 +142,7 @@ INT_PTR CALLBACK Meta_SelectDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP // Besides, we can check if there is at least one metacontact to add the contact to. if (BuildList(GetDlgItem(hwndDlg, IDC_METALIST), FALSE) <= 0) { if (MessageBox(hwndDlg, TranslateT(szConvMsg), TranslateT("No suitable MetaContact found"), MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON1) == IDYES) - Meta_Convert((WPARAM)lParam, 0); + Meta_Convert(lParam, 0); DestroyWindow(hwndDlg); return TRUE; } @@ -174,30 +161,31 @@ INT_PTR CALLBACK Meta_SelectDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP return TRUE; case WM_COMMAND: - if (HIWORD(wParam)!=BN_CLICKED) + if (HIWORD(wParam) != BN_CLICKED) break; // Only clicks of buttons are relevant, let other COMMANDs through - switch(LOWORD(wParam)) { - case IDOK: + switch (LOWORD(wParam)) { + case IDOK: { - int item = SendMessage(GetDlgItem(hwndDlg, IDC_METALIST),LB_GETCURSEL, 0, 0); // Get the index of the selected metacontact + int item = SendMessage(GetDlgItem(hwndDlg, IDC_METALIST), LB_GETCURSEL, 0, 0); // Get the index of the selected metacontact if (item == -1) return IDOK == MessageBox(hwndDlg, TranslateT("Please select a MetaContact"), TranslateT("No MetaContact selected"), MB_ICONHAND); MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - MCONTACT hMeta = (MCONTACT)SendMessage(GetDlgItem(hwndDlg, IDC_METALIST), LB_GETITEMDATA, (WPARAM)item, 0); + MCONTACT hMeta = (MCONTACT)SendMessage(GetDlgItem(hwndDlg, IDC_METALIST), LB_GETITEMDATA, item, 0); if (!Meta_Assign(hContact, hMeta, FALSE)) - MessageBox(hwndDlg, TranslateT("Assignment to the MetaContact failed."), TranslateT("Assignment failure"),MB_ICONERROR); + MessageBox(hwndDlg, TranslateT("Assignment to the MetaContact failed."), TranslateT("Assignment failure"), MB_ICONERROR); } + // fall through case IDCANCEL: DestroyWindow(hwndDlg); break; case IDC_CHK_SRT: SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_METALIST), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_METALIST), GWL_STYLE) ^ LBS_SORT); - if (BuildList(GetDlgItem(hwndDlg,IDC_METALIST), IsDlgButtonChecked(hwndDlg, IDC_CHK_SRT) ? TRUE : FALSE) <= 0) { - if (MessageBox(hwndDlg, TranslateT(szConvMsg), TranslateT("No suitable MetaContact found"),MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON1) == IDYES) - Meta_Convert((WPARAM)lParam, 0); + if (BuildList(GetDlgItem(hwndDlg, IDC_METALIST), IsDlgButtonChecked(hwndDlg, IDC_CHK_SRT) ? TRUE : FALSE) <= 0) { + if (MessageBox(hwndDlg, TranslateT(szConvMsg), TranslateT("No suitable MetaContact found"), MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON1) == IDYES) + Meta_Convert(lParam, 0); DestroyWindow(hwndDlg); return TRUE; } @@ -209,9 +197,25 @@ INT_PTR CALLBACK Meta_SelectDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP // Free all allocated memory and return the focus to the CList HWND clist = GetParent(hwndDlg); Skin_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_BIG, 0)); - EndDialog(hwndDlg,TRUE); + EndDialog(hwndDlg, TRUE); SetFocus(clist); return TRUE; } return FALSE; // All other Message are not handled } + +/** Display the 'Add to' Dialog +* +* Present a dialog in which the user can choose to which MetaContact this +* contact will be added +* +* @param wParam : HANDLE to the contact that has been chosen. +* @param lParam : Allways set to 0. +*/ + +INT_PTR Meta_AddTo(WPARAM hContact, LPARAM) +{ + HWND clui = (HWND)CallService(MS_CLUI_GETHWND, 0, 0); + DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_METASELECT), clui, &Meta_SelectDialogProc, hContact); + return 0; +} diff --git a/src/modules/metacontacts/meta_api.cpp b/src/modules/metacontacts/meta_api.cpp index 2cebf568be..d9417b9cca 100644 --- a/src/modules/metacontacts/meta_api.cpp +++ b/src/modules/metacontacts/meta_api.cpp @@ -24,10 +24,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "metacontacts.h" -//gets the handle for the default contact -//wParam=(MCONTACT)hMetaContact -//lParam=0 -//returns a handle to the default contact, or null on failure +// gets the handle for the default contact +// wParam=(MCONTACT)hMetaContact +// lParam=0 +// returns a handle to the default contact, or null on failure static INT_PTR MetaAPI_GetDefault(WPARAM hMetaContact, LPARAM) { @@ -41,10 +41,10 @@ static INT_PTR MetaAPI_GetDefault(WPARAM hMetaContact, LPARAM) return 0; } -//gets the contact number for the default contact -//wParam=(MCONTACT)hMetaContact -//lParam=0 -//returns a DWORD contact number, or -1 on failure +// gets the contact number for the default contact +// wParam=(MCONTACT)hMetaContact +// lParam=0 +// returns a DWORD contact number, or -1 on failure static INT_PTR MetaAPI_GetDefaultNum(WPARAM hMetaContact, LPARAM) { @@ -52,10 +52,10 @@ static INT_PTR MetaAPI_GetDefaultNum(WPARAM hMetaContact, LPARAM) return (cc == NULL) ? -1 : cc->nDefault; } -//gets the handle for the 'most online' contact -//wParam=(MCONTACT)hMetaContact -//lParam=0 -//returns a handle to the 'most online' contact +// gets the handle for the 'most online' contact +// wParam=(MCONTACT)hMetaContact +// lParam=0 +// returns a handle to the 'most online' contact static INT_PTR MetaAPI_GetMostOnline(WPARAM hMetaContact, LPARAM) { @@ -66,10 +66,10 @@ static INT_PTR MetaAPI_GetMostOnline(WPARAM hMetaContact, LPARAM) return Meta_GetMostOnline(cc); } -//gets the number of subcontacts for a metacontact -//wParam=(MCONTACT)hMetaContact -//lParam=0 -//returns a DWORD representing the number of subcontacts for the given metacontact +// gets the number of subcontacts for a metacontact +// wParam=(MCONTACT)hMetaContact +// lParam=0 +// returns a DWORD representing the number of subcontacts for the given metacontact static INT_PTR MetaAPI_GetNumContacts(WPARAM hMetaContact, LPARAM) { @@ -77,10 +77,10 @@ static INT_PTR MetaAPI_GetNumContacts(WPARAM hMetaContact, LPARAM) return (cc == NULL) ? -1 : cc->nSubs; } -//gets the handle of a subcontact, using the subcontact's number -//wParam=(MCONTACT)hMetaContact -//lParam=(DWORD)contact number -//returns a handle to the specified subcontact +// gets the handle of a subcontact, using the subcontact's number +// wParam=(MCONTACT)hMetaContact +// lParam=(DWORD)contact number +// returns a handle to the specified subcontact static INT_PTR MetaAPI_GetContact(WPARAM hMetaContact, LPARAM lParam) { @@ -88,10 +88,10 @@ static INT_PTR MetaAPI_GetContact(WPARAM hMetaContact, LPARAM lParam) return (cc == NULL) ? 0 : Meta_GetContactHandle(cc, lParam); } -//sets the default contact, using the subcontact's contact number -//wParam=(MCONTACT)hMetaContact -//lParam=(DWORD)contact number -//returns 0 on success +// sets the default contact, using the subcontact's contact number +// wParam=(MCONTACT)hMetaContact +// lParam=(DWORD)contact number +// returns 0 on success static INT_PTR MetaAPI_SetDefaultContactNum(WPARAM hMetaContact, LPARAM lParam) { @@ -108,10 +108,10 @@ static INT_PTR MetaAPI_SetDefaultContactNum(WPARAM hMetaContact, LPARAM lParam) return 0; } -//sets the default contact, using the subcontact's handle -//wParam=(MCONTACT)hMetaContact -//lParam=(MCONTACT)hSubcontact -//returns 0 on success +// sets the default contact, using the subcontact's handle +// wParam=(MCONTACT)hMetaContact +// lParam=(MCONTACT)hSubcontact +// returns 0 on success static INT_PTR MetaAPI_SetDefaultContact(WPARAM hMetaContact, LPARAM lParam) { @@ -130,10 +130,10 @@ static INT_PTR MetaAPI_SetDefaultContact(WPARAM hMetaContact, LPARAM lParam) return 0; } -//forces the metacontact to send using a specific subcontact, using the subcontact's contact number -//wParam=(MCONTACT)hMetaContact -//lParam=(DWORD)contact number -//returns 0 on success +// forces the metacontact to send using a specific subcontact, using the subcontact's contact number +// wParam=(MCONTACT)hMetaContact +// lParam=(DWORD)contact number +// returns 0 on success static INT_PTR MetaAPI_ForceSendContactNum(WPARAM hMetaContact, LPARAM lParam) { @@ -151,10 +151,10 @@ static INT_PTR MetaAPI_ForceSendContactNum(WPARAM hMetaContact, LPARAM lParam) return 0; } -//forces the metacontact to send using a specific subcontact, using the subcontact's handle -//wParam=(MCONTACT)hMetaContact -//lParam=(MCONTACT)hSubcontact -//returns 0 on success (will fail if 'force default' is in effect) +// forces the metacontact to send using a specific subcontact, using the subcontact's handle +// wParam=(MCONTACT)hMetaContact +// lParam=(MCONTACT)hSubcontact +// returns 0 on success (will fail if 'force default' is in effect) static INT_PTR MetaAPI_ForceSendContact(WPARAM hMetaContact, LPARAM lParam) { @@ -174,10 +174,10 @@ static INT_PTR MetaAPI_ForceSendContact(WPARAM hMetaContact, LPARAM lParam) return 0; } -//'unforces' the metacontact to send using a specific subcontact -//wParam=(MCONTACT)hMetaContact -//lParam=0 -//returns 0 on success (will fail if 'force default' is in effect) +// 'unforces' the metacontact to send using a specific subcontact +// wParam=(MCONTACT)hMetaContact +// lParam=0 +// returns 0 on success (will fail if 'force default' is in effect) INT_PTR MetaAPI_UnforceSendContact(WPARAM hMetaContact, LPARAM lParam) { @@ -259,7 +259,7 @@ static INT_PTR MetaAPI_AddToMeta(WPARAM wParam, LPARAM lParam) static INT_PTR MetaAPI_RemoveFromMeta(WPARAM wParam, LPARAM lParam) { // notice we switch args - to keep the API function consistent with the others - return Meta_Delete((WPARAM)lParam, (LPARAM)wParam); + return Meta_Delete(lParam, wParam); } void CreateApiServices() diff --git a/src/modules/metacontacts/meta_edit.cpp b/src/modules/metacontacts/meta_edit.cpp index 87929eedf4..ffd740fa4d 100644 --- a/src/modules/metacontacts/meta_edit.cpp +++ b/src/modules/metacontacts/meta_edit.cpp @@ -24,8 +24,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "metacontacts.h" -//! Holds the differents changes that have to made -struct CHANGES +// Holds the differents changes that have to made +struct { MCONTACT hMeta; // HANDLE of the MetaContact that is edited. DBCachedContact *cc; @@ -36,16 +36,12 @@ struct CHANGES MCONTACT hDeletedContacts[MAX_CONTACTS]; // HANDLEs of the subcontacts to be removed from this metacontact MCONTACT hContact[MAX_CONTACTS]; // HANDLEs of the subcontacts, in the order they should be in int force_default; -}; - -CHANGES changes; // global CHANGES structure +} +static g_data; // global CHANGES structure -/** Fills the list of contacts -* -* @param chg : Structure holding all the change info (See CHANGES). -*/ +///////////////////////////////////////////////////////////////////////////////////////// -void FillContactList(HWND hWndDlg, CHANGES *chg) +static void FillContactList(HWND hWndDlg) { HWND hList = GetDlgItem(hWndDlg, IDC_LST_CONTACTS); TCHAR buff[256]; @@ -56,10 +52,10 @@ void FillContactList(HWND hWndDlg, CHANGES *chg) LvItem.mask = LVIF_TEXT; // Text Style LvItem.cchTextMax = 256; // Max size of test - for (int i = 0; i < chg->num_contacts; i++) { + for (int i = 0; i < g_data.num_contacts; i++) { LvItem.iItem = i; - - TCHAR *ptszCDN = cli.pfnGetContactDisplayName(chg->hContact[i], 0); + + TCHAR *ptszCDN = cli.pfnGetContactDisplayName(g_data.hContact[i], 0); if (ptszCDN == NULL) ptszCDN = TranslateT("(Unknown Contact)"); @@ -68,13 +64,13 @@ void FillContactList(HWND hWndDlg, CHANGES *chg) ListView_InsertItem(hList, &LvItem); LvItem.iSubItem = 1; // id - char *szProto = GetContactProto(chg->hContact[i]); + char *szProto = GetContactProto(g_data.hContact[i]); if (szProto) { char *szField = (char *)CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); DBVARIANT dbv; - if ( !db_get(chg->hContact[i], szProto, szField, &dbv)) { - switch(dbv.type) { + if (!db_get(g_data.hContact[i], szProto, szField, &dbv)) { + switch (dbv.type) { case DBVT_ASCIIZ: _tcsncpy(buff, _A2T(dbv.pszVal), SIZEOF(buff)); break; @@ -98,7 +94,7 @@ void FillContactList(HWND hWndDlg, CHANGES *chg) else buff[0] = 0; LvItem.pszText = buff; - SendMessage(hList,LVM_SETITEM,0,(LPARAM)&LvItem); // Enter text to SubItems + SendMessage(hList, LVM_SETITEM, 0, (LPARAM)&LvItem); // Enter text to SubItems LvItem.iSubItem = 2; // protocol _tcsncpy(buff, _A2T(szProto), SIZEOF(buff)); @@ -112,18 +108,18 @@ void FillContactList(HWND hWndDlg, CHANGES *chg) ListView_SetItem(hList, &LvItem); } LvItem.iSubItem = 3; // Default (Yes/No) - LvItem.pszText = (chg->hContact[i] == chg->hDefaultContact ? TranslateT("Yes") : TranslateT("No")); + LvItem.pszText = (g_data.hContact[i] == g_data.hDefaultContact ? TranslateT("Yes") : TranslateT("No")); ListView_SetItem(hList, &LvItem); LvItem.iSubItem = 4; // Offline (Yes/No) - LvItem.pszText = (chg->hContact[i] == chg->hOfflineContact ? TranslateT("Yes") : TranslateT("No")); + LvItem.pszText = (g_data.hContact[i] == g_data.hOfflineContact ? TranslateT("Yes") : TranslateT("No")); ListView_SetItem(hList, &LvItem); } } -void SetListSelection(HWND hList, int sel) +static void SetListSelection(HWND hList, int sel) { - ListView_SetItemState(hList, sel, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED); + ListView_SetItemState(hList, sel, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); } /** Scans the \c CHANGES and call the appropriate function for each change. @@ -131,78 +127,76 @@ void SetListSelection(HWND hList, int sel) * @param chg : Structure holding all the change info (See CHANGES). */ -void ApplyChanges(CHANGES *chg) +static void ApplyChanges() { - int i; - // remove removed contacts - for (i = 0; i < chg->num_deleted; i++) { - Meta_Delete((WPARAM)chg->hDeletedContacts[i], 0); - if (chg->hDeletedContacts[i] == chg->hDefaultContact) - chg->hDefaultContact = 0; - if (chg->hDeletedContacts[i] == chg->hOfflineContact) - chg->hOfflineContact = 0; + for (int i = 0; i < g_data.num_deleted; i++) { + Meta_Delete(g_data.hDeletedContacts[i], 0); + if (g_data.hDeletedContacts[i] == g_data.hDefaultContact) + g_data.hDefaultContact = 0; + if (g_data.hDeletedContacts[i] == g_data.hOfflineContact) + g_data.hOfflineContact = 0; } // set contact positions - for (i = 0; i < chg->num_contacts; i++) - if (Meta_GetContactNumber(chg->cc, chg->hContact[i]) != i) - Meta_SwapContacts(chg->cc, Meta_GetContactNumber(chg->cc, chg->hContact[i]), i); + for (int i = 0; i < g_data.num_contacts; i++) + if (Meta_GetContactNumber(g_data.cc, g_data.hContact[i]) != i) + Meta_SwapContacts(g_data.cc, Meta_GetContactNumber(g_data.cc, g_data.hContact[i]), i); - NotifyEventHooks(hSubcontactsChanged, chg->hMeta, chg->hDefaultContact); + NotifyEventHooks(hSubcontactsChanged, g_data.hMeta, g_data.hDefaultContact); // set default - chg->cc->nDefault = (chg->hDefaultContact) ? Meta_GetContactNumber(chg->cc, chg->hDefaultContact) : 0; - currDb->MetaSetDefault(chg->cc); - NotifyEventHooks(hEventDefaultChanged, chg->hMeta, chg->hDefaultContact); + g_data.cc->nDefault = (g_data.hDefaultContact) ? Meta_GetContactNumber(g_data.cc, g_data.hDefaultContact) : 0; + currDb->MetaSetDefault(g_data.cc); + NotifyEventHooks(hEventDefaultChanged, g_data.hMeta, g_data.hDefaultContact); // set offline - if (chg->hOfflineContact) - db_set_dw(chg->hMeta, META_PROTO, "OfflineSend", Meta_GetContactNumber(chg->cc, chg->hOfflineContact)); + if (g_data.hOfflineContact) + db_set_dw(g_data.hMeta, META_PROTO, "OfflineSend", Meta_GetContactNumber(g_data.cc, g_data.hOfflineContact)); else - db_set_dw(chg->hMeta, META_PROTO, "OfflineSend", INVALID_CONTACT_ID); + db_set_dw(g_data.hMeta, META_PROTO, "OfflineSend", INVALID_CONTACT_ID); // fix nick - MCONTACT most_online = Meta_GetMostOnline(chg->cc); - Meta_CopyContactNick(chg->cc, most_online); + MCONTACT most_online = Meta_GetMostOnline(g_data.cc); + Meta_CopyContactNick(g_data.cc, most_online); // fix status - Meta_FixStatus(chg->cc); + Meta_FixStatus(g_data.cc); // fix avatar - most_online = Meta_GetMostOnlineSupporting(chg->cc, PFLAGNUM_4, PF4_AVATARS); + most_online = Meta_GetMostOnlineSupporting(g_data.cc, PFLAGNUM_4, PF4_AVATARS); if (most_online) { PROTO_AVATAR_INFORMATIONT AI; AI.cbSize = sizeof(AI); - AI.hContact = chg->hMeta; + AI.hContact = g_data.hMeta; AI.format = PA_FORMAT_UNKNOWN; _tcscpy(AI.filename, _T("X")); if ((int)CallProtoService(META_PROTO, PS_GETAVATARINFOT, 0, (LPARAM)&AI) == GAIR_SUCCESS) - db_set_ts(chg->hMeta, "ContactPhoto", "File",AI.filename); + db_set_ts(g_data.hMeta, "ContactPhoto", "File", AI.filename); } - if (MetaAPI_GetForceState((WPARAM)chg->hMeta, 0) != chg->force_default) - MetaAPI_ForceDefault((WPARAM)chg->hMeta, 0); + if (MetaAPI_GetForceState(g_data.hMeta, 0) != g_data.force_default) + MetaAPI_ForceDefault(g_data.hMeta, 0); } -LRESULT ProcessCustomDraw (LPARAM lParam) +LRESULT ProcessCustomDraw(LPARAM lParam) { - LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)lParam; - switch(lplvcd->nmcd.dwDrawStage) { - case CDDS_PREPAINT : //Before the paint cycle begins - //request notifications for individual listview items - return CDRF_NOTIFYITEMDRAW; - - case CDDS_ITEMPREPAINT: //Before an item is drawn - if (changes.hContact[(int)lplvcd->nmcd.dwItemSpec] == changes.hDefaultContact) { - lplvcd->clrText = RGB(255, 0, 0); - } - return CDRF_NEWFONT; - } - - return 0; + LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)lParam; + switch (lplvcd->nmcd.dwDrawStage) { + case CDDS_PREPAINT: //Before the paint cycle begins + //request notifications for individual listview items + return CDRF_NOTIFYITEMDRAW; + + case CDDS_ITEMPREPAINT: //Before an item is drawn + if (g_data.hContact[(int)lplvcd->nmcd.dwItemSpec] == g_data.hDefaultContact) + lplvcd->clrText = RGB(255, 0, 0); + + return CDRF_NEWFONT; + } + + return 0; } /** Callback function for the 'Edit' Dialog. @@ -219,16 +213,16 @@ LRESULT ProcessCustomDraw (LPARAM lParam) #define WMU_SETTITLE (WM_USER + 1) -INT_PTR CALLBACK Meta_EditDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +static INT_PTR CALLBACK Meta_EditDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { HWND hwnd; int sel, i; - switch(msg) { + switch (msg) { case WM_INITDIALOG: - TranslateDialogDefault( hwndDlg ); + TranslateDialogDefault(hwndDlg); SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadIconEx(I_EDIT)); - { + { DBCachedContact *cc = currDb->m_cache->GetCachedContact(lParam); if (cc == NULL) { DestroyWindow(hwndDlg); @@ -236,7 +230,7 @@ INT_PTR CALLBACK Meta_EditDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR } // Disable the 'Apply' button. - EnableWindow(GetDlgItem(hwndDlg,IDC_VALIDATE),FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_VALIDATE), FALSE); hwnd = GetDlgItem(hwndDlg, IDC_LST_CONTACTS); ListView_SetExtendedListViewStyle(hwnd, LVS_EX_FULLROWSELECT); @@ -274,21 +268,22 @@ INT_PTR CALLBACK Meta_EditDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR int offline_contact_number = db_get_dw(lParam, META_PROTO, "OfflineSend", INVALID_CONTACT_ID); - changes.cc = cc; - changes.hMeta = lParam; - changes.num_contacts = cc->nSubs; - changes.num_deleted = 0; - changes.hDefaultContact = Meta_GetContactHandle(changes.cc, cc->nDefault); - changes.hOfflineContact = Meta_GetContactHandle(changes.cc, offline_contact_number); + ZeroMemory(&g_data, sizeof(g_data)); + g_data.cc = cc; + g_data.hMeta = lParam; + g_data.num_contacts = cc->nSubs; + g_data.num_deleted = 0; + g_data.hDefaultContact = Meta_GetContactHandle(g_data.cc, cc->nDefault); + g_data.hOfflineContact = Meta_GetContactHandle(g_data.cc, offline_contact_number); for (i = 0; i < cc->nSubs; i++) - changes.hContact[i] = Meta_GetContactHandle(changes.cc, i); - changes.force_default = MetaAPI_GetForceState((WPARAM)lParam, 0); + g_data.hContact[i] = Meta_GetContactHandle(g_data.cc, i); + g_data.force_default = MetaAPI_GetForceState(lParam, 0); SendMessage(hwndDlg, WMU_SETTITLE, 0, lParam); - CheckDlgButton(hwndDlg, IDC_CHK_FORCEDEFAULT, changes.force_default); + CheckDlgButton(hwndDlg, IDC_CHK_FORCEDEFAULT, g_data.force_default); - FillContactList(hwndDlg, &changes); + FillContactList(hwndDlg); } return TRUE; @@ -303,49 +298,49 @@ INT_PTR CALLBACK Meta_EditDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR return TRUE; case WM_NOTIFY: // the message that is being sent always - switch(LOWORD(wParam)) { // hit control + switch (LOWORD(wParam)) { // hit control case IDC_LST_CONTACTS: // did we hit our ListView contorl? if (((LPNMHDR)lParam)->code == NM_CLICK) { - sel = ListView_GetNextItem(GetDlgItem(hwndDlg, IDC_LST_CONTACTS), -1, LVNI_FOCUSED|LVNI_SELECTED); // return item selected + sel = ListView_GetNextItem(GetDlgItem(hwndDlg, IDC_LST_CONTACTS), -1, LVNI_FOCUSED | LVNI_SELECTED); // return item selected // enable buttons EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_REM), sel != -1); - EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_SETDEFAULT), sel != -1 && changes.hContact[sel] != changes.hDefaultContact); - EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_SETOFFLINE), sel != -1 && changes.hContact[sel] != changes.hOfflineContact); + EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_SETDEFAULT), sel != -1 && g_data.hContact[sel] != g_data.hDefaultContact); + EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_SETOFFLINE), sel != -1 && g_data.hContact[sel] != g_data.hOfflineContact); EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_UP), sel > 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DOWN), (sel != -1 && sel < changes.num_contacts - 1)); - } + EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DOWN), (sel != -1 && sel < g_data.num_contacts - 1)); + } } break; case WM_COMMAND: - switch(HIWORD(wParam)) { + switch (HIWORD(wParam)) { case BN_CLICKED: // A button ('Remove', 'OK', 'Cancel' or 'Apply', normally) has been clicked - switch(LOWORD(wParam)) { + switch (LOWORD(wParam)) { case IDC_VALIDATE: // Apply changes, if there is still one contact attached to the metacontact. - if (changes.num_contacts == 0) { // Otherwise, delete the metacontact. + if (g_data.num_contacts == 0) { // Otherwise, delete the metacontact. if (IDYES == MessageBox(hwndDlg, TranslateT(szDelMsg), TranslateT("Delete MetaContact?"), MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON1)) { - Meta_Delete((WPARAM)changes.hMeta, 0); + Meta_Delete(g_data.hMeta, 0); DestroyWindow(hwndDlg); } return TRUE; } - ApplyChanges(&changes); + ApplyChanges(); // Disable the 'Apply' button. EnableWindow(GetDlgItem(hwndDlg, IDC_VALIDATE), FALSE); break; case IDOK: - if ( IsWindowEnabled(GetDlgItem(hwndDlg, IDC_VALIDATE))) { // If there are changes that could be made, - if (changes.num_contacts == 0) { // do the work that would have be done if the 'Apply' button was clicked. + if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_VALIDATE))) { // If there are changes that could be made, + if (g_data.num_contacts == 0) { // do the work that would have be done if the 'Apply' button was clicked. if (IDYES == MessageBox(hwndDlg, TranslateT(szDelMsg), TranslateT("Delete MetaContact?"), MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON1)) { - Meta_Delete((WPARAM)changes.hMeta,0); + Meta_Delete(g_data.hMeta, 0); DestroyWindow(hwndDlg); } return TRUE; } - ApplyChanges(&changes); + ApplyChanges(); } EndDialog(hwndDlg, IDOK); return TRUE; @@ -358,46 +353,46 @@ INT_PTR CALLBACK Meta_EditDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR hwnd = GetDlgItem(hwndDlg, IDC_LST_CONTACTS); sel = ListView_GetNextItem(hwnd, -1, LVNI_FOCUSED | LVNI_SELECTED); InvalidateRect(hwnd, 0, TRUE); - changes.hDefaultContact = changes.hContact[sel]; - SendMessage(hwndDlg, WMU_SETTITLE, 0, (LPARAM)changes.hContact[sel]); + g_data.hDefaultContact = g_data.hContact[sel]; + SendMessage(hwndDlg, WMU_SETTITLE, 0, (LPARAM)g_data.hContact[sel]); - FillContactList(hwndDlg, &changes); + FillContactList(hwndDlg); SetListSelection(hwnd, sel); - EnableWindow(GetDlgItem(hwndDlg,IDC_BTN_SETDEFAULT),FALSE); - EnableWindow(GetDlgItem(hwndDlg,IDC_VALIDATE),TRUE); + EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_SETDEFAULT), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_VALIDATE), TRUE); return TRUE; case IDC_BTN_SETOFFLINE: hwnd = GetDlgItem(hwndDlg, IDC_LST_CONTACTS); sel = ListView_GetNextItem(hwnd, -1, LVNI_FOCUSED | LVNI_SELECTED); InvalidateRect(hwnd, 0, TRUE); - changes.hOfflineContact = changes.hContact[sel]; + g_data.hOfflineContact = g_data.hContact[sel]; - FillContactList(hwndDlg, &changes); + FillContactList(hwndDlg); SetListSelection(hwnd, sel); - EnableWindow(GetDlgItem(hwndDlg,IDC_BTN_SETOFFLINE),FALSE); - EnableWindow(GetDlgItem(hwndDlg,IDC_VALIDATE),TRUE); + EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_SETOFFLINE), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_VALIDATE), TRUE); return TRUE; case IDC_BTN_REM: hwnd = GetDlgItem(hwndDlg, IDC_LST_CONTACTS); sel = ListView_GetNextItem(hwnd, -1, LVNI_FOCUSED | LVNI_SELECTED); - changes.num_contacts--; - changes.hDeletedContacts[changes.num_deleted++] = changes.hContact[sel]; - if (changes.hDefaultContact == changes.hContact[sel]) { - if (changes.num_contacts > 0) { - changes.hDefaultContact = changes.hContact[0]; - SetWindowText(GetDlgItem(hwndDlg,IDC_ED_DEFAULT), cli.pfnGetContactDisplayName(changes.hDefaultContact, 0)); + g_data.num_contacts--; + g_data.hDeletedContacts[g_data.num_deleted++] = g_data.hContact[sel]; + if (g_data.hDefaultContact == g_data.hContact[sel]) { + if (g_data.num_contacts > 0) { + g_data.hDefaultContact = g_data.hContact[0]; + SetWindowText(GetDlgItem(hwndDlg, IDC_ED_DEFAULT), cli.pfnGetContactDisplayName(g_data.hDefaultContact, 0)); } else { - changes.hDefaultContact = 0; - SetWindowText(GetDlgItem(hwndDlg,IDC_ED_DEFAULT), _T("None")); + g_data.hDefaultContact = 0; + SetWindowText(GetDlgItem(hwndDlg, IDC_ED_DEFAULT), _T("None")); } } - for (i = sel; i < changes.num_contacts; i++) - changes.hContact[i] = changes.hContact[i + 1]; - FillContactList(hwndDlg, &changes); + for (i = sel; i < g_data.num_contacts; i++) + g_data.hContact[i] = g_data.hContact[i + 1]; + FillContactList(hwndDlg); // disable buttons EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_REM), FALSE); @@ -407,46 +402,46 @@ INT_PTR CALLBACK Meta_EditDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DOWN), FALSE); // Enable the 'Apply' button. - EnableWindow(GetDlgItem(hwndDlg,IDC_VALIDATE),TRUE); + EnableWindow(GetDlgItem(hwndDlg, IDC_VALIDATE), TRUE); return TRUE; case IDC_BTN_UP: hwnd = GetDlgItem(hwndDlg, IDC_LST_CONTACTS); sel = ListView_GetNextItem(hwnd, -1, LVNI_FOCUSED | LVNI_SELECTED); { - MCONTACT temp = changes.hContact[sel]; - changes.hContact[sel] = changes.hContact[sel - 1]; - changes.hContact[sel-1] = temp; + MCONTACT temp = g_data.hContact[sel]; + g_data.hContact[sel] = g_data.hContact[sel - 1]; + g_data.hContact[sel - 1] = temp; } - FillContactList(hwndDlg, &changes); + FillContactList(hwndDlg); sel--; SetListSelection(hwnd, sel); EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_UP), (sel > 0)); - EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DOWN), (sel < changes.num_contacts - 1)); - EnableWindow(GetDlgItem(hwndDlg,IDC_VALIDATE),TRUE); + EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DOWN), (sel < g_data.num_contacts - 1)); + EnableWindow(GetDlgItem(hwndDlg, IDC_VALIDATE), TRUE); return TRUE; case IDC_BTN_DOWN: hwnd = GetDlgItem(hwndDlg, IDC_LST_CONTACTS); sel = ListView_GetNextItem(hwnd, -1, LVNI_FOCUSED | LVNI_SELECTED); { - MCONTACT temp = changes.hContact[sel]; - changes.hContact[sel] = changes.hContact[sel + 1]; - changes.hContact[sel + 1] = temp; + MCONTACT temp = g_data.hContact[sel]; + g_data.hContact[sel] = g_data.hContact[sel + 1]; + g_data.hContact[sel + 1] = temp; } - FillContactList(hwndDlg, &changes); + FillContactList(hwndDlg); sel++; SetListSelection(hwnd, sel); EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_UP), (sel > 0)); - EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DOWN), (sel < changes.num_contacts - 1)); - EnableWindow(GetDlgItem(hwndDlg,IDC_VALIDATE),TRUE); + EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DOWN), (sel < g_data.num_contacts - 1)); + EnableWindow(GetDlgItem(hwndDlg, IDC_VALIDATE), TRUE); return TRUE; case IDC_CHK_FORCEDEFAULT: - changes.force_default = IsDlgButtonChecked(hwndDlg, IDC_CHK_FORCEDEFAULT); - EnableWindow(GetDlgItem(hwndDlg,IDC_VALIDATE),TRUE); + g_data.force_default = IsDlgButtonChecked(hwndDlg, IDC_CHK_FORCEDEFAULT); + EnableWindow(GetDlgItem(hwndDlg, IDC_VALIDATE), TRUE); return TRUE; } } @@ -464,3 +459,18 @@ INT_PTR CALLBACK Meta_EditDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR return FALSE; } + +/** Display the 'Edit' Dialog +* +* Present a dialog in which the user can edit some properties of the MetaContact. +* +* @param wParam : HANDLE to the MetaContact to be edited. +* @param lParam : Allways set to 0. +*/ + +INT_PTR Meta_Edit(WPARAM wParam, LPARAM lParam) +{ + HWND clui = (HWND)CallService(MS_CLUI_GETHWND, 0, 0); + DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_METAEDIT), clui, Meta_EditDialogProc, (LPARAM)wParam); + return 0; +} diff --git a/src/modules/metacontacts/meta_menu.cpp b/src/modules/metacontacts/meta_menu.cpp index c2be5c92bd..6431591903 100644 --- a/src/modules/metacontacts/meta_menu.cpp +++ b/src/modules/metacontacts/meta_menu.cpp @@ -68,7 +68,7 @@ INT_PTR Meta_Convert(WPARAM wParam, LPARAM lParam) cc->nSubs = 0; // Add the MetaContact protocol to the new meta contact - CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hMetaContact, (LPARAM)META_PROTO); + CallService(MS_PROTO_ADDTOCONTACT, hMetaContact, (LPARAM)META_PROTO); if (group) db_set_utf(hMetaContact, "CList", "Group", group); @@ -76,7 +76,7 @@ INT_PTR Meta_Convert(WPARAM wParam, LPARAM lParam) // Assign the contact to the MetaContact just created (and make default). if (!Meta_Assign(wParam, hMetaContact, TRUE)) { MessageBox(0, TranslateT("There was a problem in assigning the contact to the MetaContact"), TranslateT("Error"), MB_ICONEXCLAMATION); - CallService(MS_DB_CONTACT_DELETE, (WPARAM)hMetaContact, 0); + CallService(MS_DB_CONTACT_DELETE, hMetaContact, 0); return 0; } @@ -89,37 +89,6 @@ INT_PTR Meta_Convert(WPARAM wParam, LPARAM lParam) return (INT_PTR)hMetaContact; } -/** Display the 'Add to' Dialog -* -* Present a dialog in which the user can choose to which MetaContact this -* contact will be added -* -* @param wParam : HANDLE to the contact that has been chosen. -* @param lParam : Allways set to 0. -*/ - -INT_PTR Meta_AddTo(WPARAM wParam, LPARAM lParam) -{ - HWND clui = (HWND)CallService(MS_CLUI_GETHWND, 0, 0); - DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_METASELECT), clui, &Meta_SelectDialogProc, (LPARAM)wParam); - return 0; -} - -/** Display the 'Edit' Dialog -* -* Present a dialog in which the user can edit some properties of the MetaContact. -* -* @param wParam : HANDLE to the MetaContact to be edited. -* @param lParam : Allways set to 0. -*/ - -INT_PTR Meta_Edit(WPARAM wParam, LPARAM lParam) -{ - HWND clui = (HWND)CallService(MS_CLUI_GETHWND, 0, 0); - DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_METAEDIT), clui, Meta_EditDialogProc, (LPARAM)wParam); - return 0; -} - void Meta_RemoveContactNumber(DBCachedContact *ccMeta, int number) { if (ccMeta == NULL) @@ -406,6 +375,7 @@ int Meta_ModifyMenu(WPARAM hMeta, LPARAM lParam) mi.flags = CMIM_NAME; mi.pszName = LPGEN("Remove from metacontact"); Menu_ModifyItem(hMenuDelete, &mi); + Menu_ShowItem(hMenuDelete, true); Menu_ShowItem(hMenuAdd, false); Menu_ShowItem(hMenuConvert, false); diff --git a/src/modules/metacontacts/meta_options.cpp b/src/modules/metacontacts/meta_options.cpp index 8e87d8a22b..2a30c3d784 100644 --- a/src/modules/metacontacts/meta_options.cpp +++ b/src/modules/metacontacts/meta_options.cpp @@ -447,12 +447,12 @@ INT_PTR CALLBACK DlgProcOptsPriorities(HWND hwndDlg, UINT msg, WPARAM wParam, LP ProtoEnumAccounts(&num_protocols, &pppDesc); hw = GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL); - int index = SendMessage(hw, CB_INSERTSTRING, (WPARAM)-1, (LPARAM)TranslateT("")); - SendMessage(hw, CB_SETITEMDATA, (WPARAM)index, -1); + int index = SendMessage(hw, CB_INSERTSTRING, -1, (LPARAM)TranslateT("")); + SendMessage(hw, CB_SETITEMDATA, index, -1); for (int i = 0; i < num_protocols; i++) { if (strcmp(pppDesc[i]->szModuleName, META_PROTO) != 0) { - index = SendMessage(hw, CB_INSERTSTRING, (WPARAM)-1, (LPARAM)pppDesc[i]->tszAccountName); - SendMessage(hw, CB_SETITEMDATA, (WPARAM)index, i); + index = SendMessage(hw, CB_INSERTSTRING, -1, (LPARAM)pppDesc[i]->tszAccountName); + SendMessage(hw, CB_SETITEMDATA, index, i); } } @@ -465,10 +465,10 @@ INT_PTR CALLBACK DlgProcOptsPriorities(HWND hwndDlg, UINT msg, WPARAM wParam, LP case WMU_FILLPRIODATA: sel = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_GETCURSEL, 0, 0); if (sel != -1) { - int index = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_GETITEMDATA, (WPARAM)sel, 0); + int index = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_GETITEMDATA, sel, 0); sel = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_STATUS), CB_GETCURSEL, 0, 0); if (sel != -1) { - int status = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_STATUS), CB_GETITEMDATA, (WPARAM)sel, 0); + int status = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_STATUS), CB_GETITEMDATA, sel, 0); SetDlgItemInt(hwndDlg, IDC_ED_PRIORITY, GetPriority(index, status), FALSE); if (index == -1) { EnableWindow(GetDlgItem(hwndDlg, IDC_ED_PRIORITY), TRUE); @@ -497,13 +497,13 @@ INT_PTR CALLBACK DlgProcOptsPriorities(HWND hwndDlg, UINT msg, WPARAM wParam, LP case WMU_FILLSTATUSCMB: sel = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_GETCURSEL, 0, 0); if (sel != -1) { - int index = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_GETITEMDATA, (WPARAM)sel, 0); + int index = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_GETITEMDATA, sel, 0); HWND hw = GetDlgItem(hwndDlg, IDC_CMB_STATUS); SendMessage(hw, CB_RESETCONTENT, 0, 0); if (index == -1) { for (int i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) { - index = SendMessage(hw, CB_INSERTSTRING, (WPARAM)-1, (LPARAM)cli.pfnGetStatusModeDescription(i, 0)); - SendMessage(hw, CB_SETITEMDATA, (WPARAM)index, i); + index = SendMessage(hw, CB_INSERTSTRING, -1, (LPARAM)cli.pfnGetStatusModeDescription(i, 0)); + SendMessage(hw, CB_SETITEMDATA, index, i); } } else { @@ -515,8 +515,8 @@ INT_PTR CALLBACK DlgProcOptsPriorities(HWND hwndDlg, UINT msg, WPARAM wParam, LP for (int i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) { if (caps & Proto_Status2Flag(i)) { - index = SendMessage(hw, CB_INSERTSTRING, (WPARAM)-1, (LPARAM)cli.pfnGetStatusModeDescription(i, 0)); - SendMessage(hw, CB_SETITEMDATA, (WPARAM)index, i); + index = SendMessage(hw, CB_INSERTSTRING, -1, (LPARAM)cli.pfnGetStatusModeDescription(i, 0)); + SendMessage(hw, CB_SETITEMDATA, index, i); } } } @@ -531,11 +531,11 @@ INT_PTR CALLBACK DlgProcOptsPriorities(HWND hwndDlg, UINT msg, WPARAM wParam, LP case IDC_CHK_DEFAULT: sel = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_GETCURSEL, 0, 0); if (sel != -1) { - int index = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_GETITEMDATA, (WPARAM)sel, 0); + int index = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_GETITEMDATA, sel, 0); sel = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_STATUS), CB_GETCURSEL, 0, 0); if (sel != -1) { BOOL checked = IsDlgButtonChecked(hwndDlg, IDC_CHK_DEFAULT); - int status = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_STATUS), CB_GETITEMDATA, (WPARAM)sel, 0); + int status = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_STATUS), CB_GETITEMDATA, sel, 0); if (checked) { SetPriority(index, status, TRUE, 0); SetDlgItemInt(hwndDlg, IDC_ED_PRIORITY, GetPriority(index, status), FALSE); @@ -562,10 +562,10 @@ INT_PTR CALLBACK DlgProcOptsPriorities(HWND hwndDlg, UINT msg, WPARAM wParam, LP if ( HIWORD( wParam ) == EN_CHANGE && LOWORD(wParam) == IDC_ED_PRIORITY && ( HWND )lParam == GetFocus()) { sel = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_GETCURSEL, 0, 0); if (sel != -1) { - int index = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_GETITEMDATA, (WPARAM)sel, 0); + int index = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_GETITEMDATA, sel, 0); sel = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_STATUS), CB_GETCURSEL, 0, 0); if (sel != -1) { - int status = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_STATUS), CB_GETITEMDATA, (WPARAM)sel, 0); + int status = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_STATUS), CB_GETITEMDATA, sel, 0); int prio = GetDlgItemInt(hwndDlg, IDC_ED_PRIORITY, 0, FALSE); SetPriority(index, status, FALSE, prio); if (prio != GetPriority(index, status)) diff --git a/src/modules/metacontacts/meta_services.cpp b/src/modules/metacontacts/meta_services.cpp index fa69782d90..34b1d85376 100644 --- a/src/modules/metacontacts/meta_services.cpp +++ b/src/modules/metacontacts/meta_services.cpp @@ -176,7 +176,7 @@ static DWORD CALLBACK sttFakeAckFail( LPVOID param ) WaitForSingleObject( tParam->hEvent, INFINITE ); Sleep( 100 ); - ProtoBroadcastAck(META_PROTO, tParam->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)tParam->id, (WPARAM)tParam->msg ); + ProtoBroadcastAck(META_PROTO, tParam->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)tParam->id, (WPARAM)tParam->msg); CloseHandle( tParam->hEvent ); mir_free(tParam); @@ -734,7 +734,7 @@ INT_PTR Meta_UserIsTyping(WPARAM hMeta, LPARAM lParam) char *proto = GetContactProto(most_online); if (proto) if (ProtoServiceExists(proto, PSS_USERISTYPING)) - ProtoCallService(proto, PSS_USERISTYPING, (WPARAM)most_online, (LPARAM)lParam); + ProtoCallService(proto, PSS_USERISTYPING, most_online, lParam); return 0; } @@ -912,7 +912,7 @@ INT_PTR Meta_ContactMenuFunc(WPARAM hMeta, LPARAM lParam) strcpy(buffer, proto); strcat(buffer, PS_GETCAPS); - int caps = CallService(buffer, (WPARAM)PFLAGNUM_1, 0); + int caps = CallService(buffer, PFLAGNUM_1, 0); if ((caps & PF1_IMSEND) || (caps & PF1_CHAT) || (proto && strcmp(proto, "IRC") == 0)) { // set default contact for sending/status and open message window cc->nDefault = (int)lParam; @@ -1062,7 +1062,7 @@ int Meta_CallMostOnline(WPARAM hContact, LPARAM lParam) int Meta_PreShutdown(WPARAM wParam, LPARAM lParam) { - Meta_SetStatus((WPARAM)ID_STATUS_OFFLINE, 0); + Meta_SetStatus(ID_STATUS_OFFLINE, 0); Meta_SuppressStatus(FALSE); if (setStatusTimerId) KillTimer(0, setStatusTimerId); diff --git a/src/modules/metacontacts/meta_utils.cpp b/src/modules/metacontacts/meta_utils.cpp index 91c35609de..37c9691dfd 100644 --- a/src/modules/metacontacts/meta_utils.cpp +++ b/src/modules/metacontacts/meta_utils.cpp @@ -187,7 +187,7 @@ BOOL Meta_Assign(MCONTACT hSub, MCONTACT hMeta, BOOL set_as_default) if (set_as_default) { ccDest->nDefault = ccDest->nSubs - 1; currDb->MetaSetDefault(ccDest); - NotifyEventHooks(hEventDefaultChanged, (WPARAM)hMeta, (LPARAM)hSub); + NotifyEventHooks(hEventDefaultChanged, hMeta, hSub); } // set nick to most online contact that can message @@ -215,12 +215,12 @@ BOOL Meta_Assign(MCONTACT hSub, MCONTACT hMeta, BOOL set_as_default) // Ignore status if the option is on if (options.suppress_status) - CallService(MS_IGNORE_IGNORE, (WPARAM)hSub, (WPARAM)IGNOREEVENT_USERONLINE); + CallService(MS_IGNORE_IGNORE, hSub, IGNOREEVENT_USERONLINE); // copy other data Meta_CopyData(ccDest); - NotifyEventHooks(hSubcontactsChanged, (WPARAM)hMeta, 0); + NotifyEventHooks(hSubcontactsChanged, hMeta, 0); return TRUE; } @@ -257,7 +257,7 @@ MCONTACT Meta_GetMostOnlineSupporting(DBCachedContact *cc, int pflagnum, unsigne MCONTACT most_online_contact = Meta_GetContactHandle(cc, cc->nDefault); char *szProto = GetContactProto(most_online_contact); - DWORD caps = szProto ? CallProtoService(szProto, PS_GETCAPS, (WPARAM)pflagnum, 0) : 0; + DWORD caps = szProto ? CallProtoService(szProto, PS_GETCAPS, pflagnum, 0) : 0; if (szProto && strcmp(szProto, "IRC") == 0) caps |= PF1_IM; // we are forced to do use default for sending - '-1' capability indicates no specific capability, but respect 'Force Default' if (szProto && db_get_b(cc->contactID, META_PROTO, "ForceDefault", 0) && capability != 0 && (capability == -1 || (caps & capability) == capability)) // capability is 0 when we're working out status @@ -265,7 +265,7 @@ MCONTACT Meta_GetMostOnlineSupporting(DBCachedContact *cc, int pflagnum, unsigne // a subcontact is being temporarily 'forced' to do sending if ((most_online_contact = db_get_dw(cc->contactID, META_PROTO, "ForceSend", 0))) { - caps = szProto ? CallProtoService(szProto, PS_GETCAPS, (WPARAM)pflagnum, 0) : 0; + caps = szProto ? CallProtoService(szProto, PS_GETCAPS, pflagnum, 0) : 0; if (szProto && strcmp(szProto, "IRC") == 0) caps |= PF1_IM; if (szProto && (caps & capability) == capability && capability != 0) // capability is 0 when we're working out status return most_online_contact; @@ -274,7 +274,7 @@ MCONTACT Meta_GetMostOnlineSupporting(DBCachedContact *cc, int pflagnum, unsigne most_online_contact = Meta_GetContactHandle(cc, cc->nDefault); szProto = GetContactProto(most_online_contact); if (szProto && CallProtoService(szProto, PS_GETSTATUS, 0, 0) >= ID_STATUS_ONLINE) { - caps = szProto ? CallProtoService(szProto, PS_GETCAPS, (WPARAM)pflagnum, 0) : 0; + caps = szProto ? CallProtoService(szProto, PS_GETCAPS, pflagnum, 0) : 0; if (szProto && strcmp(szProto, "IRC") == 0) caps |= PF1_IM; if (szProto && (capability == -1 || (caps & capability) == capability)) { most_online_status = db_get_w(most_online_contact, szProto, "Status", ID_STATUS_OFFLINE); @@ -300,7 +300,7 @@ MCONTACT Meta_GetMostOnlineSupporting(DBCachedContact *cc, int pflagnum, unsigne if (!szProto || CallProtoService(szProto, PS_GETSTATUS, 0, 0) < ID_STATUS_ONLINE) // szProto offline or connecting continue; - caps = szProto ? CallProtoService(szProto, PS_GETCAPS, (WPARAM)pflagnum, 0) : 0; + caps = szProto ? CallProtoService(szProto, PS_GETCAPS, pflagnum, 0) : 0; if (szProto && strcmp(szProto, "IRC") == 0) caps |= PF1_IM; if (szProto && (capability == -1 || (caps & capability) == capability)) { int status = db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE); @@ -618,7 +618,7 @@ int Meta_HideLinkedContacts(void) } if (options.suppress_status) - CallService(MS_IGNORE_IGNORE, hContact, (WPARAM)IGNOREEVENT_USERONLINE); + CallService(MS_IGNORE_IGNORE, hContact, IGNOREEVENT_USERONLINE); } // do metacontacts after handles set properly above @@ -683,8 +683,6 @@ int Meta_CopyContactNick(DBCachedContact *ccMeta, MCONTACT hContact) if (!db_get_s(hContact, szProto, "Nick", &dbv, 0)) { db_set(ccMeta->contactID, META_PROTO, "Nick", &dbv); db_free(&dbv); - //CallService(MS_CLIST_INVALIDATEDISPLAYNAME, (WPARAM)hMeta, 0); - //CallService(MS_CLUI_CONTACTRENAMED, (WPARAM)hMeta, 0); db_free(&dbv_proto); return 0; } diff --git a/src/modules/metacontacts/metacontacts.h b/src/modules/metacontacts/metacontacts.h index 3843e8925e..6f7f113cf5 100644 --- a/src/modules/metacontacts/metacontacts.h +++ b/src/modules/metacontacts/metacontacts.h @@ -79,9 +79,6 @@ INT_PTR Meta_SendMessage(WPARAM wParam,LPARAM lParam); INT_PTR Meta_RecvMessage(WPARAM wParam,LPARAM lParam); INT_PTR Meta_ContactMenuFunc(WPARAM wParam, LPARAM lParam); -INT_PTR CALLBACK Meta_SelectDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); -INT_PTR CALLBACK Meta_EditDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); - void Meta_InitServices(); void Meta_CloseHandles(); -- cgit v1.2.3