diff options
author | George Hazan <george.hazan@gmail.com> | 2014-11-19 22:04:33 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-11-19 22:04:33 +0000 |
commit | 25c307a140104c3b09fecbbf2f452368090a45d0 (patch) | |
tree | 99d8e24d70a0c70e37ee85339fcb348473d52bf3 /protocols/MSN | |
parent | 550c3e26b321ffb138d02f02c22e64f3e3044767 (diff) |
code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@11025 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/MSN')
-rw-r--r-- | protocols/MSN/src/msn_chat.cpp | 4 | ||||
-rw-r--r-- | protocols/MSN/src/msn_lists.cpp | 82 | ||||
-rw-r--r-- | protocols/MSN/src/msn_p2ps.cpp | 100 | ||||
-rw-r--r-- | protocols/MSN/src/msn_proto.cpp | 16 | ||||
-rw-r--r-- | protocols/MSN/src/msn_proto.h | 18 | ||||
-rw-r--r-- | protocols/MSN/src/msn_srv.cpp | 32 | ||||
-rw-r--r-- | protocols/MSN/src/msn_threads.cpp | 177 |
7 files changed, 214 insertions, 215 deletions
diff --git a/protocols/MSN/src/msn_chat.cpp b/protocols/MSN/src/msn_chat.cpp index fb90187f21..0c050204b3 100644 --- a/protocols/MSN/src/msn_chat.cpp +++ b/protocols/MSN/src/msn_chat.cpp @@ -40,8 +40,8 @@ MCONTACT CMsnProto::MSN_GetChatInernalHandle(MCONTACT hContact) int CMsnProto::MSN_ChatInit(ThreadData *info)
{
- InterlockedIncrement(&sttChatID);
- _ltot(sttChatID, info->mChatID, 10);
+ InterlockedIncrement(&m_chatID);
+ _ltot(m_chatID, info->mChatID, 10);
TCHAR szName[512];
mir_sntprintf(szName, SIZEOF(szName), _T("%s %s%s"),
diff --git a/protocols/MSN/src/msn_lists.cpp b/protocols/MSN/src/msn_lists.cpp index bd9fa308e8..b94e572aaa 100644 --- a/protocols/MSN/src/msn_lists.cpp +++ b/protocols/MSN/src/msn_lists.cpp @@ -31,15 +31,15 @@ void CMsnProto::Lists_Uninit(void) void CMsnProto::Lists_Wipe(void)
{
- mir_cslock lck(csLists);
- contList.destroy();
+ mir_cslock lck(m_csLists);
+ m_arContacts.destroy();
}
bool CMsnProto::Lists_IsInList(int list, const char* email)
{
- mir_cslock lck(csLists);
+ mir_cslock lck(m_csLists);
- MsnContact *p = contList.find((MsnContact*)&email);
+ MsnContact *p = m_arContacts.find((MsnContact*)&email);
if (p == NULL)
return false;
if (list == -1)
@@ -49,24 +49,24 @@ bool CMsnProto::Lists_IsInList(int list, const char* email) MsnContact* CMsnProto::Lists_Get(const char* email)
{
- mir_cslock lck(csLists);
- return contList.find((MsnContact*)&email);
+ mir_cslock lck(m_csLists);
+ return m_arContacts.find((MsnContact*)&email);
}
MsnContact* CMsnProto::Lists_Get(MCONTACT hContact)
{
- mir_cslock lck(csLists);
+ mir_cslock lck(m_csLists);
- for (int i = 0; i < contList.getCount(); ++i)
- if (contList[i].hContact == hContact)
- return &contList[i];
+ for (int i = 0; i < m_arContacts.getCount(); ++i)
+ if (m_arContacts[i].hContact == hContact)
+ return &m_arContacts[i];
return NULL;
}
MsnPlace* CMsnProto::Lists_GetPlace(const char* wlid)
{
- mir_cslock lck(csLists);
+ mir_cslock lck(m_csLists);
char *szEmail, *szInst;
parseWLID(NEWSTR_ALLOCA(wlid), NULL, &szEmail, &szInst);
@@ -74,7 +74,7 @@ MsnPlace* CMsnProto::Lists_GetPlace(const char* wlid) if (szInst == NULL)
szInst = (char*)sttVoidUid;
- MsnContact* p = contList.find((MsnContact*)&szEmail);
+ MsnContact* p = m_arContacts.find((MsnContact*)&szEmail);
if (p == NULL)
return NULL;
@@ -83,9 +83,9 @@ MsnPlace* CMsnProto::Lists_GetPlace(const char* wlid) MsnPlace* CMsnProto::Lists_AddPlace(const char* email, const char* id, unsigned cap1, unsigned cap2)
{
- mir_cslock lck(csLists);
+ mir_cslock lck(m_csLists);
- MsnContact *p = contList.find((MsnContact*)&email);
+ MsnContact *p = m_arContacts.find((MsnContact*)&email);
if (p == NULL)
return NULL;
@@ -105,21 +105,21 @@ MsnPlace* CMsnProto::Lists_AddPlace(const char* email, const char* id, unsigned MsnContact* CMsnProto::Lists_GetNext(int &i)
{
- mir_cslock lck(csLists);
+ mir_cslock lck(m_csLists);
MsnContact *p = NULL;
- while (p == NULL && ++i < contList.getCount())
- if (contList[i].hContact)
- p = &contList[i];
+ while (p == NULL && ++i < m_arContacts.getCount())
+ if (m_arContacts[i].hContact)
+ p = &m_arContacts[i];
return p;
}
int CMsnProto::Lists_GetMask(const char* email)
{
- mir_cslock lck(csLists);
+ mir_cslock lck(m_csLists);
- MsnContact *p = contList.find((MsnContact*)&email);
+ MsnContact *p = m_arContacts.find((MsnContact*)&email);
return p ? p->list : 0;
}
@@ -127,15 +127,15 @@ int CMsnProto::Lists_GetNetId(const char* email) {
if (email[0] == 0) return NETID_UNKNOWN;
- mir_cslock lck(csLists);
+ mir_cslock lck(m_csLists);
- MsnContact *p = contList.find((MsnContact*)&email);
+ MsnContact *p = m_arContacts.find((MsnContact*)&email);
return p ? p->netId : NETID_UNKNOWN;
}
unsigned CMsnProto::p2p_getMsgId(const char* wlid, int inc)
{
- mir_cslock lck(csLists);
+ mir_cslock lck(m_csLists);
MsnPlace *p = Lists_GetPlace(wlid);
unsigned res = p && p->p2pMsgId ? p->p2pMsgId : MSN_GenRandom();
@@ -147,7 +147,7 @@ unsigned CMsnProto::p2p_getMsgId(const char* wlid, int inc) unsigned CMsnProto::p2p_getPktNum(const char* wlid)
{
- mir_cslock lck(csLists);
+ mir_cslock lck(m_csLists);
MsnPlace *p = Lists_GetPlace(wlid);
return p ? p->p2pPktNum++ : 0;
@@ -155,9 +155,9 @@ unsigned CMsnProto::p2p_getPktNum(const char* wlid) int CMsnProto::Lists_Add(int list, int netId, const char* email, MCONTACT hContact, const char* nick, const char* invite)
{
- mir_cslock lck(csLists);
+ mir_cslock lck(m_csLists);
- MsnContact* p = contList.find((MsnContact*)&email);
+ MsnContact* p = m_arContacts.find((MsnContact*)&email);
if (p == NULL) {
p = new MsnContact;
p->list = list;
@@ -167,7 +167,7 @@ int CMsnProto::Lists_Add(int list, int netId, const char* email, MCONTACT hConta p->nick = mir_strdup(nick);
p->hContact = hContact;
p->p2pMsgId = 0;
- contList.insert(p);
+ m_arContacts.insert(p);
}
else {
p->list |= list;
@@ -182,15 +182,15 @@ int CMsnProto::Lists_Add(int list, int netId, const char* email, MCONTACT hConta void CMsnProto::Lists_Remove(int list, const char* email)
{
- mir_cslock lck(csLists);
+ mir_cslock lck(m_csLists);
- int i = contList.getIndex((MsnContact*)&email);
+ int i = m_arContacts.getIndex((MsnContact*)&email);
if (i != -1) {
- MsnContact &p = contList[i];
+ MsnContact &p = m_arContacts[i];
p.list &= ~list;
if (list & LIST_PL) { mir_free(p.invite); p.invite = NULL; }
if (p.list == 0 && p.hContact == NULL)
- contList.remove(i);
+ m_arContacts.remove(i);
}
}
@@ -217,8 +217,8 @@ void CMsnProto::Lists_Populate(void) void CMsnProto::MSN_CleanupLists(void)
{
- for (int i = contList.getCount(); i--;) {
- MsnContact& p = contList[i];
+ for (int i = m_arContacts.getCount(); i--;) {
+ MsnContact& p = m_arContacts[i];
if (p.list & LIST_FL)
MSN_SetContactDb(p.hContact, p.email);
@@ -271,24 +271,24 @@ void CMsnProto::MSN_CleanupLists(void) void CMsnProto::MSN_CreateContList(void)
{
- bool *used = (bool*)mir_calloc(contList.getCount()*sizeof(bool));
+ bool *used = (bool*)mir_calloc(m_arContacts.getCount()*sizeof(bool));
char cxml[8192];
size_t sz = mir_snprintf(cxml, sizeof(cxml), "<ml l=\"1\">");
{
- mir_cslock lck(csLists);
+ mir_cslock lck(m_csLists);
- for (int i = 0; i < contList.getCount(); i++) {
+ for (int i = 0; i < m_arContacts.getCount(); i++) {
if (used[i]) continue;
- const char* lastds = strchr(contList[i].email, '@');
+ const char* lastds = strchr(m_arContacts[i].email, '@');
bool newdom = true;
- for (int j = 0; j < contList.getCount(); j++) {
+ for (int j = 0; j < m_arContacts.getCount(); j++) {
if (used[j]) continue;
- const MsnContact& C = contList[j];
+ const MsnContact& C = m_arContacts[j];
if (C.list == LIST_RL || C.list == LIST_PL || C.list == LIST_LL) {
used[j] = true;
continue;
@@ -359,8 +359,8 @@ static void AddPrivacyListEntries(HWND hwndList, CMsnProto *proto) }
// Add new info
- for (int i = 0; i < proto->contList.getCount(); ++i) {
- MsnContact &cont = proto->contList[i];
+ for (int i = 0; i < proto->m_arContacts.getCount(); ++i) {
+ MsnContact &cont = proto->m_arContacts[i];
if (!(cont.list & (LIST_FL | LIST_LL))) {
cii.pszText = (TCHAR*)cont.email;
HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_ADDINFOITEMA, 0, (LPARAM)&cii);
diff --git a/protocols/MSN/src/msn_p2ps.cpp b/protocols/MSN/src/msn_p2ps.cpp index 372dbc9132..f7840374c8 100644 --- a/protocols/MSN/src/msn_p2ps.cpp +++ b/protocols/MSN/src/msn_p2ps.cpp @@ -28,8 +28,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. void CMsnProto::p2p_registerSession(filetransfer* ft)
{
- mir_cslock lck(sessionLock);
- sessionList.insert(ft);
+ mir_cslock lck(m_csSessions);
+ m_arSessions.insert(ft);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -37,8 +37,8 @@ void CMsnProto::p2p_registerSession(filetransfer* ft) void CMsnProto::p2p_unregisterSession(filetransfer* ft)
{
- mir_cslock lck(sessionLock);
- sessionList.remove(ft);
+ mir_cslock lck(m_csSessions);
+ m_arSessions.remove(ft);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -49,10 +49,10 @@ filetransfer* CMsnProto::p2p_getSessionByID(unsigned id) if (id == 0)
return NULL;
- mir_cslock lck(sessionLock);
+ mir_cslock lck(m_csSessions);
- for (int i = 0; i < sessionList.getCount(); i++) {
- filetransfer* FT = &sessionList[i];
+ for (int i = 0; i < m_arSessions.getCount(); i++) {
+ filetransfer* FT = &m_arSessions[i];
if (FT->p2p_sessionid == id)
return FT;
}
@@ -65,10 +65,10 @@ filetransfer* CMsnProto::p2p_getSessionByUniqueID(unsigned id) if (id == 0)
return NULL;
- mir_cslock lck(sessionLock);
+ mir_cslock lck(m_csSessions);
- for (int i = 0; i < sessionList.getCount(); i++) {
- filetransfer* FT = &sessionList[i];
+ for (int i = 0; i < m_arSessions.getCount(); i++) {
+ filetransfer* FT = &m_arSessions[i];
if (FT->p2p_acksessid == id)
return FT;
}
@@ -82,16 +82,16 @@ bool CMsnProto::p2p_sessionRegistered(filetransfer* ft) if (ft != NULL && ft->p2p_appID == 0)
return true;
- mir_cslock lck(sessionLock);
- return sessionList.getIndex(ft) > -1;
+ mir_cslock lck(m_csSessions);
+ return m_arSessions.getIndex(ft) > -1;
}
filetransfer* CMsnProto::p2p_getThreadSession(MCONTACT hContact, TInfoType mType)
{
- mir_cslock lck(sessionLock);
+ mir_cslock lck(m_csSessions);
- for (int i = 0; i < sessionList.getCount(); i++) {
- filetransfer* FT = &sessionList[i];
+ for (int i = 0; i < m_arSessions.getCount(); i++) {
+ filetransfer* FT = &m_arSessions[i];
if (FT->std.hContact == hContact && FT->tType == mType)
return FT;
}
@@ -101,10 +101,10 @@ filetransfer* CMsnProto::p2p_getThreadSession(MCONTACT hContact, TInfoType mType void CMsnProto::p2p_clearThreadSessions(MCONTACT hContact, TInfoType mType)
{
- mir_cslock lck(sessionLock);
+ mir_cslock lck(m_csSessions);
- for (int i = 0; i < sessionList.getCount(); i++) {
- filetransfer* ft = &sessionList[i];
+ for (int i = 0; i < m_arSessions.getCount(); i++) {
+ filetransfer* ft = &m_arSessions[i];
if (ft->std.hContact == hContact && ft->tType == mType) {
ft->bCanceled = true;
ft->tType = SERVER_NOTIFICATION;
@@ -115,10 +115,10 @@ void CMsnProto::p2p_clearThreadSessions(MCONTACT hContact, TInfoType mType) filetransfer* CMsnProto::p2p_getAvatarSession(MCONTACT hContact)
{
- mir_cslock lck(sessionLock);
+ mir_cslock lck(m_csSessions);
- for (int i = 0; i < sessionList.getCount(); i++) {
- filetransfer* FT = &sessionList[i];
+ for (int i = 0; i < m_arSessions.getCount(); i++) {
+ filetransfer* FT = &m_arSessions[i];
if (FT->std.hContact == hContact && !(FT->std.flags & PFTS_SENDING) && FT->p2p_type == MSN_APPID_AVATAR)
return FT;
}
@@ -128,11 +128,11 @@ filetransfer* CMsnProto::p2p_getAvatarSession(MCONTACT hContact) bool CMsnProto::p2p_isAvatarOnly(MCONTACT hContact)
{
- mir_cslock lck(sessionLock);
+ mir_cslock lck(m_csSessions);
bool result = true;
- for (int i = 0; i < sessionList.getCount(); i++) {
- filetransfer* FT = &sessionList[i];
+ for (int i = 0; i < m_arSessions.getCount(); i++) {
+ filetransfer* FT = &m_arSessions[i];
result &= FT->std.hContact != hContact || FT->p2p_type != MSN_APPID_FILE;
}
@@ -141,11 +141,11 @@ bool CMsnProto::p2p_isAvatarOnly(MCONTACT hContact) void CMsnProto::p2p_clearDormantSessions(void)
{
- mir_cslockfull lck(sessionLock);
+ mir_cslockfull lck(m_csSessions);
time_t ts = time(NULL);
- for (int i = 0; i < sessionList.getCount(); i++) {
- filetransfer* FT = &sessionList[i];
+ for (int i = 0; i < m_arSessions.getCount(); i++) {
+ filetransfer* FT = &m_arSessions[i];
if (!FT->p2p_sessionid && !MSN_GetUnconnectedThread(FT->p2p_dest, SERVER_P2P_DIRECT))
p2p_invite(FT->p2p_type, FT, NULL);
else if (FT->p2p_waitack && (ts - FT->ts) > 120) {
@@ -161,11 +161,11 @@ void CMsnProto::p2p_clearDormantSessions(void) void CMsnProto::p2p_redirectSessions(const char *wlid)
{
- mir_cslock lck(sessionLock);
+ mir_cslock lck(m_csSessions);
ThreadData* T = MSN_GetP2PThreadByContact(wlid);
- for (int i = 0; i < sessionList.getCount(); i++) {
- filetransfer* FT = &sessionList[i];
+ for (int i = 0; i < m_arSessions.getCount(); i++) {
+ filetransfer* FT = &m_arSessions[i];
if (_stricmp(FT->p2p_dest, wlid) == 0 &&
FT->std.currentFileProgress < FT->std.currentFileSize &&
(T == NULL || (FT->tType != T->mType && FT->tType != 0))) {
@@ -183,13 +183,13 @@ void CMsnProto::p2p_redirectSessions(const char *wlid) void CMsnProto::p2p_startSessions(const char* wlid)
{
- mir_cslock lck(sessionLock);
+ mir_cslock lck(m_csSessions);
char* szEmail;
parseWLID(NEWSTR_ALLOCA(wlid), NULL, &szEmail, NULL);
- for (int i = 0; i < sessionList.getCount(); i++) {
- filetransfer* FT = &sessionList[i];
+ for (int i = 0; i < m_arSessions.getCount(); i++) {
+ filetransfer* FT = &m_arSessions[i];
if (!FT->bAccepted && !_stricmp(FT->p2p_dest, szEmail)) {
if (FT->p2p_appID == MSN_APPID_FILE && (FT->std.flags & PFTS_SENDING))
p2p_invite(FT->p2p_type, FT, wlid);
@@ -201,11 +201,11 @@ void CMsnProto::p2p_startSessions(const char* wlid) void CMsnProto::p2p_cancelAllSessions(void)
{
- mir_cslock lck(sessionLock);
+ mir_cslock lck(m_csSessions);
- for (int i = 0; i < sessionList.getCount(); i++) {
- sessionList[i].bCanceled = true;
- p2p_sendCancel(&sessionList[i]);
+ for (int i = 0; i < m_arSessions.getCount(); i++) {
+ m_arSessions[i].bCanceled = true;
+ p2p_sendCancel(&m_arSessions[i]);
}
}
@@ -214,11 +214,11 @@ filetransfer* CMsnProto::p2p_getSessionByCallID(const char* CallID, const char* if (CallID == NULL)
return NULL;
- mir_cslock lck(sessionLock);
+ mir_cslock lck(m_csSessions);
char* szEmail = NULL;
- for (int i = 0; i < sessionList.getCount(); i++) {
- filetransfer* FT = &sessionList[i];
+ for (int i = 0; i < m_arSessions.getCount(); i++) {
+ filetransfer* FT = &m_arSessions[i];
if (FT->p2p_callID && !_stricmp(FT->p2p_callID, CallID)) {
if (_stricmp(FT->p2p_dest, wlid)) {
if (!szEmail)
@@ -236,14 +236,14 @@ filetransfer* CMsnProto::p2p_getSessionByCallID(const char* CallID, const char* void CMsnProto::p2p_registerDC(directconnection* dc)
{
- mir_cslock lck(sessionLock);
- dcList.insert(dc);
+ mir_cslock lck(m_csSessions);
+ m_arDirect.insert(dc);
}
void CMsnProto::p2p_unregisterDC(directconnection* dc)
{
- mir_cslock lck(sessionLock);
- dcList.remove(dc);
+ mir_cslock lck(m_csSessions);
+ m_arDirect.remove(dc);
}
directconnection* CMsnProto::p2p_getDCByCallID(const char* CallID, const char* wlid)
@@ -251,10 +251,10 @@ directconnection* CMsnProto::p2p_getDCByCallID(const char* CallID, const char* w if (CallID == NULL)
return NULL;
- mir_cslock lck(sessionLock);
+ mir_cslock lck(m_csSessions);
- for (int i = 0; i < dcList.getCount(); i++) {
- directconnection* DC = &dcList[i];
+ for (int i = 0; i < m_arDirect.getCount(); i++) {
+ directconnection* DC = &m_arDirect[i];
if (DC->callId != NULL && !strcmp(DC->callId, CallID) && !strcmp(DC->wlid, wlid))
return DC;
}
@@ -267,7 +267,7 @@ directconnection* CMsnProto::p2p_getDCByCallID(const char* CallID, const char* w void CMsnProto::P2pSessions_Uninit(void)
{
- mir_cslock lck(sessionLock);
- sessionList.destroy();
- dcList.destroy();
+ mir_cslock lck(m_csSessions);
+ m_arSessions.destroy();
+ m_arDirect.destroy();
}
diff --git a/protocols/MSN/src/msn_proto.cpp b/protocols/MSN/src/msn_proto.cpp index afd93523dd..1442006c20 100644 --- a/protocols/MSN/src/msn_proto.cpp +++ b/protocols/MSN/src/msn_proto.cpp @@ -28,18 +28,18 @@ int msn_httpGatewayBegin(HANDLE hConn,NETLIBOPENCONNECTION *nloc); int msn_httpGatewayWrapSend(HANDLE hConn,PBYTE buf,int len,int flags,MIRANDASERVICE pfnNetlibSend);
PBYTE msn_httpGatewayUnwrapRecv(NETLIBHTTPREQUEST *nlhr,PBYTE buf,int len,int *outBufLen,void *(*NetlibRealloc)(void*,size_t));
-static int CompareLists(const MsnContact* p1, const MsnContact* p2)
+static int CompareLists(const MsnContact *p1, const MsnContact *p2)
{
return _stricmp(p1->email, p2->email);
}
CMsnProto::CMsnProto(const char* aProtoName, const TCHAR* aUserName) :
PROTO<CMsnProto>(aProtoName, aUserName),
- contList(10, CompareLists),
- grpList(10, CompareId),
- sttThreads(10, PtrKeySortT),
- sessionList(10, PtrKeySortT),
- dcList(10, PtrKeySortT),
+ m_arContacts(10, CompareLists),
+ m_arGroups(10, CompareId),
+ m_arThreads(10, PtrKeySortT),
+ m_arSessions(10, PtrKeySortT),
+ m_arDirect(10, PtrKeySortT),
lsMessageQueue(1),
lsAvatarQueue(1),
msgCache(5, CompareId)
@@ -978,8 +978,8 @@ int __cdecl CMsnProto::SetStatus(int iNewStatus) return 0;
}
- sessionList.destroy();
- dcList.destroy();
+ m_arSessions.destroy();
+ m_arDirect.destroy();
usingGateway = false;
diff --git a/protocols/MSN/src/msn_proto.h b/protocols/MSN/src/msn_proto.h index 9c0b27214b..bcac61e2be 100644 --- a/protocols/MSN/src/msn_proto.h +++ b/protocols/MSN/src/msn_proto.h @@ -123,17 +123,17 @@ struct CMsnProto : public PROTO<CMsnProto> char *abCacheKey, *sharingCacheKey, *storageCacheKey;
- mir_cs csLists;
- OBJLIST<MsnContact> contList;
+ mir_cs m_csLists;
+ OBJLIST<MsnContact> m_arContacts;
- LIST<ServerGroupItem> grpList;
+ LIST<ServerGroupItem> m_arGroups;
- mir_cs csThreads;
- OBJLIST<ThreadData> sttThreads;
+ mir_cs m_csThreads;
+ OBJLIST<ThreadData> m_arThreads;
- mir_cs sessionLock;
- OBJLIST<filetransfer> sessionList;
- OBJLIST<directconnection> dcList;
+ mir_cs m_csSessions;
+ OBJLIST<filetransfer> m_arSessions;
+ OBJLIST<directconnection> m_arDirect;
mir_cs csMsgQueue;
int msgQueueSeq;
@@ -143,7 +143,7 @@ struct CMsnProto : public PROTO<CMsnProto> LIST<AvatarQueueEntry> lsAvatarQueue;
HANDLE hevAvatarQueue;
- LONG sttChatID;
+ LONG m_chatID;
int msnPingTimeout;
HANDLE hKeepAliveThreadEvt;
diff --git a/protocols/MSN/src/msn_srv.cpp b/protocols/MSN/src/msn_srv.cpp index fab6bb59a2..940b8e2496 100644 --- a/protocols/MSN/src/msn_srv.cpp +++ b/protocols/MSN/src/msn_srv.cpp @@ -28,14 +28,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. void CMsnProto::MSN_AddGroup(const char* grpName, const char *grpId, bool init)
{
- ServerGroupItem* p = grpList.find((ServerGroupItem*)&grpId);
+ ServerGroupItem* p = m_arGroups.find((ServerGroupItem*)&grpId);
if (p != NULL) return;
p = (ServerGroupItem*)mir_alloc(sizeof(ServerGroupItem));
p->id = mir_strdup(grpId);
p->name = mir_strdup(grpName);
- grpList.insert(p);
+ m_arGroups.insert(p);
if (init)
Clist_CreateGroup(0, ptrT(mir_utf8decodeT(grpName)));
@@ -46,13 +46,13 @@ void CMsnProto::MSN_AddGroup(const char* grpName, const char *grpId, bool init) void CMsnProto::MSN_DeleteGroup(const char* pId)
{
- int i = grpList.getIndex((ServerGroupItem*)&pId);
+ int i = m_arGroups.getIndex((ServerGroupItem*)&pId);
if (i > -1) {
- ServerGroupItem* p = grpList[i];
+ ServerGroupItem* p = m_arGroups[i];
mir_free(p->id);
mir_free(p->name);
mir_free(p);
- grpList.remove(i);
+ m_arGroups.remove(i);
}
}
@@ -84,13 +84,13 @@ void CMsnProto::MSN_DeleteServerGroup(LPCSTR szId) void CMsnProto::MSN_FreeGroups(void)
{
- for (int i = 0; i < grpList.getCount(); i++) {
- ServerGroupItem* p = grpList[i];
+ for (int i = 0; i < m_arGroups.getCount(); i++) {
+ ServerGroupItem* p = m_arGroups[i];
mir_free(p->id);
mir_free(p->name);
mir_free(p);
}
- grpList.destroy();
+ m_arGroups.destroy();
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -98,7 +98,7 @@ void CMsnProto::MSN_FreeGroups(void) LPCSTR CMsnProto::MSN_GetGroupById(const char* pId)
{
- ServerGroupItem* p = grpList.find((ServerGroupItem*)&pId);
+ ServerGroupItem* p = m_arGroups.find((ServerGroupItem*)&pId);
return p ? p->name : NULL;
}
@@ -107,8 +107,8 @@ LPCSTR CMsnProto::MSN_GetGroupById(const char* pId) LPCSTR CMsnProto::MSN_GetGroupByName(const char* pName)
{
- for (int i = 0; i < grpList.getCount(); i++) {
- const ServerGroupItem* p = grpList[i];
+ for (int i = 0; i < m_arGroups.getCount(); i++) {
+ const ServerGroupItem* p = m_arGroups[i];
if (strcmp(p->name, pName) == 0)
return p->id;
}
@@ -121,7 +121,7 @@ LPCSTR CMsnProto::MSN_GetGroupByName(const char* pName) void CMsnProto::MSN_SetGroupName(const char* pId, const char* pNewName)
{
- ServerGroupItem* p = grpList.find((ServerGroupItem*)&pId);
+ ServerGroupItem* p = m_arGroups.find((ServerGroupItem*)&pId);
if (p != NULL)
replaceStr(p->name, pNewName);
}
@@ -175,7 +175,7 @@ void CMsnProto::MSN_RemoveEmptyGroups(void) {
if (!MyOptions.ManageServer) return;
- unsigned *cCount = (unsigned*)mir_calloc(grpList.getCount() * sizeof(unsigned));
+ unsigned *cCount = (unsigned*)mir_calloc(m_arGroups.getCount() * sizeof(unsigned));
int count = -1;
for (;;) {
@@ -185,13 +185,13 @@ void CMsnProto::MSN_RemoveEmptyGroups(void) char szGroupID[100];
if (!db_get_static(msc->hContact, m_szModuleName, "GroupID", szGroupID, sizeof(szGroupID))) {
const char *pId = szGroupID;
- int i = grpList.getIndex((ServerGroupItem*)&pId);
+ int i = m_arGroups.getIndex((ServerGroupItem*)&pId);
if (i > -1) ++cCount[i];
}
}
- for (int i = grpList.getCount(); i--;) {
- if (cCount[i] == 0) MSN_DeleteServerGroup(grpList[i]->id);
+ for (int i = m_arGroups.getCount(); i--;) {
+ if (cCount[i] == 0) MSN_DeleteServerGroup(m_arGroups[i]->id);
}
mir_free(cCount);
}
diff --git a/protocols/MSN/src/msn_threads.cpp b/protocols/MSN/src/msn_threads.cpp index fdaeb929b9..5878171337 100644 --- a/protocols/MSN/src/msn_threads.cpp +++ b/protocols/MSN/src/msn_threads.cpp @@ -273,27 +273,27 @@ LBL_Exit: void CMsnProto::MSN_CloseConnections(void)
{
- mir_cslockfull lck(csThreads);
+ mir_cslockfull lck(m_csThreads);
NETLIBSELECTEX nls = { 0 };
nls.cbSize = sizeof(nls);
- for (int i = 0; i < sttThreads.getCount(); i++) {
- ThreadData* T = &sttThreads[i];
+ for (int i = 0; i < m_arThreads.getCount(); i++) {
+ ThreadData &T = m_arThreads[i];
- switch (T->mType) {
+ switch (T.mType) {
case SERVER_NOTIFICATION:
case SERVER_SWITCHBOARD:
- if (T->s != NULL && !T->sessionClosed && !T->termPending) {
- nls.hReadConns[0] = T->s;
+ if (T.s != NULL && !T.sessionClosed && !T.termPending) {
+ nls.hReadConns[0] = T.s;
int res = CallService(MS_NETLIB_SELECTEX, 0, (LPARAM)&nls);
if (res >= 0 || nls.hReadStatus[0] == 0)
- T->sendTerminate();
+ T.sendTerminate();
}
break;
case SERVER_P2P_DIRECT:
- CallService(MS_NETLIB_SHUTDOWN, (WPARAM)T->s, 0);
+ CallService(MS_NETLIB_SHUTDOWN, (WPARAM)T.s, 0);
break;
}
}
@@ -306,35 +306,35 @@ void CMsnProto::MSN_CloseConnections(void) void CMsnProto::Threads_Uninit(void)
{
- mir_cslock lck(csThreads);
- sttThreads.destroy();
+ mir_cslock lck(m_csThreads);
+ m_arThreads.destroy();
}
ThreadData* CMsnProto::MSN_GetThreadByContact(const char* wlid, TInfoType type)
{
- mir_cslock lck(csThreads);
+ mir_cslock lck(m_csThreads);
if (type == SERVER_P2P_DIRECT) {
- for (int i = 0; i < sttThreads.getCount(); i++) {
- ThreadData* T = &sttThreads[i];
- if (T->mType != SERVER_P2P_DIRECT || !T->mJoinedIdentContactsWLID.getCount() || T->s == NULL)
+ for (int i = 0; i < m_arThreads.getCount(); i++) {
+ ThreadData &T = m_arThreads[i];
+ if (T.mType != SERVER_P2P_DIRECT || !T.mJoinedIdentContactsWLID.getCount() || T.s == NULL)
continue;
- if (_stricmp(T->mJoinedIdentContactsWLID[0], wlid) == 0)
- return T;
+ if (_stricmp(T.mJoinedIdentContactsWLID[0], wlid) == 0)
+ return &T;
}
}
char *szEmail = NULL;
parseWLID(NEWSTR_ALLOCA(wlid), NULL, &szEmail, NULL);
- for (int i = 0; i < sttThreads.getCount(); i++) {
- ThreadData* T = &sttThreads[i];
- if (T->mType != type || !T->mJoinedContactsWLID.getCount() || T->mInitialContactWLID || T->s == NULL)
+ for (int i = 0; i < m_arThreads.getCount(); i++) {
+ ThreadData &T = m_arThreads[i];
+ if (T.mType != type || !T.mJoinedContactsWLID.getCount() || T.mInitialContactWLID || T.s == NULL)
continue;
- if (_stricmp(T->mJoinedContactsWLID[0], szEmail) == 0 && T->mChatID[0] == 0)
- return T;
+ if (_stricmp(T.mJoinedContactsWLID[0], szEmail) == 0 && T.mChatID[0] == 0)
+ return &T;
}
return NULL;
@@ -342,13 +342,12 @@ ThreadData* CMsnProto::MSN_GetThreadByContact(const char* wlid, TInfoType type) ThreadData* CMsnProto::MSN_GetThreadByChatId(const TCHAR* chatId)
{
- mir_cslock lck(csThreads);
+ mir_cslock lck(m_csThreads);
- for (int i = 0; i < sttThreads.getCount(); i++) {
- ThreadData* T = &sttThreads[i];
-
- if (_tcsicmp(T->mChatID, chatId) == 0)
- return T;
+ for (int i = 0; i < m_arThreads.getCount(); i++) {
+ ThreadData &T = m_arThreads[i];
+ if (_tcsicmp(T.mChatID, chatId) == 0)
+ return &T;
}
return NULL;
@@ -356,12 +355,12 @@ ThreadData* CMsnProto::MSN_GetThreadByChatId(const TCHAR* chatId) ThreadData* CMsnProto::MSN_GetThreadByTimer(UINT timerId)
{
- mir_cslock lck(csThreads);
+ mir_cslock lck(m_csThreads);
- for (int i = 0; i < sttThreads.getCount(); i++) {
- ThreadData* T = &sttThreads[i];
- if (T->mType == SERVER_SWITCHBOARD && T->mTimerId == timerId)
- return T;
+ for (int i = 0; i < m_arThreads.getCount(); i++) {
+ ThreadData &T = m_arThreads[i];
+ if (T.mType == SERVER_SWITCHBOARD && T.mTimerId == timerId)
+ return &T;
}
return NULL;
@@ -369,30 +368,30 @@ ThreadData* CMsnProto::MSN_GetThreadByTimer(UINT timerId) ThreadData* CMsnProto::MSN_GetP2PThreadByContact(const char *wlid)
{
- mir_cslock lck(csThreads);
+ mir_cslock lck(m_csThreads);
- for (int i = 0; i < sttThreads.getCount(); i++) {
- ThreadData* T = &sttThreads[i];
- if (T->mType != SERVER_P2P_DIRECT || !T->mJoinedIdentContactsWLID.getCount())
+ for (int i = 0; i < m_arThreads.getCount(); i++) {
+ ThreadData &T = m_arThreads[i];
+ if (T.mType != SERVER_P2P_DIRECT || !T.mJoinedIdentContactsWLID.getCount())
continue;
- if (_stricmp(T->mJoinedIdentContactsWLID[0], wlid) == 0)
- return T;
+ if (_stricmp(T.mJoinedIdentContactsWLID[0], wlid) == 0)
+ return &T;
}
char *szEmail = NULL;
parseWLID(NEWSTR_ALLOCA(wlid), NULL, &szEmail, NULL);
ThreadData *result = NULL;
- for (int i = 0; i < sttThreads.getCount(); i++) {
- ThreadData* T = &sttThreads[i];
- if (T->mJoinedContactsWLID.getCount() && !T->mInitialContactWLID &&
- _stricmp(T->mJoinedContactsWLID[0], szEmail) == 0) {
- if (T->mType == SERVER_P2P_DIRECT)
- return T;
-
- if (T->mType == SERVER_SWITCHBOARD)
- result = T;
+ for (int i = 0; i < m_arThreads.getCount(); i++) {
+ ThreadData &T = m_arThreads[i];
+ if (T.mJoinedContactsWLID.getCount() && !T.mInitialContactWLID &&
+ _stricmp(T.mJoinedContactsWLID[0], szEmail) == 0) {
+ if (T.mType == SERVER_P2P_DIRECT)
+ return &T;
+
+ if (T.mType == SERVER_SWITCHBOARD)
+ result = &T;
}
}
@@ -402,15 +401,15 @@ ThreadData* CMsnProto::MSN_GetP2PThreadByContact(const char *wlid) void CMsnProto::MSN_StartP2PTransferByContact(const char* wlid)
{
- mir_cslock lck(csThreads);
-
- for (int i = 0; i < sttThreads.getCount(); i++) {
- ThreadData* T = &sttThreads[i];
- if (T->mType == SERVER_FILETRANS && T->hWaitEvent != INVALID_HANDLE_VALUE) {
- if ((T->mInitialContactWLID && !_stricmp(T->mInitialContactWLID, wlid)) ||
- (T->mJoinedContactsWLID.getCount() && !_stricmp(T->mJoinedContactsWLID[0], wlid)) ||
- (T->mJoinedIdentContactsWLID.getCount() && !_stricmp(T->mJoinedIdentContactsWLID[0], wlid)))
- ReleaseSemaphore(T->hWaitEvent, 1, NULL);
+ mir_cslock lck(m_csThreads);
+
+ for (int i = 0; i < m_arThreads.getCount(); i++) {
+ ThreadData &T = m_arThreads[i];
+ if (T.mType == SERVER_FILETRANS && T.hWaitEvent != INVALID_HANDLE_VALUE) {
+ if ((T.mInitialContactWLID && !_stricmp(T.mInitialContactWLID, wlid)) ||
+ (T.mJoinedContactsWLID.getCount() && !_stricmp(T.mJoinedContactsWLID[0], wlid)) ||
+ (T.mJoinedIdentContactsWLID.getCount() && !_stricmp(T.mJoinedIdentContactsWLID[0], wlid)))
+ ReleaseSemaphore(T.hWaitEvent, 1, NULL);
}
}
}
@@ -418,15 +417,15 @@ void CMsnProto::MSN_StartP2PTransferByContact(const char* wlid) ThreadData* CMsnProto::MSN_GetOtherContactThread(ThreadData* thread)
{
- mir_cslock lck(csThreads);
+ mir_cslock lck(m_csThreads);
- for (int i = 0; i < sttThreads.getCount(); i++) {
- ThreadData* T = &sttThreads[i];
- if (T->mJoinedContactsWLID.getCount() == 0 || T->s == NULL)
+ for (int i = 0; i < m_arThreads.getCount(); i++) {
+ ThreadData &T = m_arThreads[i];
+ if (T.mJoinedContactsWLID.getCount() == 0 || T.s == NULL)
continue;
- if (T != thread && _stricmp(T->mJoinedContactsWLID[0], thread->mJoinedContactsWLID[0]) == 0)
- return T;
+ if (&T != thread && _stricmp(T.mJoinedContactsWLID[0], thread->mJoinedContactsWLID[0]) == 0)
+ return &T;
}
return NULL;
@@ -434,17 +433,17 @@ ThreadData* CMsnProto::MSN_GetOtherContactThread(ThreadData* thread) ThreadData* CMsnProto::MSN_GetUnconnectedThread(const char* wlid, TInfoType type)
{
- mir_cslock lck(csThreads);
+ mir_cslock lck(m_csThreads);
char* szEmail = (char*)wlid;
if (type == SERVER_SWITCHBOARD && strchr(wlid, ';'))
parseWLID(NEWSTR_ALLOCA(wlid), NULL, &szEmail, NULL);
- for (int i = 0; i < sttThreads.getCount(); i++) {
- ThreadData* T = &sttThreads[i];
- if (T->mType == type && T->mInitialContactWLID && _stricmp(T->mInitialContactWLID, szEmail) == 0)
- return T;
+ for (int i = 0; i < m_arThreads.getCount(); i++) {
+ ThreadData &T = m_arThreads[i];
+ if (T.mType == type && T.mInitialContactWLID && _stricmp(T.mInitialContactWLID, szEmail) == 0)
+ return &T;
}
return NULL;
@@ -454,7 +453,7 @@ ThreadData* CMsnProto::MSN_GetUnconnectedThread(const char* wlid, TInfoType type ThreadData* CMsnProto::MSN_StartSB(const char* wlid, bool& isOffline)
{
isOffline = false;
- ThreadData* thread = MSN_GetThreadByContact(wlid);
+ ThreadData *thread = MSN_GetThreadByContact(wlid);
if (thread == NULL) {
MCONTACT hContact = MSN_HContactFromEmail(wlid);
WORD wStatus = getWord(hContact, "Status", ID_STATUS_OFFLINE);
@@ -472,12 +471,12 @@ ThreadData* CMsnProto::MSN_StartSB(const char* wlid, bool& isOffline) int CMsnProto::MSN_GetActiveThreads(ThreadData** parResult)
{
int tCount = 0;
- mir_cslock lck(csThreads);
+ mir_cslock lck(m_csThreads);
- for (int i = 0; i < sttThreads.getCount(); i++) {
- ThreadData* T = &sttThreads[i];
- if (T->mType == SERVER_SWITCHBOARD && T->mJoinedContactsWLID.getCount() != 0 && T->mJoinedContactsWLID.getCount())
- parResult[tCount++] = T;
+ for (int i = 0; i < m_arThreads.getCount(); i++) {
+ ThreadData &T = m_arThreads[i];
+ if (T.mType == SERVER_SWITCHBOARD && T.mJoinedContactsWLID.getCount() != 0 && T.mJoinedContactsWLID.getCount())
+ parResult[tCount++] = &T;
}
return tCount;
@@ -485,12 +484,12 @@ int CMsnProto::MSN_GetActiveThreads(ThreadData** parResult) ThreadData* CMsnProto::MSN_GetThreadByConnection(HANDLE s)
{
- mir_cslock lck(csThreads);
+ mir_cslock lck(m_csThreads);
- for (int i = 0; i < sttThreads.getCount(); i++) {
- ThreadData* T = &sttThreads[i];
- if (T->s == s)
- return T;
+ for (int i = 0; i < m_arThreads.getCount(); i++) {
+ ThreadData &T = m_arThreads[i];
+ if (T.s == s)
+ return &T;
}
return NULL;
@@ -498,12 +497,12 @@ ThreadData* CMsnProto::MSN_GetThreadByConnection(HANDLE s) ThreadData* CMsnProto::MSN_GetThreadByPort(WORD wPort)
{
- mir_cslock lck(csThreads);
+ mir_cslock lck(m_csThreads);
- for (int i = 0; i < sttThreads.getCount(); i++) {
- ThreadData* T = &sttThreads[i];
- if (T->mIncomingPort == wPort)
- return T;
+ for (int i = 0; i < m_arThreads.getCount(); i++) {
+ ThreadData &T = m_arThreads[i];
+ if (T.mIncomingPort == wPort)
+ return &T;
}
return NULL;
@@ -639,8 +638,8 @@ void __cdecl CMsnProto::ThreadStub(void* arg) debugLogA("Leaving thread %08X (%08X)", GetCurrentThreadId(), info->mFunc);
{
- mir_cslock lck(csThreads);
- sttThreads.LIST<ThreadData>::remove(info);
+ mir_cslock lck(m_csThreads);
+ m_arThreads.LIST<ThreadData>::remove(info);
}
delete info;
}
@@ -650,8 +649,8 @@ void ThreadData::startThread(MsnThreadFunc parFunc, CMsnProto *prt) mFunc = parFunc;
proto = prt;
{
- mir_cslock lck(prt->csThreads);
- proto->sttThreads.insert(this);
+ mir_cslock lck(prt->m_csThreads);
+ proto->m_arThreads.insert(this);
}
proto->ForkThread(&CMsnProto::ThreadStub, this);
}
@@ -659,7 +658,7 @@ void ThreadData::startThread(MsnThreadFunc parFunc, CMsnProto *prt) /////////////////////////////////////////////////////////////////////////////////////////
// HReadBuffer members
-HReadBuffer::HReadBuffer(ThreadData* T, int iStart)
+HReadBuffer::HReadBuffer(ThreadData *T, int iStart)
{
owner = T;
buffer = (BYTE*)T->mData;
@@ -703,6 +702,6 @@ BYTE* HReadBuffer::surelyRead(size_t parBytes) totalDataSize += recvResult;
}
- BYTE* result = buffer + startOffset; startOffset += parBytes;
+ BYTE *result = buffer + startOffset; startOffset += parBytes;
return result;
}
|