From e58823d961a630eb62e60d2ccb443761ba5f1704 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 14 Jun 2012 15:51:34 +0000 Subject: - all MS_CLIST_ADD*ITEM services replaced with Menu_Add*Item stubs. - massive cleanup of the menu-related code git-svn-id: http://svn.miranda-ng.org/main/trunk@410 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/MetaContacts/addto.c | 42 ++-- plugins/MetaContacts/edit.c | 54 ++--- plugins/MetaContacts/meta_api.c | 20 +- plugins/MetaContacts/meta_main.c | 8 +- plugins/MetaContacts/meta_menu.c | 54 ++--- plugins/MetaContacts/meta_options.c | 90 ++++---- plugins/MetaContacts/meta_services.c | 384 ++++++++++++++++++----------------- plugins/MetaContacts/meta_utils.c | 298 +++++++++++++-------------- plugins/MetaContacts/metacontacts.h | 10 +- 9 files changed, 477 insertions(+), 483 deletions(-) (limited to 'plugins/MetaContacts') diff --git a/plugins/MetaContacts/addto.c b/plugins/MetaContacts/addto.c index 6b9721d504..b92e97b978 100644 --- a/plugins/MetaContacts/addto.c +++ b/plugins/MetaContacts/addto.c @@ -73,16 +73,16 @@ int FillList(HWND list, BOOL sort) // get contact display name from clist char *szCDN = (char *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hMetaUser, 0); - if(os_unicode_enabled) { + if (os_unicode_enabled) { wchar_t *swzCDN = (wchar_t *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hMetaUser, GCDNF_UNICODE), *swzContactDisplayName; // detect if the clist provided unicode display name by comparing with non-unicode - if(szCDN && swzCDN && strncmp(szCDN, (char *)swzCDN, strlen(szCDN)) != 0) { + if (szCDN && swzCDN && strncmp(szCDN, (char *)swzCDN, strlen(szCDN)) != 0) { swzContactDisplayName = swzCDN; } else { // no? convert to unicode - if(szCDN) { + if (szCDN) { swzContactDisplayName = (wchar_t *) _alloca(sizeof(wchar_t) * (strlen(szCDN) + 1)); MultiByteToWideChar(CP_ACP, 0, (char *) szCDN, -1, swzContactDisplayName, (int)strlen((char *)szCDN) + 1); } else { @@ -91,15 +91,15 @@ int FillList(HWND list, BOOL sort) } // don't insert huge strings that we have to compare with later - if(wcslen(swzContactDisplayName) > 1023) + if (wcslen(swzContactDisplayName) > 1023) swzContactDisplayName[1024] = 0; - if(sort) { + if (sort) { int j; wchar_t buff[1024]; - for(j = 0; j < i; j++) { + for (j = 0; j < i; j++) { SendMessageW(list, LB_GETTEXT, j, (LPARAM)buff); - if(wcscmp(buff, swzContactDisplayName) > 0) break; + if (wcscmp(buff, swzContactDisplayName) > 0) break; } index = SendMessageW(list, LB_INSERTSTRING, (WPARAM)j, (LPARAM)swzContactDisplayName); } else { @@ -107,15 +107,15 @@ int FillList(HWND list, BOOL sort) } } else { // don't insert huge strings that we have to compare with later - if(strlen(szCDN) > 1023) + if (strlen(szCDN) > 1023) szCDN[1024] = 0; - if(sort) { + if (sort) { int j; char buff[1024]; - for(j = 0; j < i; j++) { + for (j = 0; j < i; j++) { SendMessage(list, LB_GETTEXT, j, (LPARAM)buff); - if(strcmp(buff, szCDN) > 0) break; + if (strcmp(buff, szCDN) > 0) break; } index = SendMessage(list, LB_INSERTSTRING, (WPARAM)j, (LPARAM)szCDN); } else { @@ -172,14 +172,14 @@ INT_PTR CALLBACK Meta_SelectDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP TranslateDialogDefault( hwndDlg ); - if(DBGetContactSettingDword((HANDLE)lParam,META_PROTO,META_ID,(DWORD)-1)!=(DWORD)-1) + if (DBGetContactSettingDword((HANDLE)lParam,META_PROTO,META_ID,(DWORD)-1)!=(DWORD)-1) { MessageBox(hwndDlg,Translate("This contact is a MetaContact.\nYou can't add a MetaContact to another MetaContact.\n\nPlease choose another."), Translate("MetaContact Conflict"),MB_ICONERROR); DestroyWindow(hwndDlg); return TRUE; } - if(DBGetContactSettingDword((HANDLE)lParam,META_PROTO,META_LINK,(DWORD)-1)!=(DWORD)-1) + if (DBGetContactSettingDword((HANDLE)lParam,META_PROTO,META_LINK,(DWORD)-1)!=(DWORD)-1) { MessageBox(hwndDlg,Translate("This contact is already associated to a MetaContact.\nYou cannot add a contact to multiple MetaContacts."), Translate("Multiple MetaContacts"),MB_ICONERROR); @@ -195,9 +195,9 @@ INT_PTR CALLBACK Meta_SelectDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP // Initialize the graphical part CheckDlgButton(hwndDlg,IDC_ONLYAVAIL,BST_CHECKED); // Initially checked; display all metacontacts is only an option // 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 (BuildList(GetDlgItem(hwndDlg,IDC_METALIST), FALSE)<=0) { - if(MessageBox(hwndDlg,Translate("Either there is no MetaContact in the database (in this case you should first convert a contact into one)\n" + if (MessageBox(hwndDlg,Translate("Either there is no MetaContact in the database (in this case you should first convert a contact into one)\n" "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?"), Translate("No suitable MetaContact found"),MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON1)==IDYES) @@ -211,17 +211,17 @@ INT_PTR CALLBACK Meta_SelectDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP // get contact display name from clist char *szCDN = (char *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)lParam, 0); - if(os_unicode_enabled) { + if (os_unicode_enabled) { wchar_t *swzCDN = (wchar_t *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)lParam, GCDNF_UNICODE), *swzContactDisplayName; wchar_t buf[256]; // detect if the clist provided unicode display name by comparing with non-unicode - if(szCDN && swzCDN && strncmp(szCDN, (char *)swzCDN, strlen(szCDN)) != 0) { + if (szCDN && swzCDN && strncmp(szCDN, (char *)swzCDN, strlen(szCDN)) != 0) { swzContactDisplayName = swzCDN; } else { // no? convert to unicode - if(szCDN) { + if (szCDN) { swzContactDisplayName = (wchar_t *) _alloca(sizeof(wchar_t) * (strlen(szCDN) + 1)); MultiByteToWideChar(CP_ACP, 0, (char *) szCDN, -1, swzContactDisplayName, (int)strlen((char *)szCDN) + 1); } else { @@ -249,7 +249,7 @@ INT_PTR CALLBACK Meta_SelectDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP } } 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)) { @@ -275,9 +275,9 @@ INT_PTR CALLBACK Meta_SelectDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP 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 (BuildList(GetDlgItem(hwndDlg,IDC_METALIST), IsDlgButtonChecked(hwndDlg, IDC_CHK_SRT) ? TRUE : FALSE)<=0) { - if(MessageBox(hwndDlg,Translate("Either there is no MetaContact in the database (in this case you should first convert a contact into one)\n" + if (MessageBox(hwndDlg,Translate("Either there is no MetaContact in the database (in this case you should first convert a contact into one)\n" "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?"), Translate("No suitable MetaContact found"),MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON1)==IDYES) diff --git a/plugins/MetaContacts/edit.c b/plugins/MetaContacts/edit.c index d5c422d71c..bc4d94ba8a 100644 --- a/plugins/MetaContacts/edit.c +++ b/plugins/MetaContacts/edit.c @@ -63,7 +63,7 @@ void FillContactList(HWND hWndDlg, CHANGES *chg) { LvItemW.mask=LVIF_TEXT; // Text Style LvItemW.cchTextMax = 256; // Max size of test - for(i = 0; i < chg->num_contacts; i++) { + for (i = 0; i < chg->num_contacts; i++) { LvItem.iItem = i; LvItemW.iItem = i; @@ -71,18 +71,18 @@ void FillContactList(HWND hWndDlg, CHANGES *chg) { char *szCDN = (char *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)chg->hContact[i], 0); - if(os_unicode_enabled) { + if (os_unicode_enabled) { wchar_t *swzCDN = (wchar_t *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)chg->hContact[i], GCDNF_UNICODE), *swzContactDisplayName; LvItemW.iSubItem = 0; // clist display name // detect if the clist provided unicode display name by comparing with non-unicode - if(szCDN && swzCDN && strncmp(szCDN, (char *)swzCDN, strlen(szCDN)) != 0 && wcslen(swzCDN) >= strlen(szCDN)) { + if (szCDN && swzCDN && strncmp(szCDN, (char *)swzCDN, strlen(szCDN)) != 0 && wcslen(swzCDN) >= strlen(szCDN)) { swzContactDisplayName = swzCDN; } else { // no? convert to unicode - if(szCDN) { + if (szCDN) { swzContactDisplayName = (wchar_t *) _alloca(sizeof(wchar_t) * (strlen(szCDN) + 1)); MultiByteToWideChar(CP_ACP, 0, (char *) szCDN, -1, swzContactDisplayName, (int)strlen((char *)szCDN) + 1); } else { @@ -104,7 +104,7 @@ void FillContactList(HWND hWndDlg, CHANGES *chg) { LvItem.iSubItem = 1; // id proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)chg->hContact[i], 0); - if(proto) { + if (proto) { field = (char *)CallProtoService(proto,PS_GETCAPS,PFLAG_UNIQUEIDSETTING,0); DBGetContactSetting(chg->hContact[i],proto,field,&dbv); @@ -176,31 +176,31 @@ void ApplyChanges(CHANGES *chg) int i; // remove removed contacts - for(i = 0; i < chg->num_deleted; i++) { + for (i = 0; i < chg->num_deleted; i++) { Meta_Delete((WPARAM)chg->hDeletedContacts[i], 0); - if(chg->hDeletedContacts[i] == chg->hDefaultContact) + if (chg->hDeletedContacts[i] == chg->hDefaultContact) chg->hDefaultContact = 0; - if(chg->hDeletedContacts[i] == chg->hOfflineContact) + if (chg->hDeletedContacts[i] == chg->hOfflineContact) chg->hOfflineContact = 0; } // set contact positions - for(i = 0; i < chg->num_contacts; i++) { - if(Meta_GetContactNumber(chg->hContact[i]) != i) + for (i = 0; i < chg->num_contacts; i++) { + if (Meta_GetContactNumber(chg->hContact[i]) != i) Meta_SwapContacts(chg->hMeta, Meta_GetContactNumber(chg->hContact[i]), i); } NotifyEventHooks(hSubcontactsChanged, (WPARAM)chg->hMeta, (LPARAM)chg->hDefaultContact); // set default - if(chg->hDefaultContact) + if (chg->hDefaultContact) DBWriteContactSettingDword(chg->hMeta, META_PROTO, "Default", Meta_GetContactNumber(chg->hDefaultContact)); else DBWriteContactSettingDword(chg->hMeta, META_PROTO, "Default", 0); NotifyEventHooks(hEventDefaultChanged, (WPARAM)chg->hMeta, (LPARAM)chg->hDefaultContact); // set offline - if(chg->hOfflineContact) + if (chg->hOfflineContact) DBWriteContactSettingDword(chg->hMeta, META_PROTO, "OfflineSend", Meta_GetContactNumber(chg->hOfflineContact)); else DBWriteContactSettingDword(chg->hMeta, META_PROTO, "OfflineSend", (DWORD)-1); @@ -214,7 +214,7 @@ void ApplyChanges(CHANGES *chg) // fix avatar most_online = Meta_GetMostOnlineSupporting(chg->hMeta, PFLAGNUM_4, PF4_AVATARS); - if(most_online) { + if (most_online) { PROTO_AVATAR_INFORMATION AI; AI.cbSize = sizeof(AI); @@ -226,7 +226,7 @@ void ApplyChanges(CHANGES *chg) DBWriteContactSettingString(chg->hMeta, "ContactPhoto", "File",AI.filename); } - if(MetaAPI_GetForceState((WPARAM)chg->hMeta, 0) != chg->force_default) + if (MetaAPI_GetForceState((WPARAM)chg->hMeta, 0) != chg->force_default) MetaAPI_ForceDefault((WPARAM)chg->hMeta, 0); } @@ -253,7 +253,7 @@ LRESULT ProcessCustomDraw (LPARAM lParam) lplvcd->clrTextBk = RGB(255,255,255); } */ - if(changes.hContact[(int)lplvcd->nmcd.dwItemSpec] == changes.hDefaultContact) { + if (changes.hContact[(int)lplvcd->nmcd.dwItemSpec] == changes.hDefaultContact) { lplvcd->clrText = RGB(255, 0, 0); } return CDRF_NEWFONT; @@ -346,7 +346,7 @@ INT_PTR CALLBACK Meta_EditDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR changes.num_deleted = 0; changes.hDefaultContact = Meta_GetContactHandle((HANDLE)lParam, default_contact_number); changes.hOfflineContact = Meta_GetContactHandle((HANDLE)lParam, offline_contact_number); - for(i = 0; i < nb_contacts; i++) + for (i = 0; i < nb_contacts; i++) changes.hContact[i] = Meta_GetContactHandle((HANDLE)lParam, i); changes.force_default = MetaAPI_GetForceState((WPARAM)lParam, 0); @@ -361,16 +361,16 @@ INT_PTR CALLBACK Meta_EditDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR { char *szCDN = (char *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)lParam, 0); - if(os_unicode_enabled) { + if (os_unicode_enabled) { wchar_t *swzCDN = (wchar_t *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)lParam, GCDNF_UNICODE), *swzContactDisplayName; // detect if the clist provided unicode display name by comparing with non-unicode - if(szCDN && swzCDN && strncmp(szCDN, (char *)swzCDN, strlen(szCDN)) != 0 && wcslen(swzCDN) >= strlen(szCDN)) { + if (szCDN && swzCDN && strncmp(szCDN, (char *)swzCDN, strlen(szCDN)) != 0 && wcslen(swzCDN) >= strlen(szCDN)) { swzContactDisplayName = swzCDN; } else { // no? convert to unicode - if(szCDN) { + if (szCDN) { swzContactDisplayName = (wchar_t *) _alloca(sizeof(wchar_t) * (strlen(szCDN) + 1)); MultiByteToWideChar(CP_ACP, 0, (char *) szCDN, -1, swzContactDisplayName, (int)strlen((char *)szCDN) + 1); } else { @@ -419,9 +419,9 @@ INT_PTR CALLBACK Meta_EditDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR 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 (changes.num_contacts == 0) // Otherwise, delete the metacontact. { - if(MessageBox(hwndDlg,Translate("You are going to remove all the contacts associated with this MetaContact.\nThis will delete the MetaContact.\n\nProceed Anyway?"), + if (MessageBox(hwndDlg,Translate("You are going to remove all the contacts associated with this MetaContact.\nThis will delete the MetaContact.\n\nProceed Anyway?"), Translate("Delete MetaContact?"),MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON1)!=IDYES) return TRUE; else @@ -437,11 +437,11 @@ INT_PTR CALLBACK Meta_EditDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR EnableWindow(GetDlgItem(hwndDlg,IDC_VALIDATE),FALSE); break; case IDOK: - if(IsWindowEnabled(GetDlgItem(hwndDlg,IDC_VALIDATE))) + 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 + if (changes.num_contacts == 0) // do the work that would have be done if { // the button 'Apply' has been clicked. - if(MessageBox(hwndDlg,Translate("You are going to remove all the contacts associated with this MetaContact.\nThis will delete the MetaContact.\n\nProceed Anyway?"), + if (MessageBox(hwndDlg,Translate("You are going to remove all the contacts associated with this MetaContact.\nThis will delete the MetaContact.\n\nProceed Anyway?"), Translate("Delete MetaContact?"),MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON1)!=IDYES) { return TRUE; @@ -494,8 +494,8 @@ INT_PTR CALLBACK Meta_EditDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR sel=SendMessage(hwnd,LVM_GETNEXTITEM,-1,LVNI_FOCUSED|LVNI_SELECTED); // return item selected changes.num_contacts--; changes.hDeletedContacts[changes.num_deleted++] = changes.hContact[sel]; - if(changes.hDefaultContact == changes.hContact[sel]) { - if(changes.num_contacts > 0) { + if (changes.hDefaultContact == changes.hContact[sel]) { + if (changes.num_contacts > 0) { changes.hDefaultContact = changes.hContact[0]; str = (char *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)changes.hDefaultContact, 0); SetWindowText(GetDlgItem(hwndDlg,IDC_ED_DEFAULT),str); @@ -506,7 +506,7 @@ INT_PTR CALLBACK Meta_EditDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR } - for(i = sel; i < changes.num_contacts; i++) + for (i = sel; i < changes.num_contacts; i++) changes.hContact[i] = changes.hContact[i + 1]; FillContactList(hwndDlg, &changes); // disable buttons diff --git a/plugins/MetaContacts/meta_api.c b/plugins/MetaContacts/meta_api.c index 6a8781f6e1..331bdb55d5 100644 --- a/plugins/MetaContacts/meta_api.c +++ b/plugins/MetaContacts/meta_api.c @@ -41,7 +41,7 @@ INT_PTR MetaAPI_GetMeta(WPARAM wParam, LPARAM lParam) { //returns a handle to the default contact, or null on failure INT_PTR MetaAPI_GetDefault(WPARAM wParam, LPARAM lParam) { DWORD default_contact_number = DBGetContactSettingDword((HANDLE)wParam, META_PROTO, "Default", -1); - if(default_contact_number != -1) { + if (default_contact_number != -1) { return (int)Meta_GetContactHandle((HANDLE)wParam, default_contact_number); } return 0; @@ -86,11 +86,11 @@ INT_PTR MetaAPI_GetContact(WPARAM wParam, LPARAM lParam) { //returns 0 on success INT_PTR MetaAPI_SetDefaultContactNum(WPARAM wParam, LPARAM lParam) { DWORD num_contacts = DBGetContactSettingDword((HANDLE)wParam, META_PROTO, "NumContacts", -1); - if(num_contacts == -1) + if (num_contacts == -1) return 1; if ((DWORD)lParam >= num_contacts || (DWORD)lParam < 0) return 1; - if(DBWriteContactSettingDword((HANDLE)wParam, META_PROTO, "Default", (DWORD)lParam)) + if (DBWriteContactSettingDword((HANDLE)wParam, META_PROTO, "Default", (DWORD)lParam)) return 1; NotifyEventHooks(hEventDefaultChanged, wParam, (LPARAM)Meta_GetContactHandle((HANDLE)wParam, (int)lParam)); @@ -104,9 +104,9 @@ INT_PTR MetaAPI_SetDefaultContactNum(WPARAM wParam, LPARAM lParam) { INT_PTR MetaAPI_SetDefaultContact(WPARAM wParam, LPARAM lParam) { HANDLE hMeta = (HANDLE)DBGetContactSettingDword((HANDLE)lParam, META_PROTO, "Handle", 0); DWORD contact_number = Meta_GetContactNumber((HANDLE)lParam); - if(contact_number == -1 || !hMeta || hMeta != (HANDLE)wParam) + if (contact_number == -1 || !hMeta || hMeta != (HANDLE)wParam) return 1; - if(DBWriteContactSettingDword(hMeta, META_PROTO, "Default", contact_number)) + if (DBWriteContactSettingDword(hMeta, META_PROTO, "Default", contact_number)) return 1; NotifyEventHooks(hEventDefaultChanged, wParam, lParam); @@ -150,7 +150,7 @@ INT_PTR MetaAPI_ForceSendContact(WPARAM wParam, LPARAM lParam) { //lParam=0 //returns 0 on success (will fail if 'force default' is in effect) INT_PTR MetaAPI_UnforceSendContact(WPARAM wParam, LPARAM lParam) { - if(DBGetContactSettingByte((HANDLE)wParam, META_PROTO, "ForceDefault", 0)) + if (DBGetContactSettingByte((HANDLE)wParam, META_PROTO, "ForceDefault", 0)) return 1; DBWriteContactSettingDword((HANDLE)wParam, META_PROTO, "ForceSend", 0); @@ -184,17 +184,17 @@ INT_PTR MetaAPI_GetForceState(WPARAM wParam, LPARAM lParam) { if (!hMeta) return 0; - if(DBGetContactSettingByte(hMeta, META_PROTO, "ForceDefault", 0)) { - if(lParam) *(DWORD *)lParam = DBGetContactSettingDword((HANDLE)wParam, META_PROTO, "Default", -1); + if (DBGetContactSettingByte(hMeta, META_PROTO, "ForceDefault", 0)) { + if (lParam) *(DWORD *)lParam = DBGetContactSettingDword((HANDLE)wParam, META_PROTO, "Default", -1); return 1; } hContact = (HANDLE)DBGetContactSettingDword(hMeta, META_PROTO, "ForceSend", 0); if (!hContact) { - if(lParam) *(DWORD *)lParam = -1; + if (lParam) *(DWORD *)lParam = -1; } else { - if(lParam) *(DWORD *)lParam = (DWORD)Meta_GetContactNumber(hContact); + if (lParam) *(DWORD *)lParam = (DWORD)Meta_GetContactNumber(hContact); } return 0; diff --git a/plugins/MetaContacts/meta_main.c b/plugins/MetaContacts/meta_main.c index 30681a211e..dbe2f67224 100644 --- a/plugins/MetaContacts/meta_main.c +++ b/plugins/MetaContacts/meta_main.c @@ -169,7 +169,7 @@ int __declspec(dllexport)Load(PLUGINLINK *link) os_unicode_enabled = IsUnicodeOS(); - if(ServiceExists(MS_DB_SETSETTINGRESIDENT)) { // 0.6+ + if (ServiceExists(MS_DB_SETSETTINGRESIDENT)) { // 0.6+ CallService(MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)(META_PROTO "/Status")); CallService(MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)(META_PROTO "/IdleTS")); CallService(MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)(META_PROTO "/ContactCountCheck")); @@ -191,7 +191,7 @@ int __declspec(dllexport)Load(PLUGINLINK *link) DBWriteContactSettingByte(hContact, META_PROTO, "ContactCountCheck", 0); // restore any saved defaults that might have remained if miranda was closed or crashed while a convo was happening - if(DBGetContactSettingDword(hContact, META_PROTO, "SavedDefault", (DWORD)-1) != (DWORD)-1) { + if (DBGetContactSettingDword(hContact, META_PROTO, "SavedDefault", (DWORD)-1) != (DWORD)-1) { DBWriteContactSettingDword(hContact, META_PROTO, "Default", DBGetContactSettingDword(hContact, META_PROTO, "SavedDefault", 0)); DBWriteContactSettingDword(hContact, META_PROTO, "SavedDefault", (DWORD)-1); } @@ -212,7 +212,7 @@ int __declspec(dllexport)Load(PLUGINLINK *link) // also verifies that subcontacts: have metacontacts, and that contact numbers are reasonable, // that metacontacts: have the correct number of subcontacts, and have reasonable defaults - if(Meta_SetHandles()) { + if (Meta_SetHandles()) { // error - db corruption if (!DBGetContactSettingByte(0, META_PROTO, "DisabledMessageShown", 0)) { MessageBox(0, Translate("Error - Database corruption.\nPlugin disabled."), Translate("MetaContacts"), MB_OK | MB_ICONERROR); @@ -255,7 +255,7 @@ int __declspec(dllexport)Load(PLUGINLINK *link) // check protocol for jabber hack, and the proto modules must be loaded //Meta_HideLinkedContactsAndSetHandles(); - if(ServiceExists(MS_MSG_GETWINDOWAPI)) { + if (ServiceExists(MS_MSG_GETWINDOWAPI)) { message_window_api_enabled = TRUE; } diff --git a/plugins/MetaContacts/meta_menu.c b/plugins/MetaContacts/meta_menu.c index 37ceb1116a..6e7ad9f1c6 100644 --- a/plugins/MetaContacts/meta_menu.c +++ b/plugins/MetaContacts/meta_menu.c @@ -52,7 +52,7 @@ INT_PTR Meta_Convert(WPARAM wParam,LPARAM lParam) hMetaContact = (HANDLE)CallService(MS_DB_CONTACT_ADD,0,0); // Add the info for the metacontact - if(hMetaContact) + if (hMetaContact) { DBWriteContactSettingDword(hMetaContact,META_PROTO,META_ID,nextMetaID); @@ -62,8 +62,8 @@ INT_PTR Meta_Convert(WPARAM wParam,LPARAM lParam) // Add the MetaContact protocol to the new meta contact CallService( MS_PROTO_ADDTOCONTACT, ( WPARAM )hMetaContact, ( LPARAM )META_PROTO ); - if(group) { - if(ServiceExists(MS_DB_CONTACT_GETSETTING_STR)) + if (group) { + if (ServiceExists(MS_DB_CONTACT_GETSETTING_STR)) DBWriteContactSettingStringUtf(hMetaContact,"CList","Group",group); else DBWriteContactSettingString(hMetaContact,"CList","Group",group); @@ -147,7 +147,7 @@ void Meta_RemoveContactNumber(HANDLE hMeta, int number) { num_contacts = DBGetContactSettingDword(hMeta, META_PROTO, "NumContacts", 0); default_contact = DBGetContactSettingDword(hMeta, META_PROTO, "Default", -1); - if(number >= 0 && number < num_contacts) { + if (number >= 0 && number < num_contacts) { // get the handle hContact = Meta_GetContactHandle(hMeta, number); @@ -166,7 +166,7 @@ void Meta_RemoveContactNumber(HANDLE hMeta, int number) { //CallService(MS_PROTO_REMOVEFROMCONTACT,(WPARAM)hContact,(LPARAM)META_PROTO); CallService(MS_PROTO_REMOVEFROMCONTACT,(WPARAM)hContact,(LPARAM)META_FILTER); // stop ignoring, if we were - if(options.suppress_status) + if (options.suppress_status) CallService(MS_IGNORE_UNIGNORE, (WPARAM)hContact, (WPARAM)IGNOREEVENT_USERONLINE); } @@ -175,7 +175,7 @@ void Meta_RemoveContactNumber(HANDLE hMeta, int number) { // each contact from 'number' upwards will be moved down one // and the last one will be deleted - for(i = number + 1; i < num_contacts; i++) { + for (i = number + 1; i < num_contacts; i++) { Meta_SwapContacts(hMeta, i, i-1); } @@ -203,9 +203,9 @@ void Meta_RemoveContactNumber(HANDLE hMeta, int number) { DBDeleteContactSetting(hMeta, META_PROTO, buffer); // if the default contact was equal to or greater than 'number', decrement it (and deal with ends) - if(default_contact >= number) { + if (default_contact >= number) { default_contact--; - if(default_contact < 0) + if (default_contact < 0) default_contact = 0; DBWriteContactSettingDword(hMeta, META_PROTO, "Default", (DWORD)default_contact); @@ -223,7 +223,7 @@ void Meta_RemoveContactNumber(HANDLE hMeta, int number) { // fix avatar hContact = Meta_GetMostOnlineSupporting(hMeta, PFLAGNUM_4, PF4_AVATARS); - if(hContact) { + if (hContact) { PROTO_AVATAR_INFORMATION AI; AI.cbSize = sizeof(AI); @@ -253,7 +253,7 @@ INT_PTR Meta_Delete(WPARAM wParam,LPARAM lParam) if ((metaID=DBGetContactSettingDword((HANDLE)wParam,META_PROTO,META_ID,(DWORD)-1))!=(DWORD)-1) {// The wParam is a metacontact if (!lParam) { // check from recursion - see second half of this function - if(MessageBox((HWND)CallService(MS_CLUI_GETHWND,0,0),Translate("This will remove the MetaContact permanently.\n\nProceed Anyway?"), + if (MessageBox((HWND)CallService(MS_CLUI_GETHWND,0,0),Translate("This will remove the MetaContact permanently.\n\nProceed Anyway?"), Translate("Are you sure?"),MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2)!=IDYES) { return 0; @@ -263,7 +263,7 @@ INT_PTR Meta_Delete(WPARAM wParam,LPARAM lParam) hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0); while(hContact) { // Scans the database to get all the contacts that have been previously linked to this MetaContact - if(DBGetContactSettingDword(hContact,META_PROTO,META_LINK,(DWORD)-1)==metaID) + if (DBGetContactSettingDword(hContact,META_PROTO,META_LINK,(DWORD)-1)==metaID) { // This contact is assigned to the MetaContact that will be deleted, clear the "MetaContacts" information DBDeleteContactSetting(hContact,META_PROTO,"IsSubcontact"); DBDeleteContactSetting(hContact,META_PROTO,META_LINK); @@ -275,7 +275,7 @@ INT_PTR Meta_Delete(WPARAM wParam,LPARAM lParam) CallService(MS_PROTO_REMOVEFROMCONTACT,(WPARAM)hContact,(LPARAM)META_FILTER); // stop ignoring, if we were - if(options.suppress_status) + if (options.suppress_status) CallService(MS_IGNORE_UNIGNORE, (WPARAM)hContact, (WPARAM)IGNOREEVENT_USERONLINE); } hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact,0); @@ -288,7 +288,7 @@ INT_PTR Meta_Delete(WPARAM wParam,LPARAM lParam) } else {// The wParam is a simple contact - //if(lParam == 0) + //if (lParam == 0) // return 1; // The function has been called by the menu of a simple contact. Should not happen. //else {// The function has been called by the edit dialog @@ -297,8 +297,8 @@ INT_PTR Meta_Delete(WPARAM wParam,LPARAM lParam) DWORD num_contacts = DBGetContactSettingDword(hMeta, META_PROTO, "NumContacts", -1); - if(num_contacts == 1) { - if(MessageBox(0,Translate("You are going to remove all the contacts associated with this MetaContact.\nThis will delete the MetaContact.\n\nProceed Anyway?"), + if (num_contacts == 1) { + if (MessageBox(0,Translate("You are going to remove all the contacts associated with this MetaContact.\nThis will delete the MetaContact.\n\nProceed Anyway?"), Translate("Delete MetaContact?"),MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON1)==IDYES) { // recurse - once @@ -345,7 +345,7 @@ INT_PTR Meta_Default(WPARAM wParam,LPARAM lParam) */ INT_PTR Meta_ForceDefault(WPARAM wParam,LPARAM lParam) { - if(DBGetContactSettingDword((HANDLE)wParam,META_PROTO, META_ID, (DWORD)-1) != (DWORD)-1) + if (DBGetContactSettingDword((HANDLE)wParam,META_PROTO, META_ID, (DWORD)-1) != (DWORD)-1) { // the wParam is a MetaContact BOOL current = DBGetContactSettingByte((HANDLE)wParam, META_PROTO, "ForceDefault", 0); @@ -354,7 +354,7 @@ INT_PTR Meta_ForceDefault(WPARAM wParam,LPARAM lParam) DBWriteContactSettingDword((HANDLE)wParam, META_PROTO, "ForceSend", 0); - if(current) NotifyEventHooks(hEventForceSend, wParam, (LPARAM)Meta_GetContactHandle((HANDLE)wParam, DBGetContactSettingDword((HANDLE)wParam, META_PROTO, "Default", -1))); + if (current) NotifyEventHooks(hEventForceSend, wParam, (LPARAM)Meta_GetContactHandle((HANDLE)wParam, DBGetContactSettingDword((HANDLE)wParam, META_PROTO, "Default", -1))); else NotifyEventHooks(hEventUnforceSend, wParam, 0); } return 0; @@ -408,7 +408,7 @@ int Meta_ModifyMenu(WPARAM wParam, LPARAM lParam) mi.flags = CMIM_FLAGS; mi.cbSize = sizeof(CLISTMENUITEM); - if(DBGetContactSettingDword((HANDLE)wParam,META_PROTO,META_ID,-1) != (DWORD)-1) + if (DBGetContactSettingDword((HANDLE)wParam,META_PROTO,META_ID,-1) != (DWORD)-1) { int num_contacts, i; @@ -418,7 +418,7 @@ int Meta_ModifyMenu(WPARAM wParam, LPARAM lParam) // This is a MetaContact, show the edit, force default, and the delete menu, and hide the others CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuEdit, (LPARAM)&mi); //mi.flags |= CMIM_NAME; - //if(DBGetContactSettingByte((HANDLE)wParam, META_PROTO, "ForceDefault", 0)) + //if (DBGetContactSettingByte((HANDLE)wParam, META_PROTO, "ForceDefault", 0)) // mi.pszName = Translate("Unforce Default"); //else // mi.pszName = Translate("Force Default"); @@ -434,8 +434,8 @@ int Meta_ModifyMenu(WPARAM wParam, LPARAM lParam) //show subcontact menu items num_contacts = DBGetContactSettingDword((HANDLE)wParam, META_PROTO, "NumContacts", 0); - for(i = 0; i < MAX_CONTACTS; i++) { - if(i < num_contacts) { + for (i = 0; i < MAX_CONTACTS; i++) { + if (i < num_contacts) { hContact = Meta_GetContactHandle((HANDLE)wParam, i); proto = _strdup((char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0)); @@ -444,7 +444,7 @@ int Meta_ModifyMenu(WPARAM wParam, LPARAM lParam) else status = DBGetContactSettingWord(hContact, proto, "Status", ID_STATUS_OFFLINE); - if(options.menu_contact_label == DNT_UID) { + if (options.menu_contact_label == DNT_UID) { strcpy(buf, "Login"); strcat(buf, _itoa(i, buffer2, 10)); @@ -473,7 +473,7 @@ int Meta_ModifyMenu(WPARAM wParam, LPARAM lParam) char *name = (char *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, 0); char *wname = (char *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_UNICODE); - if(wname && strncmp(name, wname, strlen(name)) != 0) { + if (wname && strncmp(name, wname, strlen(name)) != 0) { mi.pszName = wname; mi.flags = CMIF_UNICODE; } @@ -522,12 +522,12 @@ int Meta_ModifyMenu(WPARAM wParam, LPARAM lParam) CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuAdd, (LPARAM)&mi); CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuConvert, (LPARAM)&mi); CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuEdit, (LPARAM)&mi); - for(i = 0; i < MAX_CONTACTS; i++) { + for (i = 0; i < MAX_CONTACTS; i++) { mi.flags = CMIM_FLAGS | CMIF_HIDDEN; CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuContact[i], (LPARAM)&mi); } - } else if(DBGetContactSettingDword((HANDLE)wParam,META_PROTO,META_LINK,(DWORD)-1)!=(DWORD)-1) { + } else if (DBGetContactSettingDword((HANDLE)wParam,META_PROTO,META_LINK,(DWORD)-1)!=(DWORD)-1) { // The contact is affected to a metacontact. CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuDefault, (LPARAM)&mi); mi.flags |= CMIM_NAME; @@ -537,7 +537,7 @@ int Meta_ModifyMenu(WPARAM wParam, LPARAM lParam) CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuAdd, (LPARAM)&mi); CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuConvert, (LPARAM)&mi); CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuEdit, (LPARAM)&mi); - for(i = 0; i < MAX_CONTACTS; i++) { + for (i = 0; i < MAX_CONTACTS; i++) { mi.flags = CMIM_FLAGS | CMIF_HIDDEN; CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuContact[i], (LPARAM)&mi); } @@ -549,7 +549,7 @@ int Meta_ModifyMenu(WPARAM wParam, LPARAM lParam) CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuEdit, (LPARAM)&mi); CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuDelete, (LPARAM)&mi); CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuDefault, (LPARAM)&mi); - for(i = 0; i < MAX_CONTACTS; i++) { + for (i = 0; i < MAX_CONTACTS; i++) { mi.flags = CMIM_FLAGS | CMIF_HIDDEN; CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuContact[i], (LPARAM)&mi); } diff --git a/plugins/MetaContacts/meta_options.c b/plugins/MetaContacts/meta_options.c index af23243c5e..cceb484f6f 100644 --- a/plugins/MetaContacts/meta_options.c +++ b/plugins/MetaContacts/meta_options.c @@ -131,7 +131,7 @@ INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara break; case IDC_RAD_UID: hw = GetDlgItem(hwndDlg, IDC_RAD_UID); - if(IsDlgButtonChecked(hwndDlg, IDC_RAD_UID)) { + if (IsDlgButtonChecked(hwndDlg, IDC_RAD_UID)) { options_changes.menu_contact_label = DNT_UID; CheckDlgButton(hwndDlg, IDC_RAD_DID, FALSE); } @@ -139,7 +139,7 @@ INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara break; case IDC_RAD_DID: hw = GetDlgItem(hwndDlg, IDC_RAD_DID); - if(IsDlgButtonChecked(hwndDlg, IDC_RAD_DID)) { + if (IsDlgButtonChecked(hwndDlg, IDC_RAD_DID)) { options_changes.menu_contact_label = DNT_DID; CheckDlgButton(hwndDlg, IDC_RAD_UID, FALSE); } @@ -147,7 +147,7 @@ INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara break; case IDC_RAD_MSG: hw = GetDlgItem(hwndDlg, IDC_RAD_MSG); - if(IsDlgButtonChecked(hwndDlg, IDC_RAD_MSG)) { + if (IsDlgButtonChecked(hwndDlg, IDC_RAD_MSG)) { options_changes.menu_function = FT_MSG; CheckDlgButton(hwndDlg, IDC_RAD_MENU, FALSE); CheckDlgButton(hwndDlg, IDC_RAD_INFO, FALSE); @@ -156,7 +156,7 @@ INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara break; case IDC_RAD_MENU: hw = GetDlgItem(hwndDlg, IDC_RAD_MENU); - if(IsDlgButtonChecked(hwndDlg, IDC_RAD_MENU)) { + if (IsDlgButtonChecked(hwndDlg, IDC_RAD_MENU)) { options_changes.menu_function = FT_MENU; CheckDlgButton(hwndDlg, IDC_RAD_MSG, FALSE); CheckDlgButton(hwndDlg, IDC_RAD_INFO, FALSE); @@ -165,7 +165,7 @@ INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara break; case IDC_RAD_INFO: hw = GetDlgItem(hwndDlg, IDC_RAD_INFO); - if(IsDlgButtonChecked(hwndDlg, IDC_RAD_INFO)) { + if (IsDlgButtonChecked(hwndDlg, IDC_RAD_INFO)) { options_changes.menu_function = FT_INFO; CheckDlgButton(hwndDlg, IDC_RAD_MSG, FALSE); CheckDlgButton(hwndDlg, IDC_RAD_MENU, FALSE); @@ -174,7 +174,7 @@ INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara break; case IDC_RAD_NICK: hw = GetDlgItem(hwndDlg, IDC_RAD_NICK); - if(IsDlgButtonChecked(hwndDlg, IDC_RAD_NICK)) { + if (IsDlgButtonChecked(hwndDlg, IDC_RAD_NICK)) { options_changes.clist_contact_name = CNNT_NICK; CheckDlgButton(hwndDlg, IDC_RAD_NAME, FALSE); } @@ -182,7 +182,7 @@ INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara break; case IDC_RAD_NAME: hw = GetDlgItem(hwndDlg, IDC_RAD_NAME); - if(IsDlgButtonChecked(hwndDlg, IDC_RAD_NAME)) { + if (IsDlgButtonChecked(hwndDlg, IDC_RAD_NAME)) { options_changes.clist_contact_name = CNNT_DISPLAYNAME; CheckDlgButton(hwndDlg, IDC_RAD_NICK, FALSE); } @@ -192,7 +192,7 @@ INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara hw = GetDlgItem(hwndDlg, IDC_CHK_SUBWINDOW); options_changes.subcontact_windows = IsDlgButtonChecked(hwndDlg, IDC_CHK_SUBWINDOW); - if(options_changes.subcontact_windows) { + if (options_changes.subcontact_windows) { hw = GetDlgItem(hwndDlg, IDC_CHK_METAHISTORY); EnableWindow(hw, TRUE); hw = GetDlgItem(hwndDlg, IDC_CHK_SUBHISTORY); @@ -223,7 +223,7 @@ INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara if (((LPNMHDR)lParam)->code == PSN_APPLY ) { hw = GetDlgItem(hwndDlg, IDC_ED_DAYS); GetWindowText(hw, buff, 512); - if(strlen(buff) > 0) + if (strlen(buff) > 0) options_changes.days_history = atoi(buff); options = options_changes; @@ -262,7 +262,7 @@ int Meta_WriteOptions(MetaOptions *opt) { else DBWriteContactSettingByte(NULL, META_PROTO, "MetaHistory", (BYTE)(opt->metahistory ? 1 : 0)); - if(opt->subcontact_windows) + if (opt->subcontact_windows) DBWriteContactSettingByte(NULL, META_PROTO, "SubcontactHistory", 1); else DBWriteContactSettingByte(NULL, META_PROTO, "SubcontactHistory", (BYTE)(opt->subhistory ? 1 : 0)); @@ -294,7 +294,7 @@ int Meta_ReadOptions(MetaOptions *opt) { else opt->metahistory = (DBGetContactSettingByte(NULL, META_PROTO, "MetaHistory", 1) == 1 ? TRUE : FALSE); - if(opt->subcontact_windows) + if (opt->subcontact_windows) opt->subhistory = TRUE; else opt->subhistory = (DBGetContactSettingByte(NULL, META_PROTO, "SubcontactHistory", 1) == 1 ? TRUE : FALSE); @@ -347,7 +347,7 @@ int GetRealPriority(char *proto, int status) { int prio; mir_snprintf(szSetting, 256, "ProtoPrio_%s%d", proto, status); prio = DBGetContactSettingWord(0, META_PROTO, szSetting, 0xFFFF); - if(prio == 0xFFFF) { + if (prio == 0xFFFF) { mir_snprintf(szSetting, 256, "DefaultPrio_%d", status); return DBGetContactSettingWord(0, META_PROTO, szSetting, GetDefaultPrio(status)); } else @@ -366,14 +366,14 @@ void ReadPriorities() { CallService(MS_PROTO_ENUMPROTOCOLS, (LPARAM)&num_protocols, (WPARAM)&pppDesc); current = priorities = (ProtoStatusPrio *)malloc((num_protocols + 1) * sizeof(ProtoStatusPrio)); - for(i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) { + for (i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) { mir_snprintf(szSetting, 256, "DefaultPrio_%d", i); current->def[i - ID_STATUS_OFFLINE] = TRUE; current->prio[i - ID_STATUS_OFFLINE] = DBGetContactSettingWord(0, META_PROTO, szSetting, GetDefaultPrio(i)); } - for(i = 0; i < num_protocols; i++) { + for (i = 0; i < num_protocols; i++) { current = priorities + (i + 1); - for(j = ID_STATUS_OFFLINE; j <= ID_STATUS_OUTTOLUNCH; j++) { + for (j = ID_STATUS_OFFLINE; j <= ID_STATUS_OUTTOLUNCH; j++) { mir_snprintf(szSetting, 256, "ProtoPrio_%s%d", pppDesc[i]->szName, j); current->prio[j - ID_STATUS_OFFLINE] = DBGetContactSettingWord(0, META_PROTO, szSetting, 0xFFFF); current->def[j - ID_STATUS_OFFLINE] = (current->prio[j - ID_STATUS_OFFLINE] == 0xFFFF); @@ -390,16 +390,16 @@ void WritePriorities() { CallService(MS_PROTO_ENUMPROTOCOLS, (LPARAM)&num_protocols, (WPARAM)&pppDesc); - for(i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) { + for (i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) { mir_snprintf(szSetting, 256, "DefaultPrio_%d", i); - if(current->prio[i - ID_STATUS_OFFLINE] != GetDefaultPrio(i)) + if (current->prio[i - ID_STATUS_OFFLINE] != GetDefaultPrio(i)) DBWriteContactSettingWord(0, META_PROTO, szSetting, (WORD)current->prio[i - ID_STATUS_OFFLINE]); else DBDeleteContactSetting(0, META_PROTO, szSetting); } - for(i = 0; i < num_protocols; i++) { + for (i = 0; i < num_protocols; i++) { current = priorities + (i + 1); - for(j = ID_STATUS_OFFLINE; j <= ID_STATUS_OUTTOLUNCH; j++) { + for (j = ID_STATUS_OFFLINE; j <= ID_STATUS_OUTTOLUNCH; j++) { mir_snprintf(szSetting, 256, "ProtoPrio_%s%d", pppDesc[i]->szName, j); if (!current->def[j - ID_STATUS_OFFLINE]) DBWriteContactSettingWord(0, META_PROTO, szSetting, (WORD)current->prio[j - ID_STATUS_OFFLINE]); @@ -415,12 +415,12 @@ int GetIsDefault(int proto_index, int status) { BOOL GetPriority(int proto_index, int status) { ProtoStatusPrio * current; - if(proto_index == -1) { + if (proto_index == -1) { current = priorities; return current->prio[status - ID_STATUS_OFFLINE]; } else { current = priorities + (proto_index + 1); - if(current->def[status - ID_STATUS_OFFLINE]) { + if (current->def[status - ID_STATUS_OFFLINE]) { current = priorities; } return current->prio[status - ID_STATUS_OFFLINE]; @@ -430,9 +430,9 @@ BOOL GetPriority(int proto_index, int status) { void SetPriority(int proto_index, int status, BOOL def, int prio) { ProtoStatusPrio * current; - if(prio < 0) prio = 0; - if(prio > 500) prio = 500; - if(proto_index == -1) { + if (prio < 0) prio = 0; + if (prio > 500) prio = 500; + if (proto_index == -1) { current = priorities; current->prio[status - ID_STATUS_OFFLINE] = prio; } else { @@ -453,13 +453,13 @@ void ResetPriorities() { CallService(MS_PROTO_ENUMPROTOCOLS, (LPARAM)&num_protocols, (WPARAM)&pppDesc); current = priorities; - for(i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) { + for (i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) { current->def[i - ID_STATUS_OFFLINE] = TRUE; current->prio[i - ID_STATUS_OFFLINE] = GetDefaultPrio(i); } - for(i = 0; i < num_protocols; i++) { + for (i = 0; i < num_protocols; i++) { current = priorities + (i + 1); - for(j = ID_STATUS_OFFLINE; j <= ID_STATUS_OUTTOLUNCH; j++) { + for (j = ID_STATUS_OFFLINE; j <= ID_STATUS_OUTTOLUNCH; j++) { current->def[j - ID_STATUS_OFFLINE] = TRUE; } } @@ -486,9 +486,9 @@ INT_PTR CALLBACK DlgProcOptsPriorities(HWND hwndDlg, UINT msg, WPARAM wParam, LP hw = GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL); index = SendMessage(hw, CB_INSERTSTRING, (WPARAM)-1, (LPARAM)Translate("")); SendMessage(hw, CB_SETITEMDATA, (WPARAM)index, -1); - for(i = 0; i < num_protocols; i++) { - if(pppDesc[i]->type == PROTOTYPE_PROTOCOL) { - if(strcmp(pppDesc[i]->szName, META_PROTO) != 0) { + for (i = 0; i < num_protocols; i++) { + if (pppDesc[i]->type == PROTOTYPE_PROTOCOL) { + if (strcmp(pppDesc[i]->szName, META_PROTO) != 0) { index = SendMessage(hw, CB_INSERTSTRING, (WPARAM)-1, (LPARAM)pppDesc[i]->szName); SendMessage(hw, CB_SETITEMDATA, (WPARAM)index, i); } @@ -503,19 +503,19 @@ INT_PTR CALLBACK DlgProcOptsPriorities(HWND hwndDlg, UINT msg, WPARAM wParam, LP case WMU_FILLPRIODATA: { int sel = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_GETCURSEL, 0, 0); - if(sel != -1) { + if (sel != -1) { int index = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_GETITEMDATA, (WPARAM)sel, 0); sel = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_STATUS), CB_GETCURSEL, 0, 0); - if(sel != -1) { + if (sel != -1) { int status = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_STATUS), CB_GETITEMDATA, (WPARAM)sel, 0); SetDlgItemInt(hwndDlg, IDC_ED_PRIORITY, GetPriority(index, status), FALSE); - if(index == -1) { + if (index == -1) { EnableWindow(GetDlgItem(hwndDlg, IDC_ED_PRIORITY), TRUE); EnableWindow(GetDlgItem(hwndDlg, IDC_SP_PRIORITY), TRUE); CheckDlgButton(hwndDlg, IDC_CHK_DEFAULT, TRUE); EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DEFAULT), FALSE); } else { - if(GetIsDefault(index, status)) { + if (GetIsDefault(index, status)) { CheckDlgButton(hwndDlg, IDC_CHK_DEFAULT, TRUE); EnableWindow(GetDlgItem(hwndDlg, IDC_ED_PRIORITY), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_SP_PRIORITY), FALSE); @@ -534,13 +534,13 @@ INT_PTR CALLBACK DlgProcOptsPriorities(HWND hwndDlg, UINT msg, WPARAM wParam, LP case WMU_FILLSTATUSCMB: { int sel = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_GETCURSEL, 0, 0); - if(sel != -1) { + if (sel != -1) { int index = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_GETITEMDATA, (WPARAM)sel, 0); HWND hw = GetDlgItem(hwndDlg, IDC_CMB_STATUS); SendMessage(hw, CB_RESETCONTENT, 0, 0); - if(index == -1) { + if (index == -1) { int i; - for(i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) { + for (i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) { index = SendMessage(hw, CB_INSERTSTRING, (WPARAM)-1, (LPARAM)(char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, i, 0)); SendMessage(hw, CB_SETITEMDATA, (WPARAM)index, i); } @@ -551,8 +551,8 @@ INT_PTR CALLBACK DlgProcOptsPriorities(HWND hwndDlg, UINT msg, WPARAM wParam, LP caps = CallProtoService(pppDesc[index]->szName, PS_GETCAPS, PFLAGNUM_2, 0); - for(i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) { - if(caps & Proto_Status2Flag(i)) { + for (i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) { + if (caps & Proto_Status2Flag(i)) { index = SendMessage(hw, CB_INSERTSTRING, (WPARAM)-1, (LPARAM)(char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, i, 0)); SendMessage(hw, CB_SETITEMDATA, (WPARAM)index, i); } @@ -569,13 +569,13 @@ INT_PTR CALLBACK DlgProcOptsPriorities(HWND hwndDlg, UINT msg, WPARAM wParam, LP case IDC_CHK_DEFAULT: { int sel = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_GETCURSEL, 0, 0); - if(sel != -1) { + if (sel != -1) { int index = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_GETITEMDATA, (WPARAM)sel, 0); sel = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_STATUS), CB_GETCURSEL, 0, 0); - if(sel != -1) { + if (sel != -1) { BOOL checked = IsDlgButtonChecked(hwndDlg, IDC_CHK_DEFAULT); int status = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_STATUS), CB_GETITEMDATA, (WPARAM)sel, 0); - if(checked) { + if (checked) { SetPriority(index, status, TRUE, 0); SetDlgItemInt(hwndDlg, IDC_ED_PRIORITY, GetPriority(index, status), FALSE); } else { @@ -599,14 +599,14 @@ INT_PTR CALLBACK DlgProcOptsPriorities(HWND hwndDlg, UINT msg, WPARAM wParam, LP } if ( HIWORD( wParam ) == EN_CHANGE && LOWORD(wParam) == IDC_ED_PRIORITY && ( HWND )lParam == GetFocus()) { int sel = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_GETCURSEL, 0, 0); - if(sel != -1) { + if (sel != -1) { int index = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_GETITEMDATA, (WPARAM)sel, 0); sel = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_STATUS), CB_GETCURSEL, 0, 0); - if(sel != -1) { + if (sel != -1) { int status = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_STATUS), CB_GETITEMDATA, (WPARAM)sel, 0); int prio = GetDlgItemInt(hwndDlg, IDC_ED_PRIORITY, 0, FALSE); SetPriority(index, status, FALSE, prio); - if(prio != GetPriority(index, status)) + if (prio != GetPriority(index, status)) SetDlgItemInt(hwndDlg, IDC_ED_PRIORITY, GetPriority(index, status), FALSE); SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); } diff --git a/plugins/MetaContacts/meta_services.c b/plugins/MetaContacts/meta_services.c index 67644af23c..92e503568d 100644 --- a/plugins/MetaContacts/meta_services.c +++ b/plugins/MetaContacts/meta_services.c @@ -43,20 +43,21 @@ hHooks[NB_HOOKS] = {0}; //!< list of all hooks set up (see Meta_CloseHandles()) HANDLE *hNudgeEvents = 0; int iNudgeProtos = 0; -HANDLE hMenuConvert, //!< \c HANDLE to the convert menu item. - hMenuAdd, //!< \c HANDLE to the add to menu item. - hMenuEdit, //!< \c HANDLE to the edit menu item. - hMenuDelete, //!< \c HANDLE to the delete menu item. - hMenuDefault, //!< \c HANDLE to the delete menu item. - hMenuForceDefault; //!< \c HANDLE to the delete menu item. - -HANDLE hMenuOnOff; //!< \c HANDLE to the enable/disable menu item. - -HANDLE hEventDefaultChanged, //!< \c HANDLE to the 'default changed' event - hEventForceSend, //!< \c HANDLE to the 'force send' event - hEventUnforceSend, //!< \c HANDLE to the 'unforce send' event - hSubcontactsChanged, //!< \c HANDLE to the 'contacts changed' event - hEventNudge; +HGENMENU + hMenuConvert, //!< \c HANDLE to the convert menu item. + hMenuAdd, //!< \c HANDLE to the add to menu item. + hMenuEdit, //!< \c HANDLE to the edit menu item. + hMenuDelete, //!< \c HANDLE to the delete menu item. + hMenuDefault, //!< \c HANDLE to the delete menu item. + hMenuForceDefault, //!< \c HANDLE to the delete menu item. + hMenuOnOff; //!< \c HANDLE to the enable/disable menu item. + +HANDLE + hEventDefaultChanged, //!< \c HANDLE to the 'default changed' event + hEventForceSend, //!< \c HANDLE to the 'force send' event + hEventUnforceSend, //!< \c HANDLE to the 'unforce send' event + hSubcontactsChanged, //!< \c HANDLE to the 'contacts changed' event + hEventNudge; DWORD nextMetaID; //!< Global variable specifying the ID value the next MetaContact will have. @@ -130,7 +131,7 @@ INT_PTR Meta_GetName(WPARAM wParam,LPARAM lParam) { char *name = (char *)Translate(META_PROTO); size_t size = min(strlen(name),wParam-1); // copy only the first size bytes. - if(strncpy((char *)lParam,name,size)==NULL) + if (strncpy((char *)lParam,name,size)==NULL) return 1; ((char *)lParam)[size]='\0'; return 0; @@ -189,7 +190,7 @@ void CALLBACK SetStatusThread(HWND hWnd, UINT msg, UINT_PTR id, DWORD dw) INT_PTR Meta_SetStatus(WPARAM wParam,LPARAM lParam) { // firstSetOnline starts out true - used to delay metacontact's 'onlineness' to prevent double status notifications on startup - if(mcStatus == ID_STATUS_OFFLINE && firstSetOnline) { + if (mcStatus == ID_STATUS_OFFLINE && firstSetOnline) { // causes crash on exit if miranda is closed in under options.set_status_from_offline milliseconds! //CloseHandle( CreateThread( NULL, 0, SetStatusThread, (void *)wParam, 0, 0 )); setStatusTimerId = SetTimer(0, 0, options.set_status_from_offline_delay, SetStatusThread); @@ -269,18 +270,18 @@ INT_PTR MetaFilter_SendMessage(WPARAM wParam,LPARAM lParam) } // if subcontact sending, add db event to keep metacontact history correct - if(options.metahistory && !(ccs->wParam & PREF_METANODB)) { + if (options.metahistory && !(ccs->wParam & PREF_METANODB)) { // reject "file As Message" messages - if(strlen((char *)ccs->lParam) > 5 && strncmp((char *)ccs->lParam, "<%fAM", 5) == 0) + if (strlen((char *)ccs->lParam) > 5 && strncmp((char *)ccs->lParam, "<%fAM", 5) == 0) return CallService(MS_PROTO_CHAINSEND, wParam, lParam); // continue processing // reject "data As Message" messages - if(strlen((char *)ccs->lParam) > 5 && strncmp((char *)ccs->lParam, "<%dAM", 5) == 0) + if (strlen((char *)ccs->lParam) > 5 && strncmp((char *)ccs->lParam, "<%dAM", 5) == 0) return CallService(MS_PROTO_CHAINSEND, wParam, lParam); // continue processing // reject "OTR" messages - if(strlen((char *)ccs->lParam) > 5 && strncmp((char *)ccs->lParam, "?OTR", 4) == 0) + if (strlen((char *)ccs->lParam) > 5 && strncmp((char *)ccs->lParam, "?OTR", 4) == 0) return CallService(MS_PROTO_CHAINSEND, wParam, lParam); // continue processing ZeroMemory(&dbei, sizeof(dbei)); @@ -289,8 +290,8 @@ INT_PTR MetaFilter_SendMessage(WPARAM wParam,LPARAM lParam) dbei.flags = DBEF_SENT; dbei.timestamp = time(NULL); dbei.eventType = EVENTTYPE_MESSAGE; - if(ccs->wParam & PREF_RTL) dbei.flags |= DBEF_RTL; - if(ccs->wParam & PREF_UTF) dbei.flags |= DBEF_UTF; + if (ccs->wParam & PREF_RTL) dbei.flags |= DBEF_RTL; + if (ccs->wParam & PREF_UTF) dbei.flags |= DBEF_UTF; dbei.cbBlob = (DWORD)strlen((char *)ccs->lParam) + 1; if ( ccs->wParam & PREF_UNICODE ) dbei.cbBlob *= ( sizeof( wchar_t )+1 ); @@ -379,14 +380,14 @@ INT_PTR Meta_SendMessage(WPARAM wParam,LPARAM lParam) // don't bypass filters etc strncpy(szServiceName, PSS_MESSAGE, sizeof(szServiceName)); - if(ccs->wParam & PREF_UNICODE) { + if (ccs->wParam & PREF_UNICODE) { char szTemp[100]; _snprintf(szTemp, sizeof(szTemp), "%s%sW", proto, PSS_MESSAGE); if (ServiceExists(szTemp)) strncpy(szServiceName, PSS_MESSAGE "W", sizeof(szServiceName)); } - if(options.subhistory && !(ccs->wParam & PREF_METANODB)) { + if (options.subhistory && !(ccs->wParam & PREF_METANODB)) { // add sent event to subcontact ZeroMemory(&dbei, sizeof(dbei)); dbei.cbSize = sizeof(dbei); @@ -394,8 +395,8 @@ INT_PTR Meta_SendMessage(WPARAM wParam,LPARAM lParam) dbei.flags = DBEF_SENT; dbei.timestamp = time(NULL); dbei.eventType = EVENTTYPE_MESSAGE; - if(ccs->wParam & PREF_RTL) dbei.flags |= DBEF_RTL; - if(ccs->wParam & PREF_UTF) dbei.flags |= DBEF_UTF; + if (ccs->wParam & PREF_RTL) dbei.flags |= DBEF_RTL; + if (ccs->wParam & PREF_UTF) dbei.flags |= DBEF_UTF; dbei.cbBlob = (DWORD)strlen((char *)ccs->lParam) + 1; if ( ccs->wParam & PREF_UNICODE ) dbei.cbBlob *= ( sizeof( wchar_t )+1 ); @@ -435,8 +436,8 @@ INT_PTR MetaFilter_RecvMessage(WPARAM wParam,LPARAM lParam) return 0; } - if(options.set_default_on_recv) { - if(options.temp_default && DBGetContactSettingDword(hMeta, META_PROTO, "SavedDefault", (DWORD)-1) == (DWORD)-1) + if (options.set_default_on_recv) { + if (options.temp_default && DBGetContactSettingDword(hMeta, META_PROTO, "SavedDefault", (DWORD)-1) == (DWORD)-1) DBWriteContactSettingDword(hMeta, META_PROTO, "SavedDefault", DBGetContactSettingDword(hMeta, META_PROTO, "Default", 0)); DBWriteContactSettingDword(hMeta, META_PROTO, "Default", DBGetContactSettingDword(ccs->hContact, META_PROTO, "ContactNumber", 0)); NotifyEventHooks(hEventDefaultChanged, (WPARAM)hMeta, (LPARAM)ccs->hContact); // nick set in event handler @@ -451,7 +452,7 @@ INT_PTR MetaFilter_RecvMessage(WPARAM wParam,LPARAM lParam) // add a clist event, so that e.g. there is an icon flashing // (only add it when message api available, 'cause then we can remove the event when the message window is opened) - if(message_window_api_enabled + if (message_window_api_enabled && DBGetContactSettingByte(ccs->hContact, META_PROTO, "WindowOpen", 0) == 0 && DBGetContactSettingByte(hMeta, META_PROTO, "WindowOpen", 0) == 0 && options.flash_meta_message_icon) @@ -471,23 +472,23 @@ INT_PTR MetaFilter_RecvMessage(WPARAM wParam,LPARAM lParam) CallService(MS_CLIST_ADDEVENT, 0, (LPARAM) & cle); } - if(options.metahistory) { + if (options.metahistory) { BOOL added = FALSE; // should be able to do this, but some protos mess with the memory - if(options.use_proto_recv) + if (options.use_proto_recv) { // use the subcontact's protocol 'recv' service to add the meta's history (AIMOSCAR removes HTML here!) if possible char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)ccs->hContact, 0); - if(proto) { + if (proto) { char service[256]; HANDLE hSub = ccs->hContact; DWORD flags = pre->flags; mir_snprintf(service, 256, "%s%s", proto, PSR_MESSAGE); ccs->hContact = hMeta; pre->flags |= (DBGetContactSettingByte(hMeta, META_PROTO, "WindowOpen", 0) ? 0 : PREF_CREATEREAD); - if(ServiceExists(service) && !CallService(service, 0, (LPARAM)ccs)) + if (ServiceExists(service) && !CallService(service, 0, (LPARAM)ccs)) added = TRUE; ccs->hContact = hSub; pre->flags = flags; @@ -501,8 +502,8 @@ INT_PTR MetaFilter_RecvMessage(WPARAM wParam,LPARAM lParam) dbei.szModule = META_PROTO; dbei.timestamp = pre->timestamp; dbei.flags = (DBGetContactSettingByte(hMeta, META_PROTO, "WindowOpen", 0) ? 0 : DBEF_READ); - if(pre->flags & PREF_RTL) dbei.flags |= DBEF_RTL; - if(pre->flags & PREF_UTF) dbei.flags |= DBEF_UTF; + if (pre->flags & PREF_RTL) dbei.flags |= DBEF_RTL; + if (pre->flags & PREF_UTF) dbei.flags |= DBEF_UTF; dbei.eventType = EVENTTYPE_MESSAGE; dbei.cbBlob = (DWORD)strlen(pre->szMessage) + 1; if ( pre->flags & PREF_UNICODE ) { @@ -521,13 +522,13 @@ INT_PTR MetaFilter_RecvMessage(WPARAM wParam,LPARAM lParam) /* // add event to subcontact history (would do it in meta_recvmessage, but here we have the hcontact) // should be able to use the method below, except some protos can mess with the memory - if(options.subhistory) { + if (options.subhistory) { ZeroMemory(&dbei, sizeof(dbei)); dbei.cbSize = sizeof(dbei); dbei.szModule = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)ccs->hContact, 0); dbei.timestamp = pre->timestamp; dbei.flags = (DBGetContactSettingByte(ccs->hContact, META_PROTO, "WindowOpen", 0) ? 0 : DBEF_READ); - if(pre->flags & PREF_RTL) dbei.flags |= DBEF_RTL; + if (pre->flags & PREF_RTL) dbei.flags |= DBEF_RTL; dbei.eventType = EVENTTYPE_MESSAGE; dbei.cbBlob = strlen(pre->szMessage) + 1; if ( pre->flags & PREF_UNICODE ) @@ -546,7 +547,7 @@ INT_PTR MetaFilter_RecvMessage(WPARAM wParam,LPARAM lParam) ccs->hContact = hSub; } - if(options.subhistory && !(ccs->wParam & PREF_METANODB)) { + if (options.subhistory && !(ccs->wParam & PREF_METANODB)) { // allow event pass through and thereby be added to subcontact history pre->flags |= (DBGetContactSettingByte(ccs->hContact, META_PROTO, "WindowOpen", 0) ? 0 : PREF_CREATEREAD); CallService(MS_PROTO_CHAINRECV, wParam, (LPARAM)ccs); // pass through as normal @@ -575,12 +576,12 @@ INT_PTR Meta_RecvMessage(WPARAM wParam, LPARAM lParam) return 0; } - if(options.use_proto_recv) + if (options.use_proto_recv) { // use the subcontact's protocol to add the db if possible (AIMOSCAR removes HTML here!) HANDLE most_online = Meta_GetMostOnline(ccs->hContact); char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)most_online, 0); - if(proto) { + if (proto) { char service[256]; mir_snprintf(service, 256, "%s%s", proto, PSR_MESSAGE); if (CallService(service, wParam, lParam) != CALLSERVICE_NOTFOUND) @@ -595,8 +596,8 @@ INT_PTR Meta_RecvMessage(WPARAM wParam, LPARAM lParam) dbei.szModule = META_PROTO; dbei.timestamp = pre->timestamp; dbei.flags = (pre->flags & PREF_CREATEREAD ? DBEF_READ : 0); - if(pre->flags & PREF_RTL) dbei.flags |= DBEF_RTL; - if(pre->flags & PREF_UTF) dbei.flags |= DBEF_UTF; + if (pre->flags & PREF_RTL) dbei.flags |= DBEF_RTL; + if (pre->flags & PREF_UTF) dbei.flags |= DBEF_UTF; dbei.eventType = EVENTTYPE_MESSAGE; dbei.cbBlob = (DWORD)strlen(pre->szMessage) + 1; if ( pre->flags & PREF_UNICODE ) @@ -625,7 +626,7 @@ int Meta_HandleACK(WPARAM wParam, LPARAM lParam) ACKDATA *ack = (ACKDATA*) lParam; HANDLE hUser; - if(ack->hContact == 0 || (hUser = (HANDLE)DBGetContactSettingDword(ack->hContact,META_PROTO,"Handle",0)) == 0) + if (ack->hContact == 0 || (hUser = (HANDLE)DBGetContactSettingDword(ack->hContact,META_PROTO,"Handle",0)) == 0) return 0; // Can't find the MetaID, let through the protocol chain @@ -634,7 +635,7 @@ int Meta_HandleACK(WPARAM wParam, LPARAM lParam) } // if it's for something we don't support, ignore - if(ack->type != ACKTYPE_MESSAGE && ack->type != ACKTYPE_CHAT && ack->type != ACKTYPE_FILE && ack->type != ACKTYPE_AWAYMSG + if (ack->type != ACKTYPE_MESSAGE && ack->type != ACKTYPE_CHAT && ack->type != ACKTYPE_FILE && ack->type != ACKTYPE_AWAYMSG && ack->type != ACKTYPE_AVATAR && ack->type != ACKTYPE_GETINFO) { @@ -642,15 +643,15 @@ int Meta_HandleACK(WPARAM wParam, LPARAM lParam) } // change the hContact in the avatar info struct, if it's the avatar we're using - else drop it - if(ack->type == ACKTYPE_AVATAR) { - if(ack->result == ACKRESULT_SUCCESS || ack->result == ACKRESULT_FAILED || ack->result == ACKRESULT_STATUS) { + if (ack->type == ACKTYPE_AVATAR) { + if (ack->result == ACKRESULT_SUCCESS || ack->result == ACKRESULT_FAILED || ack->result == ACKRESULT_STATUS) { HANDLE most_online; DBVARIANT dbv; // change avatar if the most online supporting avatars changes, or if we don't have one most_online = Meta_GetMostOnlineSupporting(hUser, PFLAGNUM_4, PF4_AVATARS); - //if(AI.hContact == 0 || AI.hContact != most_online) { - if(ack->hContact == 0 || ack->hContact != most_online) { + //if (AI.hContact == 0 || AI.hContact != most_online) { + if (ack->hContact == 0 || ack->hContact != most_online) { return 0; } @@ -660,10 +661,10 @@ int Meta_HandleACK(WPARAM wParam, LPARAM lParam) DBFreeVariant(&dbv); } - if(ack->hProcess) { + if (ack->hProcess) { PROTO_AVATAR_INFORMATION AI; memcpy(&AI, (PROTO_AVATAR_INFORMATION *)ack->hProcess, sizeof(PROTO_AVATAR_INFORMATION)); - if(AI.hContact) + if (AI.hContact) AI.hContact = hUser; return ProtoBroadcastAck(META_PROTO,hUser,ack->type,ack->result, (HANDLE)&AI, ack->lParam); @@ -696,7 +697,7 @@ int Meta_SettingChanged(WPARAM wParam, LPARAM lParam) // hide metacontacts when groups disabled - if(wParam == 0 + if (wParam == 0 && ((strcmp(dcws->szModule, "CList") == 0 && strcmp(dcws->szSetting, "UseGroups") == 0) || (strcmp(dcws->szModule, META_PROTO) == 0 && strcmp(dcws->szSetting, "Enabled") == 0))) { @@ -704,7 +705,7 @@ int Meta_SettingChanged(WPARAM wParam, LPARAM lParam) return 0; } - if(wParam == 0 + if (wParam == 0 && strcmp(dcws->szModule, "Import") == 0 && strcmp(dcws->szSetting, "Completed") == 0) { // import process has just been run...call startup routines... @@ -724,7 +725,7 @@ int Meta_SettingChanged(WPARAM wParam, LPARAM lParam) Meta_SuppressStatus(options.suppress_status); } - if(wParam == 0 + if (wParam == 0 && strcmp(dcws->szModule, "CListGroups") == 0 && dcws->value.type != DBVT_DELETED && strcmp(dcws->value.pszVal, META_HIDDEN_GROUP) == 0) { // someone is creating our hidden group!! @@ -732,7 +733,7 @@ int Meta_SettingChanged(WPARAM wParam, LPARAM lParam) } // from here on, we're just interested in contact settings - if(wParam == 0) return 0; + if (wParam == 0) return 0; if ((hMeta=(HANDLE)DBGetContactSettingDword((HANDLE)wParam,META_PROTO,"Handle",0))!=0 && CallService(MS_DB_CONTACT_IS, (WPARAM)hMeta, 0)) // just to be safe @@ -740,7 +741,7 @@ int Meta_SettingChanged(WPARAM wParam, LPARAM lParam) { // This contact is attached to a MetaContact. contact_number = Meta_GetContactNumber((HANDLE)wParam); - if(contact_number == -1) return 0; // exit - db corruption + if (contact_number == -1) return 0; // exit - db corruption if (!meta_group_hack_disabled && !strcmp(dcws->szModule, "CList") && !strcmp(dcws->szSetting, "Group") && Meta_IsEnabled() && DBGetContactSettingByte((HANDLE)wParam, META_PROTO, "Hidden", 0) == 0 && !Miranda_Terminated()) { @@ -748,7 +749,7 @@ int Meta_SettingChanged(WPARAM wParam, LPARAM lParam) // subcontact group reassigned - copy to saved group MyDBWriteContactSetting((HANDLE)wParam, META_PROTO, "OldCListGroup", &dcws->value); DBWriteContactSettingString((HANDLE)wParam, "CList", "Group", META_HIDDEN_GROUP); - } else if(dcws->value.type == DBVT_DELETED) { + } else if (dcws->value.type == DBVT_DELETED) { DBDeleteContactSetting((HANDLE)wParam, META_PROTO, "OldCListGroup"); DBWriteContactSettingString((HANDLE)wParam, "CList", "Group", META_HIDDEN_GROUP); } @@ -756,7 +757,7 @@ int Meta_SettingChanged(WPARAM wParam, LPARAM lParam) // copy IP if (!strcmp(dcws->szSetting, "IP")) { - if(dcws->value.type == DBVT_DWORD) + if (dcws->value.type == DBVT_DWORD) DBWriteContactSettingDword(hMeta, META_PROTO, "IP", dcws->value.dVal); else DBDeleteContactSetting(hMeta, META_PROTO, "IP"); @@ -764,7 +765,7 @@ int Meta_SettingChanged(WPARAM wParam, LPARAM lParam) // copy RealIP if (!strcmp(dcws->szSetting, "RealIP")) { - if(dcws->value.type == DBVT_DWORD) + if (dcws->value.type == DBVT_DWORD) DBWriteContactSettingDword(hMeta, META_PROTO, "RealIP", dcws->value.dVal); else DBDeleteContactSetting(hMeta, META_PROTO, "RealIP"); @@ -797,7 +798,7 @@ int Meta_SettingChanged(WPARAM wParam, LPARAM lParam) strcat(buffer, _itoa(contact_number, buffer2, 10)); MyDBWriteContactSetting(hMeta, META_PROTO, buffer, &dcws->value); - if(MyDBGetContactSetting((HANDLE)wParam, "CList", "MyHandle", &dbv)) { + if (MyDBGetContactSetting((HANDLE)wParam, "CList", "MyHandle", &dbv)) { strcpy(buffer, "CListName"); strcat(buffer, _itoa(contact_number, buffer2, 10)); MyDBWriteContactSetting(hMeta, META_PROTO, buffer, &dcws->value); @@ -813,29 +814,29 @@ int Meta_SettingChanged(WPARAM wParam, LPARAM lParam) } else if (!strcmp(dcws->szSetting, "IdleTS")) { - if(dcws->value.type == DBVT_DWORD) + if (dcws->value.type == DBVT_DWORD) DBWriteContactSettingDword(hMeta, META_PROTO, "IdleTS", dcws->value.dVal); - else if(dcws->value.type == DBVT_DELETED) + else if (dcws->value.type == DBVT_DELETED) DBWriteContactSettingDword(hMeta, META_PROTO, "IdleTS", 0); } else if (!strcmp(dcws->szSetting, "LogonTS")) { - if(dcws->value.type == DBVT_DWORD) + if (dcws->value.type == DBVT_DWORD) DBWriteContactSettingDword(hMeta, META_PROTO, "LogonTS", dcws->value.dVal); - else if(dcws->value.type == DBVT_DELETED) + else if (dcws->value.type == DBVT_DELETED) DBWriteContactSettingDword(hMeta, META_PROTO, "LogonTS", 0); } else if (!strcmp(dcws->szModule, "CList") && !strcmp(dcws->szSetting, "MyHandle")) { HANDLE most_online; - if(dcws->value.type == DBVT_DELETED) { + if (dcws->value.type == DBVT_DELETED) { DBVARIANT dbv; char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); strcpy(buffer, "CListName"); strcat(buffer, _itoa(contact_number, buffer2, 10)); - if(proto && !MyDBGetContactSetting((HANDLE)wParam, proto, "Nick", &dbv)) { + if (proto && !MyDBGetContactSetting((HANDLE)wParam, proto, "Nick", &dbv)) { MyDBWriteContactSetting(hMeta, META_PROTO, buffer, &dbv); DBFreeVariant(&dbv); } else { @@ -883,7 +884,7 @@ int Meta_SettingChanged(WPARAM wParam, LPARAM lParam) // most online contact with avatar support might have changed - update avatar most_online = Meta_GetMostOnlineSupporting(hMeta, PFLAGNUM_4, PF4_AVATARS); - if(most_online) { + if (most_online) { PROTO_AVATAR_INFORMATION AI; AI.cbSize = sizeof(AI); @@ -896,11 +897,11 @@ int Meta_SettingChanged(WPARAM wParam, LPARAM lParam) } } else - if(strcmp(dcws->szSetting, "XStatusId") == 0 || strcmp(dcws->szSetting, "XStatusMsg") == 0 || strcmp(dcws->szSetting, "XStatusName") == 0 || strcmp(dcws->szSetting, "StatusMsg") == 0) { + if (strcmp(dcws->szSetting, "XStatusId") == 0 || strcmp(dcws->szSetting, "XStatusMsg") == 0 || strcmp(dcws->szSetting, "XStatusName") == 0 || strcmp(dcws->szSetting, "StatusMsg") == 0) { Meta_CopyData(hMeta); } else - if(strcmp(dcws->szSetting, "MirVer") == 0) { + if (strcmp(dcws->szSetting, "MirVer") == 0) { Meta_CopyData(hMeta); } else @@ -922,7 +923,7 @@ int Meta_ContactDeleted(WPARAM wParam, LPARAM lParam) { // is a subcontact - update meta contact hMeta = (HANDLE)DBGetContactSettingDword((HANDLE)wParam, META_PROTO, "Handle", 0); - if(hMeta) { + if (hMeta) { Meta_RemoveContactNumber(hMeta, DBGetContactSettingDword((HANDLE)wParam, META_PROTO, "ContactNumber", -1)); NotifyEventHooks(hSubcontactsChanged, (WPARAM)hMeta, 0); return 0; @@ -932,14 +933,14 @@ int Meta_ContactDeleted(WPARAM wParam, LPARAM lParam) { int i; HANDLE hContact; - if(num_contacts) NotifyEventHooks(hSubcontactsChanged, (WPARAM)wParam, 0); + if (num_contacts) NotifyEventHooks(hSubcontactsChanged, (WPARAM)wParam, 0); // remove & restore all subcontacts - for(i = 0; i < num_contacts; i++) { + for (i = 0; i < num_contacts; i++) { hContact = Meta_GetContactHandle((HANDLE)wParam, i); - if(hContact && (HANDLE)DBGetContactSettingDword(hContact, META_PROTO, "Handle", 0) == (HANDLE)wParam) { - if(DBGetContactSettingByte(hContact, META_PROTO, "IsSubcontact", 0) == 1) + if (hContact && (HANDLE)DBGetContactSettingDword(hContact, META_PROTO, "Handle", 0) == (HANDLE)wParam) { + if (DBGetContactSettingByte(hContact, META_PROTO, "IsSubcontact", 0) == 1) DBDeleteContactSetting(hContact,META_PROTO,"IsSubcontact"); DBDeleteContactSetting(hContact,META_PROTO,META_LINK); DBDeleteContactSetting(hContact,META_PROTO,"Handle"); @@ -949,7 +950,7 @@ int Meta_ContactDeleted(WPARAM wParam, LPARAM lParam) { CallService(MS_PROTO_REMOVEFROMCONTACT, (WPARAM)hContact, (LPARAM)META_FILTER); // stop ignoring, if we were - if(options.suppress_status) + if (options.suppress_status) CallService(MS_IGNORE_UNIGNORE, (WPARAM)hContact, (WPARAM)IGNOREEVENT_USERONLINE); } } @@ -970,7 +971,7 @@ INT_PTR Meta_UserIsTyping(WPARAM wParam, LPARAM lParam) char *proto; char buff[512]; - if(DBGetContactSettingDword((HANDLE)wParam,META_PROTO,META_ID,(DWORD)-1) == (DWORD)-1) + if (DBGetContactSettingDword((HANDLE)wParam,META_PROTO,META_ID,(DWORD)-1) == (DWORD)-1) { // This is a simple contact, let through the stack of protocols return 0; @@ -985,11 +986,11 @@ INT_PTR Meta_UserIsTyping(WPARAM wParam, LPARAM lParam) if (!most_online) return 0; proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)most_online, 0); - if(proto) { + if (proto) { strncpy(buff, proto, 512); strncpy(buff + strlen(proto), PSS_USERISTYPING, 512 - strlen(proto)); - if(ServiceExists(buff)) { + if (ServiceExists(buff)) { CallService(buff, (WPARAM)most_online, (LPARAM)lParam); } } @@ -1036,7 +1037,7 @@ int Meta_UserInfo(WPARAM wParam, LPARAM lParam) { DWORD default_contact_number = DBGetContactSettingDword((HANDLE)lParam, META_PROTO, "Default", (DWORD)-1); - if(default_contact_number == -1) // not a meta contact + if (default_contact_number == -1) // not a meta contact return 0; CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)Meta_GetContactHandle((HANDLE)lParam, default_contact_number), 0); @@ -1056,13 +1057,13 @@ int Meta_MessageWindowEvent(WPARAM wParam, LPARAM lParam) { || DBGetContactSettingDword(mwed->hContact, META_PROTO, META_ID, (DWORD)-1) != (DWORD)-1) { // contact is subcontact of metacontact, or an actual metacontact - record whether window is open or closed - if(mwed->uType == MSG_WINDOW_EVT_OPEN || mwed->uType == MSG_WINDOW_EVT_OPENING) { + if (mwed->uType == MSG_WINDOW_EVT_OPEN || mwed->uType == MSG_WINDOW_EVT_OPENING) { DBWriteContactSettingByte(mwed->hContact, META_PROTO, "WindowOpen", 1); - if(hMeta) { // subcontact window opened - remove clist events we added for metacontact + if (hMeta) { // subcontact window opened - remove clist events we added for metacontact while(!CallService(MS_CLIST_REMOVEEVENT, (WPARAM)hMeta, (LPARAM)mwed->hContact)); } - } else if(mwed->uType == MSG_WINDOW_EVT_CLOSE || mwed->uType == MSG_WINDOW_EVT_CLOSING) { + } else if (mwed->uType == MSG_WINDOW_EVT_CLOSE || mwed->uType == MSG_WINDOW_EVT_CLOSING) { DBWriteContactSettingByte(mwed->hContact, META_PROTO, "WindowOpen", 0); if (!hMeta) { // hMeta is 0 for metacontact (sorry) DWORD saved_def; @@ -1070,9 +1071,9 @@ int Meta_MessageWindowEvent(WPARAM wParam, LPARAM lParam) { MetaAPI_UnforceSendContact((WPARAM)mwed->hContact, 0); // restore saved default contact - if(options.set_default_on_recv) { + if (options.set_default_on_recv) { saved_def = DBGetContactSettingDword(mwed->hContact, META_PROTO, "SavedDefault", -1); - if(options.temp_default && saved_def != (DWORD)-1) { + if (options.temp_default && saved_def != (DWORD)-1) { DBWriteContactSettingDword(mwed->hContact, META_PROTO, "Default", saved_def); DBWriteContactSettingDword(mwed->hContact, META_PROTO, "SavedDefault", (DWORD)-1); NotifyEventHooks(hEventDefaultChanged, (WPARAM)mwed->hContact, (LPARAM)Meta_GetContactHandle(hMeta, saved_def)); // nick set in event handler @@ -1091,12 +1092,12 @@ int Meta_LoadIcons(WPARAM wParam, LPARAM lParam) { //MessageBox(0, "LoadIcons", "Event", MB_OK); - if(ServiceExists(MS_CLIST_EXTRA_ADD_ICON)) { + if (ServiceExists(MS_CLIST_EXTRA_ADD_ICON)) { int index = 0, i; CallService(MS_PROTO_ENUMPROTOCOLS,(WPARAM)&proto_count,(LPARAM)&protos); - for(i = 0; i < proto_count && i < MAX_PROTOCOLS; i++) { - if(protos[i]->type!=PROTOTYPE_PROTOCOL || CallProtoService(protos[i]->szName,PS_GETCAPS,PFLAGNUM_2,0)==0) + for (i = 0; i < proto_count && i < MAX_PROTOCOLS; i++) { + if (protos[i]->type!=PROTOTYPE_PROTOCOL || CallProtoService(protos[i]->szName,PS_GETCAPS,PFLAGNUM_2,0)==0) continue; strncpy(proto_names + (index * 128), protos[i]->szName, 128); @@ -1126,8 +1127,8 @@ int Meta_CListMW_ExtraIconsRebuild(WPARAM wParam, LPARAM lParam) { //MessageBox(0, "IconsRebuild", "Event", MB_OK); Meta_LoadIcons(0, 0); - if(ServiceExists(MS_CLIST_EXTRA_ADD_ICON)) { - for(i = 0; i < proto_count; i++) { + if (ServiceExists(MS_CLIST_EXTRA_ADD_ICON)) { + for (i = 0; i < proto_count; i++) { hExtraImage[i * 2] = (HANDLE)CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM)hProtoIcons[i * 2], 0); hExtraImage[i * 2 + 1] = (HANDLE)CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM)hProtoIcons[i * 2 + 1], 0); } @@ -1140,20 +1141,20 @@ int Meta_CListMW_ExtraIconsApply(WPARAM wParam, LPARAM lParam) { //MessageBox(0, "IconsApply", "Event", MB_OK); - if(DBGetContactSettingDword((HANDLE)wParam, META_PROTO, META_ID, (DWORD)-1) != (DWORD)-1) { - if(ServiceExists(MS_CLIST_EXTRA_SET_ICON)) { + if (DBGetContactSettingDword((HANDLE)wParam, META_PROTO, META_ID, (DWORD)-1) != (DWORD)-1) { + if (ServiceExists(MS_CLIST_EXTRA_SET_ICON)) { IconExtraColumn iec; HANDLE most_online_im = Meta_GetMostOnline((HANDLE)wParam); int i; - if(most_online_im) { + if (most_online_im) { char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)most_online_im, 0); - if(proto) { + if (proto) { WORD status = DBGetContactSettingWord(most_online_im, proto, "Status", ID_STATUS_OFFLINE); iec.cbSize = sizeof(iec); - for(i = 0; i < proto_count; i++) { + for (i = 0; i < proto_count; i++) { if (!strcmp((proto_names + i * 128), proto)) { - if(hExtraImage[i * 2 + (status == ID_STATUS_OFFLINE ? 1 : 0)]) { + if (hExtraImage[i * 2 + (status == ID_STATUS_OFFLINE ? 1 : 0)]) { iec.hImage = hExtraImage[i * 2 + (status == ID_STATUS_OFFLINE ? 1 : 0)]; iec.ColumnType = EXTRA_ICON_ADV2; CallService(MS_CLIST_EXTRA_SET_ICON, (WPARAM)wParam, (LPARAM)&iec); @@ -1172,7 +1173,7 @@ int Meta_CListMW_ExtraIconsApply(WPARAM wParam, LPARAM lParam) { */ int Meta_ClistDoubleClicked(WPARAM wParam, LPARAM lParam) { - if(DBGetContactSettingDword((HANDLE)wParam,META_PROTO,"Default",(WORD)-1) == (WORD)-1) + if (DBGetContactSettingDword((HANDLE)wParam,META_PROTO,"Default",(WORD)-1) == (WORD)-1) { // This is a simple contact return 0; @@ -1189,8 +1190,8 @@ int Meta_ClistDoubleClicked(WPARAM wParam, LPARAM lParam) { if (!most_online) return 0; - if(options.subcontact_windows) { - if(lParam) { + if (options.subcontact_windows) { + if (lParam) { // contact from incoming message in lParam via (at this point) clist message event CallService(MS_CLIST_CONTACTDOUBLECLICKED, (WPARAM)lParam, 0); } else { @@ -1201,7 +1202,7 @@ int Meta_ClistDoubleClicked(WPARAM wParam, LPARAM lParam) { } else { proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)most_online, 0); - if(proto) { + if (proto) { strcpy(buffer, proto); strcat(buffer, PS_GETCAPS); @@ -1237,7 +1238,7 @@ int NudgeRecieved(WPARAM wParam, LPARAM lParam) { /* // already being forwarded by someone HANDLE hMeta = (HANDLE)DBGetContactSettingDword((HANDLE)wParam,META_PROTO, "Handle", (DWORD)0); - if(hMeta) + if (hMeta) NotifyEventHooks(hEventNudge, (WPARAM)hMeta, 0); */ return 0; @@ -1250,15 +1251,14 @@ int NudgeRecieved(WPARAM wParam, LPARAM lParam) { */ int Meta_ModulesLoaded(WPARAM wParam, LPARAM lParam) { - CLISTMENUITEM menu = {0}; + CLISTMENUITEM mi = {0}; char buffer[512], buffer2[512], buffer3[512]; int i; - if(ServiceExists(MS_MSG_GETWINDOWAPI)) { + if (ServiceExists(MS_MSG_GETWINDOWAPI)) message_window_api_enabled = TRUE; - } - if(ServiceExists(MS_UPDATE_REGISTER)) { + if (ServiceExists(MS_UPDATE_REGISTER)) { // register with updater Update update = {0}; char szVersion[16]; @@ -1285,19 +1285,17 @@ int Meta_ModulesLoaded(WPARAM wParam, LPARAM lParam) CallService(MS_UPDATE_REGISTER, 0, (WPARAM)&update); } - // disable group hack for older nicer versions without the fix - if(ServiceExists(MS_CLUI_GETVERSION)) { + if (ServiceExists(MS_CLUI_GETVERSION)) { char *version = (char *)CallService(MS_CLUI_GETVERSION, 0, 0); - if(version && strlen(version) >= strlen("CList Nicer+") && strncmp(version, "CList Nicer+", strlen("CList Nicer+")) == 0) + if (version && strlen(version) >= strlen("CList Nicer+") && strncmp(version, "CList Nicer+", strlen("CList Nicer+")) == 0) meta_group_hack_disabled = TRUE; } // for database editor++ ver 3+ - if(ServiceExists("DBEditorpp/RegisterSingleModule")) + if (ServiceExists("DBEditorpp/RegisterSingleModule")) CallService("DBEditorpp/RegisterSingleModule",(WPARAM)META_PROTO,0); - hHooks[11] = (HANDLE)HookEvent(ME_CLIST_PREBUILDCONTACTMENU, Meta_ModifyMenu); hHooks[12] = (HANDLE)HookEvent(ME_CLIST_DOUBLECLICKED, Meta_ClistDoubleClicked ); //hHooks[13] = (HANDLE)HookEvent(ME_CLIST_EXTRA_LIST_REBUILD, Meta_CListMW_ExtraIconsRebuild); @@ -1307,56 +1305,60 @@ int Meta_ModulesLoaded(WPARAM wParam, LPARAM lParam) // (BUT, the me_clist_extra_list_rebuild is send FIRST...so, we ignore this one...) hHooks[15] = 0;//(HANDLE)HookEvent(ME_SKIN_ICONSCHANGED, Meta_LoadIcons); - menu.cbSize=sizeof(menu); - menu.flags = CMIM_ALL; + mi.cbSize = sizeof(mi); + mi.flags = CMIM_ALL; // main menu item - menu.pszName = "Toggle MetaContacts Off"; - menu.pszService = "MetaContacts/OnOff"; - menu.position = 500010000; - hMenuOnOff = (HANDLE)CallService(MS_CLIST_ADDMAINMENUITEM,0,(LPARAM)&menu); + mi.pszName = "Toggle MetaContacts Off"; + mi.pszService = "MetaContacts/OnOff"; + mi.position = 500010000; + hMenuOnOff = Menu_AddMainMenuItem(&mi); // contact menu items - menu.position = -200010; - menu.pszName = "Convert to MetaContact"; - menu.pszService = "MetaContacts/Convert"; - hMenuConvert = (HANDLE)CallService(MS_CLIST_ADDCONTACTMENUITEM,0,(LPARAM)&menu); - menu.position = -200009; - menu.pszName = "Add to existing MetaContact..."; - menu.pszService = "MetaContacts/AddTo"; - hMenuAdd = (HANDLE)CallService(MS_CLIST_ADDCONTACTMENUITEM,0,(LPARAM)&menu); - - menu.position = -200010; - menu.pszName = "Edit MetaContact..."; - menu.pszService = "MetaContacts/Edit"; - hMenuEdit = (HANDLE)CallService(MS_CLIST_ADDCONTACTMENUITEM,0,(LPARAM)&menu); - menu.position = -200009; - menu.pszName = "Set as MetaContact default"; - menu.pszService = "MetaContacts/Default"; - hMenuDefault = (HANDLE)CallService(MS_CLIST_ADDCONTACTMENUITEM,0,(LPARAM)&menu); - menu.position = -200008; - menu.pszName = "Delete MetaContact"; - menu.pszService = "MetaContacts/Delete"; - hMenuDelete = (HANDLE)CallService(MS_CLIST_ADDCONTACTMENUITEM,0,(LPARAM)&menu); - //menu.pszName = "Force Default"; - //menu.pszService = "MetaContacts/ForceDefault"; - //hMenuForceDefault = (HANDLE)CallService(MS_CLIST_ADDCONTACTMENUITEM,0,(LPARAM)&menu); - - menu.flags |= CMIF_HIDDEN; - menu.pszContactOwner = META_PROTO; - - menu.position = -99000; - for(i = 0; i < MAX_CONTACTS; i++) { - menu.position--; + mi.position = -200010; + mi.pszName = "Convert to MetaContact"; + mi.pszService = "MetaContacts/Convert"; + hMenuConvert = Menu_AddContactMenuItem(&mi); + + mi.position = -200009; + mi.pszName = "Add to existing MetaContact..."; + mi.pszService = "MetaContacts/AddTo"; + hMenuAdd = Menu_AddContactMenuItem(&mi); + + mi.position = -200010; + mi.pszName = "Edit MetaContact..."; + mi.pszService = "MetaContacts/Edit"; + hMenuEdit = Menu_AddContactMenuItem(&mi); + + mi.position = -200009; + mi.pszName = "Set as MetaContact default"; + mi.pszService = "MetaContacts/Default"; + hMenuDefault = Menu_AddContactMenuItem(&mi); + + mi.position = -200008; + mi.pszName = "Delete MetaContact"; + mi.pszService = "MetaContacts/Delete"; + hMenuDelete = Menu_AddContactMenuItem(&mi); + + //mi.pszName = "Force Default"; + //mi.pszService = "MetaContacts/ForceDefault"; + //hMenuForceDefault = Menu_AddContactMenuItem(&mi); + + mi.flags |= CMIF_HIDDEN; + mi.pszContactOwner = META_PROTO; + + mi.position = -99000; + for (i = 0; i < MAX_CONTACTS; i++) { + mi.position--; strcpy(buffer3, (char *)Translate("Context")); strcat(buffer3, _itoa(i, buffer2, 10)); - menu.pszName = buffer3; + mi.pszName = buffer3; strcpy(buffer, "MetaContacts/MenuFunc"); strcat(buffer, _itoa(i, buffer2, 10)); - menu.pszService= buffer; + mi.pszService= buffer; - hMenuContact[i] = (HANDLE)CallService(MS_CLIST_ADDCONTACTMENUITEM,0,(LPARAM)&menu); + hMenuContact[i] = Menu_AddContactMenuItem(&mi); } nextMetaID = DBGetContactSettingDword(NULL,META_PROTO,"NextMetaID",(DWORD)0); @@ -1365,7 +1367,7 @@ int Meta_ModulesLoaded(WPARAM wParam, LPARAM lParam) //hHooks[] = (HANDLE)HookEvent(ME_USERINFO_INITIALISE, Meta_UserInfo); // loop and copy data from subcontacts - if(options.copydata) { + if (options.copydata) { HANDLE hContact = ( HANDLE )CallService( MS_DB_CONTACT_FINDFIRST, 0, 0 ); int meta_id; while ( hContact != NULL ) { @@ -1383,9 +1385,9 @@ int Meta_ModulesLoaded(WPARAM wParam, LPARAM lParam) if (!Meta_IsEnabled()) { // modify main menu item - menu.flags = CMIM_NAME; - menu.pszName = "Toggle MetaContacts On"; - CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuOnOff, (LPARAM)&menu); + mi.flags = CMIM_NAME; + mi.pszName = "Toggle MetaContacts On"; + CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuOnOff, (LPARAM)&mi); Meta_HideMetaContacts(TRUE); } else { @@ -1394,7 +1396,7 @@ int Meta_ModulesLoaded(WPARAM wParam, LPARAM lParam) // hook srmm window close/open events - message api ver 0.0.0.1+ hHooks[16] = (HANDLE)HookEvent(ME_MSG_WINDOWEVENT, Meta_MessageWindowEvent); - if(hHooks[16]) // message api available + if (hHooks[16]) // message api available message_window_api_enabled = TRUE; // hook protocol nudge events to forward to subcontacts @@ -1404,16 +1406,16 @@ int Meta_ModulesLoaded(WPARAM wParam, LPARAM lParam) HANDLE hNudgeEvent = NULL; PROTOCOLDESCRIPTOR ** ppProtocolDescriptors; ret = CallService(MS_PROTO_ENUMPROTOCOLS,(WPARAM) &numberOfProtocols,(LPARAM)&ppProtocolDescriptors); - if(ret == 0) + if (ret == 0) { - for(i = 0; i < numberOfProtocols ; i++) + for (i = 0; i < numberOfProtocols ; i++) { - if(ppProtocolDescriptors[i]->type == PROTOTYPE_PROTOCOL) + if (ppProtocolDescriptors[i]->type == PROTOTYPE_PROTOCOL) { - if(strcmp(ppProtocolDescriptors[i]->szName, META_PROTO)) { + if (strcmp(ppProtocolDescriptors[i]->szName, META_PROTO)) { sprintf(str,"%s/Nudge",ppProtocolDescriptors[i]->szName); hNudgeEvent = HookEvent(str, NudgeRecieved); - if(hNudgeEvent != NULL) { + if (hNudgeEvent != NULL) { ++iNudgeProtos; hNudgeEvents = realloc(hNudgeEvents, sizeof(HANDLE) * iNudgeProtos); hNudgeEvents[iNudgeProtos - 1] = hNudgeEvent; @@ -1449,7 +1451,7 @@ INT_PTR Meta_ContactMenuFunc(WPARAM wParam, LPARAM lParam) { HANDLE hContact; hContact = Meta_GetContactHandle((HANDLE)wParam, (int)lParam); - if(options.menu_function == FT_MSG) { + if (options.menu_function == FT_MSG) { // open message window if protocol supports message sending or chat, else simulate double click int caps; @@ -1458,7 +1460,7 @@ INT_PTR Meta_ContactMenuFunc(WPARAM wParam, LPARAM lParam) { proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); - if(proto) { + if (proto) { strcpy(buffer, proto); strcat(buffer, PS_GETCAPS); @@ -1476,10 +1478,10 @@ INT_PTR Meta_ContactMenuFunc(WPARAM wParam, LPARAM lParam) { // protocol does not support messaging - simulate double click CallService(MS_CLIST_CONTACTDOUBLECLICKED, (WPARAM)hContact, 0); - } else if(options.menu_function == FT_MENU) { + } else if (options.menu_function == FT_MENU) { // show contact's context menu CallFunctionAsync(sttMenuThread, hContact); - } else if(options.menu_function == FT_INFO) { + } else if (options.menu_function == FT_INFO) { // show user info for subcontact CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)hContact, 0); } @@ -1497,7 +1499,7 @@ INT_PTR Meta_FileResume(WPARAM wParam, LPARAM lParam) CCSDATA *ccs = (CCSDATA *) lParam; char *proto = 0; - if(DBGetContactSetting(ccs->hContact,META_PROTO,"Default",&dbv)) + if (DBGetContactSetting(ccs->hContact,META_PROTO,"Default",&dbv)) { // This is a simple contact // (this should normally not happen, since linked contacts do not appear on the list.) @@ -1534,7 +1536,7 @@ INT_PTR Meta_FileAllow(WPARAM wParam, LPARAM lParam) CCSDATA *ccs = (CCSDATA *) lParam; char *proto = 0; - if(DBGetContactSetting(ccs->hContact,META_PROTO,"Default",&dbv)) + if (DBGetContactSetting(ccs->hContact,META_PROTO,"Default",&dbv)) { // This is a simple contact // (this should normally not happen, since linked contacts do not appear on the list.) @@ -1570,7 +1572,7 @@ INT_PTR Meta_FileDeny(WPARAM wParam, LPARAM lParam) CCSDATA *ccs = (CCSDATA *) lParam; char *proto = 0; - if(DBGetContactSetting(ccs->hContact,META_PROTO,"Default",&dbv)) + if (DBGetContactSetting(ccs->hContact,META_PROTO,"Default",&dbv)) { // This is a simple contact // (this should normally not happen, since linked contacts do not appear on the list.) @@ -1607,7 +1609,7 @@ INT_PTR Meta_FileRecv(WPARAM wParam, LPARAM lParam) CCSDATA *ccs = (CCSDATA *) lParam; char *proto = 0; - if(DBGetContactSetting(ccs->hContact,META_PROTO,"Default",&dbv)) + if (DBGetContactSetting(ccs->hContact,META_PROTO,"Default",&dbv)) { // This is a simple contact // (this should normally not happen, since linked contacts do not appear on the list.) @@ -1645,7 +1647,7 @@ int Meta_FileCancel(WPARAM wParam, LPARAM lParam) CCSDATA *ccs = (CCSDATA *) lParam; char *proto = 0; - if(DBGetContactSetting(ccs->hContact,META_PROTO,"Default",&dbv)) + if (DBGetContactSetting(ccs->hContact,META_PROTO,"Default",&dbv)) { // This is a simple contact // (this should normally not happen, since linked contacts do not appear on the list.) @@ -1706,7 +1708,7 @@ INT_PTR Meta_FileSend(WPARAM wParam, LPARAM lParam) proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)most_online, 0); //Meta_CopyContactNick(ccs->hContact, most_online, proto); - if(proto) { + if (proto) { //ccs->hContact = most_online; //Meta_SetNick(proto); @@ -1892,25 +1894,25 @@ int Meta_CallMostOnline(WPARAM wParam, LPARAM lParam) { INT_PTR Meta_OnOff(WPARAM wParam, LPARAM lParam) { - CLISTMENUITEM menu; - menu.cbSize = sizeof(CLISTMENUITEM); + CLISTMENUITEM mi; + mi.cbSize = sizeof(CLISTMENUITEM); // just write to db - the rest is handled in the Meta_SettingChanged function - if(DBGetContactSettingByte(0, META_PROTO, "Enabled", 1)) { + if (DBGetContactSettingByte(0, META_PROTO, "Enabled", 1)) { DBWriteContactSettingByte(0, META_PROTO, "Enabled", 0); - // modify main menu item - menu.flags = CMIM_NAME | CMIM_ICON; - menu.hIcon = LoadIconEx(I_MENU); - menu.pszName = "Toggle MetaContacts On"; - CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuOnOff, (LPARAM)&menu); + // modify main mi item + mi.flags = CMIM_NAME | CMIM_ICON; + mi.hIcon = LoadIconEx(I_MENU); + mi.pszName = "Toggle MetaContacts On"; + CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuOnOff, (LPARAM)&mi); } else { DBWriteContactSettingByte(0, META_PROTO, "Enabled", 1); - // modify main menu item - menu.flags = CMIM_NAME | CMIM_ICON; - menu.hIcon = LoadIconEx(I_MENUOFF); - menu.pszName = "Toggle MetaContacts Off"; - CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuOnOff, (LPARAM)&menu); + // modify main mi item + mi.flags = CMIM_NAME | CMIM_ICON; + mi.hIcon = LoadIconEx(I_MENUOFF); + mi.pszName = "Toggle MetaContacts Off"; + CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuOnOff, (LPARAM)&mi); } - ReleaseIconEx(menu.hIcon); + ReleaseIconEx(mi.hIcon); return 0; } @@ -1924,7 +1926,7 @@ int Meta_PreShutdown(WPARAM wParam, LPARAM lParam) { //MessageBox(0, "Status is OFFLINE", "MC", MB_OK); //MessageBox(0, "Preshutdown complete", "MC", MB_OK); - if(setStatusTimerId) KillTimer(0, setStatusTimerId); + if (setStatusTimerId) KillTimer(0, setStatusTimerId); return 0; } @@ -1949,9 +1951,9 @@ void Meta_InitServices() previousMode = mcStatus = ID_STATUS_OFFLINE; // set hooks pointers and services pointers to zero - in case we do not initialize them all correctly - for(i=0;itype == id->type) + if (dbv->type == id->type) { // If the id parameter and the value returned by the DBGetContactSetting // are the same, this is the correct HANDLE, return it. switch(dbv->type) @@ -59,13 +59,13 @@ int Meta_EqualDBV(DBVARIANT *dbv, DBVARIANT *id) { case DBVT_DELETED: return 1; case DBVT_BYTE: - if(dbv->bVal == id->bVal) + if (dbv->bVal == id->bVal) return 1; case DBVT_WORD: - if(dbv->wVal == id->wVal) + if (dbv->wVal == id->wVal) return 1; case DBVT_DWORD: - if(dbv->dVal == id->dVal) + if (dbv->dVal == id->dVal) return 1; break; case DBVT_ASCIIZ: @@ -76,18 +76,18 @@ int Meta_EqualDBV(DBVARIANT *dbv, DBVARIANT *id) { if (!wcscmp(dbv->pwszVal,id->pwszVal)) return 1; case DBVT_BLOB: - if(dbv->cpbVal == id->cpbVal) + if (dbv->cpbVal == id->cpbVal) { - for(i=dbv->cpbVal;res && i<=0;i--) + for (i=dbv->cpbVal;res && i<=0;i--) res = (dbv->pbVal[i] == id->pbVal[i]); - if(res) + if (res) { return 1; } } break; } // end switch - } // end if(dbv.type == id.type) + } // end if (dbv.type == id.type) return 0; } @@ -119,7 +119,7 @@ HANDLE Meta_GetHandle(const char *protocol, DBVARIANT *id) { // Scan the database and retrieve the field for each contact if (!DBGetContactSetting(hUser,protocol,field,&dbv)) { - if(dbv.type == id->type) + if (dbv.type == id->type) { // If the id parameter and the value returned by the DBGetContactSetting // are the same, this is the correct HANDLE, return it. switch(dbv.type) @@ -127,15 +127,15 @@ HANDLE Meta_GetHandle(const char *protocol, DBVARIANT *id) case DBVT_DELETED: break; case DBVT_BYTE: - if(dbv.bVal == id->bVal) + if (dbv.bVal == id->bVal) return hUser; break; case DBVT_WORD: - if(dbv.wVal == id->wVal) + if (dbv.wVal == id->wVal) return hUser; break; case DBVT_DWORD: - if(dbv.dVal == id->dVal) + if (dbv.dVal == id->dVal) return hUser; break; case DBVT_ASCIIZ: @@ -162,11 +162,11 @@ HANDLE Meta_GetHandle(const char *protocol, DBVARIANT *id) break; } case DBVT_BLOB: - if(dbv.cpbVal == id->cpbVal) + if (dbv.cpbVal == id->cpbVal) { - for(i=dbv.cpbVal;res && i<=0;i--) + for (i=dbv.cpbVal;res && i<=0;i--) res = (dbv.pbVal[i] == id->pbVal[i]); - if(res) + if (res) { DBFreeVariant(&dbv); return hUser; @@ -201,29 +201,29 @@ int Meta_SetNick(char *proto) ci.dwFlag = CNF_DISPLAY; ci.hContact = NULL; ci.szProto = proto; - if(CallService(MS_CONTACT_GETCONTACTINFO,0,(LPARAM)&ci)) + if (CallService(MS_CONTACT_GETCONTACTINFO,0,(LPARAM)&ci)) return 1; switch(ci.type) { case CNFT_BYTE: - if(DBWriteContactSettingByte(NULL,META_PROTO,"Nick",ci.bVal)) + if (DBWriteContactSettingByte(NULL,META_PROTO,"Nick",ci.bVal)) return 1; break; case CNFT_WORD: - if(DBWriteContactSettingWord(NULL,META_PROTO,"Nick",ci.wVal)) + if (DBWriteContactSettingWord(NULL,META_PROTO,"Nick",ci.wVal)) return 1; break; case CNFT_DWORD: - if(DBWriteContactSettingDword(NULL,META_PROTO,"Nick",ci.dVal)) + if (DBWriteContactSettingDword(NULL,META_PROTO,"Nick",ci.dVal)) return 1; break; case CNFT_ASCIIZ: - if(DBWriteContactSettingString(NULL,META_PROTO,"Nick",ci.pszVal)) + if (DBWriteContactSettingString(NULL,META_PROTO,"Nick",ci.pszVal)) return 1; mir_free(ci.pszVal); break; default: - if(DBWriteContactSettingString(NULL,META_PROTO,"Nick",(char *)Translate("Sender"))) + if (DBWriteContactSettingString(NULL,META_PROTO,"Nick",(char *)Translate("Sender"))) return 1; break; } @@ -264,20 +264,20 @@ BOOL Meta_Assign(HANDLE src, HANDLE dest, BOOL set_as_default) // Get the login of the subcontact field = (char *)CallProtoService(proto,PS_GETCAPS,PFLAG_UNIQUEIDSETTING,0); - if(DBGetContactSetting(src,proto,field,&cws.value)) { + if (DBGetContactSetting(src,proto,field,&cws.value)) { MessageBox(0, Translate("Could not get unique id of contact"), Translate("Assignment Error"), MB_OK | MB_ICONWARNING); return FALSE; } // Check that is is 'on the list' - if(DBGetContactSettingByte(src, "CList", "NotOnList", 0) == 1) { + if (DBGetContactSettingByte(src, "CList", "NotOnList", 0) == 1) { MessageBox(0, Translate("Contact is 'Not on List' - please add the contact to your contact list before assigning."), Translate("Assignment Error"), MB_OK | MB_ICONWARNING); DBFreeVariant(&cws.value); return FALSE; } num_contacts++; - if(num_contacts >= MAX_CONTACTS) { + if (num_contacts >= MAX_CONTACTS) { MessageBox(0, Translate("MetaContact is full"), Translate("Assignment Error"), MB_OK | MB_ICONWARNING); DBFreeVariant(&cws.value); return FALSE; @@ -287,7 +287,7 @@ BOOL Meta_Assign(HANDLE src, HANDLE dest, BOOL set_as_default) strcpy(buffer, "Protocol"); strcat(buffer, _itoa((int)(num_contacts -1), buffer2, 10)); - if(DBWriteContactSettingString(dest, META_PROTO, buffer, proto)) { + if (DBWriteContactSettingString(dest, META_PROTO, buffer, proto)) { MessageBox(0, Translate("Could not write contact protocol to MetaContact"), Translate("Assignment Error"), MB_OK | MB_ICONWARNING); DBFreeVariant(&cws.value); return FALSE; @@ -300,7 +300,7 @@ BOOL Meta_Assign(HANDLE src, HANDLE dest, BOOL set_as_default) cws.szModule=META_PROTO; cws.szSetting=buffer; - if(CallService(MS_DB_CONTACT_WRITESETTING,(WPARAM)dest,(LPARAM)&cws)) { + if (CallService(MS_DB_CONTACT_WRITESETTING,(WPARAM)dest,(LPARAM)&cws)) { MessageBox(0, Translate("Could not write unique id of contact to MetaContact"), Translate("Assignment Error"), MB_OK | MB_ICONWARNING); DBFreeVariant(&cws.value); return FALSE; @@ -317,7 +317,7 @@ BOOL Meta_Assign(HANDLE src, HANDLE dest, BOOL set_as_default) cws.szModule=META_PROTO; cws.szSetting=buffer; - if(CallService(MS_DB_CONTACT_WRITESETTING,(WPARAM)dest,(LPARAM)&cws)) { + if (CallService(MS_DB_CONTACT_WRITESETTING,(WPARAM)dest,(LPARAM)&cws)) { MessageBox(0, Translate("Could not write nickname of contact to MetaContact"), Translate("Assignment Error"), MB_OK | MB_ICONWARNING); return FALSE; } @@ -334,7 +334,7 @@ BOOL Meta_Assign(HANDLE src, HANDLE dest, BOOL set_as_default) strcpy(buffer, "CListName"); strcat(buffer, _itoa((int)(num_contacts - 1), buffer2, 10)); - if(wname && strncmp(name, (char *)wname, strlen(name)) != 0) { + if (wname && strncmp(name, (char *)wname, strlen(name)) != 0) { DBWriteContactSettingWString(dest, META_PROTO, buffer, wname); } else DBWriteContactSettingString(dest, META_PROTO, buffer, name); @@ -349,7 +349,7 @@ BOOL Meta_Assign(HANDLE src, HANDLE dest, BOOL set_as_default) // write the status strcpy(buffer, "Status"); strcat(buffer, _itoa((int)(num_contacts - 1), buffer2, 10)); - if(DBWriteContactSettingWord(dest, META_PROTO, buffer, status)) { + if (DBWriteContactSettingWord(dest, META_PROTO, buffer, status)) { MessageBox(0, Translate("Could not write contact status to MetaContact"), Translate("Assignment Error"), MB_OK | MB_ICONWARNING); return FALSE; } @@ -357,7 +357,7 @@ BOOL Meta_Assign(HANDLE src, HANDLE dest, BOOL set_as_default) // write the handle strcpy(buffer, "Handle"); strcat(buffer, _itoa((int)(num_contacts - 1), buffer2, 10)); - if(DBWriteContactSettingDword(dest, META_PROTO, buffer, (DWORD)src)) { + if (DBWriteContactSettingDword(dest, META_PROTO, buffer, (DWORD)src)) { MessageBox(0, Translate("Could not write contact handle to MetaContact"), Translate("Assignment Error"), MB_OK | MB_ICONWARNING); return FALSE; } @@ -366,7 +366,7 @@ BOOL Meta_Assign(HANDLE src, HANDLE dest, BOOL set_as_default) strcpy(buffer, "StatusString"); strcat(buffer, _itoa((int)(num_contacts - 1), buffer2, 10)); Meta_GetStatusString(status, buffer2, 512); - if(DBWriteContactSettingString(dest, META_PROTO, buffer, buffer2)) { + if (DBWriteContactSettingString(dest, META_PROTO, buffer, buffer2)) { MessageBox(0, Translate("Could not write contact status string to MetaContact"), Translate("Assignment Error"), MB_OK | MB_ICONWARNING); return FALSE; } @@ -377,30 +377,30 @@ BOOL Meta_Assign(HANDLE src, HANDLE dest, BOOL set_as_default) CallService( MS_PROTO_ADDTOCONTACT, (WPARAM)src, ( LPARAM )META_FILTER ); // Write the link in the contact - if(DBWriteContactSettingDword(src,META_PROTO,META_LINK,metaID)) { + if (DBWriteContactSettingDword(src,META_PROTO,META_LINK,metaID)) { MessageBox(0, Translate("Could not write MetaContact id to contact"), Translate("Assignment Error"), MB_OK | MB_ICONWARNING); return FALSE; } // Write the contact number in the contact - if(DBWriteContactSettingDword(src,META_PROTO,"ContactNumber",(DWORD)(num_contacts - 1))) { + if (DBWriteContactSettingDword(src,META_PROTO,"ContactNumber",(DWORD)(num_contacts - 1))) { MessageBox(0, Translate("Could not write MetaContact contact number to contact"), Translate("Assignment Error"), MB_OK | MB_ICONWARNING); return FALSE; } // Write the handle in the contact - if(DBWriteContactSettingDword(src,META_PROTO,"Handle",(DWORD)dest)) { + if (DBWriteContactSettingDword(src,META_PROTO,"Handle",(DWORD)dest)) { MessageBox(0, Translate("Could not write MetaContact contact number to contact"), Translate("Assignment Error"), MB_OK | MB_ICONWARNING); return FALSE; } // update count of contacts - if(DBWriteContactSettingDword(dest,META_PROTO,"NumContacts",num_contacts)) { + if (DBWriteContactSettingDword(dest,META_PROTO,"NumContacts",num_contacts)) { MessageBox(0, Translate("Could not write contact count to MetaContact"), Translate("Assignment Error"), MB_OK | MB_ICONWARNING); return FALSE; } - if(set_as_default) { + if (set_as_default) { DBWriteContactSettingDword(dest, META_PROTO, "Default", (WORD)(num_contacts - 1)); NotifyEventHooks(hEventDefaultChanged, (WPARAM)dest, (LPARAM)src); } @@ -415,7 +415,7 @@ BOOL Meta_Assign(HANDLE src, HANDLE dest, BOOL set_as_default) // if the new contact is the most online contact with avatar support, get avatar info most_online = Meta_GetMostOnlineSupporting(dest, PFLAGNUM_4, PF4_AVATARS); - if(most_online == src) { + if (most_online == src) { PROTO_AVATAR_INFORMATION AI; AI.cbSize = sizeof(AI); @@ -431,11 +431,11 @@ BOOL Meta_Assign(HANDLE src, HANDLE dest, BOOL set_as_default) Meta_SetGroup(src); // copy history - if(options.copy_subcontact_history) + if (options.copy_subcontact_history) copyHistory(src, dest); // Ignore status if the option is on - if(options.suppress_status) + if (options.suppress_status) CallService(MS_IGNORE_IGNORE, (WPARAM)src, (WPARAM)IGNOREEVENT_USERONLINE); // copy other data @@ -477,36 +477,36 @@ HANDLE Meta_GetMostOnlineSupporting(HANDLE hMeta, int pflagnum, unsigned long ca } // if the default is beyond the end of the list (eek!) return null - if(default_contact_number >= (num_contacts = DBGetContactSettingDword(hMeta, META_PROTO, "NumContacts", 0))) + if (default_contact_number >= (num_contacts = DBGetContactSettingDword(hMeta, META_PROTO, "NumContacts", 0))) return NULL; most_online_contact = Meta_GetContactHandle(hMeta, default_contact_number); proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)most_online_contact, 0); caps = proto ? CallProtoService(proto, PS_GETCAPS, (WPARAM)pflagnum, 0) : 0; - if(proto && strcmp(proto, "IRC") == 0) caps |= PF1_IM; + if (proto && strcmp(proto, "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(proto && DBGetContactSettingByte(hMeta, META_PROTO, "ForceDefault", 0) && capability != 0 && (capability == -1 || (caps & capability) == capability)) // capability is 0 when we're working out status + if (proto && DBGetContactSettingByte(hMeta, META_PROTO, "ForceDefault", 0) && capability != 0 && (capability == -1 || (caps & capability) == capability)) // capability is 0 when we're working out status return most_online_contact; // a subcontact is being temporarily 'forced' to do sending if ((most_online_contact = (HANDLE)DBGetContactSettingDword(hMeta, META_PROTO, "ForceSend", 0))) { caps = proto ? CallProtoService(proto, PS_GETCAPS, (WPARAM)pflagnum, 0) : 0; - if(proto && strcmp(proto, "IRC") == 0) caps |= PF1_IM; - if(proto && (caps & capability) == capability && capability != 0) // capability is 0 when we're working out status + if (proto && strcmp(proto, "IRC") == 0) caps |= PF1_IM; + if (proto && (caps & capability) == capability && capability != 0) // capability is 0 when we're working out status return most_online_contact; } most_online_contact = Meta_GetContactHandle(hMeta, default_contact_number); proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)most_online_contact, 0); - if(proto && CallProtoService(proto, PS_GETSTATUS, 0, 0) >= ID_STATUS_ONLINE) { + if (proto && CallProtoService(proto, PS_GETSTATUS, 0, 0) >= ID_STATUS_ONLINE) { caps = proto ? CallProtoService(proto, PS_GETCAPS, (WPARAM)pflagnum, 0) : 0; - if(proto && strcmp(proto, "IRC") == 0) caps |= PF1_IM; - if(proto && (capability == -1 || (caps & capability) == capability)) { + if (proto && strcmp(proto, "IRC") == 0) caps |= PF1_IM; + if (proto && (capability == -1 || (caps & capability) == capability)) { most_online_status = DBGetContactSettingWord(most_online_contact, proto, "Status", ID_STATUS_OFFLINE); // if our default is not offline, and option to use default is set - return default // and also if our default is online, return it - if(most_online_status == ID_STATUS_ONLINE || (most_online_status != ID_STATUS_OFFLINE && options.always_use_default)) { + if (most_online_status == ID_STATUS_ONLINE || (most_online_status != ID_STATUS_OFFLINE && options.always_use_default)) { return most_online_contact; } } else @@ -516,8 +516,8 @@ HANDLE Meta_GetMostOnlineSupporting(HANDLE hMeta, int pflagnum, unsigned long ca most_online_proto = proto; // otherwise, check all the subcontacts for the one closest to the ONLINE state which supports the required capability - for(i = 0; i < num_contacts; i++) { - if(i == default_contact_number) // already checked that (i.e. initial value of most_online_contact and most_online_status are those of the default contact) + for (i = 0; i < num_contacts; i++) { + if (i == default_contact_number) // already checked that (i.e. initial value of most_online_contact and most_online_status are those of the default contact) continue; hContact = Meta_GetContactHandle(hMeta, i); @@ -527,19 +527,19 @@ HANDLE Meta_GetMostOnlineSupporting(HANDLE hMeta, int pflagnum, unsigned long ca continue; caps = proto ? CallProtoService(proto, PS_GETCAPS, (WPARAM)pflagnum, 0) : 0; - if(proto && strcmp(proto, "IRC") == 0) caps |= PF1_IM; - if(proto && (capability == -1 || (caps & capability) == capability)) { + if (proto && strcmp(proto, "IRC") == 0) caps |= PF1_IM; + if (proto && (capability == -1 || (caps & capability) == capability)) { status = DBGetContactSettingWord(hContact, proto, "Status", ID_STATUS_OFFLINE); - if(status == ID_STATUS_ONLINE) { + if (status == ID_STATUS_ONLINE) { most_online_contact = hContact; most_online_proto = proto; return most_online_contact; - } else if(status <= ID_STATUS_OFFLINE) // status below ID_STATUS_OFFLINE is a connecting status + } else if (status <= ID_STATUS_OFFLINE) // status below ID_STATUS_OFFLINE is a connecting status continue; else { - if(GetRealPriority(proto, status) < GetRealPriority(most_online_proto, most_online_status)) { + if (GetRealPriority(proto, status) < GetRealPriority(most_online_proto, most_online_status)) { most_online_status = status; most_online_contact = hContact; most_online_proto = proto; @@ -549,9 +549,9 @@ HANDLE Meta_GetMostOnlineSupporting(HANDLE hMeta, int pflagnum, unsigned long ca } // no online contacts? if we're trying to message, use 'send offline' contact - if(most_online_status == ID_STATUS_OFFLINE && capability == PF1_IM) { + if (most_online_status == ID_STATUS_OFFLINE && capability == PF1_IM) { HANDLE hOffline = Meta_GetContactHandle(hMeta, DBGetContactSettingDword(hMeta, META_PROTO, "OfflineSend", (DWORD)-1)); - if(hOffline) + if (hOffline) most_online_contact = hOffline; } @@ -563,7 +563,7 @@ int Meta_GetContactNumber(HANDLE hContact) { } BOOL dbv_same(DBVARIANT *dbv1, DBVARIANT *dbv2) { - if(dbv1->type != dbv2->type) return FALSE; + if (dbv1->type != dbv2->type) return FALSE; switch(dbv1->type) { case DBVT_BYTE: @@ -597,36 +597,36 @@ BOOL dbv_same(DBVARIANT *dbv1, DBVARIANT *dbv2) { BOOL use_default = FALSE; int source_contact = (use_default ? default_contact : most_online); - if(source_contact < 0 || source_contact >= num_contacts) return; + if (source_contact < 0 || source_contact >= num_contacts) return; - for(i = 0; i < num_settings; i++) { + for (i = 0; i < num_settings; i++) { bDataWritten = FALSE; - for(j = 0; j < num_contacts && !bDataWritten; j++) { + for (j = 0; j < num_contacts && !bDataWritten; j++) { // do source (most online) first - if(j == 0) + if (j == 0) hContact = Meta_GetContactHandle(hMeta, source_contact); - else if(j <= source_contact) + else if (j <= source_contact) hContact = Meta_GetContactHandle(hMeta, j - 1); else hContact = Meta_GetContactHandle(hMeta, j); - if(hContact) { + if (hContact) { if (!module) { used_mod = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); if (!used_mod) continue; // next contact } else used_mod = module; - if(j == 0 && strcmp(settings[i], "MirVer") == 0) { //Always reset MirVer + if (j == 0 && strcmp(settings[i], "MirVer") == 0) { //Always reset MirVer DBDeleteContactSetting(hMeta, (module ? used_mod : META_PROTO), settings[i]); } got_val = !MyDBGetContactSetting(hContact, used_mod, settings[i], &dbv2); - if(got_val) { + if (got_val) { free = !MyDBGetContactSetting(hMeta, (module ? used_mod : META_PROTO), settings[i], &dbv1); - if(strcmp(settings[i], "MirVer") == 0) { - if(DBGetContactSettingWord(hContact, used_mod, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) { + if (strcmp(settings[i], "MirVer") == 0) { + if (DBGetContactSettingWord(hContact, used_mod, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) { if (!free || (dbv1.pszVal == NULL || strcmp(dbv1.pszVal, "") == 0 || strlen(dbv1.pszVal) < 2)) { MyDBWriteContactSetting(hMeta, (module ? used_mod : META_PROTO), settings[i], &dbv2); bDataWritten = TRUE; //only break if found something to copy @@ -636,11 +636,11 @@ BOOL dbv_same(DBVARIANT *dbv1, DBVARIANT *dbv2) { } else { if (!free || !dbv_same(&dbv1, &dbv2)) { MyDBWriteContactSetting(hMeta, (module ? used_mod : META_PROTO), settings[i], &dbv2); - if(dbv2.type == DBVT_ASCIIZ || dbv2.type == DBVT_UTF8) { - if(dbv2.pszVal != NULL && strcmp(dbv2.pszVal, "") != 0) + if (dbv2.type == DBVT_ASCIIZ || dbv2.type == DBVT_UTF8) { + if (dbv2.pszVal != NULL && strcmp(dbv2.pszVal, "") != 0) bDataWritten = TRUE; //only break if found something to copy - } else if(dbv2.type == DBVT_WCHAR) { - if(dbv2.pwszVal != 0 && wcscmp(dbv2.pwszVal, L"") != 0) + } else if (dbv2.type == DBVT_WCHAR) { + if (dbv2.pwszVal != 0 && wcscmp(dbv2.pwszVal, L"") != 0) bDataWritten = TRUE; //only break if found something to copy } else bDataWritten = TRUE; //only break if found something to copy @@ -650,7 +650,7 @@ BOOL dbv_same(DBVARIANT *dbv1, DBVARIANT *dbv2) { } DBFreeVariant(&dbv2); - if(free)DBFreeVariant(&dbv1); + if (free)DBFreeVariant(&dbv1); } } } @@ -695,17 +695,17 @@ void CopyStatusData(HANDLE hMeta) { BOOL bDoneStatus = FALSE, bDoneXStatus = FALSE; int i; - for(i = 0; i < num_contacts; i++) { - if(i == 0) + for (i = 0; i < num_contacts; i++) { + if (i == 0) hContact = Meta_GetContactHandle(hMeta, most_online); - else if(i <= most_online) + else if (i <= most_online) hContact = Meta_GetContactHandle(hMeta, i - 1); else hContact = Meta_GetContactHandle(hMeta, i); proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); - if(proto && DBGetContactSettingWord(hContact, proto, "Status", ID_STATUS_OFFLINE) == status) { + if (proto && DBGetContactSettingWord(hContact, proto, "Status", ID_STATUS_OFFLINE) == status) { if (!bDoneStatus && !MyDBGetContactSetting(hContact, "CList", "StatusMsg", &dbv)) { MyDBWriteContactSetting(hMeta, "CList", "StatusMsg", &dbv); DBFreeVariant(&dbv); @@ -728,7 +728,7 @@ void CopyStatusData(HANDLE hMeta) { } } - if(bDoneStatus && bDoneXStatus) break; + if (bDoneStatus && bDoneXStatus) break; } if (!bDoneStatus) DBDeleteContactSetting(hMeta, "CList", "StatusMsg"); @@ -740,14 +740,14 @@ void CopyStatusData(HANDLE hMeta) { } void Meta_CopyData(HANDLE hMeta) { - if(options.copydata) { + if (options.copydata) { CopyStatusData(hMeta); copy_settings_array(hMeta, 0, ProtoSettings, 25); copy_settings_array(hMeta, "mBirthday", UserInfoSettings, 3); copy_settings_array(hMeta, "ContactPhoto", ContactPhotoSettings, 5); - if(options.copy_userinfo) + if (options.copy_userinfo) copy_settings_array(hMeta, "UserInfo", UserInfoSettings, 71); } } @@ -757,7 +757,7 @@ HANDLE Meta_GetContactHandle(HANDLE hMeta, int contact_number) { char buffer[512], buffer2[512]; int num_contacts = DBGetContactSettingDword(hMeta, META_PROTO, "NumContacts", 0); - if(contact_number >= num_contacts || contact_number < 0) return 0; + if (contact_number >= num_contacts || contact_number < 0) return 0; strcpy(buffer, "Handle"); strcat(buffer, _itoa(contact_number, buffer2, 10)); @@ -784,7 +784,7 @@ int Meta_SetHandles(void) { strcat(nick_buffer, ", contact num: "); strcat(nick_buffer, _itoa(contact_number, buffer2, 10)); - if(contact_number < 0) { + if (contact_number < 0) { // problem! MessageBox(0, "Subcontact contact number < 0 - deleting MetaContact", nick_buffer, MB_OK | MB_ICONERROR); //CallService(MS_DB_CONTACT_DELETE, (WPARMA)hContact, 0); @@ -804,7 +804,7 @@ int Meta_SetHandles(void) { hContact2 = ( HANDLE )CallService( MS_DB_CONTACT_FINDFIRST, 0, 0 ); while ( hContact2 != NULL ) { - if(DBGetContactSettingDword(hContact2,META_PROTO,META_ID,(DWORD)-1) == meta_id) { + if (DBGetContactSettingDword(hContact2,META_PROTO,META_ID,(DWORD)-1) == meta_id) { found = TRUE; // set handle @@ -815,7 +815,7 @@ int Meta_SetHandles(void) { (unsigned char)(DBGetContactSettingByte(hContact2, META_PROTO, "ContactCountCheck", 0) + 1)); num_contacts = DBGetContactSettingDword(hContact2, META_PROTO, "NumContacts", (DWORD)-1); - if(contact_number >= 0 && contact_number < num_contacts) { + if (contact_number >= 0 && contact_number < num_contacts) { // set metacontact's handle to us strcpy(buffer, "Handle"); strcat(buffer, _itoa((int)contact_number, buffer2, 10)); @@ -851,7 +851,7 @@ int Meta_SetHandles(void) { CallService(MS_PROTO_REMOVEFROMCONTACT, (WPARAM)hContact, (LPARAM)META_FILTER); // stop ignoring, if we were - if(options.suppress_status) + if (options.suppress_status) CallService(MS_IGNORE_UNIGNORE, (WPARAM)hContact, (WPARAM)IGNOREEVENT_USERONLINE); } else { @@ -876,7 +876,7 @@ int Meta_SetHandles(void) { contact_number = DBGetContactSettingDword(hContact, META_PROTO, "Default", -1); num_contacts = DBGetContactSettingDword(hContact, META_PROTO, "NumContacts", (DWORD)-1); - if(num_contacts < 0) { + if (num_contacts < 0) { // problem MessageBox(0, "MetaContact number of contacts < 0 - deleting MetaContact", nick_buffer, MB_OK | MB_ICONERROR); //CallService(MS_DB_CONTACT_DELETE, (WPARMA)hContact, 0); @@ -887,7 +887,7 @@ int Meta_SetHandles(void) { //return 1; } - if(contact_number < 0 || contact_number >= num_contacts) { + if (contact_number < 0 || contact_number >= num_contacts) { // problem MessageBox(0, "MetaContact default contact number out of range - deleting MetaContact", nick_buffer, MB_OK | MB_ICONERROR); hNextContact = ( HANDLE )CallService( MS_DB_CONTACT_FINDNEXT,( WPARAM )hContact, 0 ); @@ -911,9 +911,9 @@ int Meta_SetHandles(void) { strcat(nick_buffer, _itoa(meta_id, buffer2, 10)); num_contacts = DBGetContactSettingByte(hContact, META_PROTO, "ContactCountCheck", -2); - if(num_contacts != (DWORD)DBGetContactSettingDword(hContact, META_PROTO, "NumContacts", (DWORD)-1)) { + if (num_contacts != (DWORD)DBGetContactSettingDword(hContact, META_PROTO, "NumContacts", (DWORD)-1)) { // mismatch - //if(MessageBox(0, Translate("MetaContact corrupted - the number of subcontacts is incorrect.\nDelete MetaContact?"), nick_buffer, MB_YESNO | MB_ICONERROR) == IDYES) { + //if (MessageBox(0, Translate("MetaContact corrupted - the number of subcontacts is incorrect.\nDelete MetaContact?"), nick_buffer, MB_YESNO | MB_ICONERROR) == IDYES) { // Meta_Delete((WPARAM)hContact, (LPARAM)1); // second param prevents confirm dialog //} else // return 1; @@ -950,7 +950,7 @@ int Meta_HideLinkedContacts(void) { // (sometimes protocol server side groups are to blame - msn and icq) if (!meta_group_hack_disabled) do { group_name = (char *)CallService(MS_CLIST_GROUPGETNAME, (WPARAM)hGroup, 0); - if(group_name && !strcmp(group_name, META_HIDDEN_GROUP)) { + if (group_name && !strcmp(group_name, META_HIDDEN_GROUP)) { // disabled because it shows a message box //CallService(MS_CLIST_GROUPDELETE, (WPARAM)hGroup, 0); MessageBox(0, Translate("The 'MetaContacts Hidden Group' has been added to your contact list.\n" @@ -988,9 +988,9 @@ int Meta_HideLinkedContacts(void) { hContact2 = ( HANDLE )CallService( MS_DB_CONTACT_FINDFIRST, 0, 0 ); while ( hContact2 != NULL ) { - if(DBGetContactSettingDword(hContact2,META_PROTO,META_ID,(DWORD)-1) == meta_id) { + if (DBGetContactSettingDword(hContact2,META_PROTO,META_ID,(DWORD)-1) == meta_id) { num_contacts = DBGetContactSettingDword(hContact2, META_PROTO, "NumContacts", (DWORD)-1); - if(contact_number >= 0 && contact_number < num_contacts) { + if (contact_number >= 0 && contact_number < num_contacts) { if (!proto) status = ID_STATUS_OFFLINE; @@ -1003,14 +1003,14 @@ int Meta_HideLinkedContacts(void) { DBWriteContactSettingWord(hContact2, META_PROTO, buffer, status); // update metacontact's record of nick for this contact - if(proto && !DBGetContactSetting(hContact, proto, "Nick", &dbv)) { + if (proto && !DBGetContactSetting(hContact, proto, "Nick", &dbv)) { strcpy(buffer, "Nick"); strcat(buffer, _itoa(contact_number, buffer2, 10)); MyDBWriteContactSetting(hContact2, META_PROTO, buffer, &dbv); strcpy(buffer, "CListName"); strcat(buffer, _itoa(contact_number, buffer2, 10)); - if(DBGetContactSetting(hContact, "CList", "MyHandle", &dbv2)) { + if (DBGetContactSetting(hContact, "CList", "MyHandle", &dbv2)) { MyDBWriteContactSetting(hContact2, META_PROTO, buffer, &dbv); } else { MyDBWriteContactSetting(hContact2, META_PROTO, buffer, &dbv2); @@ -1032,7 +1032,7 @@ int Meta_HideLinkedContacts(void) { hContact2 = ( HANDLE )CallService( MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact2, 0 ); } - if(options.suppress_status) + if (options.suppress_status) CallService(MS_IGNORE_IGNORE, (WPARAM)hContact, (WPARAM)IGNOREEVENT_USERONLINE); } @@ -1042,7 +1042,7 @@ int Meta_HideLinkedContacts(void) { // do metacontacts after handles set properly above hContact = ( HANDLE )CallService( MS_DB_CONTACT_FINDFIRST, 0, 0 ); while ( hContact != NULL ) { - if(DBGetContactSettingDword(hContact,META_PROTO,META_ID,(DWORD)-1)!=(DWORD)-1) { + if (DBGetContactSettingDword(hContact,META_PROTO,META_ID,(DWORD)-1)!=(DWORD)-1) { // is a meta contact HANDLE hMostOnline = Meta_GetMostOnline(hContact); // set nick Meta_CopyContactNick(hContact, hMostOnline); @@ -1065,7 +1065,7 @@ int Meta_UnhideLinkedContacts(void) { HANDLE hContact = ( HANDLE )CallService( MS_DB_CONTACT_FINDFIRST, 0, 0 ); while ( hContact != NULL ) { - if(DBGetContactSettingDword(hContact,META_PROTO,META_LINK,(DWORD)-1)!=(DWORD)-1) { + if (DBGetContactSettingDword(hContact,META_PROTO,META_LINK,(DWORD)-1)!=(DWORD)-1) { // has a link - unhide it // restore old group Meta_RestoreGroup(hContact); @@ -1083,21 +1083,21 @@ int Meta_HideMetaContacts(int hide) { HANDLE hContact = ( HANDLE )CallService( MS_DB_CONTACT_FINDFIRST, 0, 0 ); // set status suppression - if(hide) Meta_SuppressStatus(FALSE); + if (hide) Meta_SuppressStatus(FALSE); else Meta_SuppressStatus(options.suppress_status); while ( hContact != NULL ) { - if(DBGetContactSettingDword(hContact,META_PROTO,META_ID,(DWORD)-1)!=(DWORD)-1) { + if (DBGetContactSettingDword(hContact,META_PROTO,META_ID,(DWORD)-1)!=(DWORD)-1) { // is a meta contact - if(hide) + if (hide) DBWriteContactSettingByte(hContact, "CList", "Hidden", 1); else DBDeleteContactSetting(hContact, "CList", "Hidden"); - } else if(DBGetContactSettingDword(hContact,META_PROTO,META_LINK,(DWORD)-1)!=(DWORD)-1) { + } else if (DBGetContactSettingDword(hContact,META_PROTO,META_LINK,(DWORD)-1)!=(DWORD)-1) { // when metacontacts are hidden, show subcontacts, and vice versa - if(hide) { + if (hide) { Meta_RestoreGroup(hContact); } else { Meta_SetGroup(hContact); @@ -1114,16 +1114,16 @@ int Meta_HideMetaContacts(int hide) { void Meta_RestoreGroup(HANDLE hContact) { - if(meta_group_hack_disabled) return; // clist has called api function to disable group hack - yay! + if (meta_group_hack_disabled) return; // clist has called api function to disable group hack - yay! // the existence of this service means that clist_meta_mw is active and will do the hiding for us - if(ServiceExists(MS_CLUI_METASUPPORT)) return; + if (ServiceExists(MS_CLUI_METASUPPORT)) return; // show it anyway - users are reporting contacts removed from meta remain 'hidden' // possible suspect - server side groups cause hidden group hack to fail, users hide contacts via clist->delete->hide option DBDeleteContactSetting(hContact, META_PROTO, "Hidden"); - if(DBGetContactSettingByte(hContact, META_PROTO, "Hidden", 0) == 1) + if (DBGetContactSettingByte(hContact, META_PROTO, "Hidden", 0) == 1) { // if we hid it, unhide it DBDeleteContactSetting(hContact, META_PROTO, "Hidden"); @@ -1141,14 +1141,14 @@ void Meta_RestoreGroup(HANDLE hContact) { BOOL found = FALSE; do { name = (char *)CallService(MS_CLIST_GROUPGETNAME, (WPARAM)hGroup, 0); - if(name && !strcmp(name, cws.value.pszVal)) { + if (name && !strcmp(name, cws.value.pszVal)) { found = TRUE; break; } hGroup++; } while(name); - if(found) { + if (found) { cws.szModule = "CList"; cws.szSetting = "Group"; CallService(MS_DB_CONTACT_WRITESETTING,(WPARAM)hContact,(LPARAM)&cws); @@ -1157,7 +1157,7 @@ void Meta_RestoreGroup(HANDLE hContact) { // put back into metacontact's group DBVARIANT dbv; HANDLE hMeta = (HANDLE)DBGetContactSettingDword(hContact, META_PROTO, "Handle", 0); - if(hMeta && !MyDBGetContactSetting(hMeta, "CList", "Group", &dbv)) { + if (hMeta && !MyDBGetContactSetting(hMeta, "CList", "Group", &dbv)) { MyDBWriteContactSetting(hContact, "CList", "Group", &dbv); DBFreeVariant(&dbv); } else @@ -1184,16 +1184,16 @@ void Meta_RestoreGroup(HANDLE hContact) { void Meta_SetGroup(HANDLE hContact) { char *proto, *uid; - if(meta_group_hack_disabled) return; // clist has called api function to disable group hack - yay! + if (meta_group_hack_disabled) return; // clist has called api function to disable group hack - yay! // the existence of this service means that clist_meta_mw is active and will do the hiding for us - if(ServiceExists(MS_CLUI_METASUPPORT)) return; + if (ServiceExists(MS_CLUI_METASUPPORT)) return; proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); if (proto) uid = (char *)CallProtoService(proto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); - if(proto && uid && (INT_PTR)uid != CALLSERVICE_NOTFOUND && !strcmp(JABBER_UNIQUE_ID_SETTING, uid)) { + if (proto && uid && (INT_PTR)uid != CALLSERVICE_NOTFOUND && !strcmp(JABBER_UNIQUE_ID_SETTING, uid)) { // if it's a jabber contact, hide it, and record the fact that it was us who did DBWriteContactSettingByte(hContact, META_PROTO, "Hidden", 1); DBWriteContactSettingByte(hContact, "CList", "Hidden", 1); @@ -1261,9 +1261,9 @@ int Meta_SuppressStatus(BOOL suppress) { HANDLE hContact = ( HANDLE )CallService( MS_DB_CONTACT_FINDFIRST, 0, 0 ); while ( hContact != NULL ) { - if(DBGetContactSettingDword(hContact,META_PROTO,META_LINK,(DWORD)-1)!=(DWORD)-1) { + if (DBGetContactSettingDword(hContact,META_PROTO,META_LINK,(DWORD)-1)!=(DWORD)-1) { // is a subcontact - if(suppress) + if (suppress) CallService(MS_IGNORE_IGNORE, (WPARAM)hContact, (WPARAM)IGNOREEVENT_USERONLINE); else CallService(MS_IGNORE_UNIGNORE, (WPARAM)hContact, (WPARAM)IGNOREEVENT_USERONLINE); @@ -1279,7 +1279,7 @@ int Meta_CopyContactNick(HANDLE hMeta, HANDLE hContact) { DBVARIANT dbv, dbv_proto; char *proto; - if(options.lockHandle) { + if (options.lockHandle) { hContact = Meta_GetContactHandle(hMeta, 0); } @@ -1290,7 +1290,7 @@ int Meta_CopyContactNick(HANDLE hMeta, HANDLE hContact) { if (!DBGetContactSetting(hContact, "Protocol", "p", &dbv_proto)) { proto = dbv_proto.pszVal; - if(options.clist_contact_name == CNNT_NICK && proto) { + if (options.clist_contact_name == CNNT_NICK && proto) { if (!MyDBGetContactSetting(hContact, proto, "Nick", &dbv)) { MyDBWriteContactSetting(hMeta, META_PROTO, "Nick", &dbv); DBFreeVariant(&dbv); @@ -1299,12 +1299,12 @@ int Meta_CopyContactNick(HANDLE hMeta, HANDLE hContact) { DBFreeVariant(&dbv_proto); return 0; } - } else if(options.clist_contact_name == CNNT_DISPLAYNAME) { + } else if (options.clist_contact_name == CNNT_DISPLAYNAME) { char *name = (char *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, 0); wchar_t *wname = (wchar_t *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_UNICODE); - if(name && strcmp(name, Translate("(Unknown Contact)")) != 0) { - if(wname && strncmp(name, (char *)wname, strlen(name)) != 0) { + if (name && strcmp(name, Translate("(Unknown Contact)")) != 0) { + if (wname && strncmp(name, (char *)wname, strlen(name)) != 0) { DBVARIANT dbv; dbv.pwszVal = wname; dbv.type = DBVT_WCHAR; @@ -1327,7 +1327,7 @@ int Meta_SetAllNicks() { HANDLE hContact = ( HANDLE )CallService( MS_DB_CONTACT_FINDFIRST, 0, 0 ), most_online; while ( hContact != NULL ) { - if(DBGetContactSettingDword(hContact,META_PROTO,META_ID,(DWORD)-1)!=(DWORD)-1) { + if (DBGetContactSettingDword(hContact,META_PROTO,META_ID,(DWORD)-1)!=(DWORD)-1) { most_online = Meta_GetMostOnline(hContact); Meta_CopyContactNick(hContact, most_online); Meta_FixStatus(hContact); @@ -1340,7 +1340,7 @@ int Meta_SetAllNicks() { } int Meta_IsHiddenGroup(const char *group_name) { - if(group_name && !strcmp(group_name, META_HIDDEN_GROUP)) return 1; + if (group_name && !strcmp(group_name, META_HIDDEN_GROUP)) return 1; return 0; } @@ -1360,11 +1360,11 @@ int Meta_SwapContacts(HANDLE hMeta, DWORD contact_number1, DWORD contact_number2 strcat(buff2, _itoa(contact_number2, buff22, 10)); ok1 = !MyDBGetContactSetting(hMeta, META_PROTO, buff1, &dbv1); ok2 = !MyDBGetContactSetting(hMeta, META_PROTO, buff2, &dbv2); - if(ok1) { + if (ok1) { MyDBWriteContactSetting(hMeta, META_PROTO, buff2, &dbv1); DBFreeVariant(&dbv1); } - if(ok2) { + if (ok2) { MyDBWriteContactSetting(hMeta, META_PROTO, buff1, &dbv2); DBFreeVariant(&dbv2); } @@ -1376,11 +1376,11 @@ int Meta_SwapContacts(HANDLE hMeta, DWORD contact_number1, DWORD contact_number2 strcat(buff2, _itoa(contact_number2, buff22, 10)); ok1 = !MyDBGetContactSetting(hMeta, META_PROTO, buff1, &dbv1); ok1 = !MyDBGetContactSetting(hMeta, META_PROTO, buff2, &dbv2); - if(ok1) { + if (ok1) { MyDBWriteContactSetting(hMeta, META_PROTO, buff2, &dbv1); DBFreeVariant(&dbv1); } - if(ok2) { + if (ok2) { MyDBWriteContactSetting(hMeta, META_PROTO, buff1, &dbv2); DBFreeVariant(&dbv2); } @@ -1392,11 +1392,11 @@ int Meta_SwapContacts(HANDLE hMeta, DWORD contact_number1, DWORD contact_number2 strcat(buff2, _itoa(contact_number2, buff22, 10)); ok1 = !MyDBGetContactSetting(hMeta, META_PROTO, buff1, &dbv1); ok2 = !MyDBGetContactSetting(hMeta, META_PROTO, buff2, &dbv2); - if(ok1) { + if (ok1) { MyDBWriteContactSetting(hMeta, META_PROTO, buff2, &dbv1); DBFreeVariant(&dbv1); } - if(ok2) { + if (ok2) { MyDBWriteContactSetting(hMeta, META_PROTO, buff1, &dbv2); DBFreeVariant(&dbv2); } @@ -1408,12 +1408,12 @@ int Meta_SwapContacts(HANDLE hMeta, DWORD contact_number1, DWORD contact_number2 strcat(buff2, _itoa(contact_number2, buff22, 10)); ok1 = !MyDBGetContactSetting(hMeta, META_PROTO, buff1, &dbv1); ok2 = !MyDBGetContactSetting(hMeta, META_PROTO, buff2, &dbv2); - if(ok1) { + if (ok1) { DBDeleteContactSetting(hMeta, META_PROTO, buff2); MyDBWriteContactSetting(hMeta, META_PROTO, buff2, &dbv1); DBFreeVariant(&dbv1); } - if(ok2) { + if (ok2) { DBDeleteContactSetting(hMeta, META_PROTO, buff1); MyDBWriteContactSetting(hMeta, META_PROTO, buff1, &dbv2); DBFreeVariant(&dbv2); @@ -1426,13 +1426,13 @@ int Meta_SwapContacts(HANDLE hMeta, DWORD contact_number1, DWORD contact_number2 strcat(buff2, _itoa(contact_number2, buff22, 10)); ok1 = !MyDBGetContactSetting(hMeta, META_PROTO, buff1, &dbv1); ok2 = !MyDBGetContactSetting(hMeta, META_PROTO, buff2, &dbv2); - if(ok1) { + if (ok1) { MyDBWriteContactSetting(hMeta, META_PROTO, buff2, &dbv1); DBFreeVariant(&dbv1); } else { DBDeleteContactSetting(hMeta, META_PROTO, buff2); } - if(ok2) { + if (ok2) { MyDBWriteContactSetting(hMeta, META_PROTO, buff1, &dbv2); DBFreeVariant(&dbv2); } else { @@ -1446,13 +1446,13 @@ int Meta_SwapContacts(HANDLE hMeta, DWORD contact_number1, DWORD contact_number2 strcat(buff2, _itoa(contact_number2, buff22, 10)); ok1 = !MyDBGetContactSetting(hMeta, META_PROTO, buff1, &dbv1); ok2 = !MyDBGetContactSetting(hMeta, META_PROTO, buff2, &dbv2); - if(ok1) { + if (ok1) { MyDBWriteContactSetting(hMeta, META_PROTO, buff2, &dbv1); DBFreeVariant(&dbv1); } else { DBDeleteContactSetting(hMeta, META_PROTO, buff2); } - if(ok2) { + if (ok2) { MyDBWriteContactSetting(hMeta, META_PROTO, buff1, &dbv2); DBFreeVariant(&dbv2); } else { @@ -1466,13 +1466,13 @@ int Meta_SwapContacts(HANDLE hMeta, DWORD contact_number1, DWORD contact_number2 strcat(buff2, _itoa(contact_number2, buff22, 10)); ok1 = !MyDBGetContactSetting(hMeta, META_PROTO, buff1, &dbv1); ok2 = !MyDBGetContactSetting(hMeta, META_PROTO, buff2, &dbv2); - if(ok1) { + if (ok1) { MyDBWriteContactSetting(hMeta, META_PROTO, buff2, &dbv1); DBFreeVariant(&dbv1); } else { DBDeleteContactSetting(hMeta, META_PROTO, buff2); } - if(ok2) { + if (ok2) { MyDBWriteContactSetting(hMeta, META_PROTO, buff1, &dbv2); DBFreeVariant(&dbv2); } else { @@ -1544,15 +1544,15 @@ void copyHistory(HANDLE hContactFrom,HANDLE hContactTo) break; // i.e. optoins.days_history == 0; - if(time_now == earliest_time) earliest_time = dbei.timestamp; + if (time_now == earliest_time) earliest_time = dbei.timestamp; - if(dbei.timestamp < earliest_time) + if (dbei.timestamp < earliest_time) continue; - if(dbei.eventType != EVENTTYPE_MESSAGE && dbei.eventType != EVENTTYPE_FILE && dbei.eventType != EVENTTYPE_URL) + if (dbei.eventType != EVENTTYPE_MESSAGE && dbei.eventType != EVENTTYPE_FILE && dbei.eventType != EVENTTYPE_URL) continue; - if(time_now > earliest_time) { // just in case! + if (time_now > earliest_time) { // just in case! SendMessage(prog, PBM_SETPOS, (WPARAM)(int)(100.0 * (dbei.timestamp - earliest_time) / (time_now - earliest_time)), 0); UpdateWindow(progress_dialog); } @@ -1567,7 +1567,7 @@ void copyHistory(HANDLE hContactFrom,HANDLE hContactTo) //CallService(MS_DB_SETSAFETYMODE, (WPARAM)TRUE, 0); DestroyWindow(progress_dialog); - if(buffer) mir_free(buffer); + if (buffer) mir_free(buffer); //mir_free(id); } @@ -1608,19 +1608,19 @@ void Meta_RemoveHistory(HANDLE hContactRemoveFrom, HANDLE hContactSource) { if (CallService(MS_DB_EVENT_GET,(WPARAM)hDbEvent,(LPARAM)&dbei)) break; - if(dbei.timestamp < earliest_time) + if (dbei.timestamp < earliest_time) earliest_time = dbei.timestamp; - if(dbei.eventType != EVENTTYPE_MESSAGE && dbei.eventType != EVENTTYPE_FILE && dbei.eventType != EVENTTYPE_URL) { + if (dbei.eventType != EVENTTYPE_MESSAGE && dbei.eventType != EVENTTYPE_FILE && dbei.eventType != EVENTTYPE_URL) { hDbEvent=(HANDLE)CallService(MS_DB_EVENT_FINDNEXT,(WPARAM)hDbEvent,0); continue; } - if(dbei.cbBlob >= id_length && strncmp((char *)(dbei.pBlob + dbei.cbBlob - id_length), id, id_length - 1) == 0) { + if (dbei.cbBlob >= id_length && strncmp((char *)(dbei.pBlob + dbei.cbBlob - id_length), id, id_length - 1) == 0) { // event is tagged with source contact id - remove HANDLE hDbEventNext; - if(time_now > earliest_time) { // just in case + if (time_now > earliest_time) { // just in case SendMessage(prog, PBM_SETPOS, (WPARAM)(int)(100.0 * (dbei.timestamp - earliest_time) / (time_now - earliest_time)), 0); UpdateWindow(progress_dialog); } @@ -1636,7 +1636,7 @@ void Meta_RemoveHistory(HANDLE hContactRemoveFrom, HANDLE hContactSource) { //CallService(MS_DB_SETSAFETYMODE, (WPARAM)TRUE, 0); DestroyWindow(progress_dialog); - if(buffer) mir_free(buffer); + if (buffer) mir_free(buffer); mir_free(id); } @@ -1681,7 +1681,7 @@ char *Meta_GetUniqueIdentifier(HANDLE hContact, DWORD *pused) { DBFreeVariant(&dbv); strncpy(id + used, buff, 256 - used); - if(used) { + if (used) { *pused = (DWORD)(used + strlen(buff) + 1); if (*pused > 256) *pused = 256; } @@ -1691,9 +1691,9 @@ char *Meta_GetUniqueIdentifier(HANDLE hContact, DWORD *pused) { */ void Meta_FixStatus(HANDLE hMeta) { HANDLE most_online = Meta_GetMostOnlineSupporting(hMeta, PFLAGNUM_1, 0); - if(most_online) { + if (most_online) { char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)most_online, 0); - if(proto) { + if (proto) { WORD status = (WORD)DBGetContactSettingWord(most_online, proto, "Status", (WORD)ID_STATUS_OFFLINE); DBWriteContactSettingWord(hMeta, META_PROTO, "Status", status); } else @@ -1702,7 +1702,7 @@ void Meta_FixStatus(HANDLE hMeta) { DBWriteContactSettingWord(hMeta, META_PROTO, "Status", (WORD)ID_STATUS_OFFLINE); // trigger setting changed in mw_clist to reset extra icons - if(ServiceExists(MS_CLIST_EXTRA_SET_ICON)) { + if (ServiceExists(MS_CLIST_EXTRA_SET_ICON)) { DBWriteContactSettingString(hMeta, "DummyModule", "e-mail", "blah"); //DBDeleteContactSetting(hMeta, "DummyModule", "e-mail"); // causes 'empty settings group' error in dbtool } diff --git a/plugins/MetaContacts/metacontacts.h b/plugins/MetaContacts/metacontacts.h index 790fb9a6a4..873b0e2e12 100644 --- a/plugins/MetaContacts/metacontacts.h +++ b/plugins/MetaContacts/metacontacts.h @@ -103,15 +103,7 @@ extern HINSTANCE hInstance; extern PLUGININFOEX pluginInfo; // contact menu items -extern HANDLE hMenuConvert, - hMenuAdd, - hMenuEdit, - hMenuDelete, - hMenuDefault, - hMenuForceDefault; - -// main menu item -extern HANDLE hMenuOnOff; +extern HGENMENU hMenuConvert, hMenuAdd, hMenuEdit, hMenuDelete, hMenuDefault, hMenuForceDefault, hMenuOnOff; extern DWORD nextMetaID; extern int mcStatus; -- cgit v1.2.3