From e1a3a426a742028570baaee7430b2b5750734e4c Mon Sep 17 00:00:00 2001
From: George Hazan <ghazan@miranda.im>
Date: Wed, 27 Dec 2017 17:19:20 +0300
Subject: obsolete structure ADDCONTACTSTRUCT, service MS_ADDCONTACT_SHOW and
 whole m_addcontact.h removed and replaced with Contact_Add* functions

---
 src/core/stdfile/src/filerecvdlg.cpp |  13 +--
 src/core/stdfile/src/stdafx.h        |   1 -
 src/core/stdmsg/src/msgdialog.cpp    |   9 +-
 src/core/stdmsg/src/stdafx.h         |   1 -
 src/mir_app/src/MDatabaseCommon.cpp  |   2 +-
 src/mir_app/src/addcontact.cpp       | 184 ++++++++++++++++++-----------------
 src/mir_app/src/auth.cpp             |  21 +---
 src/mir_app/src/clui.cpp             |   6 +-
 src/mir_app/src/findadd.cpp          |  48 ++++-----
 src/mir_app/src/mir_app.def          |   3 +
 src/mir_app/src/mir_app64.def        |   3 +
 src/mir_app/src/modules.cpp          |   2 -
 src/mir_app/src/searchresults.cpp    |   9 +-
 src/mir_app/src/stdafx.h             |   1 -
 14 files changed, 136 insertions(+), 167 deletions(-)

(limited to 'src')

diff --git a/src/core/stdfile/src/filerecvdlg.cpp b/src/core/stdfile/src/filerecvdlg.cpp
index 49d1fcd3b1..9feef53743 100644
--- a/src/core/stdfile/src/filerecvdlg.cpp
+++ b/src/core/stdfile/src/filerecvdlg.cpp
@@ -346,15 +346,10 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
 			break;
 
 		case IDC_ADD:
-			{
-				ADDCONTACTSTRUCT acs = { 0 };
-				acs.hContact = dat->hContact;
-				acs.handleType = HANDLE_CONTACT;
-				acs.szProto = "";
-				CallService(MS_ADDCONTACT_SHOW, (WPARAM)hwndDlg, (LPARAM)&acs);
-				if (!db_get_b(dat->hContact, "CList", "NotOnList", 0))
-					ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), SW_HIDE);
-			}
+			Contact_Add(dat->hContact, hwndDlg);
+
+			if (!db_get_b(dat->hContact, "CList", "NotOnList", 0))
+				ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), SW_HIDE);
 			break;
 
 		case IDC_USERMENU:
diff --git a/src/core/stdfile/src/stdafx.h b/src/core/stdfile/src/stdafx.h
index cc4b8d3742..512cc93ad7 100644
--- a/src/core/stdfile/src/stdafx.h
+++ b/src/core/stdfile/src/stdafx.h
@@ -60,7 +60,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include <m_message.h>
 #include <m_userinfo.h>
 #include <m_history.h>
-#include <m_addcontact.h>
 #include <m_findadd.h>
 #include <m_file.h>
 #include <m_icolib.h>
diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp
index 104b5fff31..937bb69857 100644
--- a/src/core/stdmsg/src/msgdialog.cpp
+++ b/src/core/stdmsg/src/msgdialog.cpp
@@ -1291,13 +1291,8 @@ INT_PTR CSrmmWindow::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
 			break;
 
 		case IDC_ADD:
-			{
-				ADDCONTACTSTRUCT acs = {};
-				acs.hContact = m_hContact;
-				acs.handleType = HANDLE_CONTACT;
-				acs.szProto = nullptr;
-				CallService(MS_ADDCONTACT_SHOW, (WPARAM)m_hwnd, (LPARAM)&acs);
-			}
+			Contact_Add(m_hContact, m_hwnd);
+
 			if (!db_get_b(m_hContact, "CList", "NotOnList", 0))
 				ShowWindow(GetDlgItem(m_hwnd, IDC_ADD), FALSE);
 			break;
diff --git a/src/core/stdmsg/src/stdafx.h b/src/core/stdmsg/src/stdafx.h
index 6069356b35..cfdb92aa2a 100644
--- a/src/core/stdmsg/src/stdafx.h
+++ b/src/core/stdmsg/src/stdafx.h
@@ -55,7 +55,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include <m_contacts.h>
 #include <m_userinfo.h>
 #include <m_history.h>
-#include <m_addcontact.h>
 #include <m_chat_int.h>
 #include <m_message.h>
 #include <m_file.h>
diff --git a/src/mir_app/src/MDatabaseCommon.cpp b/src/mir_app/src/MDatabaseCommon.cpp
index 34f1d68caf..9d3025603a 100644
--- a/src/mir_app/src/MDatabaseCommon.cpp
+++ b/src/mir_app/src/MDatabaseCommon.cpp
@@ -233,7 +233,7 @@ STDMETHODIMP_(BOOL) MDatabaseCommon::GetContactSettingStr(MCONTACT contactID, LP
 STDMETHODIMP_(BOOL) MDatabaseCommon::GetContactSettingStatic(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv)
 {
 	bool bNeedsWchars;
-	size_t cbSaved;
+	size_t cbSaved = 0;
 
 	if (dbv->type == DBVT_WCHAR) { // there's no wchar_t strings in a database, we need conversion
 		cbSaved = dbv->cchVal - 1;
diff --git a/src/mir_app/src/addcontact.cpp b/src/mir_app/src/addcontact.cpp
index 9f13b06811..31591414b9 100644
--- a/src/mir_app/src/addcontact.cpp
+++ b/src/mir_app/src/addcontact.cpp
@@ -37,15 +37,20 @@ static wchar_t* sttDecodeString(DWORD dwFlags, MAllStrings &src)
 
 class CAddContactDlg : public CDlgBase
 {
-	ADDCONTACTSTRUCT m_acs;
-
 	CCtrlEdit   m_authReq, m_myHandle;
 	CCtrlCheck  m_chkAdded, m_chkAuth, m_chkOpen;
 	CCtrlButton m_btnOk;
 	CCtrlCombo  m_group;
 
+protected:
+	MEVENT m_hDbEvent;
+	MCONTACT m_hContact;
+	const char *m_szProto;
+	PROTOSEARCHRESULT *m_psr;
+	CMStringW m_szName;
+
 public:
-	CAddContactDlg(ADDCONTACTSTRUCT *acs) :
+	CAddContactDlg() :
 		CDlgBase(g_hInst, IDD_ADDCONTACT),
 		m_chkAdded(this, IDC_ADDED),
 		m_chkAuth(this, IDC_AUTH),
@@ -58,67 +63,19 @@ public:
 		m_chkAuth.OnChange = Callback(this, &CAddContactDlg::OnAuthClicked);
 		m_chkOpen.OnChange = Callback(this, &CAddContactDlg::OnOpenClicked);
 		m_btnOk.OnClick = Callback(this, &CAddContactDlg::OnOk);
-
-		m_acs = *acs;
 	}
 
 	void OnInitDialog()
 	{
-		char szUin[10];
 		Window_SetSkinIcon_IcoLib(m_hwnd, SKINICON_OTHER_ADDCONTACT);
-		if (m_acs.handleType == HANDLE_EVENT) {
-			DWORD dwUin;
-			DBEVENTINFO dbei = {};
-			dbei.cbBlob = sizeof(DWORD);
-			dbei.pBlob = (PBYTE)&dwUin;
-			db_event_get(m_acs.hDbEvent, &dbei);
-			_ltoa(dwUin, szUin, 10);
-			m_acs.szProto = dbei.szModule;
-		}
-
-		MCONTACT hContact;
-		wchar_t *szName = nullptr, *tmpStr = nullptr;
-		if (m_acs.handleType == HANDLE_CONTACT)
-			szName = cli.pfnGetContactDisplayName(hContact = m_acs.hContact, 0);
-		else {
-			int isSet = 0;
-			hContact = 0;
-
-			if (m_acs.handleType == HANDLE_EVENT) {
-				DBEVENTINFO dbei = {};
-				dbei.cbBlob = db_event_getBlobSize(m_acs.hDbEvent);
-				dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob);
-				db_event_get(m_acs.hDbEvent, &dbei);
-				hContact = *(MCONTACT*)(dbei.pBlob + sizeof(DWORD));
-				mir_free(dbei.pBlob);
-				if (hContact != INVALID_CONTACT_ID) {
-					szName = cli.pfnGetContactDisplayName(hContact, 0);
-					isSet = 1;
-				}
-			}
-			if (!isSet) {
-				if (m_acs.handleType == HANDLE_EVENT)
-					szName = mir_a2u(szUin);
-				else {
-					szName = sttDecodeString(m_acs.psr->flags, m_acs.psr->id);
-					if (szName == nullptr)
-						szName = sttDecodeString(m_acs.psr->flags, m_acs.psr->nick);
-				}
-			}
-		}
 
-		if (szName && szName[0])
-			SetCaption(CMStringW(FORMAT, TranslateT("Add %s"), szName));
+		if (!m_szName.IsEmpty())
+			SetCaption(CMStringW(FORMAT, TranslateT("Add %s"), m_szName.c_str()));
 		else
 			SetCaption(TranslateT("Add contact"));
-		mir_free(tmpStr);
-
-		if (m_acs.handleType == HANDLE_CONTACT && m_acs.hContact)
-			if (m_acs.szProto == nullptr || (m_acs.szProto != nullptr && *m_acs.szProto == 0))
-				m_acs.szProto = GetContactProto(m_acs.hContact);
 
 		int groupSel = 0;
-		ptrW tszGroup(db_get_wsa(hContact, "CList", "Group"));
+		ptrW tszGroup(db_get_wsa(m_hContact, "CList", "Group"));
 		wchar_t *grpName;
 		for (int groupId = 1; (grpName = Clist_GroupGetName(groupId, nullptr)) != nullptr; groupId++) {
 			int id = m_group.AddString(grpName, groupId);
@@ -137,7 +94,7 @@ public:
 		if (db_get_b(0, "Miranda", "AuthOpenWindow", 1))
 			m_chkOpen.SetState(true);
 
-		DWORD flags = (m_acs.szProto) ? CallProtoServiceInt(0, m_acs.szProto, PS_GETCAPS, PFLAGNUM_4, 0) : 0;
+		DWORD flags = (m_szProto) ? CallProtoServiceInt(0, m_szProto, PS_GETCAPS, PFLAGNUM_4, 0) : 0;
 		if (flags & PF4_FORCEADDED)  // force you were added requests for this protocol
 			m_chkAdded.Enable(false);
 
@@ -159,7 +116,7 @@ public:
 
 	void OnAuthClicked(CCtrlButton*)
 	{
-		DWORD flags = CallProtoServiceInt(0, m_acs.szProto, PS_GETCAPS, PFLAGNUM_4, 0);
+		DWORD flags = CallProtoServiceInt(0, m_szProto, PS_GETCAPS, PFLAGNUM_4, 0);
 		if (flags & PF4_NOCUSTOMAUTH)
 			m_authReq.Enable(false);
 		else
@@ -174,26 +131,15 @@ public:
 
 	void OnOk(CCtrlButton*)
 	{
-		MCONTACT hContact = INVALID_CONTACT_ID;
-		switch (m_acs.handleType) {
-		case HANDLE_EVENT:
-			{
-				DBEVENTINFO dbei = {};
-				db_event_get(m_acs.hDbEvent, &dbei);
-				hContact = (MCONTACT)CallProtoServiceInt(0, dbei.szModule, PS_ADDTOLISTBYEVENT, 0, (LPARAM)m_acs.hDbEvent);
-			}
-			break;
-
-		case HANDLE_SEARCHRESULT:
-			hContact = (MCONTACT)CallProtoServiceInt(0, m_acs.szProto, PS_ADDTOLIST, 0, (LPARAM)m_acs.psr);
-			break;
-
-		case HANDLE_CONTACT:
-			hContact = m_acs.hContact;
-			break;
-		}
+		MCONTACT hContact = 0;
+		if (m_hDbEvent)
+			hContact = (MCONTACT)CallProtoServiceInt(0, m_szProto, PS_ADDTOLISTBYEVENT, 0, m_hDbEvent);
+		else if (m_psr)
+			hContact = (MCONTACT)CallProtoServiceInt(0, m_szProto, PS_ADDTOLIST, 0, (LPARAM)m_psr);
+		else
+			hContact = m_hContact;
 
-		if (hContact == 0)
+		if (hContact == 0) // something went wrong
 			return;
 
 		ptrW szHandle(m_myHandle.GetText());
@@ -210,7 +156,7 @@ public:
 			ProtoChainSend(hContact, PSS_ADDED, 0, 0);
 
 		if (m_chkAuth.GetState()) {
-			DWORD flags = CallProtoServiceInt(0, m_acs.szProto, PS_GETCAPS, PFLAGNUM_4, 0);
+			DWORD flags = CallProtoServiceInt(0, m_szProto, PS_GETCAPS, PFLAGNUM_4, 0);
 			if (flags & PF4_NOCUSTOMAUTH)
 				ProtoChainSend(hContact, PSS_AUTHREQUEST, 0, 0);
 			else
@@ -222,23 +168,85 @@ public:
 	}
 };
 
-INT_PTR AddContactDialog(WPARAM wParam, LPARAM lParam)
+MIR_APP_DLL(void) Contact_Add(MCONTACT hContact, HWND hwndParent)
 {
-	if (lParam == 0)
-		return 1;
+	if (hContact == 0)
+		return;
+
+	struct CAddByContact : public CAddContactDlg
+	{
+		CAddByContact(MCONTACT hContact)			
+		{	
+			m_hContact = hContact;
+			m_szName = cli.pfnGetContactDisplayName(hContact, 0);
+			m_szProto = GetContactProto(hContact);
+		}
+	};
 
-	ADDCONTACTSTRUCT *acs = (ADDCONTACTSTRUCT*)lParam;
-	if (wParam) {
-		CAddContactDlg dlg(acs);
-		dlg.SetParent((HWND)wParam);
+	if (hwndParent != nullptr) {
+		CAddByContact dlg(hContact);
+		dlg.SetParent(hwndParent);
 		dlg.DoModal();
 	}
-	else (new CAddContactDlg(acs))->Show();
-	return 0;
+	else (new CAddByContact(hContact))->Show();
 }
 
-int LoadAddContactModule(void)
+MIR_APP_DLL(void) Contact_AddByEvent(MEVENT hEvent, HWND hwndParent)
 {
-	CreateServiceFunction(MS_ADDCONTACT_SHOW, AddContactDialog);
-	return 0;
+	struct CAddByEvent : public CAddContactDlg
+	{
+		CAddByEvent(MEVENT hEvent)
+		{
+			m_hDbEvent = hEvent;
+
+			DWORD dwData[2];
+			DBEVENTINFO dbei = {};
+			dbei.cbBlob = sizeof(dwData);
+			dbei.pBlob = (PBYTE)&dwData;
+			db_event_get(hEvent, &dbei);
+			if (dwData[0] != 0)
+				m_szName.Format(L"%d", dwData[0]);
+
+			m_hContact = dwData[1];
+			if (m_hContact != INVALID_CONTACT_ID)
+				m_szName = cli.pfnGetContactDisplayName(m_hContact, 0);
+
+			m_szProto = dbei.szModule;
+		}
+	};
+
+	if (hwndParent != nullptr) {
+		CAddByEvent dlg(hEvent);
+		dlg.SetParent(hwndParent);
+		dlg.DoModal();
+	}
+	else (new CAddByEvent(hEvent))->Show();
+}
+
+MIR_APP_DLL(void) Contact_AddBySearch(const char *szProto, struct PROTOSEARCHRESULT *psr, HWND hwndParent)
+{
+	struct CAddBySearch : public CAddContactDlg
+	{
+		CAddBySearch(const char *szProto, struct PROTOSEARCHRESULT *psr)
+		{
+			m_szProto = szProto;
+			m_psr = psr;
+
+			wchar_t *p = sttDecodeString(psr->flags, psr->id);
+			if (p == nullptr)
+				p = sttDecodeString(psr->flags, psr->nick);
+			
+			if (p) {
+				m_szName = p;
+				mir_free(p);
+			}
+		}
+	};
+
+	if (hwndParent != nullptr) {
+		CAddBySearch dlg(szProto, psr);
+		dlg.SetParent(hwndParent);
+		dlg.DoModal();
+	}
+	else (new CAddBySearch(szProto, psr))->Show();
 }
diff --git a/src/mir_app/src/auth.cpp b/src/mir_app/src/auth.cpp
index d80d90bbc2..9c582bcfc6 100644
--- a/src/mir_app/src/auth.cpp
+++ b/src/mir_app/src/auth.cpp
@@ -143,13 +143,8 @@ public:
 		db_event_get(m_hDbEvent, &dbei);
 		CallProtoService(dbei.szModule, PS_AUTHALLOW, m_hDbEvent, 0);
 
-		if (chkAdd.GetState()) {
-			ADDCONTACTSTRUCT acs = { 0 };
-			acs.hDbEvent = m_hDbEvent;
-			acs.handleType = HANDLE_EVENT;
-			acs.szProto = "";
-			CallService(MS_ADDCONTACT_SHOW, (WPARAM)m_hwnd, (LPARAM)&acs);
-		}
+		if (chkAdd.GetState())
+			Contact_AddByEvent(m_hDbEvent, m_hwnd);
 	}
 
 	void onClick_Cancel(CCtrlButton*)
@@ -273,20 +268,12 @@ public:
 
 	void onClick_OK(CCtrlButton*)
 	{
-		ADDCONTACTSTRUCT acs = { 0 };
-		acs.hDbEvent = m_hDbEvent;
-		acs.handleType = HANDLE_EVENT;
-		acs.szProto = "";
-		CallService(MS_ADDCONTACT_SHOW, (WPARAM)m_hwnd, (LPARAM)&acs);
+		Contact_AddByEvent(m_hDbEvent, m_hwnd);
 	}
 
 	void onClick_Add(CCtrlButton*)
 	{
-		ADDCONTACTSTRUCT acs = { 0 };
-		acs.hDbEvent = m_hDbEvent;
-		acs.handleType = HANDLE_EVENT;
-		acs.szProto = "";
-		CallService(MS_ADDCONTACT_SHOW, (WPARAM)m_hwnd, (LPARAM)&acs);
+		Contact_AddByEvent(m_hDbEvent, m_hwnd);
 
 		if (m_hContact == INVALID_CONTACT_ID || !db_get_b(m_hContact, "CList", "NotOnList", 0))
 			ShowWindow(GetDlgItem(m_hwnd, IDC_ADD), FALSE);
diff --git a/src/mir_app/src/clui.cpp b/src/mir_app/src/clui.cpp
index 40db3c69ca..4e82f1ac36 100644
--- a/src/mir_app/src/clui.cpp
+++ b/src/mir_app/src/clui.cpp
@@ -204,11 +204,7 @@ static INT_PTR MenuItem_DeleteContact(WPARAM wParam, LPARAM lParam)
 
 static INT_PTR MenuItem_AddContactToList(WPARAM hContact, LPARAM)
 {
-	ADDCONTACTSTRUCT acs = { 0 };
-	acs.hContact = hContact;
-	acs.handleType = HANDLE_CONTACT;
-	acs.szProto = "";
-	CallService(MS_ADDCONTACT_SHOW, 0, (LPARAM)&acs);
+	Contact_Add(hContact);
 	return 0;
 }
 
diff --git a/src/mir_app/src/findadd.cpp b/src/mir_app/src/findadd.cpp
index 8d6fd86e88..0a66352c4a 100644
--- a/src/mir_app/src/findadd.cpp
+++ b/src/mir_app/src/findadd.cpp
@@ -745,36 +745,28 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP
 			break;
 
 		case IDC_ADD:
-			{
-				ADDCONTACTSTRUCT acs = { 0 };
-
-				if (ListView_GetSelectedCount(hwndList) == 1) {
-					LVITEM lvi;
-					lvi.mask = LVIF_PARAM;
-					lvi.iItem = ListView_GetNextItem(hwndList, -1, LVNI_ALL | LVNI_SELECTED);
-					ListView_GetItem(hwndList, &lvi);
-					ListSearchResult *lsr = (ListSearchResult*)lvi.lParam;
-					acs.szProto = lsr->szProto;
-					acs.psr = &lsr->psr;
-				}
-				else {
-					wchar_t str[256];
-					GetDlgItemText(hwndDlg, IDC_PROTOID, str, _countof(str));
-					if (*rtrimw(str) == 0)
-						break;
-
-					PROTOSEARCHRESULT psr = { 0 };
-					psr.cbSize = sizeof(psr);
-					psr.flags = PSR_UNICODE;
-					psr.id.w = str;
+			if (ListView_GetSelectedCount(hwndList) == 1) {
+				LVITEM lvi;
+				lvi.mask = LVIF_PARAM;
+				lvi.iItem = ListView_GetNextItem(hwndList, -1, LVNI_ALL | LVNI_SELECTED);
+				ListView_GetItem(hwndList, &lvi);
+				ListSearchResult *lsr = (ListSearchResult*)lvi.lParam;
+				Contact_AddBySearch(lsr->szProto, &lsr->psr, hwndDlg);
+			}
+			else {
+				wchar_t str[256];
+				GetDlgItemText(hwndDlg, IDC_PROTOID, str, _countof(str));
+				if (*rtrimw(str) == 0)
+					break;
 
-					acs.psr = &psr;
-					acs.szProto = (char*)SendDlgItemMessage(hwndDlg, IDC_PROTOLIST, CB_GETITEMDATA,
-						SendDlgItemMessage(hwndDlg, IDC_PROTOLIST, CB_GETCURSEL, 0, 0), 0);
-				}
+				char *szProto = (char*)SendDlgItemMessage(hwndDlg, IDC_PROTOLIST, CB_GETITEMDATA,
+					SendDlgItemMessage(hwndDlg, IDC_PROTOLIST, CB_GETCURSEL, 0, 0), 0);
 
-				acs.handleType = HANDLE_SEARCHRESULT;
-				CallService(MS_ADDCONTACT_SHOW, (WPARAM)hwndDlg, (LPARAM)&acs);
+				PROTOSEARCHRESULT psr = { 0 };
+				psr.cbSize = sizeof(psr);
+				psr.flags = PSR_UNICODE;
+				psr.id.w = str;
+				Contact_AddBySearch(szProto, &psr, hwndDlg);
 			}
 			break;
 
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index 983061b83d..73fd746295 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -489,3 +489,6 @@ Clist_SetStatusMode @464
 ?EnumResidentSettings@MDatabaseCommon@@UAGHP6AHPBDPAX@Z1@Z @494 NONAME
 KillModuleOptions @495
 Srmm_GetColorTable @496
+Contact_Add @497
+Contact_AddByEvent @498
+Contact_AddBySearch @499
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index 83a06250da..defbe2c365 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -489,3 +489,6 @@ Clist_SetStatusMode @464
 ?EnumResidentSettings@MDatabaseCommon@@UEAAHP6AHPEBDPEAX@Z1@Z @494 NONAME
 KillModuleOptions @495
 Srmm_GetColorTable @496
+Contact_Add @497
+Contact_AddByEvent @498
+Contact_AddBySearch @499
diff --git a/src/mir_app/src/modules.cpp b/src/mir_app/src/modules.cpp
index 3576c79056..fc992baa5a 100644
--- a/src/mir_app/src/modules.cpp
+++ b/src/mir_app/src/modules.cpp
@@ -53,7 +53,6 @@ int  LoadSkinHotkeys(void);
 int  LoadUserInfoModule(void);	// ui: user info
 int  LoadVisibilityModule(void);	// ui: visibility control
 
-int  LoadAddContactModule(void);	// ui: authcontrol contacts
 int  LoadUtilsModule(void);		// ui: utils (has a few window classes, like HyperLink)
 int  LoadCLCModule(void);		// window class: CLC control
 int  LoadButtonModule(void);		// window class: button class
@@ -150,7 +149,6 @@ int LoadDefaultModules(void)
 	if (LoadProtocolsModule()) return 1;
 	LoadDbAccounts();                    // retrieves the account array from a database
 	if (LoadContactsModule()) return 1;
-	if (LoadAddContactModule()) return 1;
 	if (LoadMetacontacts()) return 1;
 
 	if (LoadNewPluginsModule()) return 1;    // will call Load(void) on everything, clist will load first
diff --git a/src/mir_app/src/searchresults.cpp b/src/mir_app/src/searchresults.cpp
index fd8395c8d7..da1224ff7a 100644
--- a/src/mir_app/src/searchresults.cpp
+++ b/src/mir_app/src/searchresults.cpp
@@ -353,14 +353,9 @@ void ShowMoreOptionsMenu(HWND hwndDlg, int x, int y)
 	int commandId = TrackPopupMenu(hPopupMenu, TPM_RIGHTBUTTON | TPM_RETURNCMD, x, y, 0, hwndDlg, nullptr);
 	switch (commandId) {
 	case IDC_ADD:
-		{
-			ADDCONTACTSTRUCT acs = { 0 };
-			acs.handleType = HANDLE_SEARCHRESULT;
-			acs.szProto = lsr->szProto;
-			acs.psr = &lsr->psr;
-			CallService(MS_ADDCONTACT_SHOW, (WPARAM)hwndDlg, (LPARAM)&acs);
-		}
+		Contact_AddBySearch(lsr->szProto, &lsr->psr, hwndDlg);
 		break;
+
 	case IDC_DETAILS:
 		{
 			MCONTACT hContact = (MCONTACT)CallProtoServiceInt(0, lsr->szProto, PS_ADDTOLIST, PALF_TEMPORARY, (LPARAM)&lsr->psr);
diff --git a/src/mir_app/src/stdafx.h b/src/mir_app/src/stdafx.h
index cfcf71bf9e..7019ad5f50 100644
--- a/src/mir_app/src/stdafx.h
+++ b/src/mir_app/src/stdafx.h
@@ -78,7 +78,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include <m_contacts.h>
 #include <m_message.h>
 #include <m_userinfo.h>
-#include <m_addcontact.h>
 #include <m_findadd.h>
 #include <m_file.h>
 #include <m_awaymsg.h>
-- 
cgit v1.2.3