summaryrefslogtreecommitdiff
path: root/protocols/MSN/src/msn_proto.cpp
diff options
context:
space:
mode:
authorPiotr Piastucki <leech.miranda@gmail.com>2015-05-19 21:00:49 +0000
committerPiotr Piastucki <leech.miranda@gmail.com>2015-05-19 21:00:49 +0000
commit38a93d167307c8d1912abeaf32182abe97a03598 (patch)
tree2602113bb73b15a4cd1a272a2d8464d60141c844 /protocols/MSN/src/msn_proto.cpp
parent05463e65c1fa74da551b9acf701366e185e516fc (diff)
Fixed some memleaks.
Added contact list exchange feature. git-svn-id: http://svn.miranda-ng.org/main/trunk@13704 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/MSN/src/msn_proto.cpp')
-rw-r--r--protocols/MSN/src/msn_proto.cpp68
1 files changed, 64 insertions, 4 deletions
diff --git a/protocols/MSN/src/msn_proto.cpp b/protocols/MSN/src/msn_proto.cpp
index b4e35c6f2c..4a0279b398 100644
--- a/protocols/MSN/src/msn_proto.cpp
+++ b/protocols/MSN/src/msn_proto.cpp
@@ -639,7 +639,7 @@ DWORD_PTR __cdecl CMsnProto::GetCaps(int type, MCONTACT)
switch (type) {
case PFLAGNUM_1:
return PF1_IM | PF1_SERVERCLIST | PF1_AUTHREQ | PF1_BASICSEARCH |
- PF1_ADDSEARCHRES | PF1_CHAT |
+ PF1_ADDSEARCHRES | PF1_CHAT | PF1_CONTACT |
/*PF1_FILESEND | PF1_FILERECV | */PF1_URLRECV | PF1_VISLIST | PF1_MODEMSG;
case PFLAGNUM_2:
@@ -663,6 +663,9 @@ DWORD_PTR __cdecl CMsnProto::GetCaps(int type, MCONTACT)
case PFLAG_MAXLENOFMESSAGE:
return 1202;
+
+ case PFLAG_MAXCONTACTSPERPACKET:
+ return 1024; // Only an assumption...
}
return 0;
@@ -684,6 +687,35 @@ int __cdecl CMsnProto::RecvMsg(MCONTACT hContact, PROTORECVEVENT* pre)
}
/////////////////////////////////////////////////////////////////////////////////////////
+// MsnRecvContacts - creates a database event from the contacts received
+
+int CMsnProto::RecvContacts(MCONTACT hContact, PROTORECVEVENT* pre)
+{
+ PROTOSEARCHRESULT **isrList = (PROTOSEARCHRESULT**)pre->szMessage;
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ BYTE *pCurBlob;
+ int i;
+
+ for (i = 0; i < pre->lParam; i++)
+ dbei.cbBlob += mir_tstrlen(isrList[i]->nick) + 2 + mir_tstrlen(isrList[i]->id);
+ dbei.pBlob = (PBYTE)_alloca(dbei.cbBlob);
+ for (i = 0, pCurBlob = dbei.pBlob; i < pre->lParam; i++) {
+ mir_strcpy((char*)pCurBlob, _T2A(isrList[i]->nick));
+ pCurBlob += mir_strlen((char*)pCurBlob) + 1;
+ mir_strcpy((char*)pCurBlob, _T2A(isrList[i]->id));
+ pCurBlob += mir_strlen((char*)pCurBlob) + 1;
+ }
+
+ dbei.szModule = m_szModuleName;
+ dbei.timestamp = pre->timestamp;
+ dbei.flags = (pre->flags & PREF_CREATEREAD) ? DBEF_READ : 0;
+ dbei.eventType = EVENTTYPE_CONTACTS;
+ db_event_add(hContact, &dbei);
+ return 0;
+}
+
+
+/////////////////////////////////////////////////////////////////////////////////////////
// MsnSendFile - initiates a file transfer
HANDLE __cdecl CMsnProto::SendFile(MCONTACT hContact, const PROTOCHAR*, PROTOCHAR** ppszFiles)
@@ -735,14 +767,16 @@ HANDLE __cdecl CMsnProto::SendFile(MCONTACT hContact, const PROTOCHAR*, PROTOCHA
struct TFakeAckParams
{
- inline TFakeAckParams(MCONTACT p2, long p3, const char* p4, CMsnProto *p5) :
+ inline TFakeAckParams(MCONTACT p2, long p3, const char* p4, CMsnProto *p5, int p6=ACKTYPE_MESSAGE) :
hContact(p2),
id(p3),
msg(p4),
- proto(p5)
+ proto(p5),
+ type(p6)
{}
MCONTACT hContact;
+ int type;
long id;
const char* msg;
CMsnProto *proto;
@@ -753,7 +787,7 @@ void CMsnProto::MsnFakeAck(void* arg)
TFakeAckParams* tParam = (TFakeAckParams*)arg;
Sleep(150);
- tParam->proto->ProtoBroadcastAck(tParam->hContact, ACKTYPE_MESSAGE,
+ tParam->proto->ProtoBroadcastAck(tParam->hContact, tParam->type,
tParam->msg ? ACKRESULT_FAILED : ACKRESULT_SUCCESS,
(HANDLE)tParam->id, LPARAM(tParam->msg));
@@ -864,6 +898,32 @@ int __cdecl CMsnProto::SendMsg(MCONTACT hContact, int flags, const char* pszSrc)
}
/////////////////////////////////////////////////////////////////////////////////////////
+// MsnSendContacts - sends contacts to a certain user
+int __cdecl CMsnProto::SendContacts(MCONTACT hContact, int flags, int nContacts, MCONTACT *hContactsList)
+{
+ if (!msnLoggedIn)
+ return 0;
+
+ char tEmail[MSN_MAX_EMAIL_LEN];
+ if (MSN_IsMeByContact(hContact, tEmail)) return 0;
+
+ int seq = 0;
+ int netId = Lists_GetNetId(tEmail);
+ CMStringA msg;
+
+ msg.Append("<contacts alt=\"[Contacts enclosed. Please upgrade to latest Skype version to receive contacts.]\">");
+ for (int i = 0; i < nContacts; i++) {
+ ptrA wlid(getStringA(hContactsList[i], "wlid"));
+ if (wlid != NULL) msg.AppendFormat("<c t=\"s\" s=\"%s\"/>", wlid);
+ }
+ msg.Append("</contacts>");
+ seq = msnNsThread->sendMessage('1', tEmail, netId, msg, MSG_CONTACT);
+ ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, seq, NULL, this, ACKTYPE_CONTACTS));
+ return seq;
+}
+
+
+/////////////////////////////////////////////////////////////////////////////////////////
// MsnSetAwayMsg - sets the current status message for a user
int __cdecl CMsnProto::SetAwayMsg(int status, const TCHAR* msg)