diff options
author | George Hazan <ghazan@miranda.im> | 2017-12-27 17:19:20 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-12-27 17:19:20 +0300 |
commit | e1a3a426a742028570baaee7430b2b5750734e4c (patch) | |
tree | ed801bc7954fcd7c860c506d4f451a8bcb82e39b | |
parent | 3ae8bfcab00ae1b497b8c1c61d6dcf4bf7322e06 (diff) |
obsolete structure ADDCONTACTSTRUCT, service MS_ADDCONTACT_SHOW and whole m_addcontact.h removed and replaced with Contact_Add* functions
49 files changed, 203 insertions, 361 deletions
diff --git a/include/m_addcontact.h b/include/m_addcontact.h deleted file mode 100644 index c4ee042ef6..0000000000 --- a/include/m_addcontact.h +++ /dev/null @@ -1,68 +0,0 @@ -/*
-
-Miranda NG: the free IM client for Microsoft* Windows*
-
-Copyright (c) 2012-17 Miranda NG project (https://miranda-ng.org)
-Copyright (c) 2000-08 Miranda ICQ/IM project,
-all portions of this codebase are copyrighted to the people
-listed in contributors.txt.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#ifndef M_ADDCONTACT_H__
-#define M_ADDCONTACT_H__ 1
-
-typedef struct{
- int handleType; // one of the HANDLE_ constants
- union {
- MEVENT hDbEvent; // hDbEvent if acs.handleType == HANDLE_EVENT
- MCONTACT hContact; // hContact if acs.handleType == HANDLE_CONTACT
- // ignored if acs.handleType == HANDLE_SEARCHRESULT
- };
- const char *szProto; // ignored if acs.handleType != HANDLE_SEARCHRESULT
- PROTOSEARCHRESULT *psr; // ignored if acs.handleType != HANDLE_SEARCHRESULT
-}ADDCONTACTSTRUCT;
-
-/*
- Description: Open the add contact dialog, see notes
-
- wParam = [ (WPARAM)hWndParent ]
- lParam = (LPARAM)(ADDCONTACTSTRUCT*)&acs
-
- Notes:
-
- During 0.3.0.0 development (circa 2003/06/08)
-
- An entire copy of the ADDCONTACTSTRUCT structure is made,
- the PROTOSEARCHRESULT is also copied at psr->cbSize, all default
- strings are copied (even if they're not needed/used)
- if you pass a structure that is bigger than PROTOSEARCHRESULT
- then do not use pointers in the newly defined area because
- they will not be copied.
-
- passing wParam == NULL will result in a dialog that is created modeless
-
- Before the circa, a modal dialog was *always* created and
- strings within PROTOSEARCHRESULT were not copied.
-
-*/
-
-#define HANDLE_SEARCHRESULT 0
-#define HANDLE_EVENT 1
-#define HANDLE_CONTACT 2
-#define MS_ADDCONTACT_SHOW "AddContact/Show"
-
-#endif // M_ADDCONTACT_H__
diff --git a/include/m_contacts.h b/include/m_contacts.h index 9295074932..17811981b3 100644 --- a/include/m_contacts.h +++ b/include/m_contacts.h @@ -79,4 +79,13 @@ EXTERN_C MIR_APP_DLL(wchar_t*) Contact_GetInfo( MCONTACT hContact, // contact id or NULL for the global data
const char *szProto = NULL); // protocol for global data. if skipped, grabbed from hContact
+/////////////////////////////////////////////////////////////////////////////////////////
+// Add contact's dialog
+
+// passing hWnd == NULL will result in a dialog that is created modeless
+
+EXTERN_C MIR_APP_DLL(void) Contact_Add(MCONTACT hContact, HWND hwndParent = nullptr);
+EXTERN_C MIR_APP_DLL(void) Contact_AddByEvent(MEVENT hEvent, HWND hwndParent = nullptr);
+EXTERN_C MIR_APP_DLL(void) Contact_AddBySearch(const char *m_szProto, struct PROTOSEARCHRESULT *m_psr, HWND hwndParent = nullptr);
+
#endif // M_CONTACTS_H__
diff --git a/include/m_protosvc.h b/include/m_protosvc.h index cc6c6ccc13..4c1064e6e4 100644 --- a/include/m_protosvc.h +++ b/include/m_protosvc.h @@ -338,7 +338,8 @@ static __inline unsigned long Proto_Status2Flag(int status) #define PSR_UNICODE 0x0001 // all strings go in UTF16-LE
#define PSR_UTF8 0x0002 // all strings go in UTF8
-typedef struct {
+struct PROTOSEARCHRESULT
+{
int cbSize;
MAllStrings nick;
MAllStrings firstName;
@@ -346,7 +347,7 @@ typedef struct { MAllStrings email;
MAllStrings id;
int flags;
-} PROTOSEARCHRESULT;
+};
#define PS_BASICSEARCH "/BasicSearch"
@@ -371,11 +372,12 @@ typedef struct { // Results are returned as for PS_BASICSEARCH.
// This function is only available if the PF1_SEARCHBYNAME capability is set
-typedef struct {
+struct PROTOSEARCHBYNAME
+{
wchar_t *pszNick;
wchar_t *pszFirstName;
wchar_t *pszLastName;
-} PROTOSEARCHBYNAME;
+};
#define PS_SEARCHBYNAME "/SearchByName"
@@ -405,12 +407,13 @@ typedef struct { #define PS_SEARCHBYADVANCED "/SearchByAdvanced"
-typedef struct {
+struct CUSTOMSEARCHRESULTS
+{
size_t nSize;
int nFieldCount;
wchar_t **pszFields;
PROTOSEARCHRESULT psr;
-} CUSTOMSEARCHRESULTS;
+};
///////////////////////////////////////////////////////////////////////////////
// Adds a search result to the contact list
@@ -465,10 +468,11 @@ typedef struct { #define FILERESUME_RENAME 3
#define FILERESUME_SKIP 4
-typedef struct {
+struct PROTOFILERESUME
+{
int action; // a FILERESUME_ flag
const wchar_t *szFilename; // full path. Only valid if action == FILERESUME_RENAME
-} PROTOFILERESUME;
+};
#define PS_FILERESUME "/FileResume"
@@ -743,14 +747,15 @@ typedef struct { // DB event: EVENTTYPE_MESSAGE, blob contains szMessage without 0 terminator
// Return 0 - success, other failure
-typedef struct {
+struct PROTORECVEVENT
+{
DWORD flags;
DWORD timestamp; // unix time
char *szMessage; // message body in utf8
LPARAM lParam; // extra space for the network level protocol module
void *pCustomData;
DWORD cbCustomDataSize;
-} PROTORECVEVENT;
+};
#define PREF_CREATEREAD 1 // create the database event with the 'read' flag set
#define PREF_RTL 4 // 0.5+ addition: support for right-to-left messages
@@ -801,14 +806,15 @@ __forceinline INT_PTR Proto_AuthRecv(const char *szProtoName, PROTORECVEVENT *pc #define PRFF_UNICODE 1
-typedef struct {
+struct PROTORECVFILET
+{
DWORD dwFlags; // PRFF_*
DWORD timestamp; // unix time
MAllStrings descr; // file description
int fileCount; // number of files being transferred
MAllStringArray files; // array of file names
LPARAM lParam; // extra space for the network level protocol module
-} PROTORECVFILET;
+};
#define PSR_FILE "/RecvFile"
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib Binary files differindex 1ccbe1750a..1ad4944bc5 100644 --- a/libs/win32/mir_app.lib +++ b/libs/win32/mir_app.lib diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib Binary files differindex 965d9cf872..3a4f05d465 100644 --- a/libs/win64/mir_app.lib +++ b/libs/win64/mir_app.lib diff --git a/plugins/AddContactPlus/src/addcontact.cpp b/plugins/AddContactPlus/src/addcontact.cpp index 85bab9265a..44ce81bad8 100644 --- a/plugins/AddContactPlus/src/addcontact.cpp +++ b/plugins/AddContactPlus/src/addcontact.cpp @@ -25,7 +25,6 @@ struct AddDialogParam : public MZeroedObject {
AddDialogParam() {}
- int handleType;
HANDLE handle;
CMStringA proto;
PROTOSEARCHRESULT *psr;
@@ -155,7 +154,6 @@ INT_PTR CALLBACK AddContactDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM) switch (msg) {
case WM_INITDIALOG:
acs = new AddDialogParam();
- acs->handleType = HANDLE_SEARCHRESULT;
SetWindowLongPtr(hdlg, GWLP_USERDATA, (LONG_PTR)acs);
Utils_RestoreWindowPositionNoSize(hdlg, NULL, "AddContact", "");
diff --git a/plugins/AddContactPlus/src/stdafx.h b/plugins/AddContactPlus/src/stdafx.h index db8647b8b6..bd1c6996d8 100644 --- a/plugins/AddContactPlus/src/stdafx.h +++ b/plugins/AddContactPlus/src/stdafx.h @@ -32,7 +32,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include <m_langpack.h>
#include <m_message.h>
#include <m_protosvc.h>
-#include <m_addcontact.h>
+#include <m_contacts.h>
#include <m_string.h>
#include "m_toptoolbar.h"
diff --git a/plugins/Clist_nicer/src/clistmenus.cpp b/plugins/Clist_nicer/src/clistmenus.cpp index 5076f93f09..f1a57c2dac 100644 --- a/plugins/Clist_nicer/src/clistmenus.cpp +++ b/plugins/Clist_nicer/src/clistmenus.cpp @@ -173,13 +173,8 @@ static INT_PTR CALLBACK IgnoreDialogProc(HWND hWnd, UINT msg, WPARAM wParam, LPA break;
case IDC_IGN_ADDPERMANENTLY:
- {
- ADDCONTACTSTRUCT acs = { 0 };
- acs.hContact = hContact;
- acs.handleType = HANDLE_CONTACT;
- CallService(MS_ADDCONTACT_SHOW, (WPARAM)hWnd, (LPARAM)&acs);
- Utils::enableDlgControl(hWnd, IDC_IGN_ADDPERMANENTLY, db_get_b(hContact, "CList", "NotOnList", 0));
- }
+ Contact_Add(hContact, hWnd);
+ Utils::enableDlgControl(hWnd, IDC_IGN_ADDPERMANENTLY, db_get_b(hContact, "CList", "NotOnList", 0));
break;
case IDC_DSP_LOADDEFAULT:
diff --git a/plugins/Clist_nicer/src/stdafx.h b/plugins/Clist_nicer/src/stdafx.h index 9754475682..71ccf05041 100644 --- a/plugins/Clist_nicer/src/stdafx.h +++ b/plugins/Clist_nicer/src/stdafx.h @@ -48,7 +48,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <m_options.h>
#include <m_protosvc.h>
#include <m_skin.h>
-#include <m_addcontact.h>
+#include <m_contacts.h>
#include <m_timezones.h>
#include <m_cluiframes.h>
#include <m_icolib.h>
diff --git a/plugins/ContactsPlus/src/receive.cpp b/plugins/ContactsPlus/src/receive.cpp index 67b2290358..5b919d71fe 100644 --- a/plugins/ContactsPlus/src/receive.cpp +++ b/plugins/ContactsPlus/src/receive.cpp @@ -355,7 +355,7 @@ INT_PTR CALLBACK RecvDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara case ID_POPUP_ADDUSER:
hContact = CreateTemporaryContactForItem(hwndDlg, wndData, wndData->iPopupItem);
if (hContact)
- DialogAddContactExecute(hwndDlg, hContact);
+ Contact_Add(hContact, hwndDlg);
break;
case ID_POPUP_USERDETAILS:
@@ -389,7 +389,7 @@ INT_PTR CALLBACK RecvDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara break;
case IDC_ADD:
- DialogAddContactExecute(hwndDlg, wndData->mhContact);
+ Contact_Add(wndData->mhContact, hwndDlg);
break;
}
}
diff --git a/plugins/ContactsPlus/src/send.cpp b/plugins/ContactsPlus/src/send.cpp index 9887b10071..6176597a39 100644 --- a/plugins/ContactsPlus/src/send.cpp +++ b/plugins/ContactsPlus/src/send.cpp @@ -372,7 +372,7 @@ INT_PTR CALLBACK SendDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara break;
case IDC_ADD:
- DialogAddContactExecute(hwndDlg, wndData->hContact);
+ Contact_Add(wndData->hContact, hwndDlg);
break;
}
break;
diff --git a/plugins/ContactsPlus/src/stdafx.h b/plugins/ContactsPlus/src/stdafx.h index 14b3a280b9..6ae4c02e89 100644 --- a/plugins/ContactsPlus/src/stdafx.h +++ b/plugins/ContactsPlus/src/stdafx.h @@ -35,7 +35,7 @@ #include "m_clist.h"
#include "m_clistint.h"
#include "m_clc.h"
-#include "m_addcontact.h"
+#include "m_contacts.h"
#include "m_history.h"
#include "m_userinfo.h"
#include "m_button.h"
diff --git a/plugins/ContactsPlus/src/utils.cpp b/plugins/ContactsPlus/src/utils.cpp index c6c079cf3a..acc2c47a16 100644 --- a/plugins/ContactsPlus/src/utils.cpp +++ b/plugins/ContactsPlus/src/utils.cpp @@ -87,15 +87,6 @@ wchar_t* GetContactUID(MCONTACT hContact) return nullptr;
}
-void DialogAddContactExecute(HWND hwndDlg, MCONTACT hNewContact)
-{
- ADDCONTACTSTRUCT acs = { 0 };
- acs.hContact = hNewContact;
- acs.handleType = HANDLE_CONTACT;
- CallService(MS_ADDCONTACT_SHOW, (WPARAM)hwndDlg, (LPARAM)&acs);
-}
-
-
void DrawProtocolIcon(HWND hwndDlg, LPARAM lParam, MCONTACT hContact)
{
LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam;
diff --git a/plugins/ContactsPlus/src/utils.h b/plugins/ContactsPlus/src/utils.h index 01eee73411..6a15ed06c9 100644 --- a/plugins/ContactsPlus/src/utils.h +++ b/plugins/ContactsPlus/src/utils.h @@ -40,8 +40,6 @@ void UpdateDialogAddButton(HWND hwndDlg, MCONTACT hContact); HICON InitMButton(HWND hDlg, int idButton, int idIcon, wchar_t *szTip);
-void DialogAddContactExecute(HWND hwndDlg, MCONTACT hNewContact);
-
HICON LoadContactProtoIcon(MCONTACT hContact);
void EnableDlgItem(HWND hwndDlg, UINT control, int state);
diff --git a/plugins/HistoryStats/src/stdafx.h b/plugins/HistoryStats/src/stdafx.h index d0b4aee7ce..06800ecb98 100644 --- a/plugins/HistoryStats/src/stdafx.h +++ b/plugins/HistoryStats/src/stdafx.h @@ -64,7 +64,6 @@ #include <m_imgsrvc.h>
#include <m_timezones.h>
-#include <m_addcontact.h> // not used, depends on m_protosvc.h
#include <m_icq.h> // depends on m_protosvc.h
#include <m_metacontacts.h>
diff --git a/plugins/Popup/src/popup_wnd2.cpp b/plugins/Popup/src/popup_wnd2.cpp index a3d5c3c425..fada19920f 100644 --- a/plugins/Popup/src/popup_wnd2.cpp +++ b/plugins/Popup/src/popup_wnd2.cpp @@ -545,9 +545,9 @@ int PopupWnd2::fixActions(POPUPACTION *theActions, int count) {
bool isIm = (m_hContact && (CallProtoService(GetContactProto(m_hContact), PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IM)) ? true : false;
- bool enableDefaultGen = (m_hContact || !(PopupOptions.actions&ACT_DEF_NOGLOBAL)) ? true : false;
- bool enableDefaultUsr = (isIm || m_hContact && !(PopupOptions.actions&ACT_DEF_IMONLY)) ? true : false;
- bool iconSize = PopupOptions.actions&ACT_LARGE ? TRUE : FALSE;
+ bool enableDefaultGen = (m_hContact || !(PopupOptions.actions & ACT_DEF_NOGLOBAL)) ? true : false;
+ bool enableDefaultUsr = (isIm || m_hContact && !(PopupOptions.actions & ACT_DEF_IMONLY)) ? true : false;
+ bool iconSize = PopupOptions.actions & ACT_LARGE ? TRUE : FALSE;
if (PopupOptions.actions & ACT_ENABLE) {
if (enableDefaultUsr && isIm && IsActionEnabled("General/Quick reply")) ++m_actionCount;
@@ -857,7 +857,7 @@ LRESULT CALLBACK ReplyEditWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM case WM_DESTROY:
PopupThreadUnlock();
- if (!(PopupOptions.actions&ACT_DEF_KEEPWND))
+ if (!(PopupOptions.actions & ACT_DEF_KEEPWND))
PUDeletePopup(dat->hwndPopup);
SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)dat->oldWndProc);
SetWindowLongPtr(hwnd, GWLP_USERDATA, 0);
@@ -908,7 +908,7 @@ LRESULT CALLBACK PopupWnd2::WindowProc(UINT message, WPARAM wParam, LPARAM lPara switch (lParam) {
case ACT_DEF_MESSAGE:
CallServiceSync(MS_MSG_SENDMESSAGE, (WPARAM)m_hContact, 0);
- if (!(PopupOptions.actions&ACT_DEF_KEEPWND))
+ if (!(PopupOptions.actions & ACT_DEF_KEEPWND))
PUDeletePopup(m_hwnd);
break;
@@ -936,7 +936,7 @@ LRESULT CALLBACK PopupWnd2::WindowProc(UINT message, WPARAM wParam, LPARAM lPara case ACT_DEF_DETAILS:
CallServiceSync(MS_USERINFO_SHOWDIALOG, (WPARAM)m_hContact, 0);
- if (!(PopupOptions.actions&ACT_DEF_KEEPWND))
+ if (!(PopupOptions.actions & ACT_DEF_KEEPWND))
PUDeletePopup(m_hwnd);
break;
@@ -946,15 +946,9 @@ LRESULT CALLBACK PopupWnd2::WindowProc(UINT message, WPARAM wParam, LPARAM lPara break;
case ACT_DEF_ADD:
- {
- ADDCONTACTSTRUCT acs = { 0 };
- acs.hContact = m_hContact;
- acs.handleType = HANDLE_CONTACT;
- acs.szProto = nullptr;
- CallServiceSync(MS_ADDCONTACT_SHOW, NULL, (LPARAM)&acs);
- if (!(PopupOptions.actions&ACT_DEF_KEEPWND))
- PUDeletePopup(m_hwnd);
- }
+ Contact_Add(m_hContact);
+ if (!(PopupOptions.actions & ACT_DEF_KEEPWND))
+ PUDeletePopup(m_hwnd);
break;
case ACT_DEF_PIN:
@@ -965,7 +959,7 @@ LRESULT CALLBACK PopupWnd2::WindowProc(UINT message, WPARAM wParam, LPARAM lPara m_bIsPinned = !m_bIsPinned;
{
- bool iconSize = PopupOptions.actions&ACT_LARGE ? TRUE : FALSE;
+ bool iconSize = PopupOptions.actions & ACT_LARGE ? TRUE : FALSE;
PUModifyActionIcon(m_hwnd, wParam, lParam, m_bIsPinned ? LoadIconEx(IDI_ACT_PINNED, iconSize) : LoadIconEx(IDI_ACT_PIN, iconSize));
}
break;
@@ -1011,7 +1005,7 @@ LRESULT CALLBACK PopupWnd2::WindowProc(UINT message, WPARAM wParam, LPARAM lPara case UM_MENUDONE:
{
unlock();
- if (!(PopupOptions.actions&ACT_DEF_KEEPWND))
+ if (!(PopupOptions.actions & ACT_DEF_KEEPWND))
PUDeletePopup(m_hwnd);
break;
}
diff --git a/plugins/Popup/src/skin.cpp b/plugins/Popup/src/skin.cpp index 157c9aa981..bd912cf115 100644 --- a/plugins/Popup/src/skin.cpp +++ b/plugins/Popup/src/skin.cpp @@ -128,8 +128,8 @@ void PopupSkin::drawAction(MyBitmap *bmp, POPUPACTION *act, int x, int y, bool h wchar_t *str = TranslateW(wname);
GetTextExtentPoint32(bmp->getDC(), str, (int)mir_wstrlen(str), &szText);
bmp->Draw_Text(str,
- (PopupOptions.actions&ACT_LARGE) ? (x + szSpace.cx + 32) : (x + szSpace.cx + 16),
- max(y + 2, y + 2 + (((PopupOptions.actions&ACT_LARGE) ? 32 : 16) - szText.cy) / 2));
+ (PopupOptions.actions & ACT_LARGE) ? (x + szSpace.cx + 32) : (x + szSpace.cx + 16),
+ max(y + 2, y + 2 + (((PopupOptions.actions & ACT_LARGE) ? 32 : 16) - szText.cy) / 2));
mir_free(wname);
SelectObject(bmp->getDC(), hFntSave);
@@ -139,8 +139,8 @@ void PopupSkin::drawAction(MyBitmap *bmp, POPUPACTION *act, int x, int y, bool h RECT rc;
rc.left = x;
rc.top = y;
- rc.right = x + ((PopupOptions.actions&ACT_LARGE) ? 32 : 16) + 4;
- rc.bottom = y + ((PopupOptions.actions&ACT_LARGE) ? 32 : 16) + 4;
+ rc.right = x + ((PopupOptions.actions & ACT_LARGE) ? 32 : 16) + 4;
+ rc.bottom = y + ((PopupOptions.actions & ACT_LARGE) ? 32 : 16) + 4;
bmp->saveAlpha(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top);
HBRUSH hbr = CreateSolidBrush(fonts.clActionHover);
FrameRect(bmp->getDC(), &rc, hbr);
@@ -520,7 +520,7 @@ void PopupSkin::display(MyBitmap *bmp, PopupWnd2 *wnd, POPUPOPTIONS *options, DW drawActionBar(bmp, wnd,
db_get_b(NULL, MODULNAME, "CenterActions", 0) ?
(pt.x + (textAreaWidth - wnd->getRenderInfo()->actw) / 2) :
- (PopupOptions.actions&ACT_RIGHTICONS) ?
+ (PopupOptions.actions & ACT_RIGHTICONS) ?
(pt.x + textAreaWidth - wnd->getRenderInfo()->actw) :
// else
pt.x,
diff --git a/plugins/Popup/src/stdafx.h b/plugins/Popup/src/stdafx.h index e892d518f6..75e7733f12 100644 --- a/plugins/Popup/src/stdafx.h +++ b/plugins/Popup/src/stdafx.h @@ -72,7 +72,7 @@ https://miranda-ng.org/distr/ #include <m_button.h>
#include <m_message.h>
#include <m_userinfo.h>
-#include <m_addcontact.h>
+#include <m_contacts.h>
#include <m_clc.h>
#include <m_icolib.h>
#include <m_genmenu.h>
diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp index 162b22b7de..b85b0f413e 100644 --- a/plugins/Scriver/src/msgdialog.cpp +++ b/plugins/Scriver/src/msgdialog.cpp @@ -540,10 +540,7 @@ void CSrmmWindow::onClick_Quote(CCtrlButton*) void CSrmmWindow::onClick_Add(CCtrlButton*)
{
- ADDCONTACTSTRUCT acs = {};
- acs.hContact = m_hContact;
- acs.handleType = HANDLE_CONTACT;
- 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), SW_HIDE);
diff --git a/plugins/Scriver/src/stdafx.h b/plugins/Scriver/src/stdafx.h index 422d4fb8ae..2076df25a0 100644 --- a/plugins/Scriver/src/stdafx.h +++ b/plugins/Scriver/src/stdafx.h @@ -50,7 +50,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_message.h>
#include <m_file.h>
#include <m_fontservice.h>
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index f340f0d8a2..e8a653bbbe 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -1168,11 +1168,8 @@ void CSrmmWindow::onClick_Ok(CCtrlButton*) void CSrmmWindow::onClick_Add(CCtrlButton*)
{
- 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)) {
m_bNotOnList = FALSE;
ShowMultipleControls(m_hwnd, addControls, _countof(addControls), SW_HIDE);
diff --git a/plugins/TabSRMM/src/stdafx.h b/plugins/TabSRMM/src/stdafx.h index 452fb3151a..0f20db7320 100644 --- a/plugins/TabSRMM/src/stdafx.h +++ b/plugins/TabSRMM/src/stdafx.h @@ -65,7 +65,6 @@ #include <m_clist.h>
#include <m_userinfo.h>
#include <m_history.h>
-#include <m_addcontact.h>
#include <m_file.h>
#include <m_fontservice.h>
#include <m_acc.h>
diff --git a/plugins/helpers/commonheaders.h b/plugins/helpers/commonheaders.h index f85a681b1e..77ff813360 100644 --- a/plugins/helpers/commonheaders.h +++ b/plugins/helpers/commonheaders.h @@ -52,7 +52,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_email.h>
diff --git a/protocols/IRCG/src/services.cpp b/protocols/IRCG/src/services.cpp index c6ed1fb46c..07097155ce 100644 --- a/protocols/IRCG/src/services.cpp +++ b/protocols/IRCG/src/services.cpp @@ -704,17 +704,12 @@ int __cdecl CIrcProto::GCEventHook(WPARAM, LPARAM lParam) break;
case 30:
{
- PROTOSEARCHRESULT psr = { 0 };
+ PROTOSEARCHRESULT psr = {};
psr.cbSize = sizeof(psr);
psr.flags = PSR_UNICODE;
psr.id.w = gch->ptszUID;
psr.nick.w = gch->ptszUID;
-
- ADDCONTACTSTRUCT acs = { 0 };
- acs.handleType = HANDLE_SEARCHRESULT;
- acs.szProto = m_szModuleName;
- acs.psr = &psr;
- CallService(MS_ADDCONTACT_SHOW, 0, (LPARAM)&acs);
+ Contact_AddBySearch(m_szModuleName, &psr);
}
break;
case 31: //slap
diff --git a/protocols/IRCG/src/stdafx.h b/protocols/IRCG/src/stdafx.h index 5428e0fe9c..14da73d80a 100644 --- a/protocols/IRCG/src/stdafx.h +++ b/protocols/IRCG/src/stdafx.h @@ -56,7 +56,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "m_chat_int.h"
#include "m_message.h"
#include "m_userinfo.h"
-#include "m_addcontact.h"
+#include "m_contacts.h"
#include "m_button.h"
#include "m_genmenu.h"
#include "m_file.h"
diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp index b609d1a111..f0ed8f315e 100644 --- a/protocols/JabberG/src/jabber_chat.cpp +++ b/protocols/JabberG/src/jabber_chat.cpp @@ -1204,12 +1204,7 @@ static void sttNickListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK* if (wchar_t *tmp = wcschr(psr.id.w, '/'))
*tmp = 0;
psr.nick.w = psr.id.w;
-
- ADDCONTACTSTRUCT acs = { 0 };
- acs.handleType = HANDLE_SEARCHRESULT;
- acs.szProto = ppro->m_szModuleName;
- acs.psr = &psr;
- CallService(MS_ADDCONTACT_SHOW, (WPARAM)pcli->hwndContactList, (LPARAM)&acs);
+ Contact_AddBySearch(ppro->m_szModuleName, &psr, pcli->hwndContactList);
}
break;
}
diff --git a/protocols/JabberG/src/jabber_svc.cpp b/protocols/JabberG/src/jabber_svc.cpp index b4895f1cc3..8241b8a2ee 100644 --- a/protocols/JabberG/src/jabber_svc.cpp +++ b/protocols/JabberG/src/jabber_svc.cpp @@ -30,7 +30,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <sys/types.h>
#include <sys/stat.h>
-#include "m_addcontact.h"
#include "jabber_disco.h"
/////////////////////////////////////////////////////////////////////////////////////////
@@ -456,12 +455,7 @@ INT_PTR __cdecl CJabberProto::JabberServiceParseXmppURI(WPARAM, LPARAM lParam) psr.flags = PSR_UNICODE;
psr.nick.w = szJid;
psr.id.w = szJid;
-
- ADDCONTACTSTRUCT acs;
- acs.handleType = HANDLE_SEARCHRESULT;
- acs.szProto = m_szModuleName;
- acs.psr = &psr;
- CallService(MS_ADDCONTACT_SHOW, 0, (LPARAM)&acs);
+ Contact_AddBySearch(m_szModuleName, &psr);
}
return 0;
}
diff --git a/protocols/JabberG/src/stdafx.h b/protocols/JabberG/src/stdafx.h index 6610c2288c..830bb3685f 100644 --- a/protocols/JabberG/src/stdafx.h +++ b/protocols/JabberG/src/stdafx.h @@ -88,7 +88,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <m_imgsrvc.h>
#include <m_clc.h>
-#include <m_addcontact.h>
#include <m_folders.h>
#include <m_fingerprint.h>
#include <m_jabber.h>
diff --git a/protocols/MSN/src/msn_links.cpp b/protocols/MSN/src/msn_links.cpp index e6bf5641b8..3be384196a 100644 --- a/protocols/MSN/src/msn_links.cpp +++ b/protocols/MSN/src/msn_links.cpp @@ -21,8 +21,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "stdafx.h"
#include "msn_proto.h"
-#include <m_addcontact.h>
-
#include "m_assocmgr.h"
static MCONTACT GetContact(wchar_t *arg, wchar_t **pemail, CMsnProto *proto)
@@ -96,12 +94,7 @@ static INT_PTR ServiceParseMsnimLink(WPARAM, LPARAM lParam) psr.flags = PSR_UNICODE;
psr.nick.w = email;
psr.email.w = email;
-
- ADDCONTACTSTRUCT acs = { 0 };
- acs.handleType = HANDLE_SEARCHRESULT;
- acs.szProto = proto->m_szModuleName;
- acs.psr = &psr;
- CallService(MS_ADDCONTACT_SHOW, 0, (LPARAM)&acs);
+ Contact_AddBySearch(proto->m_szModuleName, &psr);
}
return 0;
}
diff --git a/protocols/Sametime/src/StdAfx.h b/protocols/Sametime/src/StdAfx.h index 3eae2826f9..5fa7d2b4d3 100644 --- a/protocols/Sametime/src/StdAfx.h +++ b/protocols/Sametime/src/StdAfx.h @@ -69,7 +69,7 @@ extern "C" { #include <m_clc.h>
#include <m_utils.h>
#include <m_idle.h>
-#include <m_addcontact.h>
+#include <m_contacts.h>
#include <m_popup.h>
#include <m_chat.h>
#include <m_genmenu.h>
diff --git a/protocols/SkypeWeb/src/skype_utils.cpp b/protocols/SkypeWeb/src/skype_utils.cpp index 6c9e1fe6cc..3317a79973 100644 --- a/protocols/SkypeWeb/src/skype_utils.cpp +++ b/protocols/SkypeWeb/src/skype_utils.cpp @@ -573,13 +573,7 @@ INT_PTR CSkypeProto::ParseSkypeUriService(WPARAM, LPARAM lParam) psr.id.w = mir_wstrdup(szJid); psr.nick.w = mir_wstrdup(szJid); psr.flags = PSR_UNICODE; - - ADDCONTACTSTRUCT acs = { 0 }; - acs.handleType = HANDLE_SEARCHRESULT; - acs.szProto = m_szModuleName; - acs.psr = &psr; - - CallService(MS_ADDCONTACT_SHOW, 0, (LPARAM)&acs); + Contact_AddBySearch(m_szModuleName, &psr); } return 0; } diff --git a/protocols/SkypeWeb/src/stdafx.h b/protocols/SkypeWeb/src/stdafx.h index eccbf4789c..dc054583da 100644 --- a/protocols/SkypeWeb/src/stdafx.h +++ b/protocols/SkypeWeb/src/stdafx.h @@ -40,7 +40,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include <m_popup.h>
#include <m_icolib.h>
#include <m_userinfo.h>
-#include <m_addcontact.h>
+#include <m_contacts.h>
#include <m_message.h>
#include <m_avatars.h>
#include <m_skin.h>
diff --git a/protocols/Tox/src/stdafx.h b/protocols/Tox/src/stdafx.h index 281c585bc5..501eeb96cf 100644 --- a/protocols/Tox/src/stdafx.h +++ b/protocols/Tox/src/stdafx.h @@ -23,7 +23,7 @@ #include <m_popup.h>
#include <m_icolib.h>
#include <m_userinfo.h>
-#include <m_addcontact.h>
+#include <m_contacts.h>
#include <m_message.h>
#include <m_avatars.h>
#include <m_skin.h>
diff --git a/protocols/Tox/src/tox_search.cpp b/protocols/Tox/src/tox_search.cpp index d03d3a091a..d8077fedd1 100644 --- a/protocols/Tox/src/tox_search.cpp +++ b/protocols/Tox/src/tox_search.cpp @@ -226,12 +226,7 @@ HWND CToxProto::OnSearchAdvanced(HWND owner) PROTOSEARCHRESULT psr = { sizeof(psr) };
psr.flags = PSR_UTF8;
psr.id.a = mir_strdup(query.c_str());
-
- ADDCONTACTSTRUCT acs = { HANDLE_SEARCHRESULT };
- acs.szProto = m_szModuleName;
- acs.psr = &psr;
-
- CallService(MS_ADDCONTACT_SHOW, (WPARAM)owner, (LPARAM)&acs);
+ Contact_AddBySearch(m_szModuleName, &psr, owner);
ForkThread(&CToxProto::SearchFailedAsync, nullptr);
}
diff --git a/protocols/Tox/src/tox_utils.cpp b/protocols/Tox/src/tox_utils.cpp index 722517c427..130e08eaec 100644 --- a/protocols/Tox/src/tox_utils.cpp +++ b/protocols/Tox/src/tox_utils.cpp @@ -165,11 +165,6 @@ INT_PTR CToxProto::ParseToxUri(WPARAM, LPARAM lParam) PROTOSEARCHRESULT psr = { sizeof(psr) };
psr.flags = PSR_UTF8;
psr.id.a = mir_u2a(&uri[4]);
-
- ADDCONTACTSTRUCT acs = { HANDLE_SEARCHRESULT };
- acs.szProto = proto->m_szModuleName;
- acs.psr = &psr;
-
- CallService(MS_ADDCONTACT_SHOW, 0, (LPARAM)&acs);
+ Contact_AddBySearch(proto->m_szModuleName, &psr);
return 0;
}
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>
|