summaryrefslogtreecommitdiff
path: root/protocols/MSN/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2016-09-17 16:37:24 +0000
committerGeorge Hazan <george.hazan@gmail.com>2016-09-17 16:37:24 +0000
commite5d58fc3bbbce2773b7c6c3f8b7da6faa66b672e (patch)
tree6432409a59b53d8098ac38aa1d3072ae2e5f9e4b /protocols/MSN/src
parent17e345e621254103a98bbc7e662a2829b7aa3ce6 (diff)
chats: more functions, less structures
git-svn-id: http://svn.miranda-ng.org/main/trunk@17309 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/MSN/src')
-rw-r--r--protocols/MSN/src/msn_chat.cpp46
-rw-r--r--protocols/MSN/src/msn_commands.cpp14
-rw-r--r--protocols/MSN/src/msn_misc.cpp10
-rw-r--r--protocols/MSN/src/msn_proto.cpp3
4 files changed, 29 insertions, 44 deletions
diff --git a/protocols/MSN/src/msn_chat.cpp b/protocols/MSN/src/msn_chat.cpp
index 386ea11a5f..86a0967aaf 100644
--- a/protocols/MSN/src/msn_chat.cpp
+++ b/protocols/MSN/src/msn_chat.cpp
@@ -58,7 +58,7 @@ int CMsnProto::MSN_ChatInit(GCThreadData *info, const char *pszID, const char *p
else mir_snwprintf(szName, L"%s %s%d",
m_tszUserName, TranslateT("Chat #"), m_chatID);
- GCSESSION gcw = { sizeof(gcw) };
+ GCSESSION gcw = {};
gcw.iType = GCW_CHATROOM;
gcw.pszModule = m_szModuleName;
gcw.ptszName = szName;
@@ -66,16 +66,15 @@ int CMsnProto::MSN_ChatInit(GCThreadData *info, const char *pszID, const char *p
Chat_NewSession(&gcw);
GCDEST gcd = { m_szModuleName, info->mChatID, GC_EVENT_ADDGROUP };
- GCEVENT gce = { sizeof(gce), &gcd };
+ GCEVENT gce = { &gcd };
for (int j = 0; j < _countof(m_ptszRoles); j++) {
gce.ptszStatus = m_ptszRoles[j];
- Chat_Event(0, &gce);
+ Chat_Event(&gce);
}
- gcd.iType = GC_EVENT_CONTROL;
- Chat_Event(SESSION_INITDONE, &gce);
- Chat_Event(SESSION_ONLINE, &gce);
- Chat_Event(WINDOW_VISIBLE, &gce);
+ Chat_Control(m_szModuleName, info->mChatID, SESSION_INITDONE);
+ Chat_Control(m_szModuleName, info->mChatID, SESSION_ONLINE);
+ Chat_Control(m_szModuleName, info->mChatID, WINDOW_VISIBLE);
mir_free((wchar_t*)gce.ptszUID);
return 0;
@@ -99,11 +98,7 @@ void CMsnProto::MSN_ChatStart(ezxml_t xmli)
MSN_ChatInit(info, pszID, ezxml_txt(ezxml_get(xmli, "properties", 0, "topic", -1)));
MSN_StartStopTyping(info, false);
}
- else {
- GCDEST gcd = { m_szModuleName, info->mChatID, GC_EVENT_CONTROL };
- GCEVENT gce = { sizeof(gce), &gcd };
- Chat_Event(SESSION_ONLINE, &gce);
- }
+ else Chat_Control(m_szModuleName, info->mChatID, SESSION_ONLINE);
const char *pszCreator = ezxml_txt(ezxml_get(xmli, "properties", 0, "creator", -1));
@@ -145,11 +140,8 @@ void CMsnProto::MSN_ChatStart(ezxml_t xmli)
void CMsnProto::MSN_KillChatSession(const wchar_t* id)
{
- GCDEST gcd = { m_szModuleName, id, GC_EVENT_CONTROL };
- GCEVENT gce = { sizeof(gce), &gcd };
- gce.dwFlags = GCEF_REMOVECONTACT;
- Chat_Event(SESSION_OFFLINE, &gce);
- Chat_Event(SESSION_TERMINATE, &gce);
+ Chat_Control(m_szModuleName, id, SESSION_OFFLINE);
+ Chat_Terminate(m_szModuleName, id, true);
}
void CMsnProto::MSN_Kickuser(GCHOOK *gch)
@@ -183,21 +175,21 @@ void CMsnProto::MSN_GCProcessThreadActivity(ezxml_t xmli, const wchar_t *mChatID
if (!mir_strcmp(xmli->name, "topicupdate")) {
ezxml_t initiator = ezxml_child(xmli, "initiator");
GCDEST gcd = { m_szModuleName, mChatID, GC_EVENT_TOPIC};
- GCEVENT gce = { sizeof(gce), &gcd };
+ GCEVENT gce = { &gcd };
gce.dwFlags = GCEF_ADDTOLOG;
gce.time = MsnTSToUnixtime(ezxml_txt(ezxml_child(xmli, "eventtime")));
gce.ptszUID = initiator ? mir_a2u(initiator->txt) : NULL;
MCONTACT hContInitiator = MSN_HContactFromEmail(initiator ? initiator->txt : NULL);
gce.ptszNick = GetContactNameT(hContInitiator);
gce.ptszText = mir_a2u(ezxml_txt(ezxml_child(xmli, "value")));
- Chat_Event(0, &gce);
+ Chat_Event(&gce);
mir_free((wchar_t*)gce.ptszUID);
mir_free((wchar_t*)gce.ptszText);
}
else if (ezxml_t target = ezxml_child(xmli, "target")) {
MCONTACT hContInitiator = NULL;
GCDEST gcd = { m_szModuleName, mChatID, 0};
- GCEVENT gce = { sizeof(gce), &gcd };
+ GCEVENT gce = { &gcd };
gce.dwFlags = GCEF_ADDTOLOG;
if (!mir_strcmp(xmli->name, "deletemember")) {
@@ -247,12 +239,10 @@ void CMsnProto::MSN_GCProcessThreadActivity(ezxml_t xmli, const wchar_t *mChatID
gce.ptszUID = mir_a2u(pszTarget);
MCONTACT hContTarget = MSN_HContactFromEmail(pszTarget);
gce.ptszNick = GetContactNameT(hContTarget);
- Chat_Event(0, &gce);
+ Chat_Event(&gce);
mir_free((wchar_t*)gce.ptszUID);
if ((gcd.iType == GC_EVENT_PART || gcd.iType == GC_EVENT_KICK) && gce.bIsMe) {
- GCDEST gcd2 = { m_szModuleName, mChatID, GC_EVENT_CONTROL };
- GCEVENT gce2 = { sizeof(gce2), &gcd2 };
- Chat_Event(SESSION_OFFLINE, &gce2);
+ Chat_Control(m_szModuleName, mChatID, SESSION_OFFLINE);
break;
}
target = ezxml_next(target);
@@ -285,7 +275,7 @@ void CMsnProto::MSN_GCRefreshThreadsInfo(void)
void CMsnProto::MSN_GCAddMessage(wchar_t *mChatID, MCONTACT hContact, char *email, time_t ts, bool sentMsg, char *msgBody)
{
GCDEST gcd = { m_szModuleName, mChatID, GC_EVENT_MESSAGE };
- GCEVENT gce = { sizeof(gce), &gcd };
+ GCEVENT gce = { &gcd };
gce.dwFlags = GCEF_ADDTOLOG;
gce.ptszUID = mir_a2u(email);
gce.ptszNick = GetContactNameT(hContact);
@@ -296,7 +286,7 @@ void CMsnProto::MSN_GCAddMessage(wchar_t *mChatID, MCONTACT hContact, char *emai
gce.ptszText = EscapeChatTags(p);
mir_free(p);
- Chat_Event(0, &gce);
+ Chat_Event(&gce);
mir_free((void*)gce.ptszUID);
mir_free((void*)gce.ptszText);
}
@@ -509,14 +499,14 @@ int CMsnProto::MSN_GCEventHook(WPARAM, LPARAM lParam)
int bError = getWString("Nick", &dbv);
GCDEST gcd = { m_szModuleName, gch->pDest->ptszID, GC_EVENT_MESSAGE };
- GCEVENT gce = { sizeof(gce), &gcd };
+ GCEVENT gce = { &gcd };
gce.dwFlags = GCEF_ADDTOLOG;
gce.ptszNick = bError ? L"" : dbv.ptszVal;
gce.ptszUID = mir_a2u(MyOptions.szEmail);
gce.time = time(NULL);
gce.ptszText = gch->ptszText;
gce.bIsMe = TRUE;
- Chat_Event(0, &gce);
+ Chat_Event(&gce);
mir_free((void*)gce.ptszUID);
if (!bError)
diff --git a/protocols/MSN/src/msn_commands.cpp b/protocols/MSN/src/msn_commands.cpp
index 3c29b41bd6..4ddfca2196 100644
--- a/protocols/MSN/src/msn_commands.cpp
+++ b/protocols/MSN/src/msn_commands.cpp
@@ -1882,13 +1882,13 @@ LBL_InvalidCommand:
// modified for chat
{
GCDEST gcd = { m_szModuleName, info->mChatID, GC_EVENT_QUIT };
- GCEVENT gce = { sizeof(gce), &gcd };
+ GCEVENT gce = { &gcd };
gce.dwFlags = GCEF_ADDTOLOG;
gce.ptszNick = GetContactNameT(hContact);
gce.ptszUID = mir_a2u(data.userEmail);
gce.time = time(NULL);
gce.bIsMe = FALSE;
- Chat_Event(0, &gce);
+ Chat_Event(&gce);
mir_free((void*)gce.ptszUID);
}
@@ -1902,14 +1902,14 @@ LBL_InvalidCommand:
if (info->mChatID[0] && personleft == 1) {
if (!mir_strcmp(data.isIdle, "1")) {
GCDEST gcd = { m_szModuleName, info->mChatID, GC_EVENT_INFORMATION };
- GCEVENT gce = { sizeof(gce), &gcd };
+ GCEVENT gce = { &gcd };
gce.dwFlags = GCEF_ADDTOLOG;
gce.bIsMe = FALSE;
gce.time = time(NULL);
gce.ptszText = TranslateT("This conversation has been inactive, participants will be removed.");
- Chat_Event(0, &gce);
+ Chat_Event(&gce);
gce.ptszText = TranslateT("To resume the conversation, please quit this session and start a new chat session.");
- Chat_Event(0, &gce);
+ Chat_Event(&gce);
}
else {
if (!g_bTerminated && MessageBox(NULL,
@@ -2138,14 +2138,14 @@ LBL_InvalidCommand:
if (chatCreated) {
GCDEST gcd = { m_szModuleName, info->mChatID, GC_EVENT_JOIN };
- GCEVENT gce = { sizeof(gce), &gcd };
+ GCEVENT gce = { &gcd };
gce.dwFlags = GCEF_ADDTOLOG;
gce.ptszNick = GetContactNameT(hContact);
gce.ptszUID = mir_a2u(data.userEmail);
gce.ptszStatus = TranslateT("Others");
gce.time = time(NULL);
gce.bIsMe = FALSE;
- Chat_Event(0, &gce);
+ Chat_Event(&gce);
mir_free((void*)gce.ptszUID);
}
else MSN_ChatStart(info);
diff --git a/protocols/MSN/src/msn_misc.cpp b/protocols/MSN/src/msn_misc.cpp
index ad4ac92d1a..e610b9c87a 100644
--- a/protocols/MSN/src/msn_misc.cpp
+++ b/protocols/MSN/src/msn_misc.cpp
@@ -396,13 +396,9 @@ void CMsnProto::MSN_GoOffline(void)
hContact = db_find_next(hContact, m_szModuleName))
{
if (isChatRoom(hContact) != 0) {
- DBVARIANT dbv;
- if (getWString(hContact, "ChatRoomID", &dbv) == 0) {
- GCDEST gcd = { m_szModuleName, dbv.ptszVal, GC_EVENT_CONTROL };
- GCEVENT gce = { sizeof(gce), &gcd };
- Chat_Event(SESSION_OFFLINE, &gce);
- db_free(&dbv);
- }
+ ptrW wszRoom(getWStringA(hContact, "ChatRoomID"));
+ if (wszRoom != NULL)
+ Chat_Control(m_szModuleName, wszRoom, SESSION_OFFLINE);
}
else {
if (ID_STATUS_OFFLINE != getWord(hContact, "Status", ID_STATUS_OFFLINE)) {
diff --git a/protocols/MSN/src/msn_proto.cpp b/protocols/MSN/src/msn_proto.cpp
index 86b68155bc..c9e104c7c7 100644
--- a/protocols/MSN/src/msn_proto.cpp
+++ b/protocols/MSN/src/msn_proto.cpp
@@ -201,8 +201,7 @@ CMsnProto::~CMsnProto()
int CMsnProto::OnModulesLoaded(WPARAM, LPARAM)
{
- GCREGISTER gcr = { 0 };
- gcr.cbSize = sizeof(GCREGISTER);
+ GCREGISTER gcr = {};
gcr.dwFlags = GC_TYPNOTIF | GC_CHANMGR;
gcr.iMaxText = 0;
gcr.nColors = 16;