From 8d2b4094f891d20381f65e3180b2b053830f3050 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 9 Mar 2014 15:00:43 +0000 Subject: - unused options removed - duplicated events in history fixed git-svn-id: http://svn.miranda-ng.org/main/trunk@8504 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- include/m_db_int.h | 3 + plugins/Db3x_mmap/src/dbevents.cpp | 19 +- src/modules/metacontacts/meta_addto.cpp | 4 +- src/modules/metacontacts/meta_menu.cpp | 27 +-- src/modules/metacontacts/meta_options.cpp | 182 +++-------------- src/modules/metacontacts/meta_services.cpp | 300 +++-------------------------- src/modules/metacontacts/meta_utils.cpp | 211 +------------------- src/modules/metacontacts/metacontacts.h | 23 +-- src/resource.h | 9 - src/resource.rc | 29 --- 10 files changed, 89 insertions(+), 718 deletions(-) diff --git a/include/m_db_int.h b/include/m_db_int.h index 4848bad326..59a555e720 100644 --- a/include/m_db_int.h +++ b/include/m_db_int.h @@ -56,6 +56,9 @@ struct DBCachedContact MCONTACT *pSubs; MCONTACT parentID; // == 0 -> not a subcontact int nDefault; // default sub number + + __forceinline bool IsMeta() const { return nSubs != -1; } + __forceinline bool IsSub() const { return parentID != 0; } }; interface MIDatabaseCache : public MZeroedObject diff --git a/plugins/Db3x_mmap/src/dbevents.cpp b/plugins/Db3x_mmap/src/dbevents.cpp index f7c8876258..7be9a20906 100644 --- a/plugins/Db3x_mmap/src/dbevents.cpp +++ b/plugins/Db3x_mmap/src/dbevents.cpp @@ -37,18 +37,27 @@ STDMETHODIMP_(HANDLE) CDb3Mmap::AddEvent(MCONTACT contactID, DBEVENTINFO *dbei) if (dbei == NULL || dbei->cbSize != sizeof(DBEVENTINFO)) return 0; if (dbei->timestamp == 0) return 0; - if (NotifyEventHooks(hEventFilterAddedEvent, contactID, (LPARAM)dbei)) - return 0; - DBEvent dbe; dbe.signature = DBEVENT_SIGNATURE; - dbe.contactID = contactID; + dbe.contactID = contactID; // store native or subcontact's id dbe.timestamp = dbei->timestamp; dbe.flags = dbei->flags; dbe.wEventType = dbei->eventType; dbe.cbBlob = dbei->cbBlob; BYTE *pBlob = dbei->pBlob; + if (contactID != 0) { + DBCachedContact *cc = m_cache->GetCachedContact(contactID); + if (cc == NULL) + return NULL; + + if (cc->IsSub()) + contactID = cc->parentID; + } + + if (NotifyEventHooks(hEventFilterAddedEvent, contactID, (LPARAM)dbei)) + return NULL; + mir_ptr pCryptBlob; if (m_bEncrypted) { size_t len; @@ -66,7 +75,7 @@ STDMETHODIMP_(HANDLE) CDb3Mmap::AddEvent(MCONTACT contactID, DBEVENTINFO *dbei) DWORD ofsContact = GetContactOffset(contactID); DBContact dbc = *(DBContact*)DBRead(ofsContact, sizeof(DBContact), NULL); if (dbc.signature != DBCONTACT_SIGNATURE) - return 0; + return NULL; DWORD ofsNew = CreateNewSpace(offsetof(DBEvent, blob) + dbe.cbBlob); diff --git a/src/modules/metacontacts/meta_addto.cpp b/src/modules/metacontacts/meta_addto.cpp index d411c32aff..98d1a310e8 100644 --- a/src/modules/metacontacts/meta_addto.cpp +++ b/src/modules/metacontacts/meta_addto.cpp @@ -116,7 +116,7 @@ static INT_PTR CALLBACK Meta_SelectDialogProc(HWND hwndDlg, UINT msg, WPARAM wPa return TRUE; } - if (IsMeta(cc)) { + if (cc->IsMeta()) { MessageBox(hwndDlg, TranslateT("This contact is a MetaContact.\nYou can't add a MetaContact to another MetaContact.\n\nPlease choose another."), TranslateT("MetaContact Conflict"), MB_ICONERROR); @@ -124,7 +124,7 @@ static INT_PTR CALLBACK Meta_SelectDialogProc(HWND hwndDlg, UINT msg, WPARAM wPa return TRUE; } - if (IsSub(cc)) { + if (cc->IsSub()) { MessageBox(hwndDlg, TranslateT("This contact is already associated to a MetaContact.\nYou cannot add a contact to multiple MetaContacts."), TranslateT("Multiple MetaContacts"), MB_ICONERROR); diff --git a/src/modules/metacontacts/meta_menu.cpp b/src/modules/metacontacts/meta_menu.cpp index 054081febe..b14e5b0c08 100644 --- a/src/modules/metacontacts/meta_menu.cpp +++ b/src/modules/metacontacts/meta_menu.cpp @@ -74,7 +74,7 @@ INT_PTR Meta_Convert(WPARAM wParam, LPARAM lParam) } // hide the contact if clist groups disabled (shouldn't create one anyway since menus disabled) - if (!Meta_IsEnabled()) + if (!options.bEnabled) db_set_b(hMetaContact, "CList", "Hidden", 1); } @@ -93,7 +93,7 @@ void Meta_RemoveContactNumber(DBCachedContact *ccMeta, int number, bool bUpdateI if (ccSub->parentID == ccMeta->contactID) { // stop ignoring, if we were - if (options.suppress_status) + if (options.bSuppressStatus) CallService(MS_IGNORE_UNIGNORE, ccSub->contactID, IGNOREEVENT_USERONLINE); } @@ -178,7 +178,7 @@ INT_PTR Meta_Delete(WPARAM hContact, LPARAM bSkipQuestion) return 0; // The wParam is a metacontact - if (IsMeta(cc)) { + if (cc->IsMeta()) { // check from recursion - see second half of this function if (!bSkipQuestion && IDYES != MessageBox((HWND)CallService(MS_CLUI_GETHWND, 0, 0), @@ -192,7 +192,7 @@ INT_PTR Meta_Delete(WPARAM hContact, LPARAM bSkipQuestion) NotifyEventHooks(hSubcontactsChanged, hContact, 0); CallService(MS_DB_CONTACT_DELETE, hContact, 0); } - else if (IsSub(cc)) { + else if (cc->IsSub()) { if ((cc = currDb->m_cache->GetCachedContact(cc->parentID)) == NULL) return 0; @@ -274,7 +274,7 @@ int Meta_ModifyMenu(WPARAM hMeta, LPARAM lParam) CLISTMENUITEM mi = { sizeof(mi) }; Menu_ShowItem(hMenuRoot, false); - if (IsMeta(cc)) { + if (cc->IsMeta()) { // save the mouse pos in case they open a subcontact menu GetCursorPos(&menuMousePoint); @@ -349,7 +349,7 @@ int Meta_ModifyMenu(WPARAM hMeta, LPARAM lParam) return 0; } - if (!Meta_IsEnabled()) { + if (!options.bEnabled) { // groups disabled - all meta menu options hidden Menu_ShowItem(hMenuDefault, false); Menu_ShowItem(hMenuDelete, false); @@ -360,7 +360,7 @@ int Meta_ModifyMenu(WPARAM hMeta, LPARAM lParam) } // the contact is affected to a metacontact - if (IsSub(cc)) { + if (cc->IsSub()) { Menu_ShowItem(hMenuDefault, true); mi.flags = CMIM_NAME; @@ -471,18 +471,9 @@ void InitMenus() hMenuContact[i] = Menu_AddContactMenuItem(&mi); } - // loop and copy data from subcontacts - if (options.copydata) { - for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - DBCachedContact *cc = CheckMeta(hContact); - if (cc != NULL) - Meta_CopyData(cc); - } - } - Meta_HideLinkedContacts(); - if (!Meta_IsEnabled()) { + if (!options.bEnabled) { // modify main menu item mi.flags = CMIM_NAME | CMIM_ICON; mi.icolibItem = GetIconHandle(I_MENU); @@ -491,5 +482,5 @@ void InitMenus() Meta_HideMetaContacts(TRUE); } - else Meta_SuppressStatus(options.suppress_status); + else Meta_SuppressStatus(options.bSuppressStatus); } diff --git a/src/modules/metacontacts/meta_options.cpp b/src/modules/metacontacts/meta_options.cpp index 2a30c3d784..382f83d446 100644 --- a/src/modules/metacontacts/meta_options.cpp +++ b/src/modules/metacontacts/meta_options.cpp @@ -37,13 +37,7 @@ INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara TranslateDialogDefault( hwndDlg ); options_changes = options; - CheckDlgButton(hwndDlg, IDC_CHK_SETDEFAULTRECV, options_changes.set_default_on_recv ? TRUE : FALSE); - hw = GetDlgItem(hwndDlg, IDC_CHK_TEMPDEFAULT); - EnableWindow(hw, options_changes.set_default_on_recv); - CheckDlgButton(hwndDlg, IDC_CHK_TEMPDEFAULT, options_changes.temp_default ? TRUE : FALSE); - - CheckDlgButton(hwndDlg, IDC_CHK_ALWAYSUSEDEFAULT, options_changes.always_use_default ? TRUE : FALSE); - CheckDlgButton(hwndDlg, IDC_CHK_SUPPRESSSTATUS, options_changes.suppress_status ? TRUE : FALSE); + CheckDlgButton(hwndDlg, IDC_CHK_SUPPRESSSTATUS, options_changes.bSuppressStatus); CheckDlgButton(hwndDlg, IDC_RAD_UID, options_changes.menu_contact_label == DNT_UID); CheckDlgButton(hwndDlg, IDC_RAD_DID, options_changes.menu_contact_label == DNT_DID); @@ -54,23 +48,7 @@ INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara CheckDlgButton(hwndDlg, IDC_RAD_NICK, options_changes.clist_contact_name == CNNT_NICK); CheckDlgButton(hwndDlg, IDC_RAD_NAME, options_changes.clist_contact_name == CNNT_DISPLAYNAME); - CheckDlgButton(hwndDlg, IDC_CHK_LOCKHANDLE, options_changes.lockHandle ? TRUE : FALSE); - CheckDlgButton(hwndDlg, IDC_CHK_SUBWINDOW, options_changes.subcontact_windows ? TRUE : FALSE); - - CheckDlgButton(hwndDlg, IDC_CHK_METAHISTORY, options_changes.metahistory ? TRUE : FALSE); - CheckDlgButton(hwndDlg, IDC_CHK_SUBHISTORY, options_changes.subhistory ? TRUE : FALSE); - CheckDlgButton(hwndDlg, IDC_CHK_COPYDATA, options_changes.copydata ? TRUE : FALSE); - - if ( !options_changes.subcontact_windows) { - hw = GetDlgItem(hwndDlg, IDC_CHK_METAHISTORY); - EnableWindow(hw, FALSE); - } else { - hw = GetDlgItem(hwndDlg, IDC_CHK_SUBHISTORY); - EnableWindow(hw, FALSE); - } - - EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_COPYHISTORY), FALSE); - CheckDlgButton(hwndDlg, IDC_CHK_COPYHISTORY, FALSE); + CheckDlgButton(hwndDlg, IDC_CHK_LOCKHANDLE, options_changes.bLockHandle); hw = GetDlgItem(hwndDlg, IDC_ED_DAYS); _itot(options_changes.days_history, buff, 10); @@ -80,33 +58,8 @@ INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara case WM_COMMAND: if ( HIWORD( wParam ) == BN_CLICKED ) { switch( LOWORD( wParam )) { - case IDC_CHK_SETDEFAULTRECV: - options_changes.set_default_on_recv = IsDlgButtonChecked(hwndDlg, IDC_CHK_SETDEFAULTRECV); - EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_TEMPDEFAULT), options_changes.set_default_on_recv); - SendMessage( GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; - case IDC_CHK_TEMPDEFAULT: - options_changes.temp_default = IsDlgButtonChecked(hwndDlg, IDC_CHK_TEMPDEFAULT); - SendMessage( GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; - case IDC_CHK_ALWAYSUSEDEFAULT: - options_changes.always_use_default = IsDlgButtonChecked(hwndDlg, IDC_CHK_ALWAYSUSEDEFAULT); - SendMessage( GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; case IDC_CHK_SUPPRESSSTATUS: - options_changes.suppress_status = IsDlgButtonChecked(hwndDlg, IDC_CHK_SUPPRESSSTATUS); - SendMessage( GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; - case IDC_CHK_METAHISTORY: - options_changes.metahistory = IsDlgButtonChecked(hwndDlg, IDC_CHK_METAHISTORY); - SendMessage( GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; - case IDC_CHK_SUBHISTORY: - options_changes.subhistory = IsDlgButtonChecked(hwndDlg, IDC_CHK_SUBHISTORY); - SendMessage( GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; - case IDC_CHK_COPYDATA: - options_changes.copydata = IsDlgButtonChecked(hwndDlg, IDC_CHK_COPYDATA); + options_changes.bSuppressStatus = IsDlgButtonChecked(hwndDlg, IDC_CHK_SUPPRESSSTATUS) != 0; SendMessage( GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case IDC_RAD_UID: @@ -161,25 +114,9 @@ INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara } SendMessage( GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; - case IDC_CHK_SUBWINDOW: - options_changes.subcontact_windows = IsDlgButtonChecked(hwndDlg, IDC_CHK_SUBWINDOW); - - if (options_changes.subcontact_windows) { - EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_METAHISTORY), TRUE); - CheckDlgButton(hwndDlg, IDC_CHK_SUBHISTORY, TRUE); - EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_SUBHISTORY), FALSE); - options_changes.subhistory = TRUE; - } else { - EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_SUBHISTORY), TRUE); - CheckDlgButton(hwndDlg, IDC_CHK_METAHISTORY, TRUE); - EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_METAHISTORY), FALSE); - options_changes.metahistory = TRUE; - } - SendMessage( GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; case IDC_CHK_LOCKHANDLE: - options_changes.lockHandle = IsDlgButtonChecked(hwndDlg, IDC_CHK_LOCKHANDLE); + options_changes.bLockHandle = IsDlgButtonChecked(hwndDlg, IDC_CHK_LOCKHANDLE) != 0; SendMessage( GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; } @@ -199,7 +136,7 @@ INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara options = options_changes; Meta_WriteOptions(&options); - Meta_SuppressStatus(options.suppress_status); + Meta_SuppressStatus(options.bSuppressStatus); Meta_SetAllNicks(); return TRUE; } @@ -211,79 +148,29 @@ INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara int Meta_WriteOptions(MetaOptions *opt) { - db_set_b(NULL, META_PROTO, "SetDefaultOnRecv", (BYTE)(opt->set_default_on_recv ? 1 : 0)); - db_set_b(NULL, META_PROTO, "TempDefault", (BYTE)(opt->temp_default ? 1 : 0)); - db_set_b(NULL, META_PROTO, "AlwaysUseDefault", (BYTE)(opt->always_use_default ? 1 : 0)); - db_set_b(NULL, META_PROTO, "SuppressStatus", (BYTE)(opt->suppress_status ? 1 : 0)); + db_set_b(NULL, META_PROTO, "SuppressStatus", opt->bSuppressStatus); db_set_w(NULL, META_PROTO, "MenuContactLabel", (WORD)opt->menu_contact_label); db_set_w(NULL, META_PROTO, "MenuContactFunction", (WORD)opt->menu_function); db_set_w(NULL, META_PROTO, "CListContactName", (WORD)opt->clist_contact_name); db_set_dw(NULL, META_PROTO, "DaysHistory", (DWORD)(opt->days_history)); db_set_dw(NULL, META_PROTO, "SetStatusFromOfflineDelay", (DWORD)(opt->set_status_from_offline_delay)); - db_set_b(NULL, META_PROTO, "SubcontactWindows", (BYTE)(opt->subcontact_windows ? 1 : 0)); - db_set_b(NULL, META_PROTO, "CopyData", (BYTE)(opt->copydata ? 1 : 0)); - db_set_b(NULL, META_PROTO, "LockHandle", (BYTE)(opt->lockHandle ? 1 : 0)); - db_set_b(NULL, META_PROTO, "MetaMessageIcon", (BYTE)(opt->flash_meta_message_icon ? 1 : 0)); - db_set_b(NULL, META_PROTO, "CopyUserInfo", (BYTE)(opt->copy_userinfo ? 1 : 0)); - - if ( !opt->subcontact_windows) - db_set_b(NULL, META_PROTO, "MetaHistory", 1); - else - db_set_b(NULL, META_PROTO, "MetaHistory", (BYTE)(opt->metahistory ? 1 : 0)); - - if (opt->subcontact_windows) - db_set_b(NULL, META_PROTO, "SubcontactHistory", 1); - else - db_set_b(NULL, META_PROTO, "SubcontactHistory", (BYTE)(opt->subhistory ? 1 : 0)); + db_set_b(NULL, META_PROTO, "LockHandle", opt->bLockHandle); return 0; - - db_set_b(NULL, META_PROTO, "UseProtoRecv", (BYTE)(opt->use_proto_recv ? 1 : 0)); } int Meta_ReadOptions(MetaOptions *opt) { - opt->set_default_on_recv = (db_get_b(NULL, META_PROTO, "SetDefaultOnRecv", 1) == 1 ? TRUE : FALSE); - opt->temp_default = (db_get_b(NULL, META_PROTO, "TempDefault", 1) == 1 ? TRUE : FALSE); - opt->always_use_default = (db_get_b(NULL, META_PROTO, "AlwaysUseDefault", 1) == 1 ? TRUE : FALSE); - opt->suppress_status = (db_get_b(NULL, META_PROTO, "SuppressStatus", 1) == 1 ? TRUE : FALSE); + opt->bEnabled = db_get_b(NULL, META_PROTO, "Enabled", true) != 0; + opt->bSuppressStatus = db_get_b(NULL, META_PROTO, "SuppressStatus", true) != 0; opt->menu_contact_label = (int)db_get_w(NULL, META_PROTO, "MenuContactLabel", DNT_UID); opt->menu_function = (int)db_get_w(NULL, META_PROTO, "MenuContactFunction", FT_MENU); opt->clist_contact_name = (int)db_get_w(NULL, META_PROTO, "CListContactName", CNNT_NICK); opt->days_history = (int)db_get_dw(NULL, META_PROTO, "DaysHistory", 0); opt->set_status_from_offline_delay = (int)db_get_dw(NULL, META_PROTO, "SetStatusFromOfflineDelay", DEFAULT_SET_STATUS_SLEEP_TIME); - opt->subcontact_windows = (db_get_b(NULL, META_PROTO, "SubcontactWindows", 0) == 1 ? TRUE : FALSE); - opt->copydata = (db_get_b(NULL, META_PROTO, "CopyData", 1) == 1 ? TRUE : FALSE); - opt->lockHandle = (db_get_b(NULL, META_PROTO, "LockHandle", 0) == 1 ? TRUE : FALSE); - opt->flash_meta_message_icon = (db_get_b(NULL, META_PROTO, "MetaMessageIcon", 1) == 1 ? TRUE : FALSE); - opt->copy_userinfo = (db_get_b(NULL, META_PROTO, "CopyUserInfo", 1) == 1 ? TRUE : FALSE); - - if ( !opt->subcontact_windows) - opt->metahistory = TRUE; - else - opt->metahistory = (db_get_b(NULL, META_PROTO, "MetaHistory", 1) == 1 ? TRUE : FALSE); - - if (opt->subcontact_windows) - opt->subhistory = TRUE; - else - opt->subhistory = (db_get_b(NULL, META_PROTO, "SubcontactHistory", 1) == 1 ? TRUE : FALSE); - - opt->use_proto_recv = (db_get_b(NULL, META_PROTO, "UseProtoRecv", 1) == 1 ? TRUE : FALSE); + opt->bLockHandle = db_get_b(NULL, META_PROTO, "LockHandle", false) != 0; return 0; } -/* -#define ID_STATUS_OFFLINE 40071 ->8 -#define ID_STATUS_ONLINE 40072 ->0 -#define ID_STATUS_AWAY 40073 ->4 -#define ID_STATUS_DND 40074 ->7 -#define ID_STATUS_NA 40075 ->6 -#define ID_STATUS_OCCUPIED 40076 ->5 -#define ID_STATUS_FREECHAT 40077 ->1 -#define ID_STATUS_INVISIBLE 40078 ->0 -#define ID_STATUS_ONTHEPHONE 40079 ->2 -#define ID_STATUS_OUTTOLUNCH 40080 ->3 -*/ - int GetDefaultPrio(int status) { switch( status ) { @@ -310,7 +197,7 @@ ProtoStatusPrio *priorities = 0; int GetRealPriority(char *proto, int status) { char szSetting[256]; - if ( !proto) { + if (!proto) { mir_snprintf(szSetting, 256, "DefaultPrio_%d", status); return db_get_w(0, META_PROTO, szSetting, GetDefaultPrio(status)); } @@ -352,24 +239,23 @@ void WritePriorities() { char szSetting[256]; ProtoStatusPrio *current = priorities; - int i, j; int num_protocols; PROTOACCOUNT **pppDesc; ProtoEnumAccounts(&num_protocols, &pppDesc); - for (i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) { + for (int 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)) db_set_w(0, META_PROTO, szSetting, (WORD)current->prio[i - ID_STATUS_OFFLINE]); else db_unset(0, META_PROTO, szSetting); } - for (i = 0; i < num_protocols; i++) { + for (int i = 0; i < num_protocols; i++) { current = priorities + (i + 1); - for (j = ID_STATUS_OFFLINE; j <= ID_STATUS_OUTTOLUNCH; j++) { + for (int j = ID_STATUS_OFFLINE; j <= ID_STATUS_OUTTOLUNCH; j++) { mir_snprintf(szSetting, 256, "ProtoPrio_%s%d", pppDesc[i]->szModuleName, j); - if ( !current->def[j - ID_STATUS_OFFLINE]) + if (!current->def[j - ID_STATUS_OFFLINE]) db_set_w(0, META_PROTO, szSetting, (WORD)current->prio[j - ID_STATUS_OFFLINE]); else db_unset(0, META_PROTO, szSetting); @@ -403,28 +289,27 @@ void SetPriority(int proto_index, int status, BOOL def, int prio) else { ProtoStatusPrio *current = priorities + (proto_index + 1); current->def[status - ID_STATUS_OFFLINE] = def; - if ( !def) + if (!def) current->prio[status - ID_STATUS_OFFLINE] = prio; } } void ResetPriorities() { - int i, j, num_protocols; + int num_protocols; PROTOACCOUNT **pppDesc; ProtoEnumAccounts(&num_protocols, &pppDesc); ProtoStatusPrio *current = priorities; - for (i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) { + for (int 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 (int i = 0; i < num_protocols; i++) { current = priorities + (i + 1); - for (j = ID_STATUS_OFFLINE; j <= ID_STATUS_OUTTOLUNCH; j++) { + for (int j = ID_STATUS_OFFLINE; j <= ID_STATUS_OUTTOLUNCH; j++) current->def[j - ID_STATUS_OFFLINE] = TRUE; - } } } @@ -436,9 +321,9 @@ INT_PTR CALLBACK DlgProcOptsPriorities(HWND hwndDlg, UINT msg, WPARAM wParam, LP HWND hw; int sel; - switch ( msg ) { + switch (msg) { case WM_INITDIALOG: - TranslateDialogDefault( hwndDlg ); + TranslateDialogDefault(hwndDlg); SendMessage(GetDlgItem(hwndDlg, IDC_SP_PRIORITY), UDM_SETRANGE, 0, (LPARAM)MAKELONG(500, 0)); ReadPriorities(); { @@ -526,8 +411,8 @@ INT_PTR CALLBACK DlgProcOptsPriorities(HWND hwndDlg, UINT msg, WPARAM wParam, LP return TRUE; case WM_COMMAND: - if ( HIWORD( wParam ) == BN_CLICKED ) { - switch( LOWORD( wParam )) { + if (HIWORD(wParam) == BN_CLICKED) { + switch (LOWORD(wParam)) { case IDC_CHK_DEFAULT: sel = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_GETCURSEL, 0, 0); if (sel != -1) { @@ -544,7 +429,7 @@ INT_PTR CALLBACK DlgProcOptsPriorities(HWND hwndDlg, UINT msg, WPARAM wParam, LP EnableWindow(GetDlgItem(hwndDlg, IDC_ED_PRIORITY), !checked); EnableWindow(GetDlgItem(hwndDlg, IDC_SP_PRIORITY), !checked); - SendMessage( GetParent(hwndDlg), PSM_CHANGED, 0, 0); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } } break; @@ -554,12 +439,12 @@ INT_PTR CALLBACK DlgProcOptsPriorities(HWND hwndDlg, UINT msg, WPARAM wParam, LP SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_SETCURSEL, 0, 0); SendMessage(hwndDlg, WMU_FILLSTATUSCMB, 0, 0); SendMessage(hwndDlg, WMU_FILLPRIODATA, 0, 0); - SendMessage( GetParent(hwndDlg), PSM_CHANGED, 0, 0); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; } } - if ( HIWORD( wParam ) == EN_CHANGE && LOWORD(wParam) == IDC_ED_PRIORITY && ( HWND )lParam == GetFocus()) { + if (HIWORD(wParam) == EN_CHANGE && LOWORD(wParam) == IDC_ED_PRIORITY && (HWND)lParam == GetFocus()) { sel = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_GETCURSEL, 0, 0); if (sel != -1) { int index = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_GETITEMDATA, sel, 0); @@ -570,12 +455,12 @@ INT_PTR CALLBACK DlgProcOptsPriorities(HWND hwndDlg, UINT msg, WPARAM wParam, LP SetPriority(index, status, FALSE, prio); if (prio != GetPriority(index, status)) SetDlgItemInt(hwndDlg, IDC_ED_PRIORITY, GetPriority(index, status), FALSE); - SendMessage( GetParent(hwndDlg), PSM_CHANGED, 0, 0); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } } } - if ( HIWORD( wParam ) == CBN_SELCHANGE) { - switch( LOWORD( wParam )) { + if (HIWORD(wParam) == CBN_SELCHANGE) { + switch (LOWORD(wParam)) { case IDC_CMB_STATUS: SendMessage(hwndDlg, WMU_FILLPRIODATA, 0, 0); break; @@ -587,7 +472,7 @@ INT_PTR CALLBACK DlgProcOptsPriorities(HWND hwndDlg, UINT msg, WPARAM wParam, LP break; case WM_NOTIFY: - if (((LPNMHDR)lParam)->code == PSN_APPLY ) { + if (((LPNMHDR)lParam)->code == PSN_APPLY) { WritePriorities(); return TRUE; } @@ -621,10 +506,5 @@ int Meta_OptInit(WPARAM wParam, LPARAM lParam) odp.pszTab = LPGEN("Priorities"); odp.pfnDlgProc = DlgProcOptsPriorities; Options_AddPage(wParam, &odp); - - odp.pszTemplate = MAKEINTRESOURCEA(IDD_METAHISTORY); - odp.pszTab = LPGEN("History"); - odp.pfnDlgProc = DlgProcOpts; - Options_AddPage(wParam, &odp); return 0; } diff --git a/src/modules/metacontacts/meta_services.cpp b/src/modules/metacontacts/meta_services.cpp index 7efa81463b..467b4c4620 100644 --- a/src/modules/metacontacts/meta_services.cpp +++ b/src/modules/metacontacts/meta_services.cpp @@ -183,47 +183,6 @@ static DWORD CALLBACK sttFakeAckFail( LPVOID param ) return 0; } -/** Filter messages sent by subcontacts -* -* When groups are disabled, add an event to the DB for the metacontact to maintain history -* -* @param wParam : index of the protocol in the protocol chain. -* @param lParam : CCSDATA structure holding all the information about the message. -* -* @return 0 on success, 1 otherwise. -*/ - -INT_PTR MetaFilter_SendMessage(WPARAM wParam, LPARAM lParam) -{ - CCSDATA *ccs = (CCSDATA*)lParam; - - DBCachedContact *cc = currDb->m_cache->GetCachedContact(ccs->hContact); - if (cc != NULL) { - // if subcontact sending, add db event to keep metacontact history correct - if (IsSub(cc) && options.metahistory && !(ccs->wParam & PREF_METANODB)) { - // reject "file As Message" messages - if (strlen((char*)ccs->lParam) > 5) - if (!strncmp((char *)ccs->lParam, "<%fAM", 5) || !strncmp((char *)ccs->lParam, "<%dAM", 5) || !strncmp((char *)ccs->lParam, "?OTR", 4) == 0) - return CallService(MS_PROTO_CHAINSEND, wParam, lParam); // continue processing - - DBEVENTINFO dbei = { sizeof(dbei) }; - dbei.szModule = META_PROTO; - 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; - dbei.cbBlob = (DWORD)strlen((char *)ccs->lParam) + 1; - if (ccs->wParam & PREF_UNICODE) - dbei.cbBlob *= (sizeof(wchar_t)+1); - dbei.pBlob = (PBYTE)ccs->lParam; - db_event_add(cc->parentID, &dbei); - } - } - - return CallService(MS_PROTO_CHAINSEND, wParam, lParam); -} - INT_PTR Meta_SendNudge(WPARAM wParam, LPARAM lParam) { DBCachedContact *cc = CheckMeta(wParam); @@ -281,178 +240,12 @@ INT_PTR Meta_SendMessage(WPARAM wParam,LPARAM lParam) char *proto = GetContactProto(most_online); Meta_SetNick(proto); // (no matter what was there before) - // don't bypass filters etc - if (options.subhistory && !(ccs->wParam & PREF_METANODB)) { - // add sent event to subcontact - DBEVENTINFO dbei = { sizeof(dbei) }; - dbei.szModule = GetContactProto(ccs->hContact); - if (dbei.szModule) { - 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; - dbei.cbBlob = (DWORD)strlen((char *)ccs->lParam) + 1; - if ( ccs->wParam & PREF_UNICODE ) - dbei.cbBlob *= ( sizeof( wchar_t )+1 ); - dbei.pBlob = (PBYTE)ccs->lParam; - db_event_add(ccs->hContact, &dbei); - } - } - // prevent send filter from adding another copy of this send event to the db ccs->wParam |= PREF_METANODB; return CallContactService(ccs->hContact, PSS_MESSAGE, ccs->wParam, ccs->lParam); } -/** Transmit a message received by a contact. -* -* Forward the message received by a contact linked to a MetaContact -* to that MetaContact and inhibit the further reception of this message -* by the standard protocol of the contact. -* -* @param wParam : index of the protocol in the protocol chain. -* @param lParam : CCSDATA structure holding all the information about the message. -* -* @return 0 on success, 1 otherwise. -*/ - -INT_PTR MetaFilter_RecvMessage(WPARAM wParam,LPARAM lParam) -{ - DBEVENTINFO dbei; - CCSDATA *ccs = (CCSDATA*)lParam; - PROTORECVEVENT *pre = (PROTORECVEVENT *)ccs->lParam; - - DBCachedContact *cc = currDb->m_cache->GetCachedContact(ccs->hContact); - if (cc == NULL || !IsSub(cc)) - return CallService(MS_PROTO_CHAINRECV, wParam, (LPARAM)ccs); - - if (options.set_default_on_recv) { - cc->nDefault = Meta_GetContactNumber(cc, ccs->hContact); - currDb->MetaSetDefault(cc); - NotifyEventHooks(hEventDefaultChanged, cc->parentID, ccs->hContact); // nick set in event handler - } - - // if meta disabled (now message api) or window open (message api), or using subcontact windows, - // let through but add db event for metacontact history - if (!Meta_IsEnabled() || db_get_b(ccs->hContact, META_PROTO, "WindowOpen", 0) == 1 || options.subcontact_windows) { - // 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 (db_get_b(ccs->hContact, META_PROTO, "WindowOpen", 0) == 0 && - db_get_b(cc->parentID, META_PROTO, "WindowOpen", 0) == 0 && - options.flash_meta_message_icon) { - TCHAR toolTip[256]; - - CLISTEVENT cle = { sizeof(cle) }; - cle.hContact = cc->parentID; - cle.flags = CLEF_TCHAR; - cle.hDbEvent = (HANDLE)ccs->hContact; // use subcontact handle as key - then we can remove all events if the subcontact window is opened - cle.hIcon = LoadSkinnedIcon(SKINICON_EVENT_MESSAGE); - cle.pszService = "MetaContacts/CListMessageEvent"; - mir_sntprintf(toolTip, SIZEOF(toolTip), TranslateT("Message from %s"), cli.pfnGetContactDisplayName(cc->parentID, 0)); - cle.ptszTooltip = toolTip; - CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle); - } - - if (options.metahistory) { - BOOL added = FALSE; - - // should be able to do this, but some protos mess with the memory - 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 = GetContactProto(ccs->hContact); - if (proto) { - MCONTACT hSub = ccs->hContact; - DWORD flags = pre->flags; - ccs->hContact = cc->parentID; - pre->flags |= (db_get_b(cc->parentID, META_PROTO, "WindowOpen", 0) ? 0 : PREF_CREATEREAD); - if (ProtoServiceExists(proto, PSR_MESSAGE) && !ProtoCallService(proto, PSR_MESSAGE, 0, (LPARAM)ccs)) - added = TRUE; - ccs->hContact = hSub; - pre->flags = flags; - } - } - - if (!added) { - // otherwise add raw db event - ZeroMemory(&dbei, sizeof(dbei)); - dbei.cbSize = sizeof(dbei); - dbei.szModule = META_PROTO; - dbei.timestamp = pre->timestamp; - dbei.flags = (db_get_b(cc->parentID, 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; - dbei.eventType = EVENTTYPE_MESSAGE; - dbei.cbBlob = (DWORD)strlen(pre->szMessage) + 1; - if (pre->flags & PREF_UNICODE) - dbei.cbBlob *= (sizeof(wchar_t)+1); - - dbei.pBlob = (PBYTE)pre->szMessage; - db_event_add(cc->parentID, &dbei); - } - } - - return CallService(MS_PROTO_CHAINRECV, wParam, (LPARAM)ccs); - } - - MCONTACT hSub = ccs->hContact; - ccs->hContact = cc->parentID; // Forward to the associated MetaContact. - CallService(MS_PROTO_CHAINRECV, 0, (LPARAM)ccs); - ccs->hContact = hSub; - - if (options.subhistory && !(ccs->wParam & PREF_METANODB)) { - // allow event pass through and thereby be added to subcontact history - pre->flags |= (db_get_b(ccs->hContact, META_PROTO, "WindowOpen", 0) ? 0 : PREF_CREATEREAD); - return CallService(MS_PROTO_CHAINRECV, wParam, (LPARAM)ccs); // pass through as normal - } - - return 1; // Stop further processing. -} - -/** Receive a message for a MetaContact -* -* @return 0 -*/ - -INT_PTR Meta_RecvMessage(WPARAM wParam, LPARAM lParam) -{ - CCSDATA *ccs = (CCSDATA*)lParam; - PROTORECVEVENT *pre = (PROTORECVEVENT *)ccs->lParam; - - // contact is not a meta proto contact - just leave it - char *proto = GetContactProto(ccs->hContact); - if (!proto || strcmp(proto, META_PROTO)) - return 0; - - if (options.use_proto_recv) { - DBCachedContact *cc = CheckMeta(wParam); - if (cc == NULL) - return 0; - - // use the subcontact's protocol to add the db if possible (AIMOSCAR removes HTML here!) - MCONTACT most_online = Meta_GetMostOnline(cc); - if (char *subProto = GetContactProto(most_online)) - if (ProtoCallService(subProto, PSR_MESSAGE, wParam, lParam) != CALLSERVICE_NOTFOUND) - return 0; - } - - // otherwise, add event to db directly - DBEVENTINFO dbei = { sizeof(dbei) }; - 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; - dbei.eventType = EVENTTYPE_MESSAGE; - dbei.cbBlob = (DWORD)strlen(pre->szMessage) + 1; - if (pre->flags & PREF_UNICODE) - dbei.cbBlob *= (sizeof(wchar_t)+1); - dbei.pBlob = (PBYTE)pre->szMessage; - db_event_add(ccs->hContact, &dbei); - return 0; -} - /** Called when an ACK is received. * * Retransmit the ACK sent by a simple contact so that it @@ -534,7 +327,7 @@ int Meta_SettingChanged(WPARAM hContact, LPARAM lParam) if (hContact == 0) if ((!strcmp(dcws->szModule, "CList") && !strcmp(dcws->szSetting, "UseGroups")) || (!strcmp(dcws->szModule, META_PROTO) && !strcmp(dcws->szSetting, "Enabled"))) { - sttHideContacts(!Meta_IsEnabled()); + sttHideContacts(!options.bEnabled); return 0; } @@ -543,11 +336,11 @@ int Meta_SettingChanged(WPARAM hContact, LPARAM lParam) return 0; DBCachedContact *cc = currDb->m_cache->GetCachedContact(hContact); - if (cc == NULL || !IsSub(cc)) + if (cc == NULL || !cc->IsSub()) return 0; DBCachedContact *ccMeta = currDb->m_cache->GetCachedContact(cc->parentID); - if (ccMeta == NULL || !IsMeta(ccMeta)) + if (ccMeta == NULL || !ccMeta->IsMeta()) return 0; // This contact is attached to a MetaContact. @@ -658,9 +451,7 @@ int Meta_SettingChanged(WPARAM hContact, LPARAM lParam) else { // set status to that of most online contact Meta_CopyContactNick(ccMeta, Meta_GetMostOnline(ccMeta)); - Meta_FixStatus(ccMeta); - Meta_CopyData(ccMeta); } // most online contact with avatar support might have changed - update avatar @@ -674,11 +465,6 @@ int Meta_SettingChanged(WPARAM hContact, LPARAM lParam) db_set_ts(ccMeta->contactID, "ContactPhoto", "File", AI.filename); } } - else if (strcmp(dcws->szSetting, "XStatusId") == 0 || strcmp(dcws->szSetting, "XStatusMsg") == 0 || strcmp(dcws->szSetting, "XStatusName") == 0 || strcmp(dcws->szSetting, "StatusMsg") == 0) { - Meta_CopyData(ccMeta); - } - else if (strcmp(dcws->szSetting, "MirVer") == 0) - Meta_CopyData(ccMeta); return 0; } @@ -690,14 +476,14 @@ int Meta_ContactDeleted(WPARAM hContact, LPARAM lParam) return 0; // is a subcontact - update meta contact - if (IsSub(cc)) { + if (cc->IsSub()) { Meta_RemoveContactNumber(cc, Meta_GetContactNumber(cc, hContact), true); NotifyEventHooks(hSubcontactsChanged, cc->parentID, 0); return 0; } // not a subcontact - is it a metacontact? - if (!IsMeta(cc)) + if (!cc->IsMeta()) return 0; if (cc->nSubs > 0) @@ -708,7 +494,7 @@ int Meta_ContactDeleted(WPARAM hContact, LPARAM lParam) currDb->MetaDetouchSub(cc, i); // stop ignoring, if we were - if (options.suppress_status) + if (options.bSuppressStatus) CallService(MS_IGNORE_UNIGNORE, cc->pSubs[i], IGNOREEVENT_USERONLINE); } return 0; @@ -745,18 +531,15 @@ INT_PTR Meta_UserIsTyping(WPARAM hMeta, LPARAM lParam) * @param lParam either PROTOTYPE_SELFTYPING_ON or PROTOTYPE_SELFTYPING_OFF */ -int Meta_ContactIsTyping(WPARAM hMeta, LPARAM lParam) +int Meta_ContactIsTyping(WPARAM hContact, LPARAM lParam) { - DBCachedContact *cc = CheckMeta(hMeta); - if (cc != NULL && Meta_IsEnabled()) { - // This contact is attached to a MetaContact. - if (!options.subcontact_windows) { // we don't want clicking on the clist notification icon to open the metacontact message window - // try to remove any clist events we added for subcontact - CallServiceSync(MS_CLIST_REMOVEEVENT, hMeta, 1); - CallService(MS_PROTO_CONTACTISTYPING, hMeta, lParam); - // stop processing of event - return 1; - } + if (!options.bEnabled) + return 0; + + DBCachedContact *cc = currDb->m_cache->GetCachedContact(hContact); + if (cc != NULL && cc->IsSub()) { + CallService(MS_PROTO_CONTACTISTYPING, cc->parentID, lParam); + return 1; } return 0; @@ -788,12 +571,12 @@ int Meta_MessageWindowEvent(WPARAM wParam, LPARAM lParam) if (cc == NULL) return 0; - if (IsMeta(cc) || IsSub(cc)) { + if (cc->IsMeta() || cc->IsSub()) { // 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) { db_set_b(mwed->hContact, META_PROTO, "WindowOpen", 1); - if (IsSub(cc)) // subcontact window opened - remove clist events we added for metacontact + if (cc->IsSub()) // subcontact window opened - remove clist events we added for metacontact while (!CallService(MS_CLIST_REMOVEEVENT, cc->parentID, mwed->hContact)); } else if (mwed->uType == MSG_WINDOW_EVT_CLOSE || mwed->uType == MSG_WINDOW_EVT_CLOSING) @@ -805,40 +588,14 @@ int Meta_MessageWindowEvent(WPARAM wParam, LPARAM lParam) int Meta_ClistDoubleClicked(WPARAM hMeta, LPARAM lParam) { - DBCachedContact *cc = CheckMeta(hMeta); - if (cc == NULL || cc->nDefault == -1) - return 0; - - // -1 indicates no specific capability but respect 'ForceDefault' - MCONTACT most_online = Meta_GetMostOnlineSupporting(cc, PFLAGNUM_1, -1); - if (!most_online) - return 0; - - if (options.subcontact_windows) { - if (lParam) // contact from incoming message in lParam via (at this point) clist message event - CallService(MS_CLIST_CONTACTDOUBLECLICKED, lParam, 0); - else // simulate double click on most_online contact and stop event processing - CallService(MS_CLIST_CONTACTDOUBLECLICKED, most_online, 0); + DBCachedContact *cc = currDb->m_cache->GetCachedContact(hMeta); + if (cc != NULL && cc->IsSub()) { + // simulate double click on the metacontact and stop event processing + CallService(MS_CLIST_CONTACTDOUBLECLICKED, cc->parentID, 0); return 1; } - char *proto = GetContactProto(most_online); - if (proto == NULL) - return 0; - - char buffer[512]; - strcpy(buffer, proto); - strcat(buffer, PS_GETCAPS); - - // get the contacts messaging capabilities - int caps = CallService(buffer, PFLAGNUM_1, 0); - if ((caps & PF1_IMSEND) || (caps & PF1_CHAT) || (proto && strcmp(proto, "IRC") == 0)) - // let event process normally - return 0; - - // simulate double click on most_online contact and stop event processing - CallService(MS_CLIST_CONTACTDOUBLECLICKED, most_online, 0); - return 1; + return 0; } INT_PTR Meta_ClistMessageEventClicked(WPARAM wParam, LPARAM lParam) @@ -1047,16 +804,8 @@ int Meta_CallMostOnline(WPARAM hContact, LPARAM lParam) if (cc == NULL) return 0; - MCONTACT most_online_im = Meta_GetMostOnline(cc); - - // fix nick - Meta_CopyContactNick(cc, most_online_im); - - // fix status + Meta_CopyContactNick(cc, Meta_GetMostOnline(cc)); Meta_FixStatus(cc); - - // copy all other data - Meta_CopyData(cc); return 0; } @@ -1108,8 +857,6 @@ void Meta_InitServices() CreateProtoServiceFunction(META_PROTO, PSS_USERISTYPING, Meta_UserIsTyping); - CreateProtoServiceFunction(META_PROTO, PSR_MESSAGE, Meta_RecvMessage); - // file recv is done by subcontacts CreateProtoServiceFunction(META_PROTO, PSS_FILE, Meta_FileSend); @@ -1119,9 +866,6 @@ void Meta_InitServices() CreateProtoServiceFunction(META_PROTO, PSS_GETINFO, Meta_GetInfo); - CreateProtoServiceFunction(META_FILTER, PSR_MESSAGE, MetaFilter_RecvMessage); - CreateProtoServiceFunction(META_FILTER, PSS_MESSAGE, MetaFilter_SendMessage); - // API services and events CreateApiServices(); diff --git a/src/modules/metacontacts/meta_utils.cpp b/src/modules/metacontacts/meta_utils.cpp index af13339382..990e3e10b4 100644 --- a/src/modules/metacontacts/meta_utils.cpp +++ b/src/modules/metacontacts/meta_utils.cpp @@ -210,12 +210,9 @@ BOOL Meta_Assign(MCONTACT hSub, MCONTACT hMeta, BOOL set_as_default) currDb->MetaMergeHistory(ccDest, ccSub); // Ignore status if the option is on - if (options.suppress_status) + if (options.bSuppressStatus) CallService(MS_IGNORE_IGNORE, hSub, IGNOREEVENT_USERONLINE); - // copy other data - Meta_CopyData(ccDest); - NotifyEventHooks(hSubcontactsChanged, hMeta, 0); return TRUE; } @@ -277,7 +274,7 @@ MCONTACT Meta_GetMostOnlineSupporting(DBCachedContact *cc, int pflagnum, unsigne // 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) return most_online_contact; } else most_online_status = ID_STATUS_OFFLINE; @@ -341,198 +338,6 @@ int Meta_GetContactNumber(DBCachedContact *cc, MCONTACT hContact) return -1; } -BOOL dbv_same(DBVARIANT *dbv1, DBVARIANT *dbv2) -{ - if (dbv1->type != dbv2->type) return FALSE; - - switch (dbv1->type) { - case DBVT_BYTE: - return dbv1->bVal == dbv2->bVal; - case DBVT_WORD: - return dbv1->wVal == dbv2->wVal; - case DBVT_DWORD: - return dbv1->dVal == dbv2->dVal; - case DBVT_ASCIIZ: - return !strcmp(dbv1->pszVal, dbv2->pszVal); - case DBVT_BLOB: - return (dbv1->cpbVal == dbv2->cpbVal && !memcmp(dbv1->pbVal, dbv2->pbVal, dbv1->cpbVal)); - break; - default: - return FALSE; - } -} - -void copy_settings_array(DBCachedContact *ccMeta, char *module, const char *settings[], int num_settings) -{ - int most_online = Meta_GetContactNumber(ccMeta, Meta_GetMostOnline(ccMeta)); - - BOOL use_default = FALSE; - int source_contact = (use_default ? ccMeta->nDefault : most_online); - if (source_contact < 0 || source_contact >= ccMeta->nSubs) - return; - - for (int i = 0; i < num_settings; i++) { - BOOL bDataWritten = FALSE; - for (int j = 0; j < ccMeta->nSubs && !bDataWritten; j++) { - // do source (most online) first - MCONTACT hContact; - if (j == 0) - hContact = Meta_GetContactHandle(ccMeta, source_contact); - else if (j <= source_contact) - hContact = Meta_GetContactHandle(ccMeta, j - 1); - else - hContact = Meta_GetContactHandle(ccMeta, j); - - if (hContact == 0) - continue; - - char *used_mod; - if (!module) { - used_mod = GetContactProto(hContact); - if (!used_mod) - continue; // next contact - } - else used_mod = module; - - if (j == 0 && strcmp(settings[i], "MirVer") == 0) //Always reset MirVer - db_unset(ccMeta->contactID, (module ? used_mod : META_PROTO), settings[i]); - - DBVARIANT dbv1, dbv2; - BOOL bFree, got_val = !db_get_s(hContact, used_mod, settings[i], &dbv2, 0); - if (got_val) { - bFree = !db_get_s(ccMeta->contactID, (module ? used_mod : META_PROTO), settings[i], &dbv1, 0); - - if (strcmp(settings[i], "MirVer") == 0) { - if (db_get_w(hContact, used_mod, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) { - if (!bFree || (dbv1.pszVal == NULL || strcmp(dbv1.pszVal, "") == 0 || strlen(dbv1.pszVal) < 2)) { - db_set(ccMeta->contactID, (module ? used_mod : META_PROTO), settings[i], &dbv2); - bDataWritten = TRUE; //only break if found something to copy - } - } - } - else { - if (!bFree || !dbv_same(&dbv1, &dbv2)) { - db_set(ccMeta->contactID, (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) - bDataWritten = TRUE; //only break if found something to copy - } - 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 - } - else bDataWritten = TRUE; - } - db_free(&dbv2); - if (bFree) - db_free(&dbv1); - } - } - } -} - -const char *ProtoSettings[25] = -{ "BirthDay", "BirthMonth", "BirthYear", "Age", "Cell", "Cellular", "Homepage", "email", "Email", "e-mail", -"FirstName", "MiddleName", "LastName", "Title", "Timezone", "Gender", "MirVer", "ApparentMode", "IdleTS", "LogonTS", "IP", "RealIP", -"Auth", "ListeningTo", "Country" }; -const char *UserInfoSettings[71] = -{ "NickName", "FirstName", "MiddleName", "LastName", "Title", "Timezone", "Gender", "DOBd", "DOBm", "DOBy", -"Mye-mail0", "Mye-mail1", "MyPhone0", "MyPhone1", "MyNotes", "PersonalWWW", -"HomePhone", "HomeFax", "HomeMobile", "HomeStreet", "HomeCity", "HomeState", "HomeZip", "HomeCountry", -"WorkPhone", "WorkFax", "WorkMobile", "WorkStreet", "WorkCity", "WorkState", "WorkZip", "WorkCountry", "Company", "Department", "Position", -"Occupation", "Cellular", "Cell", "Phone", "Notes", - -"e-mail", "e-mail0", "e-mail1", "Homepage", "MaritalStatus", -"CompanyCellular", "CompanyCity", "CompanyState", "CompanyStreet", "CompanyCountry", "Companye-mail", -"CompanyHomepage", "CompanyDepartment", "CompanyOccupation", "CompanyPosition", "CompanyZip", - -"OriginCity", "OriginState", "OriginStreet", "OriginCountry", "OriginZip", -"City", "State", "Street", "Country", "Zip", - -"Language1", "Language2", "Language3", "Partner", "Gender" }; -const char *ContactPhotoSettings[5] = -{ "File", "Backup", "Format", "ImageHash", "RFile" }; -const char *MBirthdaySettings[3] = -{ "BirthDay", "BirthMonth", "BirthYear" }; - -// special handling for status message -// copy from first subcontact with any of these values that has the same status as the most online contact -// szProto: -// clist: "StatusMsg" - -void CopyStatusData(DBCachedContact *ccMeta) -{ - int num_contacts = db_get_dw(ccMeta->contactID, META_PROTO, "NumContacts", INVALID_CONTACT_ID), - most_online = Meta_GetContactNumber(ccMeta, Meta_GetMostOnline(ccMeta)); - WORD status = db_get_w(ccMeta->contactID, META_PROTO, "Status", ID_STATUS_OFFLINE); - MCONTACT hContact; - BOOL bDoneStatus = FALSE, bDoneXStatus = FALSE; - - for (int i = 0; i < num_contacts; i++) { - if (i == 0) - hContact = Meta_GetContactHandle(ccMeta, most_online); - else if (i <= most_online) - hContact = Meta_GetContactHandle(ccMeta, i - 1); - else - hContact = Meta_GetContactHandle(ccMeta, i); - - char *szProto = GetContactProto(hContact); - - if (szProto && db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE) == status) { - DBVARIANT dbv; - if (!bDoneStatus && !db_get_s(hContact, "CList", "StatusMsg", &dbv, 0)) { - db_set(ccMeta->contactID, "CList", "StatusMsg", &dbv); - db_free(&dbv); - bDoneStatus = TRUE; - } - if ((!bDoneXStatus) && (!db_get_s(hContact, szProto, "XStatusId", &dbv, 0)) && dbv.type != DBVT_DELETED) { - db_set_s(ccMeta->contactID, META_PROTO, "XStatusProto", szProto); - db_set(ccMeta->contactID, META_PROTO, "XStatusId", &dbv); - - db_free(&dbv); - if (!db_get_s(hContact, szProto, "XStatusMsg", &dbv, 0)) { - db_set(ccMeta->contactID, META_PROTO, "XStatusMsg", &dbv); - db_free(&dbv); - } - if (!db_get_s(hContact, szProto, "XStatusName", &dbv, 0)) { - db_set(ccMeta->contactID, META_PROTO, "XStatusName", &dbv); - db_free(&dbv); - } - bDoneXStatus = TRUE; - } - } - - if (bDoneStatus && bDoneXStatus) - break; - } - - if (!bDoneStatus) - db_unset(ccMeta->contactID, "CList", "StatusMsg"); - - if (!bDoneXStatus) { - db_unset(ccMeta->contactID, META_PROTO, "XStatusId"); - db_unset(ccMeta->contactID, META_PROTO, "XStatusMsg"); - db_unset(ccMeta->contactID, META_PROTO, "XStatusName"); - } -} - -void Meta_CopyData(DBCachedContact *cc) -{ - if (!options.copydata || cc == NULL) - return; - - CopyStatusData(cc); - - copy_settings_array(cc, 0, ProtoSettings, 25); - copy_settings_array(cc, "mBirthday", UserInfoSettings, 3); - copy_settings_array(cc, "ContactPhoto", ContactPhotoSettings, 5); - - if (options.copy_userinfo) - copy_settings_array(cc, "UserInfo", UserInfoSettings, 71); -} - MCONTACT Meta_GetContactHandle(DBCachedContact *cc, int contact_number) { if (contact_number >= cc->nSubs || contact_number < 0) @@ -613,7 +418,7 @@ int Meta_HideLinkedContacts(void) } } - if (options.suppress_status) + if (options.bSuppressStatus) CallService(MS_IGNORE_IGNORE, hContact, IGNOREEVENT_USERONLINE); } @@ -637,7 +442,7 @@ int Meta_HideMetaContacts(int hide) if (hide) Meta_SuppressStatus(FALSE); else - Meta_SuppressStatus(options.suppress_status); + Meta_SuppressStatus(options.bSuppressStatus); for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { if (CheckMeta(hContact) == NULL) @@ -665,7 +470,7 @@ int Meta_CopyContactNick(DBCachedContact *ccMeta, MCONTACT hContact) { DBVARIANT dbv, dbv_proto; - if (options.lockHandle) + if (options.bLockHandle) hContact = Meta_GetContactHandle(ccMeta, 0); if (!hContact) @@ -705,7 +510,6 @@ int Meta_SetAllNicks() MCONTACT most_online = Meta_GetMostOnline(cc); Meta_CopyContactNick(cc, most_online); Meta_FixStatus(cc); - Meta_CopyData(cc); } return 0; } @@ -778,8 +582,3 @@ void Meta_FixStatus(DBCachedContact *ccMeta) } else db_set_w(ccMeta->contactID, META_PROTO, "Status", ID_STATUS_OFFLINE); } - -INT_PTR Meta_IsEnabled() -{ - return db_get_b(0, META_PROTO, "Enabled", 1); -} diff --git a/src/modules/metacontacts/metacontacts.h b/src/modules/metacontacts/metacontacts.h index 2d7155b73d..d4dab57a54 100644 --- a/src/modules/metacontacts/metacontacts.h +++ b/src/modules/metacontacts/metacontacts.h @@ -33,9 +33,6 @@ INT_PTR TranslateMenuFunc(MCONTACT hContact, int i); void InitMenus(); extern int mcStatus; -__forceinline bool IsMeta(DBCachedContact *cc) { return cc->nSubs != -1; } -__forceinline bool IsSub(DBCachedContact *cc) { return cc->parentID != 0; } - INT_PTR Meta_Convert(WPARAM wParam,LPARAM lParam); INT_PTR Meta_AddTo(WPARAM wParam,LPARAM lParam); INT_PTR Meta_Edit(WPARAM wParam,LPARAM lParam); @@ -43,8 +40,6 @@ INT_PTR Meta_Delete(WPARAM wParam,LPARAM lParam); INT_PTR Meta_Default(WPARAM wParam,LPARAM lParam); INT_PTR Meta_ForceDefault(WPARAM wParam,LPARAM lParam); -INT_PTR Meta_IsEnabled(); - INT_PTR Meta_OnOff(WPARAM wParam, LPARAM lParam); int Meta_ModifyMenu(WPARAM wParam,LPARAM lParam); BOOL Meta_Assign(MCONTACT src, MCONTACT dest, BOOL set_as_default); @@ -55,7 +50,6 @@ int Meta_GetContactNumber(DBCachedContact *cc, MCONTACT hContact); int Meta_HideMetaContacts(int hide); int Meta_SuppressStatus(int suppress); int Meta_CopyContactNick(DBCachedContact *cc, MCONTACT hContact); -void Meta_CopyData(DBCachedContact *cc); int Meta_SetAllNicks(); int Meta_SwapContacts(DBCachedContact *cc, int contact_number1, int contact_number2); @@ -76,7 +70,6 @@ INT_PTR Meta_LoadIcon(WPARAM wParam,LPARAM lParam); INT_PTR Meta_SetStatus(WPARAM wParam,LPARAM lParam); INT_PTR Meta_GetStatus(WPARAM wParam,LPARAM lParam); INT_PTR Meta_SendMessage(WPARAM wParam,LPARAM lParam); -INT_PTR Meta_RecvMessage(WPARAM wParam,LPARAM lParam); INT_PTR Meta_ContactMenuFunc(WPARAM wParam, LPARAM lParam); void Meta_InitServices(); @@ -88,18 +81,9 @@ enum CListDisplayNameType {CNNT_NICK = 0, CNNT_DISPLAYNAME = 1}; struct MetaOptions { - BYTE set_default_on_recv; - BYTE always_use_default; - BYTE suppress_status; - BYTE subcontact_windows; - BYTE metahistory; - BYTE subhistory; - BYTE copydata; - BYTE lockHandle; - BYTE temp_default; - BYTE flash_meta_message_icon; - BYTE copy_userinfo; - BYTE use_proto_recv; + bool bEnabled; + bool bLockHandle; + bool bSuppressStatus; int menu_contact_label; int menu_function; @@ -131,7 +115,6 @@ HICON LoadIconEx(IconIndex i); HANDLE GetIconHandle(IconIndex i); extern HANDLE hEventDefaultChanged, hEventForceSend, hEventUnforceSend, hSubcontactsChanged; - extern POINT menuMousePoint; #define MAX_PROTOCOLS 20 diff --git a/src/resource.h b/src/resource.h index f00175281b..2b9f2f107e 100644 --- a/src/resource.h +++ b/src/resource.h @@ -51,7 +51,6 @@ #define IDD_METAEDIT 152 #define IDD_METAOPTIONS 153 #define IDD_METAPRIORITIES 154 -#define IDD_METAHISTORY 155 #define IDD_METACOPYPROGRESS 156 #define IDI_DND 158 #define IDI_OCCUPIED 159 @@ -378,9 +377,6 @@ #define IDC_RESETPROTOCOLDATA 1407 #define IDC_BYCUSTOM 1408 #define IDC_PROTOCOLORDERWARNING 1409 -#define IDC_CHK_SETDEFAULTRECV 1410 -#define IDC_CHK_ALWAYSUSEDEFAULT 1411 -#define IDC_CHK_TEMPDEFAULT 1412 #define IDC_CHK_SUPPRESSSTATUS 1413 #define IDC_RAD_UID 1414 #define IDC_RAD_DID 1415 @@ -390,11 +386,6 @@ #define IDC_RAD_NICK 1419 #define IDC_RAD_NAME 1420 #define IDC_CHK_LOCKHANDLE 1421 -#define IDC_CHK_SUBWINDOW 1422 -#define IDC_CHK_METAHISTORY 1423 -#define IDC_CHK_SUBHISTORY 1424 -#define IDC_CHK_COPYDATA 1425 -#define IDC_CHK_COPYHISTORY 1426 #define IDC_ED_DAYS 1427 #define IDC_SP_PRIORITY 1428 #define IDC_CMB_PROTOCOL 1429 diff --git a/src/resource.rc b/src/resource.rc index aa1e9517e7..f75eaaf0b5 100644 --- a/src/resource.rc +++ b/src/resource.rc @@ -776,13 +776,6 @@ STYLE DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_CHILD EXSTYLE WS_EX_CONTROLPARENT FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - CONTROL "Set default contact on receipt of message",IDC_CHK_SETDEFAULTRECV, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,9,290,10 - CONTROL "Always send to default contact if not offline",IDC_CHK_ALWAYSUSEDEFAULT, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,31,290,10 - GROUPBOX "Options",IDC_STATIC,0,0,297,178 - CONTROL "Suppress status notification for subcontacts",IDC_CHK_SUPPRESSSTATUS, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,42,290,10 GROUPBOX "Context Menu",IDC_STATIC,4,79,289,58 CONTROL "Use contact's unique ID",IDC_RAD_UID,"Button",BS_AUTORADIOBUTTON | WS_GROUP,13,100,112,10 CONTROL "Use contact's display name",IDC_RAD_DID,"Button",BS_AUTORADIOBUTTON | WS_GROUP,13,114,112,10 @@ -794,12 +787,7 @@ BEGIN GROUPBOX "Contact List",IDC_STATIC,4,139,289,33,WS_GROUP CONTROL "Display subcontact nickname",IDC_RAD_NICK,"Button",BS_AUTORADIOBUTTON | WS_GROUP,9,149,144,10 CONTROL "Display subcontact display name",IDC_RAD_NAME,"Button",BS_AUTORADIOBUTTON | WS_GROUP,9,160,144,10 - CONTROL "Use subcontact message windows",IDC_CHK_SUBWINDOW, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,64,155,10 - CONTROL "Copy subcontact data",IDC_CHK_COPYDATA,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,162,64,133,10 CONTROL "Lock name to first contact",IDC_CHK_LOCKHANDLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,173,155,115,10 - CONTROL "but only for the current conversation",IDC_CHK_TEMPDEFAULT, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,20,260,10 END IDD_METACOPYPROGRESS DIALOG 0, 0, 186, 90 @@ -838,23 +826,6 @@ BEGIN CTEXT "(Lower ranks are preferred)",IDC_STATIC,51,99,162,8 END -IDD_METAHISTORY DIALOGEX 0, 0, 287, 109 -STYLE DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_CHILD -EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - CONTROL "Copy subcontact history to MetaContact when creating or adding",IDC_CHK_COPYHISTORY, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,23,258,10 - RTEXT "Number of days to copy (0=all):",IDC_STATIC,13,37,125,8 - EDITTEXT IDC_ED_DAYS,158,35,31,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER - CONTROL "Keep MetaContact history synchronized with subcontacts",IDC_CHK_METAHISTORY, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,60,258,10 - CONTROL "Keep subcontact history synchronized with MetaContact",IDC_CHK_SUBHISTORY, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,78,258,10 - GROUPBOX "History (** beware - change at your own risk **)",IDC_STATIC,7,7,273,95,WS_GROUP -END - - ///////////////////////////////////////////////////////////////////////////// // // DESIGNINFO -- cgit v1.2.3