diff options
author | George Hazan <george.hazan@gmail.com> | 2014-01-08 19:39:48 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-01-08 19:39:48 +0000 |
commit | 05cd7934d4bdb097e112efdda356946868f3f5d6 (patch) | |
tree | 0fa678b494af8b994abf7319298a1af06fc9218a /protocols | |
parent | 50a2ba5bf6827b8f010288021c1797c11bd1531e (diff) |
- end of ANSI support in chats;
- manual crit section control removed from chat engine;
- bunch of memory-related clutches either removed or replaced with smart pointers
git-svn-id: http://svn.miranda-ng.org/main/trunk@7549 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
33 files changed, 943 insertions, 1459 deletions
diff --git a/protocols/AimOscar/src/chat.cpp b/protocols/AimOscar/src/chat.cpp index 1c9f329486..f58f824016 100644 --- a/protocols/AimOscar/src/chat.cpp +++ b/protocols/AimOscar/src/chat.cpp @@ -21,13 +21,11 @@ static const COLORREF crCols[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; void CAimProto::chat_register(void)
{
- GCREGISTER gcr = {0};
- gcr.cbSize = sizeof(gcr);
- gcr.dwFlags = GC_TYPNOTIF | GC_CHANMGR | GC_TCHAR;
- gcr.iMaxText = 0;
+ GCREGISTER gcr = { sizeof(gcr) };
+ gcr.dwFlags = GC_TYPNOTIF | GC_CHANMGR;
gcr.nColors = 16;
gcr.pColors = (COLORREF*)crCols;
- gcr.ptszModuleDispName = m_tszUserName;
+ gcr.ptszDispName = m_tszUserName;
gcr.pszModule = m_szModuleName;
CallServiceSync(MS_GC_REGISTER, 0, (LPARAM)&gcr);
@@ -39,22 +37,15 @@ void CAimProto::chat_start(const char* id, unsigned short exchange) {
TCHAR* idt = mir_a2t(id);
- GCSESSION gcw = {0};
- gcw.cbSize = sizeof(gcw);
- gcw.dwFlags = GC_TCHAR;
+ GCSESSION gcw = { sizeof(gcw) };
gcw.iType = GCW_CHATROOM;
gcw.pszModule = m_szModuleName;
gcw.ptszName = idt;
gcw.ptszID = idt;
CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM)&gcw);
- GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_ADDGROUP };
- gcd.ptszID = idt;
-
- GCEVENT gce = {0};
- gce.cbSize = sizeof(gce);
- gce.dwFlags = GC_TCHAR;
- gce.pDest = &gcd;
+ GCDEST gcd = { m_szModuleName, idt, GC_EVENT_ADDGROUP };
+ GCEVENT gce = { sizeof(gce), &gcd };
gce.ptszStatus = TranslateT("Me");
CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
@@ -81,12 +72,9 @@ void CAimProto::chat_event(const char* id, const char* sn, int evt, const TCHAR* TCHAR* nick = hContact ? (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,
WPARAM(hContact), GCDNF_TCHAR) : snt;
- GCDEST gcd = { m_szModuleName, { NULL }, evt };
- gcd.ptszID = idt;
-
- GCEVENT gce = {0};
- gce.cbSize = sizeof(gce);
- gce.dwFlags = GC_TCHAR | GCEF_ADDTOLOG;
+ GCDEST gcd = { m_szModuleName, idt, evt };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ gce.dwFlags = GCEF_ADDTOLOG;
gce.pDest = &gcd;
gce.ptszNick = nick;
gce.ptszUID = snt;
@@ -104,12 +92,8 @@ void CAimProto::chat_leave(const char* id) {
TCHAR* idt = mir_a2t(id);
- GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_CONTROL };
- gcd.ptszID = idt;
-
- GCEVENT gce = {0};
- gce.cbSize = sizeof(GCEVENT);
- gce.dwFlags = GC_TCHAR;
+ GCDEST gcd = { m_szModuleName, idt, GC_EVENT_CONTROL };
+ GCEVENT gce = { sizeof(gce), &gcd };
gce.pDest = &gcd;
CallServiceSync(MS_GC_EVENT, SESSION_OFFLINE, (LPARAM)&gce);
CallServiceSync(MS_GC_EVENT, SESSION_TERMINATE, (LPARAM)&gce);
diff --git a/protocols/FacebookRM/src/chat.cpp b/protocols/FacebookRM/src/chat.cpp index 9744cb89dc..5315294fe7 100644 --- a/protocols/FacebookRM/src/chat.cpp +++ b/protocols/FacebookRM/src/chat.cpp @@ -30,22 +30,15 @@ void FacebookProto::UpdateChat(const TCHAR *tchat_id, const char *id, const char ptrT tnick( mir_a2t_cp(name,CP_UTF8));
ptrT ttext( mir_a2t_cp(message,CP_UTF8));
- GCDEST gcd = { m_szModuleName };
- gcd.ptszID = (TCHAR *)tchat_id;
-
- GCEVENT gce = {sizeof(gce)};
- gce.pDest = &gcd;
+ GCDEST gcd = { m_szModuleName, (TCHAR*)tchat_id, GC_EVENT_MESSAGE };
+ GCEVENT gce = { sizeof(gce), &gcd };
gce.ptszText = ttext;
- gce.time = timestamp ? timestamp : ::time(NULL);
- gce.dwFlags = GC_TCHAR;
- gcd.iType = GC_EVENT_MESSAGE;
+ gce.time = timestamp ? timestamp : ::time(NULL);
if (id != NULL)
gce.bIsMe = !strcmp(id,facy.self_.user_id.c_str());
- gce.dwFlags |= GCEF_ADDTOLOG;
-
+ gce.dwFlags |= GCEF_ADDTOLOG;
gce.ptszNick = tnick;
gce.ptszUID = tid;
-
CallServiceSync(MS_GC_EVENT,0,reinterpret_cast<LPARAM>(&gce));
std::map<std::tstring, facebook_chatroom>::iterator chatroom = facy.chat_rooms.find(tchat_id);
@@ -60,15 +53,9 @@ void FacebookProto::RenameChat(const char *chat_id, const char *name) ptrT tchat_id( mir_a2t(chat_id));
ptrT tname( mir_a2t_cp(name, CP_UTF8));
- GCDEST gcd = { m_szModuleName };
- gcd.ptszID = tchat_id;
-
- GCEVENT gce = {sizeof(gce)};
- gce.pDest = &gcd;
+ GCDEST gcd = { m_szModuleName, tchat_id, GC_EVENT_CHANGESESSIONAME };
+ GCEVENT gce = { sizeof(gce), &gcd };
gce.ptszText = tname;
- gce.dwFlags = GC_TCHAR;
- gcd.iType = GC_EVENT_CHANGESESSIONAME;
-
CallService(MS_GC_EVENT, 0, reinterpret_cast<LPARAM>(&gce));
}
@@ -159,17 +146,14 @@ void FacebookProto::AddChatContact(const TCHAR *tchat_id, const char *id, const ptrT tnick( mir_a2t_cp(name, CP_UTF8));
ptrT tid( mir_a2t(id));
- GCDEST gcd = { m_szModuleName };
- gcd.ptszID = (TCHAR *)tchat_id;
- gcd.iType = GC_EVENT_JOIN;
-
- GCEVENT gce = {sizeof(gce)};
- gce.pDest = &gcd;
- gce.dwFlags = GC_TCHAR | GCEF_ADDTOLOG;
- gce.ptszNick = tnick;
- gce.ptszUID = tid;
- gce.time = ::time(NULL);
- gce.bIsMe = !strcmp(id, facy.self_.user_id.c_str());
+ GCDEST gcd = { m_szModuleName, (TCHAR *)tchat_id, GC_EVENT_JOIN };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ gce.pDest = &gcd;
+ gce.dwFlags = GCEF_ADDTOLOG;
+ gce.ptszNick = tnick;
+ gce.ptszUID = tid;
+ gce.time = ::time(NULL);
+ gce.bIsMe = !strcmp(id, facy.self_.user_id.c_str());
if (gce.bIsMe)
gce.ptszStatus = _T("Admin");
@@ -192,18 +176,12 @@ void FacebookProto::RemoveChatContact(const TCHAR *tchat_id, const char *id) ptrT tid( mir_a2t(id));
- GCDEST gcd = { m_szModuleName };
- gcd.ptszID = (TCHAR *)tchat_id;
- gcd.iType = GC_EVENT_PART;
-
- GCEVENT gce = {sizeof(gce)};
- gce.pDest = &gcd;
- gce.dwFlags = GC_TCHAR | GCEF_ADDTOLOG;
- //gce.ptszNick = mir_a2t_cp(name, CP_UTF8);
- gce.ptszUID = tid;
- gce.ptszNick = tid;
- gce.time = ::time(NULL);
- gce.bIsMe = false;//!strcmp(id, facy.self_.user_id.c_str());
+ GCDEST gcd = { m_szModuleName, (TCHAR *)tchat_id, GC_EVENT_PART };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ gce.dwFlags = GCEF_ADDTOLOG;
+ gce.ptszUID = gce.ptszNick = tid;
+ gce.time = ::time(NULL);
+ gce.bIsMe = false;//!strcmp(id, facy.self_.user_id.c_str());
std::map<std::tstring, facebook_chatroom>::iterator room = facy.chat_rooms.find(tchat_id);
if (room != facy.chat_rooms.end())
@@ -235,26 +213,19 @@ bool FacebookProto::IsChatContact(const TCHAR *chat_id, const char *id) void FacebookProto::AddChat(const TCHAR *tid, const TCHAR *tname)
{
- GCSESSION gcw = {sizeof(gcw)};
-
// Create the group chat session
- gcw.dwFlags = GC_TCHAR;
- gcw.iType = GCW_CHATROOM;
+ GCSESSION gcw = { sizeof(gcw) };
+ gcw.iType = GCW_CHATROOM;
+ gcw.ptszID = tid;
gcw.pszModule = m_szModuleName;
- gcw.ptszName = tname;
- gcw.ptszID = tid;
+ gcw.ptszName = tname;
CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM)&gcw);
// Send setting events
- GCDEST gcd = { m_szModuleName };
- gcd.ptszID = (TCHAR *)tid;
-
- GCEVENT gce = {sizeof(gce)};
- gce.pDest = &gcd;
- gce.dwFlags = GC_TCHAR;
+ GCDEST gcd = { m_szModuleName, (TCHAR*)tid, GC_EVENT_ADDGROUP };
+ GCEVENT gce = { sizeof(gce), &gcd };
// Create a user statuses
- gcd.iType = GC_EVENT_ADDGROUP;
gce.ptszStatus = _T("Admin");
CallServiceSync(MS_GC_EVENT, NULL, reinterpret_cast<LPARAM>(&gce));
gce.ptszStatus = _T("Normal");
@@ -275,23 +246,6 @@ void FacebookProto::AddChat(const TCHAR *tid, const TCHAR *tname) CallServiceSync(MS_GC_EVENT,SESSION_ONLINE, reinterpret_cast<LPARAM>(&gce));
}
-/*void FacebookProto::SetTopic(const char *topic)
-{
- GCDEST gcd = { m_szModuleName };
- gcd.ptszID = const_cast<TCHAR*>(m_tszUserName);
- gcd.iType = GC_EVENT_TOPIC;
-
- GCEVENT gce = {sizeof(gce)};
- gce.pDest = &gcd;
- gce.dwFlags = GC_TCHAR;
- gce.time = ::time(NULL);
-
- std::string top = Translate(topic);
- gce.ptszText = mir_a2t(top.c_str());
- CallServiceSync(MS_GC_EVENT,0, reinterpret_cast<LPARAM>(&gce));
-}
-*/
-
INT_PTR FacebookProto::OnJoinChat(WPARAM wParam,LPARAM suppress)
{
HANDLE hContact = (HANDLE)wParam;
@@ -317,15 +271,8 @@ INT_PTR FacebookProto::OnJoinChat(WPARAM wParam,LPARAM suppress) return 0;
// Create a group
- GCDEST gcd = { m_szModuleName };
- gcd.ptszID = const_cast<TCHAR*>(m_tszUserName);
-
- GCEVENT gce = {sizeof(gce)};
- gce.pDest = &gcd;
- gce.dwFlags = GC_TCHAR;
-
- gcd.iType = GC_EVENT_ADDGROUP;
-
+ GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_ADDGROUP };
+ GCEVENT gce = { sizeof(gce), &gcd };
gce.ptszStatus = _T("Admin");
CallServiceSync(MS_GC_EVENT, NULL, reinterpret_cast<LPARAM>(&gce));
@@ -343,18 +290,12 @@ INT_PTR FacebookProto::OnJoinChat(WPARAM wParam,LPARAM suppress) INT_PTR FacebookProto::OnLeaveChat(WPARAM,LPARAM)
{
- GCDEST gcd = { m_szModuleName };
- gcd.ptszID = NULL;
- gcd.iType = GC_EVENT_CONTROL;
-
- GCEVENT gce = {sizeof(gce)};
- gce.dwFlags = GC_TCHAR;
+ GCDEST gcd = { m_szModuleName, NULL, GC_EVENT_CONTROL };
+ GCEVENT gce = { sizeof(gce), &gcd };
gce.time = ::time(NULL);
- gce.pDest = &gcd;
CallServiceSync(MS_GC_EVENT,SESSION_OFFLINE, reinterpret_cast<LPARAM>(&gce));
CallServiceSync(MS_GC_EVENT,SESSION_TERMINATE,reinterpret_cast<LPARAM>(&gce));
-
return 0;
}
@@ -365,10 +306,8 @@ void FacebookProto::SetChatStatus(int status) gcd.ptszID = const_cast<TCHAR*>(m_tszUserName);
gcd.iType = GC_EVENT_CONTROL;
- GCEVENT gce = {sizeof(gce)};
- gce.dwFlags = GC_TCHAR;
+ GCEVENT gce = { sizeof(gce), &gcd };
gce.time = ::time(NULL);
- gce.pDest = &gcd;
if(status == ID_STATUS_ONLINE)
{
diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp index 86ab425c2d..bbe948120d 100644 --- a/protocols/FacebookRM/src/proto.cpp +++ b/protocols/FacebookRM/src/proto.cpp @@ -385,7 +385,7 @@ int FacebookProto::OnModulesLoaded(WPARAM wParam, LPARAM lParam) GCREGISTER gcr = {sizeof(gcr)};
gcr.dwFlags = 0; //GC_ACKMSG;
gcr.pszModule = m_szModuleName;
- gcr.pszModuleDispName = m_szModuleName;
+ gcr.ptszDispName = m_tszUserName;
gcr.iMaxText = FACEBOOK_MESSAGE_LIMIT;
gcr.nColors = 0;
gcr.pColors = NULL;
diff --git a/protocols/Gadu-Gadu/src/core.cpp b/protocols/Gadu-Gadu/src/core.cpp index 26a0f6d477..938e1dead2 100644 --- a/protocols/Gadu-Gadu/src/core.cpp +++ b/protocols/Gadu-Gadu/src/core.cpp @@ -826,21 +826,19 @@ retry: if (chat)
{
TCHAR id[32];
- GCDEST gcdest = {0};
- gcdest.pszModule = m_szModuleName;
- gcdest.ptszID = chat;
- gcdest.iType = GC_EVENT_MESSAGE;
- GCEVENT gcevent = {sizeof(GCEVENT), &gcdest};
- time_t t = time(NULL);
UIN2IDT(e->event.msg.sender, id);
- gcevent.ptszUID = id;
+
+ GCDEST gcd = { m_szModuleName, chat, GC_EVENT_MESSAGE };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ time_t t = time(NULL);
+ gce.ptszUID = id;
TCHAR* messageT = mir_utf8decodeT(e->event.msg.message);
- gcevent.ptszText = messageT;
- gcevent.ptszNick = (TCHAR*) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) getcontact(e->event.msg.sender, 1, 0, NULL), GCDNF_TCHAR);
- gcevent.time = (!(e->event.msg.msgclass & GG_CLASS_OFFLINE) || e->event.msg.time > (t - timeDeviation)) ? t : e->event.msg.time;
- gcevent.dwFlags = GC_TCHAR | GCEF_ADDTOLOG;
+ gce.ptszText = messageT;
+ gce.ptszNick = (TCHAR*) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) getcontact(e->event.msg.sender, 1, 0, NULL), GCDNF_TCHAR);
+ gce.time = (!(e->event.msg.msgclass & GG_CLASS_OFFLINE) || e->event.msg.time > (t - timeDeviation)) ? t : e->event.msg.time;
+ gce.dwFlags = GCEF_ADDTOLOG;
debugLog(_T("mainthread() (%x): Conference message to room %s & id %s."), this, chat, id);
- CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gcevent);
+ CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
mir_free(messageT);
}
}
@@ -893,29 +891,26 @@ retry: if (chat)
{
TCHAR id[32];
- DBVARIANT dbv;
- GCDEST gcdest = {0};
- gcdest.pszModule = m_szModuleName;
- gcdest.ptszID = chat;
- gcdest.iType = GC_EVENT_MESSAGE;
- GCEVENT gcevent = {sizeof(GCEVENT), &gcdest};
UIN2IDT(getDword(GG_KEY_UIN, 0), id);
- gcevent.ptszUID = id;
+
+ DBVARIANT dbv;
+ GCDEST gcd = { m_szModuleName, chat, GC_EVENT_MESSAGE };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ gce.ptszUID = id;
TCHAR* messageT = mir_utf8decodeT(e->event.multilogon_msg.message);
- gcevent.ptszText = messageT;
+ gce.ptszText = messageT;
TCHAR* nickT;
if (!getTString(GG_KEY_NICK, &dbv)){
nickT = mir_tstrdup(dbv.ptszVal);
db_free(&dbv);
- } else {
- nickT = mir_tstrdup(TranslateT("Me"));
}
- gcevent.ptszNick = nickT;
- gcevent.time = e->event.multilogon_msg.time;
- gcevent.bIsMe = 1;
- gcevent.dwFlags = GC_TCHAR | GCEF_ADDTOLOG;
+ else nickT = mir_tstrdup(TranslateT("Me"));
+ gce.ptszNick = nickT;
+ gce.time = e->event.multilogon_msg.time;
+ gce.bIsMe = 1;
+ gce.dwFlags = GCEF_ADDTOLOG;
debugLog(_T("mainthread() (%x): Sent conference message to room %s."), this, chat);
- CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gcevent);
+ CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
mir_free(messageT);
mir_free(nickT);
}
@@ -1284,12 +1279,8 @@ int GGPROTO::contactdeleted(WPARAM wParam, LPARAM lParam) DBVARIANT dbv;
if ( isChatRoom(hContact) && !getTString(hContact, "ChatRoomID", &dbv) && gc_enabled)
{
- GCDEST gcdest = {0};
- gcdest.pszModule = m_szModuleName;
- gcdest.ptszID = dbv.ptszVal;
- gcdest.iType = GC_EVENT_CONTROL;
- GCEVENT gcevent = {sizeof(GCEVENT), &gcdest};
- gcevent.dwFlags = GC_TCHAR;
+ GCDEST gcd = { m_szModuleName, dbv.ptszVal, GC_EVENT_CONTROL };
+ GCEVENT gce = { sizeof(gce), &gcd };
GGGC *chat = gc_lookup(dbv.ptszVal);
debugLogA("contactdeleted(): Terminating chat %x, id %s from contact list...", chat, dbv.pszVal);
@@ -1299,8 +1290,8 @@ int GGPROTO::contactdeleted(WPARAM wParam, LPARAM lParam) free(chat->recipients);
list_remove(&chats, chat, 1);
// Terminate chat window / shouldn't cascade entry is deleted
- CallServiceSync(MS_GC_EVENT, SESSION_OFFLINE, (LPARAM)&gcevent);
- CallServiceSync(MS_GC_EVENT, SESSION_TERMINATE, (LPARAM)&gcevent);
+ CallServiceSync(MS_GC_EVENT, SESSION_OFFLINE, (LPARAM)&gce);
+ CallServiceSync(MS_GC_EVENT, SESSION_TERMINATE, (LPARAM)&gce);
}
db_free(&dbv);
@@ -1366,17 +1357,13 @@ int GGPROTO::dbsettingchanged(WPARAM wParam, LPARAM lParam) static int cascade = 0;
if (!cascade && dbv.ptszVal)
{
- GCDEST gcdest = {0};
- gcdest.pszModule = m_szModuleName;
- gcdest.ptszID = dbv.ptszVal;
- gcdest.iType = GC_EVENT_CHANGESESSIONAME;
- GCEVENT gcevent = {sizeof(GCEVENT), &gcdest};
- gcevent.dwFlags = GC_TCHAR;
- gcevent.ptszText = ptszVal;
+ GCDEST gcd = { m_szModuleName, dbv.ptszVal, GC_EVENT_CHANGESESSIONAME };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ gce.ptszText = ptszVal;
debugLogA("dbsettingchanged(): Conference %s was renamed.", dbv.pszVal);
// Mark cascading
/* FIXME */ cascade = 1;
- CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gcevent);
+ CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
/* FIXME */ cascade = 0;
}
db_free(&dbv);
diff --git a/protocols/Gadu-Gadu/src/groupchat.cpp b/protocols/Gadu-Gadu/src/groupchat.cpp index 0845a550be..3ae8ecf309 100644 --- a/protocols/Gadu-Gadu/src/groupchat.cpp +++ b/protocols/Gadu-Gadu/src/groupchat.cpp @@ -30,28 +30,23 @@ int GGPROTO::gc_init()
{
- if (ServiceExists(MS_GC_REGISTER))
- {
+ if (ServiceExists(MS_GC_REGISTER)) {
char service[64];
- GCREGISTER gcr = {0};
// Register Gadu-Gadu proto
- gcr.cbSize = sizeof(GCREGISTER);
- gcr.dwFlags = GC_TCHAR;
- gcr.iMaxText = 0;
- gcr.nColors = 0;
- gcr.pColors = 0;
- gcr.ptszModuleDispName = m_tszUserName;
+ GCREGISTER gcr = { sizeof(gcr) };
+ gcr.ptszDispName = m_tszUserName;
gcr.pszModule = m_szModuleName;
CallServiceSync(MS_GC_REGISTER, 0, (LPARAM)&gcr);
+
HookProtoEvent(ME_GC_EVENT, &GGPROTO::gc_event);
+
gc_enabled = TRUE;
// create & hook event
mir_snprintf(service, 64, GG_GC_GETCHAT, m_szModuleName);
debugLogA("gc_init(): Registered with groupchat plugin.");
}
- else
- debugLogA("gc_init(): Cannot register with groupchat plugin !!!");
+ else debugLogA("gc_init(): Cannot register with groupchat plugin !!!");
return 1;
}
@@ -160,36 +155,30 @@ int GGPROTO::gc_event(WPARAM wParam, LPARAM lParam) if (isonline() && (gch->pDest->iType == GC_USER_MESSAGE) && gch->ptszText)
{
TCHAR id[32];
- DBVARIANT dbv;
- GCDEST gcdest = {0};
- gcdest.pszModule = m_szModuleName;
- gcdest.ptszID = gch->pDest->ptszID;
- gcdest.iType = GC_EVENT_MESSAGE;
- GCEVENT gcevent = {sizeof(GCEVENT), &gcdest};
- int lc;
-
UIN2IDT(uin, id);
+ DBVARIANT dbv;
- gcevent.ptszUID = id;
- gcevent.ptszText = gch->ptszText;
+ GCDEST gcd = { m_szModuleName, gch->pDest->ptszID, GC_EVENT_MESSAGE };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ gce.ptszUID = id;
+ gce.ptszText = gch->ptszText;
TCHAR* nickT;
if (!getTString(GG_KEY_NICK, &dbv)){
nickT = mir_tstrdup(dbv.ptszVal);
db_free(&dbv);
- } else {
- nickT = mir_tstrdup(TranslateT("Me"));
}
- gcevent.ptszNick = nickT;
+ else nickT = mir_tstrdup(TranslateT("Me"));
+ gce.ptszNick = nickT;
// Get rid of CRLF at back
- lc = (int)_tcslen(gch->ptszText) - 1;
+ int lc = (int)_tcslen(gch->ptszText) - 1;
while(lc >= 0 && (gch->ptszText[lc] == '\n' || gch->ptszText[lc] == '\r')) gch->ptszText[lc --] = 0;
- gcevent.time = time(NULL);
- gcevent.bIsMe = 1;
- gcevent.dwFlags = GC_TCHAR | GCEF_ADDTOLOG;
+ gce.time = time(NULL);
+ gce.bIsMe = 1;
+ gce.dwFlags = GCEF_ADDTOLOG;
debugLog(_T("gc_event(): Sending conference message to room %s, \"%s\"."), gch->pDest->ptszID, gch->ptszText);
- CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gcevent);
+ CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
mir_free(nickT);
char* pszText_utf8 = mir_utf8encodeT(gch->ptszText);
@@ -230,8 +219,8 @@ TCHAR* GGPROTO::gc_getchat(uin_t sender, uin_t *recipients, int recipients_count GGGC *chat;
TCHAR id[32];
uin_t uin; DBVARIANT dbv;
- GCDEST gcdest = {m_szModuleName, 0, GC_EVENT_ADDGROUP};
- GCEVENT gcevent = {sizeof(GCEVENT), &gcdest};
+ GCDEST gcd = {m_szModuleName, 0, GC_EVENT_ADDGROUP};
+ GCEVENT gce = { sizeof(gce), &gcd };
debugLogA("gc_getchat(): Count %d.", recipients_count);
if (!recipients) return NULL;
@@ -317,14 +306,12 @@ TCHAR* GGPROTO::gc_getchat(uin_t sender, uin_t *recipients, int recipients_count TCHAR status[256];
TCHAR *senderName = sender ? pcli->pfnGetContactDisplayName(getcontact(sender, 1, 0, NULL), 0) : NULL;
mir_sntprintf(status, 255, (sender) ? TranslateT("%s initiated the conference.") : TranslateT("This is my own conference."), senderName);
- GCSESSION gcwindow = { 0 };
- gcwindow.cbSize = sizeof(GCSESSION);
+
+ GCSESSION gcwindow = { sizeof(gcwindow) };
gcwindow.iType = GCW_CHATROOM;
- gcwindow.dwFlags = GC_TCHAR;
gcwindow.pszModule = m_szModuleName;
gcwindow.ptszName = sender ? senderName : TranslateT("Conference");
gcwindow.ptszID = chat->id;
- gcwindow.dwFlags = GC_TCHAR;
gcwindow.dwItemData = (DWORD)chat;
gcwindow.ptszStatusbarText = status;
@@ -332,9 +319,9 @@ TCHAR* GGPROTO::gc_getchat(uin_t sender, uin_t *recipients, int recipients_count TCHAR *name = (TCHAR*)calloc(_tcslen(gcwindow.ptszName) + 2, sizeof(TCHAR));
*name = '#'; _tcscpy(name + 1, gcwindow.ptszName);
gcwindow.ptszName = name;
+
// Create new room
- if (CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM) &gcwindow))
- {
+ if (CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM) &gcwindow)) {
debugLog(_T("gc_getchat(): Cannot create new chat window %s."), chat->id);
free(name);
free(chat);
@@ -342,15 +329,15 @@ TCHAR* GGPROTO::gc_getchat(uin_t sender, uin_t *recipients, int recipients_count }
free(name);
- gcdest.ptszID = chat->id;
- gcevent.ptszUID = id;
- gcevent.dwFlags = GC_TCHAR | GCEF_ADDTOLOG;
- gcevent.time = 0;
+ gcd.ptszID = chat->id;
+ gce.ptszUID = id;
+ gce.dwFlags = GCEF_ADDTOLOG;
+ gce.time = 0;
// Add normal group
- gcevent.ptszStatus = TranslateT("Participants");
- CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gcevent);
- gcdest.iType = GC_EVENT_JOIN;
+ gce.ptszStatus = TranslateT("Participants");
+ CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
+ gcd.iType = GC_EVENT_JOIN;
// Add myself
if (uin = getDword(GG_KEY_UIN, 0))
@@ -364,12 +351,12 @@ TCHAR* GGPROTO::gc_getchat(uin_t sender, uin_t *recipients, int recipients_count } else {
nickT = mir_tstrdup(TranslateT("Me"));
}
- gcevent.ptszNick = nickT;
+ gce.ptszNick = nickT;
- gcevent.bIsMe = 1;
- CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gcevent);
+ gce.bIsMe = 1;
+ CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
mir_free(nickT);
- debugLog(_T("gc_getchat(): Myself %s: %s (%s) to the list..."), gcevent.ptszUID, gcevent.ptszNick, gcevent.ptszStatus);
+ debugLog(_T("gc_getchat(): Myself %s: %s (%s) to the list..."), gce.ptszUID, gce.ptszNick, gce.ptszStatus);
}
else debugLogA("gc_getchat(): Myself adding failed with uin %d !!!", uin);
@@ -385,17 +372,17 @@ TCHAR* GGPROTO::gc_getchat(uin_t sender, uin_t *recipients, int recipients_count HANDLE hContact = getcontact(chat->recipients[i], 1, 0, NULL);
UIN2IDT(chat->recipients[i], id);
if (hContact && (name = pcli->pfnGetContactDisplayName(hContact, 0)) != NULL)
- gcevent.ptszNick = name;
+ gce.ptszNick = name;
else
- gcevent.ptszNick = TranslateT("'Unknown'");
- gcevent.bIsMe = 0;
- gcevent.dwFlags = GC_TCHAR;
- debugLog(_T("gc_getchat(): Added %s: %s (%s) to the list..."), gcevent.ptszUID, gcevent.ptszNick, gcevent.pszStatus);
- CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gcevent);
+ gce.ptszNick = TranslateT("'Unknown'");
+ gce.bIsMe = 0;
+ gce.dwFlags = 0;
+ debugLog(_T("gc_getchat(): Added %s: %s (%s) to the list..."), gce.ptszUID, gce.ptszNick, gce.ptszStatus);
+ CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
}
- gcdest.iType = GC_EVENT_CONTROL;
- CallServiceSync(MS_GC_EVENT, SESSION_INITDONE, (LPARAM)&gcevent);
- CallServiceSync(MS_GC_EVENT, SESSION_ONLINE, (LPARAM)&gcevent);
+ gcd.iType = GC_EVENT_CONTROL;
+ CallServiceSync(MS_GC_EVENT, SESSION_INITDONE, (LPARAM)&gce);
+ CallServiceSync(MS_GC_EVENT, SESSION_ONLINE, (LPARAM)&gce);
debugLog(_T("gc_getchat(): Returning new chat window %s, count %d."), chat->id, chat->recipients_count);
list_add(&chats, chat, 0);
@@ -501,13 +488,9 @@ static INT_PTR CALLBACK gg_gc_openconfdlg(HWND hwndDlg, UINT message, WPARAM wPa chat = gg->gc_getchat(0, participants, count);
if (chat)
{
- GCDEST gcdest = {0};
- gcdest.pszModule = gg->m_szModuleName;
- gcdest.ptszID = chat;
- gcdest.iType = GC_EVENT_CONTROL;
- GCEVENT gcevent = {sizeof(GCEVENT), &gcdest};
- gcevent.dwFlags = GC_TCHAR;
- CallServiceSync(MS_GC_EVENT, WINDOW_VISIBLE, (LPARAM)&gcevent);
+ GCDEST gcd = { gg->m_szModuleName, chat, GC_EVENT_CONTROL };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ CallServiceSync(MS_GC_EVENT, WINDOW_VISIBLE, (LPARAM)&gce);
}
free(participants);
}
@@ -653,16 +636,12 @@ int GGPROTO::gc_changenick(HANDLE hContact, TCHAR *ptszNick) if (chat->recipients[i] == uin)
{
TCHAR id[32];
- GCEVENT gce = {sizeof(GCEVENT)};
- GCDEST gcd;
-
UIN2IDT(uin, id);
- gcd.iType = GC_EVENT_NICK;
- gcd.pszModule = m_szModuleName;
+
+ GCDEST gcd = { m_szModuleName, chat->id, GC_EVENT_NICK };
+ GCEVENT gce = { sizeof(gce), &gcd };
gce.pDest = &gcd;
- gcd.ptszID = chat->id;
gce.ptszUID = id;
- gce.dwFlags = GC_TCHAR;
gce.ptszText = ptszNick;
debugLog(_T("gc_changenick(): Found room %s with uin %d, sending nick change %s."), chat->id, uin, id);
diff --git a/protocols/IRCG/src/commandmonitor.cpp b/protocols/IRCG/src/commandmonitor.cpp index fa9a38b2a4..ae19f64af2 100644 --- a/protocols/IRCG/src/commandmonitor.cpp +++ b/protocols/IRCG/src/commandmonitor.cpp @@ -368,15 +368,9 @@ bool CIrcProto::OnIrc_QUIT(const CIrcMessage* pmsg) struct CONTACT user = { (LPTSTR)pmsg->prefix.sNick.c_str(), (LPTSTR)pmsg->prefix.sUser.c_str(), (LPTSTR)pmsg->prefix.sHost.c_str(), false, false, false};
CList_SetOffline( &user );
if ( pmsg->prefix.sNick == m_info.sNick ) {
- GCDEST gcd = {0};
- GCEVENT gce = {0};
-
- gce.cbSize = sizeof(GCEVENT);
- gcd.ptszID = NULL;
- gcd.pszModule = m_szModuleName;
- gcd.iType = GC_EVENT_CONTROL;
- gce.pDest = &gcd;
- CallChatEvent( SESSION_OFFLINE, (LPARAM)&gce);
+ GCDEST gcd = { m_szModuleName, NULL, GC_EVENT_CONTROL };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ CallChatEvent(SESSION_OFFLINE, (LPARAM)&gce);
}
}
else ShowMessage( pmsg );
@@ -390,17 +384,10 @@ bool CIrcProto::OnIrc_PART(const CIrcMessage* pmsg) CMString host = pmsg->prefix.sUser + _T("@") + pmsg->prefix.sHost;
DoEvent(GC_EVENT_PART, pmsg->parameters[0].c_str(), pmsg->prefix.sNick.c_str(), pmsg->parameters.getCount()>1?pmsg->parameters[1].c_str():NULL, NULL, host.c_str(), NULL, true, false);
if ( pmsg->prefix.sNick == m_info.sNick ) {
- GCDEST gcd = {0};
- GCEVENT gce = {0};
-
- CMString S = MakeWndID( pmsg->parameters[0].c_str());
- gce.cbSize = sizeof(GCEVENT);
- gcd.ptszID = ( TCHAR* )S.c_str();
- gce.dwFlags = GC_TCHAR;
- gcd.pszModule = m_szModuleName;
- gcd.iType = GC_EVENT_CONTROL;
- gce.pDest = &gcd;
- CallChatEvent( SESSION_OFFLINE, (LPARAM)&gce);
+ CMString S = MakeWndID(pmsg->parameters[0].c_str());
+ GCDEST gcd = { m_szModuleName, (TCHAR*)S.c_str(), GC_EVENT_CONTROL };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ CallChatEvent(SESSION_OFFLINE, (LPARAM)&gce);
}
}
else ShowMessage( pmsg );
@@ -416,17 +403,10 @@ bool CIrcProto::OnIrc_KICK(const CIrcMessage* pmsg) ShowMessage( pmsg );
if ( pmsg->parameters[1] == m_info.sNick ) {
- GCDEST gcd = {0};
- GCEVENT gce = {0};
-
CMString S = MakeWndID( pmsg->parameters[0].c_str());
- gce.cbSize = sizeof(GCEVENT);
- gce.dwFlags = GC_TCHAR;
- gcd.ptszID = ( TCHAR* )S.c_str();
- gcd.pszModule = m_szModuleName;
- gcd.iType = GC_EVENT_CONTROL;
- gce.pDest = &gcd;
- CallChatEvent( SESSION_OFFLINE, (LPARAM)&gce);
+ GCDEST gcd = { m_szModuleName, (TCHAR*)S.c_str(), GC_EVENT_CONTROL };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ CallChatEvent(SESSION_OFFLINE, (LPARAM)&gce);
if ( m_rejoinIfKicked ) {
CHANNELINFO *wi = (CHANNELINFO *)DoEvent(GC_EVENT_GETITEMDATA, pmsg->parameters[0].c_str(), NULL, NULL, NULL, NULL, NULL, FALSE, FALSE, 0);
@@ -1267,34 +1247,22 @@ bool CIrcProto::OnIrc_ENDNAMES(const CIrcMessage* pmsg) sChanName++;
// Add a new chat window
- GCSESSION gcw = {0};
- CMString sID = MakeWndID( sChanName );
+ CMString sID = MakeWndID(sChanName);
BYTE btOwnMode = 0;
- gcw.cbSize = sizeof(GCSESSION);
+
+ GCSESSION gcw = { sizeof(gcw) };
gcw.iType = GCW_CHATROOM;
- gcw.dwFlags = GC_TCHAR;
gcw.ptszID = sID.c_str();
gcw.pszModule = m_szModuleName;
gcw.ptszName = sChanName;
- if ( !CallServiceSync( MS_GC_NEWSESSION, 0, ( LPARAM )&gcw )) {
+ if (!CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM)&gcw)) {
DBVARIANT dbv;
- GCDEST gcd = {0};
- GCEVENT gce = {0};
- CMString sTemp;
- int i = 0;
+ GCDEST gcd = { m_szModuleName, (TCHAR*)sID.c_str(), GC_EVENT_ADDGROUP };
+ GCEVENT gce = { sizeof(gce), &gcd };
PostIrcMessage( _T("/MODE %s"), sChanName );
- gcd.ptszID = ( TCHAR* )sID.c_str();
- gcd.pszModule = m_szModuleName;
- gcd.iType = GC_EVENT_ADDGROUP;
- gce.time = 0;
- gce.dwFlags = GC_TCHAR;
-
//register the statuses
- gce.cbSize = sizeof(GCEVENT);
- gce.pDest = &gcd;
-
gce.ptszStatus = _T("Owner");
CallChatEvent(0, (LPARAM)&gce);
gce.ptszStatus = _T("Admin");
@@ -1308,11 +1276,11 @@ bool CIrcProto::OnIrc_ENDNAMES(const CIrcMessage* pmsg) gce.ptszStatus = _T("Normal");
CallChatEvent(0, (LPARAM)&gce);
- i = 0;
- sTemp = GetWord(sNamesList.c_str(), i);
+ int i = 0;
+ CMString sTemp = GetWord(sNamesList.c_str(), i);
// Fill the nicklist
- while ( !sTemp.IsEmpty()) {
+ while (!sTemp.IsEmpty()) {
CMString sStat;
CMString sTemp2 = sTemp;
sStat = PrefixToStatus(sTemp[0]);
@@ -1328,7 +1296,7 @@ bool CIrcProto::OnIrc_ENDNAMES(const CIrcMessage* pmsg) BOOL bIsMe = ( !lstrcmpi( gce.ptszNick, m_info.sNick.c_str())) ? TRUE : FALSE;
if ( bIsMe ) {
char BitNr = -1;
- switch ( sTemp2[0] ) {
+ switch (sTemp2[0]) {
case '+': BitNr = 0; break;
case '%': BitNr = 1; break;
case '@': BitNr = 2; break;
@@ -1340,20 +1308,20 @@ bool CIrcProto::OnIrc_ENDNAMES(const CIrcMessage* pmsg) else
btOwnMode = 0;
}
- gce.dwFlags = GC_TCHAR;
gce.bIsMe = bIsMe;
- gce.time = bIsMe?time(0):0;
+ gce.time = bIsMe ? time(0) : 0;
CallChatEvent(0, (LPARAM)&gce);
- DoEvent( GC_EVENT_SETCONTACTSTATUS, sChanName, sTemp.c_str(), NULL, NULL, NULL, ID_STATUS_ONLINE, FALSE, FALSE );
+ DoEvent(GC_EVENT_SETCONTACTSTATUS, sChanName, sTemp.c_str(), NULL, NULL, NULL, ID_STATUS_ONLINE, FALSE, FALSE);
// fix for networks like freshirc where they allow more than one prefix
- if ( PrefixToStatus( sTemp2[0]) != _T("Normal")) {
- sTemp2.Delete(0,1);
+ if (PrefixToStatus(sTemp2[0]) != _T("Normal")) {
+ sTemp2.Delete(0, 1);
sStat = PrefixToStatus(sTemp2[0]);
- while ( sStat != _T("Normal")) {
- DoEvent( GC_EVENT_ADDSTATUS, sID.c_str(), sTemp.c_str(), _T("system"), sStat.c_str(), NULL, NULL, false, false, 0 );
- sTemp2.Delete(0,1);
+ while (sStat != _T("Normal")) {
+ DoEvent(GC_EVENT_ADDSTATUS, sID.c_str(), sTemp.c_str(), _T("system"), sStat.c_str(), NULL, NULL, false, false, 0);
+ sTemp2.Delete(0, 1);
sStat = PrefixToStatus(sTemp2[0]);
- } }
+ }
+ }
i++;
sTemp = GetWord(sNamesList.c_str(), i);
@@ -1383,14 +1351,14 @@ bool CIrcProto::OnIrc_ENDNAMES(const CIrcMessage* pmsg) gcd.ptszID = (TCHAR*)sID.c_str();
gcd.iType = GC_EVENT_CONTROL;
gce.cbSize = sizeof(GCEVENT);
- gce.dwFlags = GC_TCHAR;
+ gce.dwFlags = 0;
gce.bIsMe = false;
gce.dwItemData = false;
- gce.pszNick = NULL;
- gce.pszStatus = NULL;
- gce.pszText = NULL;
- gce.pszUID = NULL;
- gce.pszUserInfo = NULL;
+ gce.ptszNick = NULL;
+ gce.ptszStatus = NULL;
+ gce.ptszText = NULL;
+ gce.ptszUID = NULL;
+ gce.ptszUserInfo = NULL;
gce.time = time(0);
gce.pDest = &gcd;
@@ -1426,7 +1394,7 @@ bool CIrcProto::OnIrc_ENDNAMES(const CIrcMessage* pmsg) }
else CallChatEvent( SESSION_INITDONE, (LPARAM)&gce);
- if ( save.IsEmpty())
+ if (save.IsEmpty())
db_unset(NULL, m_szModuleName, "JTemp");
else
setTString("JTemp", save.c_str());
@@ -1434,10 +1402,10 @@ bool CIrcProto::OnIrc_ENDNAMES(const CIrcMessage* pmsg) }
else CallChatEvent( SESSION_INITDONE, (LPARAM)&gce);
- { gcd.iType = GC_EVENT_CONTROL;
- gce.pDest = &gcd;
- CallChatEvent( SESSION_ONLINE, (LPARAM)&gce);
- } } } }
+ gcd.iType = GC_EVENT_CONTROL;
+ gce.pDest = &gcd;
+ CallChatEvent( SESSION_ONLINE, (LPARAM)&gce);
+ } } }
sNamesList = _T("");
ShowMessage( pmsg );
@@ -1446,263 +1414,264 @@ bool CIrcProto::OnIrc_ENDNAMES(const CIrcMessage* pmsg) bool CIrcProto::OnIrc_INITIALTOPIC(const CIrcMessage* pmsg)
{
- if ( pmsg->m_bIncoming && pmsg->parameters.getCount() > 2 ) {
- AddWindowItemData( pmsg->parameters[1].c_str(), 0, 0, 0, pmsg->parameters[2].c_str());
+ if (pmsg->m_bIncoming && pmsg->parameters.getCount() > 2) {
+ AddWindowItemData(pmsg->parameters[1].c_str(), 0, 0, 0, pmsg->parameters[2].c_str());
sTopic = pmsg->parameters[1] + _T(" ") + pmsg->parameters[2];
sTopicName = _T("");
sTopicTime = _T("");
}
- ShowMessage( pmsg );
+ ShowMessage(pmsg);
return true;
}
bool CIrcProto::OnIrc_INITIALTOPICNAME(const CIrcMessage* pmsg)
{
- if ( pmsg->m_bIncoming && pmsg->parameters.getCount() > 3 ) {
+ if (pmsg->m_bIncoming && pmsg->parameters.getCount() > 3) {
TCHAR tTimeBuf[128], *tStopStr;
time_t ttTopicTime;
sTopicName = pmsg->parameters[2];
- ttTopicTime = _tcstol( pmsg->parameters[3].c_str(), &tStopStr, 10);
+ ttTopicTime = _tcstol(pmsg->parameters[3].c_str(), &tStopStr, 10);
_tcsftime(tTimeBuf, 128, _T("%#c"), localtime(&ttTopicTime));
sTopicTime = tTimeBuf;
}
- ShowMessage( pmsg );
+ ShowMessage(pmsg);
return true;
}
bool CIrcProto::OnIrc_TOPIC(const CIrcMessage* pmsg)
{
- if ( pmsg->parameters.getCount() > 1 && pmsg->m_bIncoming ) {
- DoEvent( GC_EVENT_TOPIC, pmsg->parameters[0].c_str(), pmsg->prefix.sNick.c_str(), pmsg->parameters[1].c_str(), NULL, sTopicTime.IsEmpty() ? NULL : sTopicTime.c_str(), NULL, true, false);
+ if (pmsg->parameters.getCount() > 1 && pmsg->m_bIncoming) {
+ DoEvent(GC_EVENT_TOPIC, pmsg->parameters[0].c_str(), pmsg->prefix.sNick.c_str(), pmsg->parameters[1].c_str(), NULL, sTopicTime.IsEmpty() ? NULL : sTopicTime.c_str(), NULL, true, false);
AddWindowItemData(pmsg->parameters[0].c_str(), 0, 0, 0, pmsg->parameters[1].c_str());
}
- ShowMessage( pmsg );
+ ShowMessage(pmsg);
return true;
}
-static void __stdcall sttShowDlgList( void* param )
+static void __stdcall sttShowDlgList(void* param)
{
- CIrcProto *ppro = ( CIrcProto* )param;
- if ( ppro->m_listDlg == NULL ) {
- ppro->m_listDlg = new CListDlg( ppro );
+ CIrcProto *ppro = (CIrcProto*)param;
+ if (ppro->m_listDlg == NULL) {
+ ppro->m_listDlg = new CListDlg(ppro);
ppro->m_listDlg->Show();
}
- SetEvent( ppro->m_evWndCreate );
+ SetEvent(ppro->m_evWndCreate);
}
bool CIrcProto::OnIrc_LISTSTART(const CIrcMessage* pmsg)
{
- if ( pmsg->m_bIncoming ) {
- CallFunctionAsync( sttShowDlgList, this );
- WaitForSingleObject( m_evWndCreate, INFINITE );
+ if (pmsg->m_bIncoming) {
+ CallFunctionAsync(sttShowDlgList, this);
+ WaitForSingleObject(m_evWndCreate, INFINITE);
m_channelNumber = 0;
}
- ShowMessage( pmsg );
+ ShowMessage(pmsg);
return true;
}
bool CIrcProto::OnIrc_LIST(const CIrcMessage* pmsg)
{
- if ( pmsg->m_bIncoming == 1 && m_listDlg && pmsg->parameters.getCount() > 2 ) {
+ if (pmsg->m_bIncoming == 1 && m_listDlg && pmsg->parameters.getCount() > 2) {
m_channelNumber++;
LVITEM lvItem;
- HWND hListView = GetDlgItem( m_listDlg->GetHwnd(), IDC_INFO_LISTVIEW );
- lvItem.iItem = ListView_GetItemCount( hListView );
+ HWND hListView = GetDlgItem(m_listDlg->GetHwnd(), IDC_INFO_LISTVIEW);
+ lvItem.iItem = ListView_GetItemCount(hListView);
lvItem.mask = LVIF_TEXT | LVIF_PARAM;
lvItem.iSubItem = 0;
lvItem.pszText = (TCHAR*)pmsg->parameters[1].c_str();
lvItem.lParam = lvItem.iItem;
- lvItem.iItem = ListView_InsertItem( hListView, &lvItem );
+ lvItem.iItem = ListView_InsertItem(hListView, &lvItem);
lvItem.mask = LVIF_TEXT;
- lvItem.iSubItem =1;
- lvItem.pszText = (TCHAR*)pmsg->parameters[pmsg->parameters.getCount()-2].c_str();
- ListView_SetItem( hListView, &lvItem );
+ lvItem.iSubItem = 1;
+ lvItem.pszText = (TCHAR*)pmsg->parameters[pmsg->parameters.getCount() - 2].c_str();
+ ListView_SetItem(hListView, &lvItem);
- TCHAR* temp = mir_tstrdup( pmsg->parameters[pmsg->parameters.getCount()-1] );
- TCHAR* find = _tcsstr( temp , _T("[+"));
- TCHAR* find2 = _tcsstr( temp , _T("]"));
+ TCHAR* temp = mir_tstrdup(pmsg->parameters[pmsg->parameters.getCount() - 1]);
+ TCHAR* find = _tcsstr(temp, _T("[+"));
+ TCHAR* find2 = _tcsstr(temp, _T("]"));
TCHAR* save = temp;
- if ( find == temp && find2 != NULL && find+8 >= find2 ) {
- temp = _tcsstr( temp, _T("]"));
- if ( lstrlen(temp) > 1 ) {
+ if (find == temp && find2 != NULL && find + 8 >= find2) {
+ temp = _tcsstr(temp, _T("]"));
+ if (lstrlen(temp) > 1) {
temp++;
temp[0] = '\0';
- lvItem.iSubItem =2;
+ lvItem.iSubItem = 2;
lvItem.pszText = save;
- ListView_SetItem(hListView,&lvItem);
+ ListView_SetItem(hListView, &lvItem);
temp[0] = ' ';
temp++;
}
- else temp =save;
+ else temp = save;
}
-
- lvItem.iSubItem =3;
+
+ lvItem.iSubItem = 3;
CMString S = DoColorCodes(temp, TRUE, FALSE);
- lvItem.pszText = ( TCHAR* )S.c_str();
- ListView_SetItem( hListView, &lvItem );
+ lvItem.pszText = (TCHAR*)S.c_str();
+ ListView_SetItem(hListView, &lvItem);
temp = save;
- mir_free( temp );
-
+ mir_free(temp);
+
int percent = 100;
- if ( m_noOfChannels > 0 )
- percent = (int)(m_channelNumber*100) / m_noOfChannels;
+ if (m_noOfChannels > 0)
+ percent = (int)(m_channelNumber * 100) / m_noOfChannels;
TCHAR text[100];
- if ( percent < 100)
+ if (percent < 100)
mir_sntprintf(text, SIZEOF(text), TranslateT("Downloading list (%u%%) - %u channels"), percent, m_channelNumber);
else
mir_sntprintf(text, SIZEOF(text), TranslateT("Downloading list - %u channels"), m_channelNumber);
- m_listDlg->m_status.SetText( text );
+ m_listDlg->m_status.SetText(text);
}
-
+
return true;
}
bool CIrcProto::OnIrc_LISTEND(const CIrcMessage* pmsg)
{
- if ( pmsg->m_bIncoming && m_listDlg ) {
+ if (pmsg->m_bIncoming && m_listDlg) {
EnableWindow(GetDlgItem(m_listDlg->GetHwnd(), IDC_JOIN), true);
- ListView_SetSelectionMark(GetDlgItem(m_listDlg->GetHwnd(), IDC_INFO_LISTVIEW), 0);
+ ListView_SetSelectionMark(GetDlgItem(m_listDlg->GetHwnd(), IDC_INFO_LISTVIEW), 0);
ListView_SetColumnWidth(GetDlgItem(m_listDlg->GetHwnd(), IDC_INFO_LISTVIEW), 1, LVSCW_AUTOSIZE);
ListView_SetColumnWidth(GetDlgItem(m_listDlg->GetHwnd(), IDC_INFO_LISTVIEW), 2, LVSCW_AUTOSIZE);
ListView_SetColumnWidth(GetDlgItem(m_listDlg->GetHwnd(), IDC_INFO_LISTVIEW), 3, LVSCW_AUTOSIZE);
m_listDlg->UpdateList();
TCHAR text[100];
- mir_sntprintf( text, SIZEOF(text), TranslateT("Done: %u channels"), m_channelNumber );
+ mir_sntprintf(text, SIZEOF(text), TranslateT("Done: %u channels"), m_channelNumber);
int percent = 100;
- if ( m_noOfChannels > 0 )
- percent = (int)(m_channelNumber*100) / m_noOfChannels;
- if ( percent < 70 ) {
- lstrcat( text, _T(" "));
- lstrcat( text, TranslateT("(probably truncated by server)"));
+ if (m_noOfChannels > 0)
+ percent = (int)(m_channelNumber * 100) / m_noOfChannels;
+ if (percent < 70) {
+ lstrcat(text, _T(" "));
+ lstrcat(text, TranslateT("(probably truncated by server)"));
}
- SetDlgItemText( m_listDlg->GetHwnd(), IDC_TEXT, text );
+ SetDlgItemText(m_listDlg->GetHwnd(), IDC_TEXT, text);
}
- ShowMessage( pmsg );
+ ShowMessage(pmsg);
return true;
}
bool CIrcProto::OnIrc_BANLIST(const CIrcMessage* pmsg)
{
- if ( pmsg->m_bIncoming && pmsg->parameters.getCount() > 2 ) {
- if ( m_managerDlg->GetHwnd() && (
+ if (pmsg->m_bIncoming && pmsg->parameters.getCount() > 2) {
+ if (m_managerDlg->GetHwnd() && (
m_managerDlg->m_radio1.GetState() && pmsg->sCommand == _T("367") ||
m_managerDlg->m_radio2.GetState() && pmsg->sCommand == _T("346") ||
- m_managerDlg->m_radio3.GetState() && pmsg->sCommand == _T("348")) &&
- !m_managerDlg->m_radio1.Enabled() && !m_managerDlg->m_radio2.Enabled() && !m_managerDlg->m_radio3.Enabled())
- {
+ m_managerDlg->m_radio3.GetState() && pmsg->sCommand == _T("348")) &&
+ !m_managerDlg->m_radio1.Enabled() && !m_managerDlg->m_radio2.Enabled() && !m_managerDlg->m_radio3.Enabled()) {
CMString S = pmsg->parameters[2];
- if ( pmsg->parameters.getCount() > 3 ) {
+ if (pmsg->parameters.getCount() > 3) {
S += _T(" - ");
S += pmsg->parameters[3];
- if ( pmsg->parameters.getCount() > 4 ) {
+ if (pmsg->parameters.getCount() > 4) {
S += _T(" - ( ");
- time_t time = StrToInt( pmsg->parameters[4].c_str());
- S += _tctime( &time );
- ReplaceString( S, _T("\n"), _T(" "));
+ time_t time = StrToInt(pmsg->parameters[4].c_str());
+ S += _tctime(&time);
+ ReplaceString(S, _T("\n"), _T(" "));
S += _T(")");
- } }
+ }
+ }
SendDlgItemMessage(m_managerDlg->GetHwnd(), IDC_LIST, LB_ADDSTRING, 0, (LPARAM)S.c_str());
- } }
+ }
+ }
- ShowMessage( pmsg );
+ ShowMessage(pmsg);
return true;
}
bool CIrcProto::OnIrc_BANLISTEND(const CIrcMessage* pmsg)
{
- if ( pmsg->m_bIncoming && pmsg->parameters.getCount() > 1 ) {
- if ( m_managerDlg->GetHwnd() &&
- ( m_managerDlg->m_radio1.GetState() && pmsg->sCommand == _T("368")
+ if (pmsg->m_bIncoming && pmsg->parameters.getCount() > 1) {
+ if (m_managerDlg->GetHwnd() &&
+ (m_managerDlg->m_radio1.GetState() && pmsg->sCommand == _T("368")
|| m_managerDlg->m_radio2.GetState() && pmsg->sCommand == _T("347")
- || m_managerDlg->m_radio3.GetState() && pmsg->sCommand == _T("349")) &&
- !m_managerDlg->m_radio1.Enabled() && !m_managerDlg->m_radio2.Enabled() && !m_managerDlg->m_radio3.Enabled())
- {
- if ( strchr( sChannelModes.c_str(), 'b' ))
+ || m_managerDlg->m_radio3.GetState() && pmsg->sCommand == _T("349")) &&
+ !m_managerDlg->m_radio1.Enabled() && !m_managerDlg->m_radio2.Enabled() && !m_managerDlg->m_radio3.Enabled()) {
+ if (strchr(sChannelModes.c_str(), 'b'))
m_managerDlg->m_radio1.Enable();
- if ( strchr( sChannelModes.c_str(), 'I' ))
+ if (strchr(sChannelModes.c_str(), 'I'))
m_managerDlg->m_radio2.Enable();
- if ( strchr( sChannelModes.c_str(), 'e' ))
+ if (strchr(sChannelModes.c_str(), 'e'))
m_managerDlg->m_radio3.Enable();
- if ( !IsDlgButtonChecked(m_managerDlg->GetHwnd(), IDC_NOTOP))
+ if (!IsDlgButtonChecked(m_managerDlg->GetHwnd(), IDC_NOTOP))
m_managerDlg->m_add.Enable();
- } }
-
- ShowMessage( pmsg );
+ }
+ }
+
+ ShowMessage(pmsg);
return true;
}
-static void __stdcall sttShowWhoisWnd( void* param )
+static void __stdcall sttShowWhoisWnd(void* param)
{
- CIrcMessage* pmsg = ( CIrcMessage* )param;
- CIrcProto *ppro = ( CIrcProto* )pmsg->m_proto;
- if ( ppro->m_whoisDlg == NULL ) {
- ppro->m_whoisDlg = new CWhoisDlg( ppro );
+ CIrcMessage* pmsg = (CIrcMessage*)param;
+ CIrcProto *ppro = (CIrcProto*)pmsg->m_proto;
+ if (ppro->m_whoisDlg == NULL) {
+ ppro->m_whoisDlg = new CWhoisDlg(ppro);
ppro->m_whoisDlg->Show();
}
- SetEvent( ppro->m_evWndCreate );
+ SetEvent(ppro->m_evWndCreate);
- ppro->m_whoisDlg->ShowMessage( pmsg );
+ ppro->m_whoisDlg->ShowMessage(pmsg);
delete pmsg;
}
bool CIrcProto::OnIrc_WHOIS_NAME(const CIrcMessage* pmsg)
{
- if ( pmsg->m_bIncoming && pmsg->parameters.getCount() > 5 && m_manualWhoisCount > 0 ) {
- CallFunctionAsync( sttShowWhoisWnd, new CIrcMessage( *pmsg ));
- WaitForSingleObject( m_evWndCreate, INFINITE );
+ if (pmsg->m_bIncoming && pmsg->parameters.getCount() > 5 && m_manualWhoisCount > 0) {
+ CallFunctionAsync(sttShowWhoisWnd, new CIrcMessage(*pmsg));
+ WaitForSingleObject(m_evWndCreate, INFINITE);
}
- ShowMessage( pmsg );
+ ShowMessage(pmsg);
return true;
}
bool CIrcProto::OnIrc_WHOIS_CHANNELS(const CIrcMessage* pmsg)
{
- if ( pmsg->m_bIncoming && m_whoisDlg && pmsg->parameters.getCount() > 2 && m_manualWhoisCount > 0 )
- m_whoisDlg->m_InfoChannels.SetText( pmsg->parameters[2].c_str());
- ShowMessage( pmsg );
+ if (pmsg->m_bIncoming && m_whoisDlg && pmsg->parameters.getCount() > 2 && m_manualWhoisCount > 0)
+ m_whoisDlg->m_InfoChannels.SetText(pmsg->parameters[2].c_str());
+ ShowMessage(pmsg);
return true;
}
bool CIrcProto::OnIrc_WHOIS_AWAY(const CIrcMessage* pmsg)
{
- if ( pmsg->m_bIncoming && m_whoisDlg && pmsg->parameters.getCount() > 2 && m_manualWhoisCount > 0 )
- m_whoisDlg->m_InfoAway2.SetText( pmsg->parameters[2].c_str());
- if ( m_manualWhoisCount < 1 && pmsg->m_bIncoming && pmsg->parameters.getCount() > 2 )
+ if (pmsg->m_bIncoming && m_whoisDlg && pmsg->parameters.getCount() > 2 && m_manualWhoisCount > 0)
+ m_whoisDlg->m_InfoAway2.SetText(pmsg->parameters[2].c_str());
+ if (m_manualWhoisCount < 1 && pmsg->m_bIncoming && pmsg->parameters.getCount() > 2)
WhoisAwayReply = pmsg->parameters[2];
- ShowMessage( pmsg );
+ ShowMessage(pmsg);
return true;
}
bool CIrcProto::OnIrc_WHOIS_OTHER(const CIrcMessage* pmsg)
{
- if ( pmsg->m_bIncoming && m_whoisDlg && pmsg->parameters.getCount() > 2 && m_manualWhoisCount > 0 ) {
+ if (pmsg->m_bIncoming && m_whoisDlg && pmsg->parameters.getCount() > 2 && m_manualWhoisCount > 0) {
TCHAR temp[1024], temp2[1024];
- m_whoisDlg->m_InfoOther.GetText( temp, 1000 );
- lstrcat( temp, _T("%s\r\n"));
- mir_sntprintf( temp2, 1020, temp, pmsg->parameters[2].c_str());
- m_whoisDlg->m_InfoOther.SetText( temp2 );
+ m_whoisDlg->m_InfoOther.GetText(temp, 1000);
+ lstrcat(temp, _T("%s\r\n"));
+ mir_sntprintf(temp2, 1020, temp, pmsg->parameters[2].c_str());
+ m_whoisDlg->m_InfoOther.SetText(temp2);
}
- ShowMessage( pmsg );
+ ShowMessage(pmsg);
return true;
}
bool CIrcProto::OnIrc_WHOIS_END(const CIrcMessage* pmsg)
{
- if ( pmsg->m_bIncoming && pmsg->parameters.getCount() > 1 && m_manualWhoisCount < 1 ) {
- CONTACT user = { (TCHAR*)pmsg->parameters[1].c_str(), NULL, NULL, false, false, true};
- HANDLE hContact = CList_FindContact( &user );
- if ( hContact )
- ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE) 1, (LPARAM)WhoisAwayReply.c_str());
+ if (pmsg->m_bIncoming && pmsg->parameters.getCount() > 1 && m_manualWhoisCount < 1) {
+ CONTACT user = { (TCHAR*)pmsg->parameters[1].c_str(), NULL, NULL, false, false, true };
+ HANDLE hContact = CList_FindContact(&user);
+ if (hContact)
+ ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)WhoisAwayReply.c_str());
}
m_manualWhoisCount--;
if (m_manualWhoisCount < 0)
m_manualWhoisCount = 0;
- ShowMessage( pmsg );
+ ShowMessage(pmsg);
return true;
}
@@ -1712,17 +1681,17 @@ bool CIrcProto::OnIrc_WHOIS_IDLE(const CIrcMessage* pmsg) int H = 0;
int M = 0;
int S = 0;
- if ( pmsg->m_bIncoming && m_whoisDlg && pmsg->parameters.getCount() > 2 && m_manualWhoisCount > 0 ) {
+ if (pmsg->m_bIncoming && m_whoisDlg && pmsg->parameters.getCount() > 2 && m_manualWhoisCount > 0) {
S = StrToInt(pmsg->parameters[2].c_str());
- D = S/(60*60*24);
- S -= (D * 60 * 60 *24);
- H = S/(60*60);
+ D = S / (60 * 60 * 24);
+ S -= (D * 60 * 60 * 24);
+ H = S / (60 * 60);
S -= (H * 60 * 60);
- M = S/60;
- S -= (M * 60 );
-
+ M = S / 60;
+ S -= (M * 60);
+
TCHAR temp[100];
- if ( D )
+ if (D)
mir_sntprintf(temp, 99, _T("%ud, %uh, %um, %us"), D, H, M, S);
else if (H)
mir_sntprintf(temp, 99, _T("%uh, %um, %us"), H, M, S);
@@ -1735,260 +1704,263 @@ bool CIrcProto::OnIrc_WHOIS_IDLE(const CIrcMessage* pmsg) TCHAR temp3[256];
TCHAR tTimeBuf[128], *tStopStr;
- time_t ttTime = _tcstol( pmsg->parameters[3].c_str(), &tStopStr, 10);
+ time_t ttTime = _tcstol(pmsg->parameters[3].c_str(), &tStopStr, 10);
_tcsftime(tTimeBuf, 128, _T("%c"), localtime(&ttTime));
- mir_sntprintf( temp3, SIZEOF(temp3), _T("online since %s, idle %s"), tTimeBuf, temp);
- m_whoisDlg->m_AwayTime.SetText( temp3 );
+ mir_sntprintf(temp3, SIZEOF(temp3), _T("online since %s, idle %s"), tTimeBuf, temp);
+ m_whoisDlg->m_AwayTime.SetText(temp3);
}
- ShowMessage( pmsg );
+ ShowMessage(pmsg);
return true;
}
bool CIrcProto::OnIrc_WHOIS_SERVER(const CIrcMessage* pmsg)
{
- if ( pmsg->m_bIncoming && m_whoisDlg && pmsg->parameters.getCount() > 2 && m_manualWhoisCount > 0 )
- m_whoisDlg->m_InfoServer.SetText( pmsg->parameters[2].c_str());
- ShowMessage( pmsg );
+ if (pmsg->m_bIncoming && m_whoisDlg && pmsg->parameters.getCount() > 2 && m_manualWhoisCount > 0)
+ m_whoisDlg->m_InfoServer.SetText(pmsg->parameters[2].c_str());
+ ShowMessage(pmsg);
return true;
}
bool CIrcProto::OnIrc_WHOIS_AUTH(const CIrcMessage* pmsg)
{
- if ( pmsg->m_bIncoming && m_whoisDlg && pmsg->parameters.getCount() > 2 && m_manualWhoisCount > 0 ) {
- if ( pmsg->sCommand == _T("330"))
- m_whoisDlg->m_InfoAuth.SetText( pmsg->parameters[2].c_str());
- else if ( pmsg->parameters[2] == _T("is an identified user") || pmsg->parameters[2] == _T("is a registered nick"))
- m_whoisDlg->m_InfoAuth.SetText( pmsg->parameters[2].c_str());
+ if (pmsg->m_bIncoming && m_whoisDlg && pmsg->parameters.getCount() > 2 && m_manualWhoisCount > 0) {
+ if (pmsg->sCommand == _T("330"))
+ m_whoisDlg->m_InfoAuth.SetText(pmsg->parameters[2].c_str());
+ else if (pmsg->parameters[2] == _T("is an identified user") || pmsg->parameters[2] == _T("is a registered nick"))
+ m_whoisDlg->m_InfoAuth.SetText(pmsg->parameters[2].c_str());
else
- OnIrc_WHOIS_OTHER( pmsg );
+ OnIrc_WHOIS_OTHER(pmsg);
}
- ShowMessage( pmsg );
+ ShowMessage(pmsg);
return true;
}
bool CIrcProto::OnIrc_WHOIS_NO_USER(const CIrcMessage* pmsg)
{
- if ( pmsg->m_bIncoming && pmsg->parameters.getCount() > 2 && !IsChannel( pmsg->parameters[1] )) {
- if ( m_whoisDlg )
- m_whoisDlg->ShowMessageNoUser( pmsg );
-
- CONTACT user = { (TCHAR*)pmsg->parameters[1].c_str(), NULL, NULL, false, false, false};
- HANDLE hContact = CList_FindContact( &user );
- if ( hContact ) {
- AddOutgoingMessageToDB( hContact, (TCHAR*)((CMString)_T("> ") + pmsg->parameters[2] + (CMString)_T(": ") + pmsg->parameters[1]).c_str());
+ if (pmsg->m_bIncoming && pmsg->parameters.getCount() > 2 && !IsChannel(pmsg->parameters[1])) {
+ if (m_whoisDlg)
+ m_whoisDlg->ShowMessageNoUser(pmsg);
+
+ CONTACT user = { (TCHAR*)pmsg->parameters[1].c_str(), NULL, NULL, false, false, false };
+ HANDLE hContact = CList_FindContact(&user);
+ if (hContact) {
+ AddOutgoingMessageToDB(hContact, (TCHAR*)((CMString)_T("> ") + pmsg->parameters[2] + (CMString)_T(": ") + pmsg->parameters[1]).c_str());
DBVARIANT dbv;
- if ( !getTString( hContact, "Default", &dbv )) {
- setTString( hContact, "Nick", dbv.ptszVal );
-
+ if (!getTString(hContact, "Default", &dbv)) {
+ setTString(hContact, "Nick", dbv.ptszVal);
+
DBVARIANT dbv2;
- if ( getByte( hContact, "AdvancedMode", 0 ) == 0 )
- DoUserhostWithReason(1, ((CMString)_T("S") + dbv.ptszVal).c_str(), true, dbv.ptszVal );
+ if (getByte(hContact, "AdvancedMode", 0) == 0)
+ DoUserhostWithReason(1, ((CMString)_T("S") + dbv.ptszVal).c_str(), true, dbv.ptszVal);
else {
- if ( !getTString( hContact, "UWildcard", &dbv2 )) {
- DoUserhostWithReason(2, ((CMString)_T("S") + dbv2.ptszVal).c_str(), true, dbv2.ptszVal );
+ if (!getTString(hContact, "UWildcard", &dbv2)) {
+ DoUserhostWithReason(2, ((CMString)_T("S") + dbv2.ptszVal).c_str(), true, dbv2.ptszVal);
db_free(&dbv2);
}
- else DoUserhostWithReason(2, ((CMString)_T("S") + dbv.ptszVal).c_str(), true, dbv.ptszVal );
+ else DoUserhostWithReason(2, ((CMString)_T("S") + dbv.ptszVal).c_str(), true, dbv.ptszVal);
}
setString(hContact, "User", "");
setString(hContact, "Host", "");
db_free(&dbv);
- } } }
+ }
+ }
+ }
- ShowMessage( pmsg );
+ ShowMessage(pmsg);
return true;
}
-static void __stdcall sttShowNickWnd( void* param )
+static void __stdcall sttShowNickWnd(void* param)
{
- CIrcMessage* pmsg = ( CIrcMessage* )param;
+ CIrcMessage* pmsg = (CIrcMessage*)param;
CIrcProto *ppro = pmsg->m_proto;
- if ( ppro->m_nickDlg == NULL ) {
- ppro->m_nickDlg = new CNickDlg( ppro );
+ if (ppro->m_nickDlg == NULL) {
+ ppro->m_nickDlg = new CNickDlg(ppro);
ppro->m_nickDlg->Show();
}
- SetEvent( ppro->m_evWndCreate );
- SetWindowText( GetDlgItem( ppro->m_nickDlg->GetHwnd(), IDC_CAPTION ), TranslateT("Change nickname"));
- SetWindowText( GetDlgItem( ppro->m_nickDlg->GetHwnd(), IDC_TEXT ), pmsg->parameters.getCount() > 2 ? pmsg->parameters[2].c_str() : _T(""));
- ppro->m_nickDlg->m_Enick.SetText( pmsg->parameters[1].c_str());
- ppro->m_nickDlg->m_Enick.SendMsg( CB_SETEDITSEL, 0, MAKELPARAM(0,-1));
+ SetEvent(ppro->m_evWndCreate);
+ SetWindowText(GetDlgItem(ppro->m_nickDlg->GetHwnd(), IDC_CAPTION), TranslateT("Change nickname"));
+ SetWindowText(GetDlgItem(ppro->m_nickDlg->GetHwnd(), IDC_TEXT), pmsg->parameters.getCount() > 2 ? pmsg->parameters[2].c_str() : _T(""));
+ ppro->m_nickDlg->m_Enick.SetText(pmsg->parameters[1].c_str());
+ ppro->m_nickDlg->m_Enick.SendMsg(CB_SETEDITSEL, 0, MAKELPARAM(0, -1));
delete pmsg;
}
bool CIrcProto::OnIrc_NICK_ERR(const CIrcMessage* pmsg)
{
- if ( pmsg->m_bIncoming ) {
- if ( nickflag && ((m_alternativeNick[0] != 0)) && (pmsg->parameters.getCount() > 2 && _tcscmp(pmsg->parameters[1].c_str(), m_alternativeNick))) {
+ if (pmsg->m_bIncoming) {
+ if (nickflag && ((m_alternativeNick[0] != 0)) && (pmsg->parameters.getCount() > 2 && _tcscmp(pmsg->parameters[1].c_str(), m_alternativeNick))) {
TCHAR m[200];
- mir_sntprintf( m, SIZEOF(m), _T("NICK %s"), m_alternativeNick );
- if ( IsConnected())
- SendIrcMessage( m );
+ mir_sntprintf(m, SIZEOF(m), _T("NICK %s"), m_alternativeNick);
+ if (IsConnected())
+ SendIrcMessage(m);
}
else {
- CallFunctionAsync( sttShowNickWnd, new CIrcMessage( *pmsg ));
- WaitForSingleObject( m_evWndCreate, INFINITE );
- } }
+ CallFunctionAsync(sttShowNickWnd, new CIrcMessage(*pmsg));
+ WaitForSingleObject(m_evWndCreate, INFINITE);
+ }
+ }
- ShowMessage( pmsg );
- return true;
+ ShowMessage(pmsg);
+ return true;
}
bool CIrcProto::OnIrc_JOINERROR(const CIrcMessage* pmsg)
{
- if ( pmsg->m_bIncoming ) {
+ if (pmsg->m_bIncoming) {
DBVARIANT dbv;
- if ( !getTString( "JTemp", &dbv )) {
+ if (!getTString("JTemp", &dbv)) {
CMString command = _T("a");
CMString save = _T("");
int i = 0;
- while ( !command.IsEmpty()) {
- command = GetWord( dbv.ptszVal, i );
+ while (!command.IsEmpty()) {
+ command = GetWord(dbv.ptszVal, i);
i++;
- if ( !command.IsEmpty() && pmsg->parameters[0] == command.Mid(1, command.GetLength()))
+ if (!command.IsEmpty() && pmsg->parameters[0] == command.Mid(1, command.GetLength()))
save += command + _T(" ");
}
-
+
db_free(&dbv);
- if ( save.IsEmpty())
- db_unset( NULL, m_szModuleName, "JTemp" );
+ if (save.IsEmpty())
+ db_unset(NULL, m_szModuleName, "JTemp");
else
- setTString( "JTemp", save.c_str());
- } }
+ setTString("JTemp", save.c_str());
+ }
+ }
- ShowMessage( pmsg );
+ ShowMessage(pmsg);
return true;
}
bool CIrcProto::OnIrc_UNKNOWN(const CIrcMessage* pmsg)
{
- if ( pmsg->m_bIncoming && pmsg->parameters.getCount() > 0 ) {
- if ( pmsg->parameters[0] == _T("WHO") && GetNextUserhostReason(2) != _T("U"))
+ if (pmsg->m_bIncoming && pmsg->parameters.getCount() > 0) {
+ if (pmsg->parameters[0] == _T("WHO") && GetNextUserhostReason(2) != _T("U"))
return true;
- if ( pmsg->parameters[0] == _T("USERHOST") && GetNextUserhostReason(1) != _T("U"))
+ if (pmsg->parameters[0] == _T("USERHOST") && GetNextUserhostReason(1) != _T("U"))
return true;
}
- ShowMessage( pmsg );
+ ShowMessage(pmsg);
return true;
}
bool CIrcProto::OnIrc_ENDMOTD(const CIrcMessage* pmsg)
{
- if ( pmsg->m_bIncoming && !bPerformDone )
- DoOnConnect( pmsg );
- ShowMessage( pmsg );
+ if (pmsg->m_bIncoming && !bPerformDone)
+ DoOnConnect(pmsg);
+ ShowMessage(pmsg);
return true;
}
bool CIrcProto::OnIrc_NOOFCHANNELS(const CIrcMessage* pmsg)
{
- if ( pmsg->m_bIncoming && pmsg->parameters.getCount() > 1 )
- m_noOfChannels = StrToInt( pmsg->parameters[1].c_str());
+ if (pmsg->m_bIncoming && pmsg->parameters.getCount() > 1)
+ m_noOfChannels = StrToInt(pmsg->parameters[1].c_str());
- if ( pmsg->m_bIncoming && !bPerformDone )
- DoOnConnect( pmsg );
+ if (pmsg->m_bIncoming && !bPerformDone)
+ DoOnConnect(pmsg);
- ShowMessage( pmsg );
+ ShowMessage(pmsg);
return true;
}
bool CIrcProto::OnIrc_ERROR(const CIrcMessage* pmsg)
{
- if ( pmsg->m_bIncoming && !m_disableErrorPopups && m_iDesiredStatus != ID_STATUS_OFFLINE) {
+ if (pmsg->m_bIncoming && !m_disableErrorPopups && m_iDesiredStatus != ID_STATUS_OFFLINE) {
MIRANDASYSTRAYNOTIFY msn;
msn.cbSize = sizeof(MIRANDASYSTRAYNOTIFY);
msn.szProto = m_szModuleName;
msn.tszInfoTitle = TranslateT("IRC error");
-
+
CMString S;
- if ( pmsg->parameters.getCount() > 0 )
- S = DoColorCodes( pmsg->parameters[0].c_str(), TRUE, FALSE );
+ if (pmsg->parameters.getCount() > 0)
+ S = DoColorCodes(pmsg->parameters[0].c_str(), TRUE, FALSE);
else
- S = TranslateT( "Unknown" );
+ S = TranslateT("Unknown");
- msn.tszInfo = ( TCHAR* )S.c_str();
+ msn.tszInfo = (TCHAR*)S.c_str();
msn.dwInfoFlags = NIIF_ERROR | NIIF_INTERN_UNICODE;
msn.uTimeout = 15000;
CallService(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM)&msn);
}
- ShowMessage( pmsg );
- return true;
+ ShowMessage(pmsg);
+ return true;
}
bool CIrcProto::OnIrc_WHO_END(const CIrcMessage* pmsg)
{
CMString command = GetNextUserhostReason(2);
- if ( command[0] == 'S' ) {
- if ( pmsg->m_bIncoming && pmsg->parameters.getCount() > 1 ) {
+ if (command[0] == 'S') {
+ if (pmsg->m_bIncoming && pmsg->parameters.getCount() > 1) {
// is it a channel?
- if ( IsChannel( pmsg->parameters[1] )) {
+ if (IsChannel(pmsg->parameters[1])) {
CMString S;
- CMString User = GetWord( m_whoReply.c_str(), 0 );
- while ( !User.IsEmpty()) {
- if ( GetWord( m_whoReply.c_str(), 3)[0] == 'G' ) {
+ CMString User = GetWord(m_whoReply.c_str(), 0);
+ while (!User.IsEmpty()) {
+ if (GetWord(m_whoReply.c_str(), 3)[0] == 'G') {
S += User;
S += _T("\t");
- DoEvent( GC_EVENT_SETCONTACTSTATUS, pmsg->parameters[1].c_str(), User.c_str(), NULL, NULL, NULL, ID_STATUS_AWAY, FALSE, FALSE);
+ DoEvent(GC_EVENT_SETCONTACTSTATUS, pmsg->parameters[1].c_str(), User.c_str(), NULL, NULL, NULL, ID_STATUS_AWAY, FALSE, FALSE);
}
- else DoEvent( GC_EVENT_SETCONTACTSTATUS, pmsg->parameters[1].c_str(), User.c_str(), NULL, NULL, NULL, ID_STATUS_ONLINE, FALSE, FALSE);
+ else DoEvent(GC_EVENT_SETCONTACTSTATUS, pmsg->parameters[1].c_str(), User.c_str(), NULL, NULL, NULL, ID_STATUS_ONLINE, FALSE, FALSE);
- CMString SS = GetWordAddress( m_whoReply.c_str(), 4 );
- if ( SS.IsEmpty())
+ CMString SS = GetWordAddress(m_whoReply.c_str(), 4);
+ if (SS.IsEmpty())
break;
m_whoReply = SS;
User = GetWord(m_whoReply.c_str(), 0);
}
-
- DoEvent( GC_EVENT_SETSTATUSEX, pmsg->parameters[1].c_str(), NULL, S.IsEmpty() ? NULL : S.c_str(), NULL, NULL, GC_SSE_TABDELIMITED, FALSE, FALSE);
+
+ DoEvent(GC_EVENT_SETSTATUSEX, pmsg->parameters[1].c_str(), NULL, S.IsEmpty() ? NULL : S.c_str(), NULL, NULL, GC_SSE_TABDELIMITED, FALSE, FALSE);
return true;
}
/// if it is not a channel
- TCHAR* UserList = mir_tstrdup( m_whoReply.c_str());
- const TCHAR* p1= UserList;
+ TCHAR* UserList = mir_tstrdup(m_whoReply.c_str());
+ const TCHAR* p1 = UserList;
m_whoReply = _T("");
- CONTACT user = { (TCHAR*)pmsg->parameters[1].c_str(), NULL, NULL, false, true, false};
- HANDLE hContact = CList_FindContact( &user );
+ CONTACT user = { (TCHAR*)pmsg->parameters[1].c_str(), NULL, NULL, false, true, false };
+ HANDLE hContact = CList_FindContact(&user);
- if ( hContact && getByte( hContact, "AdvancedMode", 0 ) == 1 ) {
- DBVARIANT dbv1, dbv2, dbv3, dbv4, dbv5, dbv6, dbv7;
+ if (hContact && getByte(hContact, "AdvancedMode", 0) == 1) {
+ DBVARIANT dbv1, dbv2, dbv3, dbv4, dbv5, dbv6, dbv7;
TCHAR *DBDefault = NULL, *DBNick = NULL, *DBWildcard = NULL;
TCHAR *DBUser = NULL, *DBHost = NULL, *DBManUser = NULL, *DBManHost = NULL;
- if ( !getTString(hContact, "Default", &dbv1)) DBDefault = dbv1.ptszVal;
- if ( !getTString(hContact, "Nick", &dbv2)) DBNick = dbv2.ptszVal;
- if ( !getTString(hContact, "UWildcard", &dbv3)) DBWildcard = dbv3.ptszVal;
- if ( !getTString(hContact, "UUser", &dbv4)) DBUser = dbv4.ptszVal;
- if ( !getTString(hContact, "UHost", &dbv5)) DBHost = dbv5.ptszVal;
- if ( !getTString(hContact, "User", &dbv6)) DBManUser = dbv6.ptszVal;
- if ( !getTString(hContact, "Host", &dbv7)) DBManHost = dbv7.ptszVal;
- if ( DBWildcard )
- CharLower( DBWildcard );
+ if (!getTString(hContact, "Default", &dbv1)) DBDefault = dbv1.ptszVal;
+ if (!getTString(hContact, "Nick", &dbv2)) DBNick = dbv2.ptszVal;
+ if (!getTString(hContact, "UWildcard", &dbv3)) DBWildcard = dbv3.ptszVal;
+ if (!getTString(hContact, "UUser", &dbv4)) DBUser = dbv4.ptszVal;
+ if (!getTString(hContact, "UHost", &dbv5)) DBHost = dbv5.ptszVal;
+ if (!getTString(hContact, "User", &dbv6)) DBManUser = dbv6.ptszVal;
+ if (!getTString(hContact, "Host", &dbv7)) DBManHost = dbv7.ptszVal;
+ if (DBWildcard)
+ CharLower(DBWildcard);
CMString nick;
CMString user;
CMString host;
CMString away = GetWord(p1, 3);
- while ( !away.IsEmpty()) {
+ while (!away.IsEmpty()) {
nick = GetWord(p1, 0);
user = GetWord(p1, 1);
host = GetWord(p1, 2);
- if (( DBWildcard && WCCmp( DBWildcard, nick.c_str()) || DBNick && !lstrcmpi(DBNick, nick.c_str()) || DBDefault && !lstrcmpi(DBDefault, nick.c_str()))
- && (WCCmp(DBUser, user.c_str()) && WCCmp(DBHost, host.c_str())))
- {
- if (away[0] == 'G' && getWord( hContact, "Status", ID_STATUS_OFFLINE) != ID_STATUS_AWAY)
+ if ((DBWildcard && WCCmp(DBWildcard, nick.c_str()) || DBNick && !lstrcmpi(DBNick, nick.c_str()) || DBDefault && !lstrcmpi(DBDefault, nick.c_str()))
+ && (WCCmp(DBUser, user.c_str()) && WCCmp(DBHost, host.c_str()))) {
+ if (away[0] == 'G' && getWord(hContact, "Status", ID_STATUS_OFFLINE) != ID_STATUS_AWAY)
setWord(hContact, "Status", ID_STATUS_AWAY);
- else if (away[0] == 'H' && getWord( hContact, "Status", ID_STATUS_OFFLINE) != ID_STATUS_ONLINE)
+ else if (away[0] == 'H' && getWord(hContact, "Status", ID_STATUS_OFFLINE) != ID_STATUS_ONLINE)
setWord(hContact, "Status", ID_STATUS_ONLINE);
- if (( DBNick && lstrcmpi( nick.c_str(), DBNick)) || !DBNick )
- setTString( hContact, "Nick", nick.c_str());
- if (( DBManUser && lstrcmpi( user.c_str(), DBManUser)) || !DBManUser )
- setTString( hContact, "User", user.c_str());
- if (( DBManHost && lstrcmpi(host.c_str(), DBManHost)) || !DBManHost )
+ if ((DBNick && lstrcmpi(nick.c_str(), DBNick)) || !DBNick)
+ setTString(hContact, "Nick", nick.c_str());
+ if ((DBManUser && lstrcmpi(user.c_str(), DBManUser)) || !DBManUser)
+ setTString(hContact, "User", user.c_str());
+ if ((DBManHost && lstrcmpi(host.c_str(), DBManHost)) || !DBManHost)
setTString(hContact, "Host", host.c_str());
goto LBL_Exit;
@@ -1996,77 +1968,78 @@ bool CIrcProto::OnIrc_WHO_END(const CIrcMessage* pmsg) p1 = GetWordAddress(p1, 4);
away = GetWord(p1, 3);
}
-
- if ( DBWildcard && DBNick && !WCCmp( CharLower( DBWildcard ), CharLower( DBNick ))) {
+
+ if (DBWildcard && DBNick && !WCCmp(CharLower(DBWildcard), CharLower(DBNick))) {
setTString(hContact, "Nick", DBDefault);
-
+
DoUserhostWithReason(2, ((CMString)_T("S") + DBWildcard).c_str(), true, DBWildcard);
-
+
setString(hContact, "User", "");
setString(hContact, "Host", "");
goto LBL_Exit;
}
- if ( getWord( hContact, "Status", ID_STATUS_OFFLINE ) != ID_STATUS_OFFLINE ) {
+ if (getWord(hContact, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) {
setWord(hContact, "Status", ID_STATUS_OFFLINE);
setTString(hContact, "Nick", DBDefault);
setString(hContact, "User", "");
setString(hContact, "Host", "");
}
LBL_Exit:
- if ( DBDefault ) db_free(&dbv1);
- if ( DBNick ) db_free(&dbv2);
- if ( DBWildcard ) db_free(&dbv3);
- if ( DBUser ) db_free(&dbv4);
- if ( DBHost ) db_free(&dbv5);
- if ( DBManUser ) db_free(&dbv6);
- if ( DBManHost ) db_free(&dbv7);
+ if (DBDefault) db_free(&dbv1);
+ if (DBNick) db_free(&dbv2);
+ if (DBWildcard) db_free(&dbv3);
+ if (DBUser) db_free(&dbv4);
+ if (DBHost) db_free(&dbv5);
+ if (DBManUser) db_free(&dbv6);
+ if (DBManHost) db_free(&dbv7);
}
- mir_free( UserList );
+ mir_free(UserList);
}
}
- else ShowMessage( pmsg );
+ else ShowMessage(pmsg);
return true;
}
bool CIrcProto::OnIrc_WHO_REPLY(const CIrcMessage* pmsg)
{
CMString command = PeekAtReasons(2);
- if ( pmsg->m_bIncoming && pmsg->parameters.getCount() > 6 && command[0] == 'S' ) {
- m_whoReply.AppendFormat( _T("%s %s %s %s "), pmsg->parameters[5].c_str(), pmsg->parameters[2].c_str(), pmsg->parameters[3].c_str(), pmsg->parameters[6].c_str());
- if ( lstrcmpi( pmsg->parameters[5].c_str(), m_info.sNick.c_str()) == 0 ) {
+ if (pmsg->m_bIncoming && pmsg->parameters.getCount() > 6 && command[0] == 'S') {
+ m_whoReply.AppendFormat(_T("%s %s %s %s "), pmsg->parameters[5].c_str(), pmsg->parameters[2].c_str(), pmsg->parameters[3].c_str(), pmsg->parameters[6].c_str());
+ if (lstrcmpi(pmsg->parameters[5].c_str(), m_info.sNick.c_str()) == 0) {
TCHAR host[1024];
- lstrcpyn( host, pmsg->parameters[3].c_str(), 1024 );
- ForkThread( &CIrcProto::ResolveIPThread, new IPRESOLVE( _T2A(host), IP_AUTO ));
- } }
+ lstrcpyn(host, pmsg->parameters[3].c_str(), 1024);
+ ForkThread(&CIrcProto::ResolveIPThread, new IPRESOLVE(_T2A(host), IP_AUTO));
+ }
+ }
- if ( command[0] == 'U' )
- ShowMessage( pmsg );
+ if (command[0] == 'U')
+ ShowMessage(pmsg);
return true;
}
bool CIrcProto::OnIrc_TRYAGAIN(const CIrcMessage* pmsg)
{
CMString command = _T("");
- if ( pmsg->m_bIncoming && pmsg->parameters.getCount() > 1 ) {
- if ( pmsg->parameters[1] == _T("WHO"))
+ if (pmsg->m_bIncoming && pmsg->parameters.getCount() > 1) {
+ if (pmsg->parameters[1] == _T("WHO"))
command = GetNextUserhostReason(2);
- if ( pmsg->parameters[1] == _T("USERHOST"))
+ if (pmsg->parameters[1] == _T("USERHOST"))
command = GetNextUserhostReason(1);
}
if (command[0] == 'U')
- ShowMessage( pmsg );
+ ShowMessage(pmsg);
return true;
}
bool CIrcProto::OnIrc_USERHOST_REPLY(const CIrcMessage* pmsg)
{
CMString command = _T("");
- if ( pmsg->m_bIncoming ) {
+ if (pmsg->m_bIncoming) {
command = GetNextUserhostReason(1);
- if ( !command.IsEmpty() && command != _T("U") && pmsg->parameters.getCount() > 1 ) {
- CONTACT finduser = {NULL, NULL, NULL, false, false, false};
+ if (!command.IsEmpty() && command != _T("U") && pmsg->parameters.getCount() > 1) {
+ CONTACT finduser = { NULL, NULL, NULL, false, false, false };
TCHAR* p1 = NULL;
TCHAR* p2 = NULL;
int awaystatus = 0;
@@ -2081,35 +2054,36 @@ bool CIrcProto::OnIrc_USERHOST_REPLY(const CIrcMessage* pmsg) int j;
// Status-check pre-processing: Setup check-list
- OBJLIST<CMString> checklist( 10 );
- if ( command[0] == 'S' ) {
+ OBJLIST<CMString> checklist(10);
+ if (command[0] == 'S') {
j = 0;
sTemp = GetWord(command.c_str(), 0);
- sTemp.Delete(0,1);
- while ( !sTemp.IsEmpty()) {
- checklist.insert( new CMString( sTemp ));
+ sTemp.Delete(0, 1);
+ while (!sTemp.IsEmpty()) {
+ checklist.insert(new CMString(sTemp));
j++;
sTemp = GetWord(command.c_str(), j);
- } }
+ }
+ }
// Cycle through results
j = 0;
- sTemp = GetWord( pmsg->parameters[1].c_str(), j );
- while ( !sTemp.IsEmpty()) {
- p1 = mir_tstrdup( sTemp.c_str());
+ sTemp = GetWord(pmsg->parameters[1].c_str(), j);
+ while (!sTemp.IsEmpty()) {
+ p1 = mir_tstrdup(sTemp.c_str());
p2 = p1;
// Pull out host, user and nick
p2 = _tcschr(p1, '@');
- if ( p2 ) {
+ if (p2) {
*p2 = '\0';
p2++;
host = p2;
}
p2 = _tcschr(p1, '=');
- if ( p2 ) {
- if (*(p2-1) == '*')
- *(p2-1) = '\0'; // remove special char for IRCOps
+ if (p2) {
+ if (*(p2 - 1) == '*')
+ *(p2 - 1) = '\0'; // remove special char for IRCOps
*p2 = '\0';
p2++;
awaystatus = *p2;
@@ -2119,38 +2093,38 @@ bool CIrcProto::OnIrc_USERHOST_REPLY(const CIrcMessage* pmsg) }
mess = _T("");
mask = nick + _T("!") + user + _T("@") + host;
- if ( host.IsEmpty() || user.IsEmpty() || nick.IsEmpty()) {
- mir_free( p1 );
+ if (host.IsEmpty() || user.IsEmpty() || nick.IsEmpty()) {
+ mir_free(p1);
continue;
}
// Do command
- switch ( command[0] ) {
+ switch (command[0]) {
case 'S': // Status check
{
- finduser.name = (TCHAR*)nick.c_str();
- finduser.host = (TCHAR*)host.c_str();
- finduser.user = (TCHAR*)user.c_str();
-
- HANDLE hContact = CList_FindContact(&finduser);
- if ( hContact && getByte( hContact, "AdvancedMode", 0 ) == 0 ) {
- setWord(hContact, "Status", awaystatus == '-'? ID_STATUS_AWAY : ID_STATUS_ONLINE);
- setTString(hContact, "User", user.c_str());
- setTString(hContact, "Host", host.c_str());
- setTString(hContact, "Nick", nick.c_str());
-
- // If user found, remove from checklist
- for ( i = 0; i < checklist.getCount(); i++ )
- if ( !lstrcmpi(checklist[i].c_str(), nick.c_str()))
- checklist.remove( i );
- }
- break;
+ finduser.name = (TCHAR*)nick.c_str();
+ finduser.host = (TCHAR*)host.c_str();
+ finduser.user = (TCHAR*)user.c_str();
+
+ HANDLE hContact = CList_FindContact(&finduser);
+ if (hContact && getByte(hContact, "AdvancedMode", 0) == 0) {
+ setWord(hContact, "Status", awaystatus == '-' ? ID_STATUS_AWAY : ID_STATUS_ONLINE);
+ setTString(hContact, "User", user.c_str());
+ setTString(hContact, "Host", host.c_str());
+ setTString(hContact, "Nick", nick.c_str());
+
+ // If user found, remove from checklist
+ for (i = 0; i < checklist.getCount(); i++)
+ if (!lstrcmpi(checklist[i].c_str(), nick.c_str()))
+ checklist.remove(i);
+ }
+ break;
}
case 'I': // m_ignore
mess = _T("/IGNORE %question=\"");
mess += TranslateT("Please enter the hostmask (nick!user@host)\nNOTE! Contacts on your contact list are never ignored");
mess += (CMString)_T("\",\"") + TranslateT("Ignore") + _T("\",\"*!*@") + host + _T("\"");
- if ( m_ignoreChannelDefault )
+ if (m_ignoreChannelDefault)
mess += _T(" +qnidcm");
else
mess += _T(" +qnidc");
@@ -2167,39 +2141,41 @@ bool CIrcProto::OnIrc_USERHOST_REPLY(const CIrcMessage* pmsg) case 'K': // Ban & Kick
channel = (command.c_str() + 1);
- mess.Format( _T("/MODE %s +b *!*@%s%%newl/KICK %s %s"), channel.c_str(), host.c_str(), channel.c_str(), nick.c_str());
+ mess.Format(_T("/MODE %s +b *!*@%s%%newl/KICK %s %s"), channel.c_str(), host.c_str(), channel.c_str(), nick.c_str());
break;
case 'L': // Ban & Kick with reason
channel = (command.c_str() + 1);
- mess.Format( _T("/MODE %s +b *!*@%s%%newl/KICK %s %s %%question=\"%s\",\"%s\",\"%s\""),
+ mess.Format(_T("/MODE %s +b *!*@%s%%newl/KICK %s %s %%question=\"%s\",\"%s\",\"%s\""),
channel.c_str(), host.c_str(), channel.c_str(), nick.c_str(),
TranslateT("Please enter the reason"), TranslateT("Ban'n Kick"), TranslateT("Jerk"));
break;
}
-
- mir_free( p1 );
+
+ mir_free(p1);
// Post message
- if ( !mess.IsEmpty())
- PostIrcMessageWnd( NULL, NULL, mess.c_str());
+ if (!mess.IsEmpty())
+ PostIrcMessageWnd(NULL, NULL, mess.c_str());
j++;
sTemp = GetWord(pmsg->parameters[1].c_str(), j);
}
-
+
// Status-check post-processing: make buddies in ckeck-list offline
- if ( command[0] == 'S' ) {
- for ( i = 0; i < checklist.getCount(); i++ ) {
+ if (command[0] == 'S') {
+ for (i = 0; i < checklist.getCount(); i++) {
finduser.name = (TCHAR*)checklist[i].c_str();
finduser.ExactNick = true;
- CList_SetOffline( &finduser );
- } }
+ CList_SetOffline(&finduser);
+ }
+ }
return true;
- } }
-
- if ( !pmsg->m_bIncoming || command == _T("U"))
- ShowMessage( pmsg );
+ }
+ }
+
+ if (!pmsg->m_bIncoming || command == _T("U"))
+ ShowMessage(pmsg);
return true;
}
@@ -2208,80 +2184,83 @@ bool CIrcProto::OnIrc_SUPPORT(const CIrcMessage* pmsg) static const TCHAR* lpszFmt = _T("Try server %99[^ ,], port %19s");
TCHAR szAltServer[100];
TCHAR szAltPort[20];
- if ( pmsg->parameters.getCount() > 1 && _stscanf(pmsg->parameters[1].c_str(), lpszFmt, &szAltServer, &szAltPort) == 2 ) {
- ShowMessage( pmsg );
- lstrcpynA( m_serverName, _T2A(szAltServer), 99 );
- lstrcpynA( m_portStart, _T2A(szAltPort), 9 );
+ if (pmsg->parameters.getCount() > 1 && _stscanf(pmsg->parameters[1].c_str(), lpszFmt, &szAltServer, &szAltPort) == 2) {
+ ShowMessage(pmsg);
+ lstrcpynA(m_serverName, _T2A(szAltServer), 99);
+ lstrcpynA(m_portStart, _T2A(szAltPort), 9);
m_noOfChannels = 0;
ConnectToServer();
return true;
}
- if ( pmsg->m_bIncoming && !bPerformDone )
+ if (pmsg->m_bIncoming && !bPerformDone)
DoOnConnect(pmsg);
-
- if ( pmsg->m_bIncoming && pmsg->parameters.getCount() > 0 ) {
+
+ if (pmsg->m_bIncoming && pmsg->parameters.getCount() > 0) {
CMString S;
- for ( int i = 0; i < pmsg->parameters.getCount(); i++ ) {
- TCHAR* temp = mir_tstrdup( pmsg->parameters[i].c_str());
- if ( _tcsstr( temp, _T("CHANTYPES="))) {
- TCHAR* p1 = _tcschr( temp, '=' );
+ for (int i = 0; i < pmsg->parameters.getCount(); i++) {
+ TCHAR* temp = mir_tstrdup(pmsg->parameters[i].c_str());
+ if (_tcsstr(temp, _T("CHANTYPES="))) {
+ TCHAR* p1 = _tcschr(temp, '=');
p1++;
- if ( lstrlen( p1 ) > 0 )
+ if (lstrlen(p1) > 0)
sChannelPrefixes = p1;
}
- if ( _tcsstr(temp, _T("CHANMODES="))) {
- TCHAR* p1 = _tcschr( temp, '=' );
+ if (_tcsstr(temp, _T("CHANMODES="))) {
+ TCHAR* p1 = _tcschr(temp, '=');
p1++;
- if ( lstrlen( p1 ) > 0)
- sChannelModes = ( char* )_T2A( p1 );
+ if (lstrlen(p1) > 0)
+ sChannelModes = (char*)_T2A(p1);
}
- if ( _tcsstr( temp, _T("PREFIX="))) {
- TCHAR* p1 = _tcschr( temp, '(' );
- TCHAR* p2 = _tcschr( temp, ')' );
- if ( p1 && p2 ) {
+ if (_tcsstr(temp, _T("PREFIX="))) {
+ TCHAR* p1 = _tcschr(temp, '(');
+ TCHAR* p2 = _tcschr(temp, ')');
+ if (p1 && p2) {
p1++;
- if ( p1 != p2 )
- sUserModes = ( char* )_T2A( p1 );
- sUserModes = sUserModes.Mid(0, p2-p1);
+ if (p1 != p2)
+ sUserModes = (char*)_T2A(p1);
+ sUserModes = sUserModes.Mid(0, p2 - p1);
p2++;
- if ( *p2 != '\0' )
+ if (*p2 != '\0')
sUserModePrefixes = p2;
}
else {
- p1 = _tcschr( temp, '=' );
+ p1 = _tcschr(temp, '=');
p1++;
sUserModePrefixes = p1;
- for ( int i =0; i < sUserModePrefixes.GetLength()+1; i++ ) {
- if ( sUserModePrefixes[i] == '@' )
- sUserModes.SetAt( i, 'o' );
- else if ( sUserModePrefixes[i] == '+' )
- sUserModes.SetAt( i, 'v' );
- else if ( sUserModePrefixes[i] == '-' )
- sUserModes.SetAt( i, 'u' );
- else if ( sUserModePrefixes[i] == '%' )
- sUserModes.SetAt( i, 'h' );
- else if ( sUserModePrefixes[i] == '!' )
- sUserModes.SetAt( i, 'a' );
- else if ( sUserModePrefixes[i] == '*' )
- sUserModes.SetAt( i, 'q' );
- else if ( sUserModePrefixes[i] == '\0' )
- sUserModes.SetAt( i, '\0' );
- else
- sUserModes.SetAt( i, '_' );
- } } }
+ for (int i = 0; i < sUserModePrefixes.GetLength() + 1; i++) {
+ if (sUserModePrefixes[i] == '@')
+ sUserModes.SetAt(i, 'o');
+ else if (sUserModePrefixes[i] == '+')
+ sUserModes.SetAt(i, 'v');
+ else if (sUserModePrefixes[i] == '-')
+ sUserModes.SetAt(i, 'u');
+ else if (sUserModePrefixes[i] == '%')
+ sUserModes.SetAt(i, 'h');
+ else if (sUserModePrefixes[i] == '!')
+ sUserModes.SetAt(i, 'a');
+ else if (sUserModePrefixes[i] == '*')
+ sUserModes.SetAt(i, 'q');
+ else if (sUserModePrefixes[i] == '\0')
+ sUserModes.SetAt(i, '\0');
+ else
+ sUserModes.SetAt(i, '_');
+ }
+ }
+ }
- mir_free( temp );
- } }
+ mir_free(temp);
+ }
+ }
- ShowMessage( pmsg );
+ ShowMessage(pmsg);
return true;
}
void CIrcProto::OnIrcDefault(const CIrcMessage* pmsg)
{
- ShowMessage( pmsg );
+ ShowMessage(pmsg);
}
void CIrcProto::OnIrcDisconnected()
@@ -2296,36 +2275,29 @@ void CIrcProto::OnIrcDisconnected() int Temp = m_iStatus;
KillIdent();
- KillChatTimer( OnlineNotifTimer );
- KillChatTimer( OnlineNotifTimer3 );
- KillChatTimer( KeepAliveTimer );
- KillChatTimer( InitTimer );
- KillChatTimer( IdentTimer );
+ KillChatTimer(OnlineNotifTimer);
+ KillChatTimer(OnlineNotifTimer3);
+ KillChatTimer(KeepAliveTimer);
+ KillChatTimer(InitTimer);
+ KillChatTimer(IdentTimer);
m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE;
ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)Temp, ID_STATUS_OFFLINE);
CMString sDisconn = _T("\0035\002");
sDisconn += TranslateT("*Disconnected*");
- DoEvent(GC_EVENT_INFORMATION, SERVERWINDOW, NULL, sDisconn.c_str(), NULL, NULL, NULL, true, false);
+ DoEvent(GC_EVENT_INFORMATION, SERVERWINDOW, NULL, sDisconn.c_str(), NULL, NULL, NULL, true, false);
- {
- GCDEST gcd = {0};
- GCEVENT gce = {0};
-
- gce.cbSize = sizeof(GCEVENT);
- gcd.pszModule = m_szModuleName;
- gcd.iType = GC_EVENT_CONTROL;
- gce.pDest = &gcd;
- CallChatEvent( SESSION_OFFLINE, (LPARAM)&gce);
- }
+ GCDEST gcd = { m_szModuleName, 0, GC_EVENT_CONTROL };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ CallChatEvent(SESSION_OFFLINE, (LPARAM)&gce);
+
+ if (!Miranda_Terminated())
+ CList_SetAllOffline(m_disconnectDCCChats);
- if ( !Miranda_Terminated())
- CList_SetAllOffline( m_disconnectDCCChats );
-
// restore the original nick, cause it might be changed
- memcpy( m_nick, m_pNick, sizeof( m_nick ));
- setTString( "Nick", m_pNick );
-
+ memcpy(m_nick, m_pNick, sizeof(m_nick));
+ setTString("Nick", m_pNick);
+
CLISTMENUITEM mi = { sizeof(mi) };
mi.flags = CMIM_FLAGS | CMIF_GRAYED;
Menu_ModifyItem(hMenuJoin, &mi);
@@ -2336,25 +2308,26 @@ void CIrcProto::OnIrcDisconnected() /////////////////////////////////////////////////////////////////////////////////////////
// OnConnect
-static void __stdcall sttMainThrdOnConnect( void* param )
+static void __stdcall sttMainThrdOnConnect(void* param)
{
- CIrcProto *ppro = ( CIrcProto* )param;
+ CIrcProto *ppro = (CIrcProto*)param;
- ppro->SetChatTimer( ppro->InitTimer, 1*1000, TimerProc );
- if ( ppro->m_identTimer )
- ppro->SetChatTimer( ppro->IdentTimer, 60*1000, IdentTimerProc );
- if ( ppro->m_sendKeepAlive )
- ppro->SetChatTimer( ppro->KeepAliveTimer, 60*1000, KeepAliveTimerProc );
- if ( ppro->m_autoOnlineNotification && !ppro->bTempDisableCheck || ppro->bTempForceCheck ) {
- ppro->SetChatTimer( ppro->OnlineNotifTimer, 1000, OnlineNotifTimerProc );
- if ( ppro->m_channelAwayNotification )
- ppro->SetChatTimer( ppro->OnlineNotifTimer3, 3000, OnlineNotifTimerProc3);
-} }
+ ppro->SetChatTimer(ppro->InitTimer, 1 * 1000, TimerProc);
+ if (ppro->m_identTimer)
+ ppro->SetChatTimer(ppro->IdentTimer, 60 * 1000, IdentTimerProc);
+ if (ppro->m_sendKeepAlive)
+ ppro->SetChatTimer(ppro->KeepAliveTimer, 60 * 1000, KeepAliveTimerProc);
+ if (ppro->m_autoOnlineNotification && !ppro->bTempDisableCheck || ppro->bTempForceCheck) {
+ ppro->SetChatTimer(ppro->OnlineNotifTimer, 1000, OnlineNotifTimerProc);
+ if (ppro->m_channelAwayNotification)
+ ppro->SetChatTimer(ppro->OnlineNotifTimer3, 3000, OnlineNotifTimerProc3);
+ }
+}
-bool CIrcProto::DoOnConnect( const CIrcMessage* )
+bool CIrcProto::DoOnConnect(const CIrcMessage*)
{
bPerformDone = true;
- nickflag = true;
+ nickflag = true;
CLISTMENUITEM mi = { sizeof(mi) };
mi.flags = CMIM_FLAGS;
@@ -2364,50 +2337,47 @@ bool CIrcProto::DoOnConnect( const CIrcMessage* ) int Temp = m_iStatus;
m_iStatus = ID_STATUS_ONLINE;
- ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, ( HANDLE )Temp, m_iStatus );
-
- if ( m_iDesiredStatus == ID_STATUS_AWAY )
- PostIrcMessage( _T("/AWAY %s"), m_statusMessage.Mid(0,450).c_str());
-
- if ( m_perform ) {
- DoPerform( "ALL NETWORKS" );
- if ( IsConnected()) {
- DoPerform( _T2A( m_info.sNetwork.c_str()));
- switch( m_iStatus ) {
- case ID_STATUS_FREECHAT: DoPerform( "Event: Free for chat" ); break;
- case ID_STATUS_ONLINE: DoPerform( "Event: Available" ); break;
- } } }
+ ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)Temp, m_iStatus);
+
+ if (m_iDesiredStatus == ID_STATUS_AWAY)
+ PostIrcMessage(_T("/AWAY %s"), m_statusMessage.Mid(0, 450).c_str());
+
+ if (m_perform) {
+ DoPerform("ALL NETWORKS");
+ if (IsConnected()) {
+ DoPerform(_T2A(m_info.sNetwork.c_str()));
+ switch (m_iStatus) {
+ case ID_STATUS_FREECHAT: DoPerform("Event: Free for chat"); break;
+ case ID_STATUS_ONLINE: DoPerform("Event: Available"); break;
+ }
+ }
+ }
- if ( m_rejoinChannels ) {
- int count = CallServiceSync( MS_GC_GETSESSIONCOUNT, 0, (LPARAM)m_szModuleName);
- for ( int i = 0; i < count ; i++ ) {
- GC_INFO gci = {0};
+ if (m_rejoinChannels) {
+ int count = CallServiceSync(MS_GC_GETSESSIONCOUNT, 0, (LPARAM)m_szModuleName);
+ for (int i = 0; i < count; i++) {
+ GC_INFO gci = { 0 };
gci.Flags = BYINDEX | DATA | NAME | TYPE;
gci.iItem = i;
gci.pszModule = m_szModuleName;
- if ( !CallServiceSync( MS_GC_GETINFO, 0, (LPARAM)&gci) && gci.iType == GCW_CHATROOM ) {
- CHANNELINFO *wi = ( CHANNELINFO* )gci.dwItemData;
- if ( wi && wi->pszPassword )
- PostIrcMessage( _T("/JOIN %s %s"), gci.pszName, wi->pszPassword);
+ if (!CallServiceSync(MS_GC_GETINFO, 0, (LPARAM)&gci) && gci.iType == GCW_CHATROOM) {
+ CHANNELINFO *wi = (CHANNELINFO*)gci.dwItemData;
+ if (wi && wi->pszPassword)
+ PostIrcMessage(_T("/JOIN %s %s"), gci.pszName, wi->pszPassword);
else
- PostIrcMessage( _T("/JOIN %s"), gci.pszName);
- } } }
+ PostIrcMessage(_T("/JOIN %s"), gci.pszName);
+ }
+ }
+ }
- DoEvent( GC_EVENT_ADDGROUP, SERVERWINDOW, NULL, NULL, _T("Normal"), NULL, NULL, FALSE, TRUE);
+ DoEvent(GC_EVENT_ADDGROUP, SERVERWINDOW, NULL, NULL, _T("Normal"), NULL, NULL, FALSE, TRUE);
{
- GCDEST gcd = {0};
- GCEVENT gce = {0};
-
- gce.dwFlags = GC_TCHAR;
- gce.cbSize = sizeof(GCEVENT);
- gcd.ptszID = SERVERWINDOW;
- gcd.pszModule = m_szModuleName;
- gcd.iType = GC_EVENT_CONTROL;
- gce.pDest = &gcd;
- CallChatEvent( SESSION_ONLINE, (LPARAM)&gce);
+ GCDEST gcd = { m_szModuleName, SERVERWINDOW, GC_EVENT_CONTROL };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ CallChatEvent(SESSION_ONLINE, (LPARAM)&gce);
}
- CallFunctionAsync( sttMainThrdOnConnect, this );
+ CallFunctionAsync(sttMainThrdOnConnect, this);
nickflag = false;
return 0;
}
@@ -2417,77 +2387,77 @@ static void __cdecl AwayWarningThread(LPVOID) MessageBox(NULL, TranslateT("The usage of /AWAY in your perform buffer is restricted\n as IRC sends this command automatically."), TranslateT("IRC Error"), MB_OK);
}
-int CIrcProto::DoPerform( const char* event )
+int CIrcProto::DoPerform(const char* event)
{
String sSetting = String("PERFORM:") + event;
sSetting.MakeUpper();
DBVARIANT dbv;
- if ( !getTString( sSetting.c_str(), &dbv )) {
- if ( !my_strstri( dbv.ptszVal, _T("/away")))
- PostIrcMessageWnd( NULL, NULL, dbv.ptszVal );
+ if (!getTString(sSetting.c_str(), &dbv)) {
+ if (!my_strstri(dbv.ptszVal, _T("/away")))
+ PostIrcMessageWnd(NULL, NULL, dbv.ptszVal);
else
- mir_forkthread( AwayWarningThread, NULL );
- db_free( &dbv );
+ mir_forkthread(AwayWarningThread, NULL);
+ db_free(&dbv);
return 1;
}
return 0;
}
-int CIrcProto::IsIgnored( const CMString& nick, const CMString& address, const CMString& host, char type)
-{
- return IsIgnored( nick + _T("!") + address + _T("@") + host, type );
+int CIrcProto::IsIgnored(const CMString& nick, const CMString& address, const CMString& host, char type)
+{
+ return IsIgnored(nick + _T("!") + address + _T("@") + host, type);
}
-int CIrcProto::IsIgnored( CMString user, char type )
+int CIrcProto::IsIgnored(CMString user, char type)
{
- for ( int i=0; i < m_ignoreItems.getCount(); i++ ) {
+ for (int i = 0; i < m_ignoreItems.getCount(); i++) {
const CIrcIgnoreItem& C = m_ignoreItems[i];
- if ( type == '\0' )
- if ( !lstrcmpi( user.c_str(), C.mask.c_str()))
- return i+1;
-
- bool bUserContainsWild = ( _tcschr( user.c_str(), '*') != NULL || _tcschr( user.c_str(), '?' ) != NULL );
- if ( !bUserContainsWild && WCCmp( C.mask.c_str(), user.c_str()) ||
- bUserContainsWild && !lstrcmpi( user.c_str(), C.mask.c_str()))
- {
- if ( C.flags.IsEmpty() || C.flags[0] != '+' )
+ if (type == '\0')
+ if (!lstrcmpi(user.c_str(), C.mask.c_str()))
+ return i + 1;
+
+ bool bUserContainsWild = (_tcschr(user.c_str(), '*') != NULL || _tcschr(user.c_str(), '?') != NULL);
+ if (!bUserContainsWild && WCCmp(C.mask.c_str(), user.c_str()) ||
+ bUserContainsWild && !lstrcmpi(user.c_str(), C.mask.c_str())) {
+ if (C.flags.IsEmpty() || C.flags[0] != '+')
continue;
- if ( !_tcschr( C.flags.c_str(), type ))
+ if (!_tcschr(C.flags.c_str(), type))
continue;
- if ( C.network.IsEmpty())
- return i+1;
+ if (C.network.IsEmpty())
+ return i + 1;
- if ( IsConnected() && !lstrcmpi( C.network.c_str(), m_info.sNetwork.c_str()))
- return i+1;
- } }
+ if (IsConnected() && !lstrcmpi(C.network.c_str(), m_info.sNetwork.c_str()))
+ return i + 1;
+ }
+ }
- return 0;
+ return 0;
}
-bool CIrcProto::AddIgnore( const TCHAR* mask, const TCHAR* flags, const TCHAR* network )
-{
- RemoveIgnore( mask );
- m_ignoreItems.insert( new CIrcIgnoreItem( mask, (_T("+") + CMString(flags)).c_str(), network ));
+bool CIrcProto::AddIgnore(const TCHAR* mask, const TCHAR* flags, const TCHAR* network)
+{
+ RemoveIgnore(mask);
+ m_ignoreItems.insert(new CIrcIgnoreItem(mask, (_T("+") + CMString(flags)).c_str(), network));
RewriteIgnoreSettings();
- if ( m_ignoreDlg )
+ if (m_ignoreDlg)
m_ignoreDlg->RebuildList();
return true;
-}
+}
-bool CIrcProto::RemoveIgnore( const TCHAR* mask )
-{
+bool CIrcProto::RemoveIgnore(const TCHAR* mask)
+{
int idx;
- while (( idx = IsIgnored( mask, '\0')) != 0 )
- m_ignoreItems.remove( idx-1 );
+ while ((idx = IsIgnored(mask, '\0')) != 0)
+ m_ignoreItems.remove(idx - 1);
RewriteIgnoreSettings();
- if ( m_ignoreDlg )
+ if (m_ignoreDlg)
m_ignoreDlg->RebuildList();
- return true;
-}
+ return true;
+}
diff --git a/protocols/IRCG/src/input.cpp b/protocols/IRCG/src/input.cpp index eb8125a351..674f8e857c 100644 --- a/protocols/IRCG/src/input.cpp +++ b/protocols/IRCG/src/input.cpp @@ -224,14 +224,8 @@ BOOL CIrcProto::DoHardcodedCommand( CMString text, TCHAR* window, HANDLE hContac if ( command == _T("/servershow") || command == _T("/serverhide")) {
if ( m_useServer ) {
- GCEVENT gce = {0};
- GCDEST gcd = {0};
- gce.dwFlags = GC_TCHAR;
- gcd.iType = GC_EVENT_CONTROL;
- gcd.ptszID = SERVERWINDOW;
- gcd.pszModule = m_szModuleName;
- gce.cbSize = sizeof(GCEVENT);
- gce.pDest = &gcd;
+ GCDEST gcd = { m_szModuleName, SERVERWINDOW, GC_EVENT_CONTROL };
+ GCEVENT gce = { sizeof(gce), &gcd };
CallChatEvent( command == _T("/servershow") ? WINDOW_VISIBLE : WINDOW_HIDDEN, (LPARAM)&gce);
}
return true;
@@ -261,15 +255,9 @@ BOOL CIrcProto::DoHardcodedCommand( CMString text, TCHAR* window, HANDLE hContac else
S = MakeWndID( window );
- GCEVENT gce = {0};
- GCDEST gcd = {0};
- gce.cbSize = sizeof(GCEVENT);
- gcd.iType = GC_EVENT_CONTROL;
- gcd.pszModule = m_szModuleName;
- gce.pDest = &gcd;
- gce.dwFlags = GC_TCHAR;
- gcd.ptszID = (TCHAR*)S.c_str();
- CallChatEvent( WINDOW_CLEARLOG, (LPARAM)&gce);
+ GCDEST gcd = { m_szModuleName, (TCHAR*)S.c_str(), GC_EVENT_CONTROL };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ CallChatEvent(WINDOW_CLEARLOG, (LPARAM)&gce);
return true;
}
@@ -488,15 +476,9 @@ BOOL CIrcProto::DoHardcodedCommand( CMString text, TCHAR* window, HANDLE hContac return true;
}
- GCEVENT gce = {0};
- GCDEST gcd = {0};
- gcd.iType = GC_EVENT_CONTROL;
CMString S = MakeWndID(window);
- gcd.ptszID = (TCHAR*)S.c_str();
- gcd.pszModule = m_szModuleName;
- gce.cbSize = sizeof(GCEVENT);
- gce.dwFlags = GC_TCHAR;
- gce.pDest = &gcd;
+ GCDEST gcd = { m_szModuleName, (TCHAR*)S.c_str(), GC_EVENT_CONTROL };
+ GCEVENT gce = { sizeof(gce), &gcd };
CallChatEvent( SESSION_TERMINATE, (LPARAM)&gce);
PostIrcMessage( _T("/JOIN %s"), GetWordAddress(text.c_str(), 1));
diff --git a/protocols/IRCG/src/irc.h b/protocols/IRCG/src/irc.h index f6028219ee..367b92a905 100644 --- a/protocols/IRCG/src/irc.h +++ b/protocols/IRCG/src/irc.h @@ -464,7 +464,7 @@ struct CIrcProto : public PROTO<CIrcProto> INT_PTR __cdecl Scripting_GetIrcData(WPARAM wparam, LPARAM lparam);
BOOL Scripting_TriggerMSPRawIn(char ** pszRaw);
BOOL Scripting_TriggerMSPRawOut(char ** pszRaw);
- BOOL Scripting_TriggerMSPGuiIn(WPARAM * wparam, GCEVENT * gce);
+ BOOL Scripting_TriggerMSPGuiIn(WPARAM * wparam, GCEVENT *gce);
BOOL Scripting_TriggerMSPGuiOut(GCHOOK * gch);
// services.cpp
diff --git a/protocols/IRCG/src/ircproto.cpp b/protocols/IRCG/src/ircproto.cpp index f50b074a4f..360d572843 100644 --- a/protocols/IRCG/src/ircproto.cpp +++ b/protocols/IRCG/src/ircproto.cpp @@ -214,10 +214,10 @@ int CIrcProto::OnModulesLoaded( WPARAM, LPARAM ) if ( ServiceExists( MS_GC_REGISTER )) {
GCREGISTER gcr = { sizeof(GCREGISTER) };
- gcr.dwFlags = GC_CHANMGR | GC_BOLD | GC_ITALICS | GC_UNDERLINE | GC_COLOR | GC_BKGCOLOR | GC_TCHAR;
+ gcr.dwFlags = GC_CHANMGR | GC_BOLD | GC_ITALICS | GC_UNDERLINE | GC_COLOR | GC_BKGCOLOR;
gcr.nColors = 16;
gcr.pColors = colors;
- gcr.ptszModuleDispName = m_tszUserName;
+ gcr.ptszDispName = m_tszUserName;
gcr.pszModule = m_szModuleName;
CallServiceSync(MS_GC_REGISTER, NULL, (LPARAM)&gcr);
@@ -225,26 +225,18 @@ int CIrcProto::OnModulesLoaded( WPARAM, LPARAM ) HookProtoEvent(ME_GC_BUILDMENU, &CIrcProto::GCMenuHook);
GCSESSION gcw = { sizeof(GCSESSION) };
- gcw.dwFlags = GC_TCHAR;
gcw.iType = GCW_SERVER;
gcw.ptszID = SERVERWINDOW;
gcw.pszModule = m_szModuleName;
gcw.ptszName = NEWTSTR_ALLOCA(( TCHAR* )_A2T( m_network ));
CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM)&gcw);
- GCDEST gcd = { 0 };
- gcd.ptszID = SERVERWINDOW;
- gcd.pszModule = m_szModuleName;
- gcd.iType = GC_EVENT_CONTROL;
-
- GCEVENT gce = { sizeof(GCEVENT) };
- gce.dwFlags = GC_TCHAR;
- gce.pDest = &gcd;
-
+ GCDEST gcd = { m_szModuleName, SERVERWINDOW, GC_EVENT_CONTROL };
+ GCEVENT gce = { sizeof(gce), &gcd };
if ( m_useServer && !m_hideServerWindow )
- CallChatEvent( WINDOW_VISIBLE, (LPARAM)&gce);
+ CallChatEvent(WINDOW_VISIBLE, (LPARAM)&gce);
else
- CallChatEvent( WINDOW_HIDDEN, (LPARAM)&gce);
+ CallChatEvent(WINDOW_HIDDEN, (LPARAM)&gce);
bChatInstalled = TRUE;
}
else {
diff --git a/protocols/IRCG/src/scripting.cpp b/protocols/IRCG/src/scripting.cpp index f03b58d252..ea63dc16a2 100644 --- a/protocols/IRCG/src/scripting.cpp +++ b/protocols/IRCG/src/scripting.cpp @@ -78,17 +78,10 @@ INT_PTR __cdecl CIrcProto::Scripting_InsertGuiIn(WPARAM wParam,LPARAM lParam) static void __stdcall OnHook(void * pi)
{
GCHOOK* gch = ( GCHOOK* )pi;
-
- //Service_GCEventHook(1, (LPARAM) gch);
-
- if(gch->pszUID)
- free(gch->pszUID);
- if(gch->pszText)
- free(gch->pszText);
- if(gch->pDest->ptszID)
- free(gch->pDest->ptszID);
- if(gch->pDest->pszModule)
- free(gch->pDest->pszModule);
+ free(gch->ptszUID);
+ free(gch->ptszText);
+ free(gch->pDest->ptszID);
+ free(gch->pDest->pszModule);
delete gch->pDest;
delete gch;
}
@@ -111,11 +104,12 @@ INT_PTR __cdecl CIrcProto::Scripting_InsertGuiOut( WPARAM, LPARAM lParam ) gchook->pDest->iType = gch->pDest->iType;
if ( gch->ptszText )
gchook->ptszText = _tcsdup( gch->ptszText );
- else gchook->pszText = NULL;
+ else gchook->ptszText = NULL;
if ( gch->ptszUID )
gchook->ptszUID = _tcsdup( gch->ptszUID );
- else gchook->pszUID = NULL;
+ else
+ gchook->ptszUID = NULL;
if ( gch->pDest->ptszID ) {
CMString S = MakeWndID( gch->pDest->ptszID );
@@ -152,7 +146,7 @@ BOOL CIrcProto::Scripting_TriggerMSPRawOut(char ** pszRaw) return iVal > 0 ? FALSE : TRUE;
}
-BOOL CIrcProto::Scripting_TriggerMSPGuiIn(WPARAM * wparam, GCEVENT * gce)
+BOOL CIrcProto::Scripting_TriggerMSPGuiIn(WPARAM * wparam, GCEVENT *gce)
{
WPARAM_GUI_IN wgi = {0};
diff --git a/protocols/IRCG/src/services.cpp b/protocols/IRCG/src/services.cpp index 211e9e0dc1..c0f68e43b2 100644 --- a/protocols/IRCG/src/services.cpp +++ b/protocols/IRCG/src/services.cpp @@ -221,20 +221,13 @@ int __cdecl CIrcProto::OnContactDeleted(WPARAM wp, LPARAM) if ( !getTString( hContact, "Nick", &dbv )) {
int type = getByte(hContact, "ChatRoom", 0);
if ( type != 0 ) {
- GCEVENT gce = {0};
- GCDEST gcd = {0};
CMString S = _T("");
if (type == GCW_CHATROOM)
S = MakeWndID( dbv.ptszVal );
if (type == GCW_SERVER)
S = SERVERWINDOW;
- gce.cbSize = sizeof(GCEVENT);
- gce.dwItemData = 0;
- gcd.iType = GC_EVENT_CONTROL;
- gcd.pszModule = m_szModuleName;
- gce.dwFlags = GC_TCHAR;
- gce.pDest = &gcd;
- gcd.ptszID = ( TCHAR* )S.c_str();
+ GCDEST gcd = { m_szModuleName, (TCHAR*)S.c_str(), GC_EVENT_CONTROL };
+ GCEVENT gce = { sizeof(gce), &gcd };
int i = CallChatEvent( SESSION_TERMINATE, (LPARAM)&gce);
if (i && type == GCW_CHATROOM)
PostIrcMessage( _T("/PART %s %s"), dbv.ptszVal, m_userInfo);
@@ -276,16 +269,10 @@ INT_PTR __cdecl CIrcProto::OnLeaveChat(WPARAM wp, LPARAM) if ( getByte(( HANDLE )wp, "ChatRoom", 0) == GCW_CHATROOM) {
PostIrcMessage( _T("/PART %s %s"), dbv.ptszVal, m_userInfo);
- GCEVENT gce = {0};
- GCDEST gcd = {0};
CMString S = MakeWndID(dbv.ptszVal);
- gce.cbSize = sizeof(GCEVENT);
- gce.dwFlags = GC_TCHAR;
- gcd.iType = GC_EVENT_CONTROL;
- gcd.pszModule = m_szModuleName;
- gce.pDest = &gcd;
- gcd.ptszID = ( TCHAR* )S.c_str();
- CallChatEvent( SESSION_TERMINATE, (LPARAM)&gce);
+ GCDEST gcd = { m_szModuleName, (TCHAR*)S.c_str(), GC_EVENT_CONTROL };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ CallChatEvent(SESSION_TERMINATE, (LPARAM)&gce);
}
db_free(&dbv);
}
@@ -399,14 +386,8 @@ INT_PTR __cdecl CIrcProto::OnShowListMenuCommand(WPARAM, LPARAM) INT_PTR __cdecl CIrcProto::OnShowServerMenuCommand(WPARAM, LPARAM)
{
- GCEVENT gce = {0};
- GCDEST gcd = {0};
- gcd.iType = GC_EVENT_CONTROL;
- gcd.ptszID = SERVERWINDOW;
- gce.dwFlags = GC_TCHAR;
- gcd.pszModule = m_szModuleName;
- gce.cbSize = sizeof(GCEVENT);
- gce.pDest = &gcd;
+ GCDEST gcd = { m_szModuleName, SERVERWINDOW, GC_EVENT_CONTROL };
+ GCEVENT gce = { sizeof(gce), &gcd };
CallChatEvent( WINDOW_VISIBLE, (LPARAM)&gce);
return 0;
}
@@ -530,8 +511,8 @@ int __cdecl CIrcProto::GCEventHook(WPARAM wParam,LPARAM lParam) // first see if the scripting module should modify or stop this event
if (m_bMbotInstalled && m_scriptingEnabled && wParam == NULL) {
- gchtemp = (GCHOOK *)mir_alloc(sizeof(GCHOOK));
- gchtemp->pDest = (GCDEST *)mir_alloc(sizeof(GCDEST));
+ gchtemp = (GCHOOK*)mir_alloc(sizeof(GCHOOK));
+ gchtemp->pDest = (GCDEST*)mir_alloc(sizeof(GCDEST));
gchtemp->pDest->iType = gchook->pDest->iType;
gchtemp->dwData = gchook->dwData;
@@ -567,7 +548,7 @@ int __cdecl CIrcProto::GCEventHook(WPARAM wParam,LPARAM lParam) break;
case GC_USER_MESSAGE:
- if (gch && gch->pszText && lstrlen(gch->ptszText) > 0 ) {
+ if (gch && gch->ptszText && *gch->ptszText) {
TCHAR* pszText = new TCHAR[lstrlen(gch->ptszText)+1000];
lstrcpy(pszText, gch->ptszText);
DoChatFormatting(pszText);
@@ -599,16 +580,11 @@ int __cdecl CIrcProto::GCEventHook(WPARAM wParam,LPARAM lParam) case 3:
PostIrcMessage( _T("/PART %s %s"), p1, m_userInfo );
- { GCEVENT gce = {0};
- GCDEST gcd = {0};
+ {
S = MakeWndID(p1);
- gce.cbSize = sizeof(GCEVENT);
- gcd.iType = GC_EVENT_CONTROL;
- gcd.pszModule = m_szModuleName;
- gce.dwFlags = GC_TCHAR;
- gce.pDest = &gcd;
- gcd.ptszID = ( TCHAR* )S.c_str();
- CallChatEvent( SESSION_TERMINATE, (LPARAM)&gce);
+ GCDEST gcd = { m_szModuleName, (TCHAR*)S.c_str(), GC_EVENT_CONTROL };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ CallChatEvent(SESSION_TERMINATE, (LPARAM)&gce);
}
break;
case 4: // show server window
@@ -836,8 +812,8 @@ int __cdecl CIrcProto::GCEventHook(WPARAM wParam,LPARAM lParam) } } }
if ( gchtemp ) {
- mir_free(gchtemp->pszUID);
- mir_free(gchtemp->pszText);
+ mir_free(gchtemp->ptszUID);
+ mir_free(gchtemp->ptszText);
mir_free(gchtemp->pDest->ptszID);
mir_free(gchtemp->pDest->pszModule);
mir_free(gchtemp->pDest);
@@ -1149,18 +1125,11 @@ void CIrcProto::ConnectToServer(void) void CIrcProto::DisconnectFromServer(void)
{
- GCEVENT gce = {0};
- GCDEST gcd = {0};
-
if ( m_perform && IsConnected())
DoPerform( "Event: Disconnect" );
- gcd.iType = GC_EVENT_CONTROL;
- gcd.ptszID = NULL; // all windows
- gcd.pszModule = m_szModuleName;
- gce.cbSize = sizeof(GCEVENT);
- gce.pDest = &gcd;
-
+ GCDEST gcd = { m_szModuleName, 0, GC_EVENT_CONTROL };
+ GCEVENT gce = { sizeof(gce), &gcd };
CallChatEvent( SESSION_TERMINATE, (LPARAM)&gce);
ForkThread( &CIrcProto::DisconnectServerThread, 0 );
}
diff --git a/protocols/IRCG/src/tools.cpp b/protocols/IRCG/src/tools.cpp index 8489a2557a..ee4fcbb51c 100644 --- a/protocols/IRCG/src/tools.cpp +++ b/protocols/IRCG/src/tools.cpp @@ -406,18 +406,17 @@ TCHAR* __stdcall DoColorCodes(const TCHAR* text, bool bStrip, bool bReplacePerce INT_PTR CIrcProto::CallChatEvent(WPARAM wParam, LPARAM lParam)
{
- GCEVENT * gce = (GCEVENT *)lParam;
+ GCEVENT *gce = (GCEVENT *)lParam;
INT_PTR iVal = 0;
// first see if the scripting module should modify or stop this event
- if (m_bMbotInstalled && m_scriptingEnabled && gce
- && gce->time != 0 && (gce->pDest->ptszID == NULL
- || lstrlen(gce->pDest->ptszID) != 0 && lstrcmpi(gce->pDest->ptszID, SERVERWINDOW))) {
+ if (m_bMbotInstalled && m_scriptingEnabled && gce && gce->time != 0 &&
+ (gce->pDest->ptszID == NULL || lstrlen(gce->pDest->ptszID) != 0 && lstrcmpi(gce->pDest->ptszID, SERVERWINDOW)))
+ {
GCEVENT *gcevent = (GCEVENT*)lParam;
- GCEVENT *gcetemp = NULL;
- WPARAM wp = wParam;
- gcetemp = (GCEVENT *)mir_alloc(sizeof(GCEVENT));
- gcetemp->pDest = (GCDEST *)mir_alloc(sizeof(GCDEST));
+ WPARAM wp = wParam;
+ GCEVENT *gcetemp = (GCEVENT*)mir_alloc(sizeof(GCEVENT));
+ gcetemp->pDest = (GCDEST*)mir_alloc(sizeof(GCDEST));
gcetemp->pDest->iType = gcevent->pDest->iType;
gcetemp->dwFlags = gcevent->dwFlags;
gcetemp->bIsMe = gcevent->bIsMe;
@@ -446,11 +445,11 @@ INT_PTR CIrcProto::CallChatEvent(WPARAM wParam, LPARAM lParam) }
if (gcetemp) {
- mir_free((void*)gcetemp->pszNick);
- mir_free((void*)gcetemp->pszUID);
- mir_free((void*)gcetemp->pszStatus);
- mir_free((void*)gcetemp->pszUserInfo);
- mir_free((void*)gcetemp->pszText);
+ mir_free((void*)gcetemp->ptszNick);
+ mir_free((void*)gcetemp->ptszUID);
+ mir_free((void*)gcetemp->ptszStatus);
+ mir_free((void*)gcetemp->ptszUserInfo);
+ mir_free((void*)gcetemp->ptszText);
mir_free((void*)gcetemp->pDest->ptszID);
mir_free((void*)gcetemp->pDest->pszModule);
mir_free((void*)gcetemp->pDest);
@@ -467,8 +466,7 @@ INT_PTR CIrcProto::DoEvent(int iEvent, const TCHAR* pszWindow, const TCHAR* pszN const TCHAR* pszText, const TCHAR* pszStatus, const TCHAR* pszUserInfo,
DWORD_PTR dwItemData, bool bAddToLog, bool bIsMe, time_t timestamp)
{
- GCDEST gcd = { 0 };
- GCEVENT gce = { 0 };
+ GCDEST gcd = { m_szModuleName, NULL, iEvent };
CMString sID;
CMString sText = _T("");
@@ -491,13 +489,9 @@ INT_PTR CIrcProto::DoEvent(int iEvent, const TCHAR* pszWindow, const TCHAR* pszN }
else gcd.ptszID = NULL;
- gcd.pszModule = m_szModuleName;
- gcd.iType = iEvent;
-
- gce.cbSize = sizeof(GCEVENT);
- gce.pDest = &gcd;
+ GCEVENT gce = { sizeof(gce), &gcd };
gce.ptszStatus = pszStatus;
- gce.dwFlags = GC_TCHAR + ((bAddToLog) ? GCEF_ADDTOLOG : 0);
+ gce.dwFlags = (bAddToLog) ? GCEF_ADDTOLOG : 0;
gce.ptszNick = pszNick;
gce.ptszUID = pszNick;
if (iEvent == GC_EVENT_TOPIC)
diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp index 16764bc529..32e77d3c0b 100644 --- a/protocols/JabberG/src/jabber_chat.cpp +++ b/protocols/JabberG/src/jabber_chat.cpp @@ -133,7 +133,6 @@ int CJabberProto::GcInit(JABBER_LIST_ITEM *item) gcw.pszModule = m_szModuleName;
gcw.ptszName = szNick;
gcw.ptszID = item->jid;
- gcw.dwFlags = GC_TCHAR;
CallServiceSync(MS_GC_NEWSESSION, NULL, (LPARAM)&gcw);
HANDLE hContact = HContactFromJID(item->jid);
@@ -166,19 +165,13 @@ int CJabberProto::GcInit(JABBER_LIST_ITEM *item) item->bChatActive = TRUE;
- GCDEST gcd = { m_szModuleName, NULL, GC_EVENT_ADDGROUP };
- gcd.ptszID = item->jid;
-
- GCEVENT gce = { sizeof(GCEVENT) };
- gce.pDest = &gcd;
- gce.dwFlags = GC_TCHAR;
+ GCDEST gcd = { m_szModuleName, item->jid, GC_EVENT_ADDGROUP };
+ GCEVENT gce = { sizeof(gce), &gcd };
for (i = SIZEOF(sttStatuses)-1; i >= 0; i--) {
gce.ptszStatus = TranslateTS(sttStatuses[i]);
CallServiceSync(MS_GC_EVENT, NULL, (LPARAM)&gce);
}
- gce.cbSize = sizeof(GCEVENT);
- gce.pDest = &gcd;
gcd.iType = GC_EVENT_CONTROL;
CallServiceSync(MS_GC_EVENT, (item->bAutoJoin && m_options.AutoJoinHidden) ? WINDOW_HIDDEN : SESSION_INITDONE, (LPARAM)&gce);
CallServiceSync(MS_GC_EVENT, SESSION_ONLINE, (LPARAM)&gce);
@@ -253,17 +246,13 @@ void CJabberProto::GcLogShowInformation(JABBER_LIST_ITEM *item, pResourceStatus }
if (*buf) {
- GCDEST gcd = { m_szModuleName, 0, 0 };
- gcd.ptszID = item->jid;
- GCEVENT gce = {0};
- gce.cbSize = sizeof(GCEVENT);
+ GCDEST gcd = { m_szModuleName, item->jid, GC_EVENT_INFORMATION };
+ GCEVENT gce = { sizeof(gce), &gcd };
gce.ptszNick = user->m_tszResourceName;
gce.ptszUID = user->m_tszResourceName;
gce.ptszText = EscapeChatTags(buf);
- gce.dwFlags = GC_TCHAR | GCEF_ADDTOLOG;
- gce.pDest = &gcd;
+ gce.dwFlags = GCEF_ADDTOLOG;
gce.time = time(0);
- gcd.iType = GC_EVENT_INFORMATION;
CallServiceSync(MS_GC_EVENT, NULL, (LPARAM)&gce);
mir_free((void*)gce.ptszText); // Since we processed msgText and created a new string
@@ -286,17 +275,13 @@ void CJabberProto::GcLogUpdateMemberStatus(JABBER_LIST_ITEM *item, const TCHAR * if (myNick == NULL)
myNick = JabberNickFromJID(m_szJabberJID);
- GCDEST gcd = { m_szModuleName, 0, 0 };
- gcd.ptszID = item->jid;
- GCEVENT gce = {0};
- gce.cbSize = sizeof(GCEVENT);
+ GCDEST gcd = { m_szModuleName, item->jid };
+ GCEVENT gce = { sizeof(gce), &gcd };
gce.ptszNick = nick;
gce.ptszUID = resource;
if (jid != NULL)
gce.ptszUserInfo = jid;
gce.ptszText = szReason;
- gce.dwFlags = GC_TCHAR;
- gce.pDest = &gcd;
if (item->bChatActive == 2) {
gce.dwFlags |= GCEF_ADDTOLOG;
gce.time = time(0);
@@ -351,14 +336,10 @@ void CJabberProto::GcQuit(JABBER_LIST_ITEM *item, int code, HXML reason) {
TCHAR *szMessage = NULL;
- GCDEST gcd = { m_szModuleName, NULL, GC_EVENT_CONTROL };
- gcd.ptszID = item->jid;
- GCEVENT gce = {0};
- gce.cbSize = sizeof(GCEVENT);
+ GCDEST gcd = { m_szModuleName, item->jid, GC_EVENT_CONTROL };
+ GCEVENT gce = { sizeof(gce), &gcd };
gce.ptszUID = item->jid;
gce.ptszText = xmlGetText(reason);
- gce.dwFlags = GC_TCHAR;
- gce.pDest = &gcd;
if (code != 307 && code != 301) {
CallServiceSync(MS_GC_EVENT, SESSION_TERMINATE, (LPARAM)&gce);
@@ -1453,7 +1434,7 @@ int CJabberProto::JabberGcEventHook(WPARAM, LPARAM lParam) switch (gch->pDest->iType) {
case GC_USER_MESSAGE:
- if (gch->pszText && lstrlen(gch->ptszText) > 0) {
+ if (gch->ptszText && lstrlen(gch->ptszText) > 0) {
rtrimt(gch->ptszText);
if (m_bJabberOnline) {
diff --git a/protocols/JabberG/src/jabber_groupchat.cpp b/protocols/JabberG/src/jabber_groupchat.cpp index fc27e29e78..3a1c740926 100644 --- a/protocols/JabberG/src/jabber_groupchat.cpp +++ b/protocols/JabberG/src/jabber_groupchat.cpp @@ -820,18 +820,13 @@ void CJabberProto::RenameParticipantNick(JABBER_LIST_ITEM *item, const TCHAR *ol setTString(hContact, "MyNick", newNick);
}
- GCDEST gcd = { m_szModuleName, NULL, GC_EVENT_CHUID };
- gcd.ptszID = item->jid;
-
- GCEVENT gce = {0};
- gce.cbSize = sizeof(GCEVENT);
- gce.pDest = &gcd;
+ GCDEST gcd = { m_szModuleName, item->jid, GC_EVENT_CHUID };
+ GCEVENT gce = { sizeof(gce), &gcd };
gce.ptszNick = oldNick;
gce.ptszText = newNick;
if (jid != NULL)
gce.ptszUserInfo = jid;
gce.time = time(0);
- gce.dwFlags = GC_TCHAR;
CallServiceSync(MS_GC_EVENT, NULL, (LPARAM)&gce);
gcd.iType = GC_EVENT_NICK;
@@ -1072,8 +1067,7 @@ void CJabberProto::GroupchatProcessMessage(HXML node) if ( !lstrcmp(type, _T("error")))
return;
- GCDEST gcd = { m_szModuleName, NULL, 0 };
- gcd.ptszID = item->jid;
+ GCDEST gcd = { m_szModuleName, item->jid, 0 };
const TCHAR *msgText = NULL;
@@ -1141,14 +1135,12 @@ void CJabberProto::GroupchatProcessMessage(HXML node) }
else nick = NULL;
- GCEVENT gce = { sizeof(GCEVENT) };
- gce.pDest = &gcd;
+ GCEVENT gce = { sizeof(gce), &gcd };
gce.ptszUID = resource;
gce.ptszNick = nick;
gce.time = msgTime;
gce.ptszText = EscapeChatTags((TCHAR*)msgText);
gce.bIsMe = nick == NULL ? FALSE : (lstrcmp(resource, item->nick) == 0);
- gce.dwFlags = GC_TCHAR;
if (!isHistory)
gce.dwFlags |= GCEF_ADDTOLOG;
@@ -1166,7 +1158,7 @@ void CJabberProto::GroupchatProcessMessage(HXML node) CallServiceSync(MS_GC_EVENT, NULL, (LPARAM)&gce);
}
- mir_free((void*)gce.pszText); // Since we processed msgText and created a new string
+ mir_free((void*)gce.ptszText); // Since we processed msgText and created a new string
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp index 93469fe0a4..27ec3fcfbd 100644 --- a/protocols/JabberG/src/jabber_iqid.cpp +++ b/protocols/JabberG/src/jabber_iqid.cpp @@ -445,11 +445,9 @@ void CJabberProto::OnIqResultGetRoster(HXML iqNode, CJabberIqInfo *pInfo) else db_unset(hContact, "CList", "MyHandle");
if ( isChatRoom(hContact)) {
- GCSESSION gcw = {0};
- gcw.cbSize = sizeof(GCSESSION);
+ GCSESSION gcw = { sizeof(gcw) };
gcw.iType = GCW_CHATROOM;
gcw.pszModule = m_szModuleName;
- gcw.dwFlags = GC_TCHAR;
gcw.ptszID = jid;
gcw.ptszName = NEWTSTR_ALLOCA(jid);
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index 174ebdb262..276777df2e 100644 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -218,13 +218,11 @@ int CJabberProto::OnModulesLoadedEx(WPARAM, LPARAM) m_pInfoFrame = new CJabberInfoFrame(this);
- GCREGISTER gcr = {0};
- gcr.cbSize = sizeof(GCREGISTER);
- gcr.dwFlags = GC_TYPNOTIF | GC_CHANMGR | GC_TCHAR;
- gcr.iMaxText = 0;
+ GCREGISTER gcr = { sizeof(gcr) };
+ gcr.dwFlags = GC_TYPNOTIF | GC_CHANMGR;
gcr.nColors = 16;
gcr.pColors = &crCols[0];
- gcr.ptszModuleDispName = m_tszUserName;
+ gcr.ptszDispName = m_tszUserName;
gcr.pszModule = m_szModuleName;
CallServiceSync(MS_GC_REGISTER, NULL, (LPARAM)&gcr);
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index 05217363e7..1d344ad783 100644 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -125,9 +125,7 @@ static VOID CALLBACK JabberOfflineChatWindows(void* param) {
CJabberProto *ppro = (CJabberProto*)param;
GCDEST gcd = { ppro->m_szModuleName, NULL, GC_EVENT_CONTROL };
- GCEVENT gce = { 0 };
- gce.cbSize = sizeof(GCEVENT);
- gce.pDest = &gcd;
+ GCEVENT gce = { sizeof(gce), &gcd };
CallService(MS_GC_EVENT, SESSION_TERMINATE, (LPARAM)&gce);
}
diff --git a/protocols/MRA/src/MraChat.cpp b/protocols/MRA/src/MraChat.cpp index 86c83daff6..2622dfe4d5 100644 --- a/protocols/MRA/src/MraChat.cpp +++ b/protocols/MRA/src/MraChat.cpp @@ -16,12 +16,10 @@ bool CMraProto::MraChatRegister() if ( !ServiceExists(MS_GC_REGISTER))
return FALSE;
- GCREGISTER gcr = {0};
- gcr.cbSize = sizeof(GCREGISTER);
- gcr.dwFlags = GC_UNICODE;
+ GCREGISTER gcr = { sizeof(gcr) };
gcr.iMaxText = MRA_MAXLENOFMESSAGE;
gcr.nColors = 0;
- gcr.ptszModuleDispName = m_tszUserName;
+ gcr.ptszDispName = m_tszUserName;
gcr.pszModule = m_szModuleName;
CallServiceSync(MS_GC_REGISTER, NULL, (LPARAM)&gcr);
@@ -33,38 +31,25 @@ INT_PTR CMraProto::MraChatSessionNew(HANDLE hContact) {
if (bChatExists)
if (hContact) {
- GCSESSION gcw = {0};
CMStringW wszEMail;
mraGetStringW(hContact, "e-mail", wszEMail);
- gcw.cbSize = sizeof(GCSESSION);
+ GCSESSION gcw = { sizeof(gcw) };
gcw.iType = GCW_CHATROOM;
gcw.pszModule = m_szModuleName;
gcw.ptszName = GetContactNameW(hContact);
gcw.ptszID = wszEMail;
gcw.ptszStatusbarText = _T("status bar");
- gcw.dwFlags = GC_TCHAR;
gcw.dwItemData = (DWORD)hContact;
if ( !CallServiceSync(MS_GC_NEWSESSION, NULL, (LPARAM)&gcw)) {
- GCDEST gcd = {0};
- GCEVENT gce = {0};
-
- gcd.pszModule = m_szModuleName;
- gcd.ptszID = (TCHAR*)wszEMail.c_str();
- gcd.iType = GC_EVENT_ADDGROUP;
-
- gce.cbSize = sizeof(GCEVENT);
- gce.pDest = &gcd;
- gce.dwFlags = GC_UNICODE;
+ GCDEST gcd = { m_szModuleName, (TCHAR*)wszEMail.c_str(), GC_EVENT_ADDGROUP };
+ GCEVENT gce = { sizeof(gce), &gcd };
for (int i = 0; i < SIZEOF(lpwszStatuses); i++) {
gce.ptszStatus = TranslateTS(lpwszStatuses[i]);
CallServiceSync(MS_GC_EVENT, NULL, (LPARAM)&gce);
}
- gce.cbSize = sizeof(GCEVENT);
- gce.pDest = &gcd;
gcd.iType = GC_EVENT_CONTROL;
-
CallServiceSync(MS_GC_EVENT, SESSION_INITDONE, (LPARAM)&gce);
CallServiceSync(MS_GC_EVENT, SESSION_ONLINE, (LPARAM)&gce);
@@ -83,19 +68,14 @@ void CMraProto::MraChatSessionDestroy(HANDLE hContact) if ( !bChatExists)
return;
- GCDEST gcd = {0};
- GCEVENT gce = {0};
- CMStringW wszEMail;
+ GCDEST gcd = { m_szModuleName, NULL, GC_EVENT_CONTROL };
+ GCEVENT gce = { sizeof(gce), &gcd };
- gcd.pszModule = m_szModuleName;
- gcd.iType = GC_EVENT_CONTROL;
+ CMStringW wszEMail;
if (hContact) {
mraGetStringW(hContact, "e-mail", wszEMail);
gcd.ptszID = (LPWSTR)wszEMail.c_str();
}
- gce.cbSize = sizeof(GCEVENT);
- gce.pDest = &gcd;
- gce.dwFlags = GC_UNICODE;
CallServiceSync(MS_GC_EVENT, SESSION_TERMINATE, (LPARAM)&gce);
CallServiceSync(MS_GC_EVENT, WINDOW_CLEARLOG, (LPARAM)&gce);
@@ -108,18 +88,14 @@ INT_PTR CMraProto::MraChatSessionEventSendByHandle(HANDLE hContactChatSession, D CMStringW wszID, wszUID, wszNick;
- GCDEST gcd = {0};
- gcd.pszModule = m_szModuleName;
+ GCDEST gcd = { m_szModuleName, 0, dwType };
if (hContactChatSession) {
mraGetStringW(hContactChatSession, "e-mail", wszID);
gcd.ptszID = (LPWSTR)wszID.c_str();
}
- gcd.iType = dwType;
- GCEVENT gce = {0};
- gce.cbSize = sizeof(GCEVENT);
- gce.pDest = &gcd;
- gce.dwFlags = GC_UNICODE|dwFlags;
+ GCEVENT gce = { sizeof(gce), &gcd };
+ gce.dwFlags = dwFlags;
gce.ptszUID = wszUID;
gce.ptszStatus = lpwszStatus;
gce.ptszText = lpwszMessage;
diff --git a/protocols/MRA/src/Mra_functions.cpp b/protocols/MRA/src/Mra_functions.cpp index 83f0ccd79c..c1f65f4d5c 100644 --- a/protocols/MRA/src/Mra_functions.cpp +++ b/protocols/MRA/src/Mra_functions.cpp @@ -509,15 +509,13 @@ HANDLE CMraProto::MraHContactFromEmail(const CMStringA& szEmail, BOOL bAddIfNeed if (!bFound && bAddIfNeeded) {
//not already there: add
if (IsEMailChatAgent(szEmail)) {
- GCSESSION gcw = {0};
CMStringW wszEMail = szEmail;
- gcw.cbSize = sizeof(GCSESSION);
+ GCSESSION gcw = { sizeof(gcw) };
gcw.iType = GCW_CHATROOM;
gcw.pszModule = m_szModuleName;
gcw.ptszName = wszEMail;
gcw.ptszID = (LPWSTR)wszEMail.c_str();
- gcw.dwFlags = GC_UNICODE;
if (CallServiceSync(MS_GC_NEWSESSION, NULL, (LPARAM)&gcw) == 0) {
BOOL bChatAdded = FALSE;
diff --git a/protocols/MSN/src/msn_chat.cpp b/protocols/MSN/src/msn_chat.cpp index d7e2bc3f90..d5718bb34e 100644 --- a/protocols/MSN/src/msn_chat.cpp +++ b/protocols/MSN/src/msn_chat.cpp @@ -47,21 +47,15 @@ int CMsnProto::MSN_ChatInit(ThreadData *info) mir_sntprintf(szName, SIZEOF(szName), _T("%s %s%s"),
m_tszUserName, TranslateT("Chat #"), info->mChatID);
- GCSESSION gcw = {0};
- gcw.cbSize = sizeof(GCSESSION);
- gcw.dwFlags = GC_TCHAR;
+ GCSESSION gcw = { sizeof(gcw) };
gcw.iType = GCW_CHATROOM;
gcw.pszModule = m_szModuleName;
gcw.ptszName = szName;
gcw.ptszID = info->mChatID;
CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM)&gcw);
- GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_ADDGROUP };
- gcd.ptszID = info->mChatID;
- GCEVENT gce = {0};
- gce.cbSize = sizeof(GCEVENT);
- gce.dwFlags = GC_TCHAR;
- gce.pDest = &gcd;
+ GCDEST gcd = { m_szModuleName, info->mChatID, GC_EVENT_ADDGROUP };
+ GCEVENT gce = { sizeof(gce), &gcd };
gce.ptszStatus = TranslateT("Me");
CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
@@ -95,13 +89,9 @@ void CMsnProto::MSN_ChatStart(ThreadData* info) MSN_ChatInit(info);
// add all participants onto the list
- GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_JOIN };
- gcd.ptszID = info->mChatID;
-
- GCEVENT gce = {0};
- gce.cbSize = sizeof(GCEVENT);
- gce.dwFlags = GC_TCHAR | GCEF_ADDTOLOG;
- gce.pDest = &gcd;
+ GCDEST gcd = { m_szModuleName, info->mChatID, GC_EVENT_JOIN };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ gce.dwFlags = GCEF_ADDTOLOG;
gce.ptszStatus = TranslateT("Others");
gce.time = time(NULL);
gce.bIsMe = FALSE;
@@ -121,12 +111,9 @@ void CMsnProto::MSN_ChatStart(ThreadData* info) void CMsnProto::MSN_KillChatSession(TCHAR* id)
{
- GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_CONTROL };
- gcd.ptszID = id;
- GCEVENT gce = {0};
- gce.cbSize = sizeof(GCEVENT);
- gce.dwFlags = GC_TCHAR | GCEF_REMOVECONTACT;
- gce.pDest = &gcd;
+ GCDEST gcd = { m_szModuleName, id, GC_EVENT_CONTROL };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ gce.dwFlags = GCEF_REMOVECONTACT;
CallServiceSync(MS_GC_EVENT, SESSION_OFFLINE, (LPARAM)&gce);
CallServiceSync(MS_GC_EVENT, SESSION_TERMINATE, (LPARAM)&gce);
}
@@ -320,7 +307,7 @@ INT_PTR CALLBACK DlgInviteToChat(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l int CMsnProto::MSN_GCEventHook(WPARAM, LPARAM lParam)
{
- GCHOOK *gch = (GCHOOK*) lParam;
+ GCHOOK *gch = (GCHOOK*)lParam;
if (!gch)
return 1;
@@ -349,13 +336,9 @@ int CMsnProto::MSN_GCEventHook(WPARAM, LPARAM lParam) DBVARIANT dbv;
int bError = getTString("Nick", &dbv);
- GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_MESSAGE };
- gcd.ptszID = gch->pDest->ptszID;
-
- GCEVENT gce = {0};
- gce.cbSize = sizeof(GCEVENT);
- gce.dwFlags = GC_TCHAR | GCEF_ADDTOLOG;
- gce.pDest = &gcd;
+ GCDEST gcd = { m_szModuleName, gch->pDest->ptszID, GC_EVENT_MESSAGE };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ gce.dwFlags = GCEF_ADDTOLOG;
gce.ptszNick = bError ? _T("") : dbv.ptszVal;
gce.ptszUID = mir_a2t(MyOptions.szEmail);
gce.time = time(NULL);
diff --git a/protocols/MSN/src/msn_commands.cpp b/protocols/MSN/src/msn_commands.cpp index aa8fe39c21..63836bea6a 100644 --- a/protocols/MSN/src/msn_commands.cpp +++ b/protocols/MSN/src/msn_commands.cpp @@ -470,13 +470,9 @@ void CMsnProto::MSN_ReceiveMessage(ThreadData* info, char* cmdString, char* para if (info->mChatID[0])
{
- GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_MESSAGE };
- gcd.ptszID = info->mChatID;
-
- GCEVENT gce = {0};
- gce.cbSize = sizeof(GCEVENT);
- gce.dwFlags = GC_TCHAR | GCEF_ADDTOLOG;
- gce.pDest = &gcd;
+ GCDEST gcd = { m_szModuleName, info->mChatID, GC_EVENT_MESSAGE };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ gce.dwFlags = GCEF_ADDTOLOG;
gce.ptszUID = mir_a2t(email);
gce.ptszNick = GetContactNameT(hContact);
gce.time = time(NULL);
@@ -487,7 +483,7 @@ void CMsnProto::MSN_ReceiveMessage(ThreadData* info, char* cmdString, char* para mir_free(p);
CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
- mir_free((void*)gce.pszText);
+ mir_free((void*)gce.ptszText);
mir_free((void*)gce.ptszUID);
}
else if (hContact)
@@ -1181,19 +1177,15 @@ LBL_InvalidCommand: // modified for chat
if (msnHaveChatDll)
{
- GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_QUIT };
- gcd.ptszID = info->mChatID;
-
- GCEVENT gce = {0};
- gce.cbSize = sizeof(GCEVENT);
- gce.dwFlags = GC_TCHAR | GCEF_ADDTOLOG;
- gce.pDest = &gcd;
+ GCDEST gcd = { m_szModuleName, info->mChatID, GC_EVENT_QUIT };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ gce.dwFlags = GCEF_ADDTOLOG;
gce.ptszNick = GetContactNameT(hContact);
gce.ptszUID = mir_a2t(data.userEmail);
gce.time = time(NULL);
gce.bIsMe = FALSE;
CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
- mir_free((void*)gce.pszUID);
+ mir_free((void*)gce.ptszUID);
}
int personleft = info->contactLeft(data.userEmail);
@@ -1207,13 +1199,9 @@ LBL_InvalidCommand: {
if (!strcmp(data.isIdle, "1"))
{
- GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_INFORMATION };
- gcd.ptszID = info->mChatID;
-
- GCEVENT gce = {0};
- gce.cbSize = sizeof(GCEVENT);
- gce.dwFlags = GC_TCHAR | GCEF_ADDTOLOG;
- gce.pDest = &gcd;
+ GCDEST gcd = { m_szModuleName, info->mChatID, GC_EVENT_INFORMATION };
+ GCEVENT gce = { sizeof(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.");
@@ -1565,13 +1553,9 @@ remove: {
if (chatCreated)
{
- GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_JOIN };
- gcd.ptszID = info->mChatID;
-
- GCEVENT gce = {0};
- gce.cbSize = sizeof(GCEVENT);
- gce.dwFlags = GC_TCHAR | GCEF_ADDTOLOG;
- gce.pDest = &gcd;
+ GCDEST gcd = { m_szModuleName, info->mChatID, GC_EVENT_JOIN };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ gce.dwFlags = GCEF_ADDTOLOG;
gce.ptszNick = GetContactNameT(hContact);
gce.ptszUID = mir_a2t(data.userEmail);
gce.ptszStatus = TranslateT("Others");
diff --git a/protocols/MSN/src/msn_proto.cpp b/protocols/MSN/src/msn_proto.cpp index 0c492a34ae..63191ab22f 100644 --- a/protocols/MSN/src/msn_proto.cpp +++ b/protocols/MSN/src/msn_proto.cpp @@ -184,11 +184,11 @@ int CMsnProto::OnModulesLoaded(WPARAM, LPARAM) if (msnHaveChatDll) {
GCREGISTER gcr = {0};
gcr.cbSize = sizeof(GCREGISTER);
- gcr.dwFlags = GC_TYPNOTIF | GC_CHANMGR | GC_TCHAR;
+ gcr.dwFlags = GC_TYPNOTIF | GC_CHANMGR;
gcr.iMaxText = 0;
gcr.nColors = 16;
gcr.pColors = (COLORREF*)crCols;
- gcr.ptszModuleDispName = m_tszUserName;
+ gcr.ptszDispName = m_tszUserName;
gcr.pszModule = m_szModuleName;
CallServiceSync(MS_GC_REGISTER, 0, (LPARAM)&gcr);
diff --git a/protocols/Omegle/src/chat.cpp b/protocols/Omegle/src/chat.cpp index 39ad7925e5..88f6874c71 100644 --- a/protocols/Omegle/src/chat.cpp +++ b/protocols/Omegle/src/chat.cpp @@ -23,30 +23,23 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. void OmegleProto::UpdateChat(const TCHAR *name, const TCHAR *message, bool addtolog)
{
- GCDEST gcd = { m_szModuleName };
- gcd.ptszID = const_cast<TCHAR*>(m_tszUserName);
-
- GCEVENT gce = {sizeof(gce)};
- gce.pDest = &gcd;
+ GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_MESSAGE };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ gce.time = ::time(NULL);
gce.ptszText = message;
- gce.time = ::time(NULL);
- gce.dwFlags = GC_TCHAR;
- gcd.iType = GC_EVENT_MESSAGE;
if (name == NULL) {
gcd.iType = GC_EVENT_INFORMATION;
name = TranslateT("Server");
gce.bIsMe = false;
- } else {
- gce.bIsMe = !_tcscmp(name, this->facy.nick_);
}
+ else gce.bIsMe = !_tcscmp(name, this->facy.nick_);
if (addtolog)
gce.dwFlags |= GCEF_ADDTOLOG;
gce.ptszNick = name;
gce.ptszUID = gce.ptszNick;
-
CallServiceSync(MS_GC_EVENT,0,reinterpret_cast<LPARAM>(&gce));
}
@@ -214,29 +207,19 @@ int OmegleProto::OnChatEvent(WPARAM wParam,LPARAM lParam) /*void OmegleProto::SendChatEvent(int type)
{
- GCDEST gcd = { m_szModuleName };
- gcd.ptszID = const_cast<TCHAR*>(m_tszUserName);
- gcd.iType = GC_EVENT_CONTROL;
-
- GCEVENT gce = {sizeof(gce)};
- gce.dwFlags = GC_TCHAR;
- gce.pDest = &gcd;
-
+ GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_CONTROL };
+ GCEVENT gce = { sizeof(gce), &gcd };
CallServiceSync(MS_GC_EVENT,WINDOW_CLEARLOG,reinterpret_cast<LPARAM>(&gce));
}*/
void OmegleProto::AddChatContact(const TCHAR *name)
{
- GCDEST gcd = { m_szModuleName };
- gcd.ptszID = const_cast<TCHAR*>(m_tszUserName);
- gcd.iType = GC_EVENT_JOIN;
-
- GCEVENT gce = {sizeof(gce)};
- gce.pDest = &gcd;
- gce.dwFlags = GC_TCHAR | GCEF_ADDTOLOG;
- gce.ptszNick = name;
- gce.ptszUID = gce.ptszNick;
- gce.time = static_cast<DWORD>(time(0));
+ GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_JOIN };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ gce.time = DWORD(time(0));
+ gce.dwFlags = GCEF_ADDTOLOG;
+ gce.ptszNick = name;
+ gce.ptszUID = gce.ptszNick;
if (name == NULL)
gce.bIsMe = false;
@@ -253,16 +236,12 @@ void OmegleProto::AddChatContact(const TCHAR *name) void OmegleProto::DeleteChatContact(const TCHAR *name)
{
- GCDEST gcd = { m_szModuleName };
- gcd.ptszID = const_cast<TCHAR*>(m_tszUserName);
- gcd.iType = GC_EVENT_PART;
-
- GCEVENT gce = {sizeof(gce)};
- gce.pDest = &gcd;
- gce.dwFlags = GC_TCHAR | GCEF_ADDTOLOG;
- gce.ptszNick = name;
- gce.ptszUID = gce.ptszNick;
- gce.time = static_cast<DWORD>(time(0));
+ GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_PART };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ gce.dwFlags = GCEF_ADDTOLOG;
+ gce.ptszNick = name;
+ gce.ptszUID = gce.ptszNick;
+ gce.time = DWORD(time(0));
if (name == NULL)
gce.bIsMe = false;
else
@@ -273,29 +252,21 @@ void OmegleProto::DeleteChatContact(const TCHAR *name) INT_PTR OmegleProto::OnJoinChat(WPARAM,LPARAM suppress)
{
- GCSESSION gcw = {sizeof(gcw)};
-
// Create the group chat session
- gcw.dwFlags = GC_TCHAR;
- gcw.iType = GCW_CHATROOM;
+ GCSESSION gcw = {sizeof(gcw)};
+ gcw.iType = GCW_CHATROOM;
+ gcw.ptszID = m_tszUserName;
+ gcw.ptszName = m_tszUserName;
gcw.pszModule = m_szModuleName;
- gcw.ptszName = m_tszUserName;
- gcw.ptszID = m_tszUserName;
CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM)&gcw);
if(m_iStatus == ID_STATUS_OFFLINE)
return 0;
// Create a group
- GCDEST gcd = { m_szModuleName };
- gcd.ptszID = const_cast<TCHAR*>(m_tszUserName);
-
- GCEVENT gce = {sizeof(gce)};
- gce.pDest = &gcd;
- gce.dwFlags = GC_TCHAR;
-
- gcd.iType = GC_EVENT_ADDGROUP;
-
+ GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_ADDGROUP };
+ GCEVENT gce = { sizeof(gce), &gcd };
+
gce.ptszStatus = _T("Admin");
CallServiceSync( MS_GC_EVENT, NULL, reinterpret_cast<LPARAM>(&gce));
@@ -313,15 +284,10 @@ INT_PTR OmegleProto::OnJoinChat(WPARAM,LPARAM suppress) void OmegleProto::SetTopic(const TCHAR *topic)
{
- GCDEST gcd = { m_szModuleName };
- gcd.ptszID = const_cast<TCHAR*>(m_tszUserName);
- gcd.iType = GC_EVENT_TOPIC;
-
- GCEVENT gce = {sizeof(gce)};
- gce.pDest = &gcd;
- gce.dwFlags = GC_TCHAR;
+ GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_TOPIC };
+ GCEVENT gce = { sizeof(gce), &gcd };
gce.time = ::time(NULL);
-
+
if (topic == NULL)
gce.ptszText = TranslateT("Omegle is a great way of meeting new friends!");
else
@@ -332,14 +298,9 @@ void OmegleProto::SetTopic(const TCHAR *topic) INT_PTR OmegleProto::OnLeaveChat(WPARAM,LPARAM)
{
- GCDEST gcd = { m_szModuleName };
- gcd.ptszID = const_cast<TCHAR*>(m_tszUserName);
- gcd.iType = GC_EVENT_CONTROL;
-
- GCEVENT gce = {sizeof(gce)};
- gce.dwFlags = GC_TCHAR;
+ GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_CONTROL };
+ GCEVENT gce = { sizeof(gce), &gcd };
gce.time = ::time(NULL);
- gce.pDest = &gcd;
CallServiceSync(MS_GC_EVENT,SESSION_OFFLINE, reinterpret_cast<LPARAM>(&gce));
CallServiceSync(MS_GC_EVENT,SESSION_TERMINATE,reinterpret_cast<LPARAM>(&gce));
@@ -349,14 +310,9 @@ INT_PTR OmegleProto::OnLeaveChat(WPARAM,LPARAM) void OmegleProto::SetChatStatus(int status)
{
- GCDEST gcd = { m_szModuleName };
- gcd.ptszID = const_cast<TCHAR*>(m_tszUserName);
- gcd.iType = GC_EVENT_CONTROL;
-
- GCEVENT gce = {sizeof(gce)};
- gce.dwFlags = GC_TCHAR;
+ GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_CONTROL };
+ GCEVENT gce = { sizeof(gce), &gcd };
gce.time = ::time(NULL);
- gce.pDest = &gcd;
if(status == ID_STATUS_ONLINE)
{
@@ -391,15 +347,9 @@ void OmegleProto::ClearChat() if (getByte(OMEGLE_KEY_NO_CLEAR, 0))
return;
- GCDEST gcd = { m_szModuleName };
- gcd.ptszID = const_cast<TCHAR*>(m_tszUserName);
- gcd.iType = GC_EVENT_CONTROL;
-
- GCEVENT gce = {sizeof(gce)};
- gce.dwFlags = GC_TCHAR;
- gce.pDest = &gcd;
-
- CallServiceSync(MS_GC_EVENT,WINDOW_CLEARLOG,reinterpret_cast<LPARAM>(&gce));
+ GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_CONTROL };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ CallServiceSync(MS_GC_EVENT, WINDOW_CLEARLOG, reinterpret_cast<LPARAM>(&gce));
}
// TODO: Could this be done better?
diff --git a/protocols/Omegle/src/proto.cpp b/protocols/Omegle/src/proto.cpp index f0ebd14717..245fa749ea 100644 --- a/protocols/Omegle/src/proto.cpp +++ b/protocols/Omegle/src/proto.cpp @@ -176,7 +176,7 @@ int OmegleProto::OnModulesLoaded(WPARAM wParam,LPARAM lParam) GCREGISTER gcr = {sizeof(gcr)};
gcr.dwFlags = GC_TYPNOTIF; //GC_ACKMSG;
gcr.pszModule = m_szModuleName;
- gcr.pszModuleDispName = m_szModuleName;
+ gcr.ptszDispName = m_tszUserName;
gcr.iMaxText = OMEGLE_MESSAGE_LIMIT;
gcr.nColors = 0;
gcr.pColors = NULL;
diff --git a/protocols/Skype/src/skype_chat.cpp b/protocols/Skype/src/skype_chat.cpp index 3bb2534bbf..6f42d44393 100644 --- a/protocols/Skype/src/skype_chat.cpp +++ b/protocols/Skype/src/skype_chat.cpp @@ -161,17 +161,10 @@ void ChatRoom::CreateChatSession(bool showWindow) gcw.dwItemData = (DWORD)this;
::CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM)&gcw);
- GCDEST gcd = { ppro->m_szModuleName, { NULL }, GC_EVENT_ADDGROUP };
- gcd.ptszID = this->cid;
-
// load chat roles
- GCEVENT gce = {0};
- gce.cbSize = sizeof(GCEVENT);
- gce.dwFlags = GC_TCHAR;
- gce.pDest = &gcd;
-
- for (int i = 1; i < SIZEOF(ChatRoom::Roles) - 2; i++)
- {
+ GCDEST gcd = { ppro->m_szModuleName, this->cid, GC_EVENT_ADDGROUP };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ for (int i = 1; i < SIZEOF(ChatRoom::Roles) - 2; i++) {
gce.ptszStatus = ::TranslateTS(ChatRoom::Roles[i]);
::CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
}
@@ -205,16 +198,9 @@ wchar_t *ChatRoom::GetUri() void ChatRoom::ShowWindow()
{
- GCDEST gcd = { this->ppro->m_szModuleName, { NULL }, GC_EVENT_CONTROL };
- gcd.ptszID = this->cid;
-
- GCEVENT gce = {0};
- gce.cbSize = sizeof(GCEVENT);
- gce.dwFlags = GC_TCHAR;
- gce.pDest = &gcd;
-
// show window
- gcd.iType = GC_EVENT_CONTROL;
+ GCDEST gcd = { this->ppro->m_szModuleName, this->cid, GC_EVENT_CONTROL };
+ GCEVENT gce = { sizeof(gce), &gcd };
::CallServiceSync(MS_GC_EVENT, WINDOW_VISIBLE, (LPARAM)&gce);
}
@@ -357,13 +343,8 @@ void ChatRoom::LeaveChat() if (this->conversation->RetireFrom())
this->ppro->debugLogW(L"Retired from conversation %s", this->cid);
- GCDEST gcd = { ppro->m_szModuleName, { NULL }, GC_EVENT_CONTROL };
- gcd.ptszID = this->cid;
-
- GCEVENT gce = {0};
- gce.cbSize = sizeof(GCEVENT);
- gce.dwFlags = GC_TCHAR;
- gce.pDest = &gcd;
+ GCDEST gcd = { ppro->m_szModuleName, this->cid, GC_EVENT_CONTROL };
+ GCEVENT gce = { sizeof(gce), &gcd };
::CallServiceSync(MS_GC_EVENT, SESSION_OFFLINE, (LPARAM)&gce);
::CallServiceSync(MS_GC_EVENT, SESSION_TERMINATE, (LPARAM)&gce);
}
@@ -378,28 +359,19 @@ void ChatRoom::LeaveChatAndDelete() if (this->conversation->Delete())
this->ppro->debugLogW(L"Delete conversation %s", this->cid);
- GCDEST gcd = { ppro->m_szModuleName, { NULL }, GC_EVENT_CONTROL };
- gcd.ptszID = this->cid;
-
- GCEVENT gce = {0};
- gce.cbSize = sizeof(GCEVENT);
- gce.dwFlags = GC_TCHAR;
- gce.pDest = &gcd;
+ GCDEST gcd = { ppro->m_szModuleName, this->cid, GC_EVENT_CONTROL };
+ GCEVENT gce = { sizeof(gce), &gcd };
::CallServiceSync(MS_GC_EVENT, SESSION_OFFLINE, (LPARAM)&gce);
::CallServiceSync(MS_GC_EVENT, SESSION_TERMINATE, (LPARAM)&gce);
}
void ChatRoom::SendEvent(const ChatMember &item, int eventType, DWORD timestamp, DWORD flags, DWORD itemData, const wchar_t *status, const wchar_t *message)
{
- GCDEST gcd = { ppro->m_szModuleName, { NULL }, eventType };
- gcd.ptszID = this->cid;
-
bool isMe = this->IsMe(item);
- GCEVENT gce = {0};
- gce.cbSize = sizeof(gce);
- gce.dwFlags = GC_TCHAR | flags;
- gce.pDest = &gcd;
+ GCDEST gcd = { ppro->m_szModuleName, this->cid, eventType };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ gce.dwFlags = flags;
gce.ptszUID = item.GetSid();
gce.ptszNick = !isMe ? item.GetNick() : ::TranslateT("me");
gce.bIsMe = isMe;
@@ -1270,14 +1242,8 @@ void CSkypeProto::CloseAllChatSessions() gci.iItem = i;
if ( !::CallServiceSync(MS_GC_GETINFO, 0, (LPARAM)&gci))
{
- GCDEST gcd = { this->m_szModuleName, { NULL }, GC_EVENT_CONTROL };
- gcd.ptszID = gci.pszID;
-
- GCEVENT gce = {0};
- gce.cbSize = sizeof(GCEVENT);
- gce.dwFlags = GC_TCHAR;
- gce.pDest = &gcd;
-
+ GCDEST gcd = { this->m_szModuleName, gci.pszID, GC_EVENT_CONTROL };
+ GCEVENT gce = { sizeof(gce), &gcd };
::CallServiceSync(MS_GC_EVENT, SESSION_OFFLINE, (LPARAM)&gce);
::CallServiceSync(MS_GC_EVENT, SESSION_TERMINATE, (LPARAM)&gce);
}
diff --git a/protocols/SkypeClassic/src/gchat.cpp b/protocols/SkypeClassic/src/gchat.cpp index c9f5e5e97f..815521e699 100644 --- a/protocols/SkypeClassic/src/gchat.cpp +++ b/protocols/SkypeClassic/src/gchat.cpp @@ -109,12 +109,11 @@ gchat_contact *GetChatContact(gchat_contacts *gc, const TCHAR *who) { -2 = On failure
>=0 = Number of added item
*/
-static int AddChatContact(gchat_contacts *gc, char *who, TCHAR *pszRole) {
+static int AddChatContact(gchat_contacts *gc, char *who, TCHAR *pszRole)
+{
int i = -2;
HANDLE hContact;
- GCDEST gcd = {0};
- GCEVENT gce = {0};
- CONTACTINFO ci = {0};
+ CONTACTINFO ci = {0};
TCHAR *twho;
LOG (("AddChatContact %s", who));
@@ -123,15 +122,11 @@ static int AddChatContact(gchat_contacts *gc, char *who, TCHAR *pszRole) { if ((i=ExistsChatContact(gc, twho))>=0) return i;
hContact=find_contact(who);
- gcd.pszModule = SKYPE_PROTONAME;
- gcd.ptszID = gc->szChatName;
- gcd.iType = GC_EVENT_JOIN;
-
- gce.cbSize = sizeof(GCEVENT);
- gce.pDest = &gcd;
- gce.ptszStatus = pszRole?pszRole:_T("USER");
+ GCDEST gcd = { SKYPE_PROTONAME, gc->szChatName, GC_EVENT_JOIN };
+ GCEVENT gce = { sizeof(gce), &gcd };
gce.time = (DWORD)time(NULL);
- gce.dwFlags = GCEF_ADDTOLOG | GC_TCHAR;
+ gce.dwFlags = GCEF_ADDTOLOG;
+ gce.ptszStatus = pszRole ? pszRole : _T("USER");
ci.cbSize = sizeof(ci);
ci.szProto = SKYPE_PROTONAME;
@@ -279,17 +274,10 @@ int __cdecl AddMembers(char *szSkypeMsg) { }
// Quit contacts which are no longer there
if (iRet == 0 && contactmask) {
- GCDEST gcd = {0};
- GCEVENT gce = {0};
-
- gcd.pszModule = SKYPE_PROTONAME;
- gcd.ptszID = szChatId;
- gcd.iType = GC_EVENT_QUIT;
-
- gce.cbSize = sizeof(GCEVENT);
- gce.pDest = &gcd;
+ GCDEST gcd = { SKYPE_PROTONAME, szChatId, GC_EVENT_QUIT };
+ GCEVENT gce = { sizeof(gce), &gcd };
gce.time = (DWORD)time(NULL);
- gce.dwFlags = GCEF_ADDTOLOG | GC_TCHAR;
+ gce.dwFlags = GCEF_ADDTOLOG;
ci.cbSize = sizeof(ci);
ci.szProto = SKYPE_PROTONAME;
@@ -373,22 +361,18 @@ INT_PTR CALLBACK InputBoxDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l lParam = 1 - Create groupchat, but don't open it
0 - Default - open groupchat after init
*/
-int __cdecl ChatInit(WPARAM wParam, LPARAM lParam) {
- GCSESSION gcw = {0};
- GCEVENT gce = {0};
- GCDEST gcd = {0};
+
+int __cdecl ChatInit(WPARAM wParam, LPARAM lParam)
+{
DBVARIANT dbv, dbv2;
char *szChatName;
int iRet = -1;
- UNREFERENCED_PARAMETER(lParam);
-
if (!wParam) return -1;
- gcw.cbSize = sizeof(GCSESSION);
+ GCSESSION gcw = { sizeof(gcw) };
gcw.iType = GCW_CHATROOM;
gcw.pszModule = SKYPE_PROTONAME;
- gcw.dwFlags = GC_TCHAR;
if (!(szChatName = SkypeGet ("CHAT", (char *)wParam, "FRIENDLYNAME")) || !*szChatName)
gcw.ptszName=TranslateT("Unknown"); else {
@@ -401,18 +385,14 @@ int __cdecl ChatInit(WPARAM wParam, LPARAM lParam) { #endif
}
gcw.ptszID = make_nonutf_tchar_string((const unsigned char*)wParam);
- gcw.pszStatusbarText = NULL;
+ gcw.ptszStatusbarText = NULL;
EnterCriticalSection(&m_GCMutex);
if (!CallService(MS_GC_NEWSESSION, 0, (LPARAM)&gcw)) {
char *szChatRole;
- gce.cbSize = sizeof(GCEVENT);
- gcd.pszModule = SKYPE_PROTONAME;
- gcd.ptszID = (TCHAR*)gcw.ptszID;
- gcd.iType = GC_EVENT_ADDGROUP;
- gce.pDest = &gcd;
+ GCDEST gcd = { SKYPE_PROTONAME, (TCHAR*)gcw.ptszID, GC_EVENT_ADDGROUP };
+ GCEVENT gce = { sizeof(gce), &gcd };
gce.ptszStatus = _T("CREATOR");
- gce.dwFlags = GC_TCHAR;
// BUG: Groupchat returns nonzero on success here in earlier versions, so we don't check
// it here
CallService(MS_GC_EVENT, 0, (LPARAM)&gce);
@@ -450,15 +430,15 @@ int __cdecl ChatInit(WPARAM wParam, LPARAM lParam) { gce.bIsMe = TRUE;
gce.dwFlags |= GCEF_ADDTOLOG;
if (!CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce)) {
- gce.cbSize = sizeof(GCEVENT);
gcd.iType = GC_EVENT_CONTROL;
- gce.pDest = &gcd;
- if (!lParam) CallService(MS_GC_EVENT, SESSION_INITDONE, (LPARAM)&gce);
+ if (!lParam)
+ CallService(MS_GC_EVENT, SESSION_INITDONE, (LPARAM)&gce);
CallService(MS_GC_EVENT, SESSION_ONLINE, (LPARAM)&gce);
- CallService(MS_GC_EVENT, lParam?WINDOW_HIDDEN:WINDOW_VISIBLE, (LPARAM)&gce);
+ CallService(MS_GC_EVENT, lParam ? WINDOW_HIDDEN : WINDOW_VISIBLE, (LPARAM)&gce);
SkypeSend ("GET CHAT %s MEMBERS", (char *)wParam);
iRet = 0;
- } else {LOG (("ChatInit: Joining 'me' failed."));}
+ }
+ else {LOG (("ChatInit: Joining 'me' failed."));}
}
db_free(&dbv2);
}
@@ -482,14 +462,11 @@ int __cdecl ChatStart(char *szChatId, BOOL bJustCreate) { }
-void KillChatSession(GCDEST *gcd) {
- GCEVENT gce = {0};
-
+void KillChatSession(GCDEST *gcd)
+{
+ GCEVENT gce = { sizeof(gce), gcd };
EnterCriticalSection(&m_GCMutex);
LOG(("KillChatSession: Groupchatsession terminated."));
- gce.cbSize = sizeof(GCEVENT);
- gce.dwFlags = GC_TCHAR;
- gce.pDest = gcd;
gcd->iType = GC_EVENT_CONTROL;
if (SkypeSend ("ALTER CHAT "STR" LEAVE", gcd->ptszID) == 0)
{
@@ -499,7 +476,8 @@ void KillChatSession(GCDEST *gcd) { LeaveCriticalSection(&m_GCMutex);
}
-void InviteUser(TCHAR *szChatId) {
+void InviteUser(TCHAR *szChatId)
+{
HMENU tMenu = CreatePopupMenu();
HANDLE hContact = db_find_first(), hInvitedUser;
DBVARIANT dbv;
@@ -557,21 +535,13 @@ static void KickUser (HANDLE hContact, GCHOOK *gch) if (SkypeSend ("ALTER CHAT "STR" KICK "STR, gch->pDest->ptszID, gch->ptszUID)!=-1) {
if (ptr=SkypeRcv("ALTER CHAT KICK", 2000)) {
if (strncmp(ptr, "ERROR", 5)) {
- GCDEST gcd = {0};
- GCEVENT gce = {0};
- CONTACTINFO ci = {0};
- DBVARIANT dbv;
-
- gcd.pszModule = SKYPE_PROTONAME;
- gcd.ptszID = (TCHAR*)gch->pDest->ptszID;
- gcd.iType = GC_EVENT_KICK;
-
- gce.cbSize = sizeof(GCEVENT);
- gce.pDest = &gcd;
+ GCDEST gcd = { SKYPE_PROTONAME, (TCHAR*)gch->pDest->ptszID, GC_EVENT_KICK };
+ GCEVENT gce = { sizeof(gce), &gcd };
gce.time = (DWORD)time(NULL);
- gce.dwFlags = GCEF_ADDTOLOG | GC_TCHAR;
- gce.ptszUID= gch->ptszUID;
+ gce.dwFlags = GCEF_ADDTOLOG;
+ gce.ptszUID = gch->ptszUID;
+ CONTACTINFO ci = {0};
ci.cbSize = sizeof(ci);
ci.szProto = SKYPE_PROTONAME;
ci.dwFlag = CNF_DISPLAY | CNF_TCHAR;
@@ -579,6 +549,7 @@ static void KickUser (HANDLE hContact, GCHOOK *gch) if (hContact && !CallService(MS_CONTACT_GETCONTACTINFO,0,(LPARAM)&ci)) gce.ptszNick=ci.pszVal;
else gce.ptszNick=gce.ptszUID;
+ DBVARIANT dbv;
if (!db_get_ts(NULL, SKYPE_PROTONAME, "Nick", &dbv)) {
gce.ptszStatus = dbv.ptszVal;
CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
@@ -595,21 +566,16 @@ static void KickUser (HANDLE hContact, GCHOOK *gch) void SetChatTopic (TCHAR *szChatId, TCHAR *szTopic, BOOL bSet)
{
- GCDEST gcd = {0};
- GCEVENT gce = {0};
HANDLE hContact = find_chat (szChatId);
char *szUTFTopic;
- gce.cbSize = sizeof(GCEVENT);
- gcd.pszModule = SKYPE_PROTONAME;
- gcd.ptszID = szChatId;
- gcd.iType = GC_EVENT_TOPIC;
- gce.pDest = &gcd;
+ GCDEST gcd = { SKYPE_PROTONAME, szChatId, GC_EVENT_TOPIC };
+ GCEVENT gce = { sizeof(gce), &gcd };
gce.ptszText = szTopic;
- gce.dwFlags = GCEF_ADDTOLOG | GC_TCHAR;
+ gce.dwFlags = GCEF_ADDTOLOG;
gce.time = (DWORD)time (NULL);
- gce.dwFlags = GC_TCHAR;
CallService(MS_GC_EVENT, 0, (LPARAM)&gce);
+
gcd.iType = GC_EVENT_SETSBTEXT;
CallService(MS_GC_EVENT, 0, (LPARAM)&gce);
@@ -665,8 +631,6 @@ int GCEventHook(WPARAM wParam,LPARAM lParam) { if(gch && gch->ptszText && _tcslen(gch->ptszText) > 0) {
DBVARIANT dbv, dbv2;
CCSDATA ccs = {0};
- GCDEST gcd = {0};
- GCEVENT gce = {0};
TCHAR *pEnd;
// remove the ending linebreak
@@ -698,8 +662,8 @@ int GCEventHook(WPARAM wParam,LPARAM lParam) { }
// Add our line to the chatlog
- gcd.pszModule = gch->pDest->pszModule;
- gcd.ptszID = gch->pDest->ptszID;
+ GCDEST gcd = { gch->pDest->pszModule, gch->pDest->ptszID, 0 };
+ GCEVENT gce = { sizeof(gce), &gcd };
if ( _tcsncmp(gch->ptszText, _T("/me "), 4)==0 && _tcslen(gch->ptszText)>4) {
gce.ptszText = gch->ptszText+4;
gcd.iType = GC_EVENT_ACTION;
@@ -709,14 +673,14 @@ int GCEventHook(WPARAM wParam,LPARAM lParam) { gcd.iType = GC_EVENT_MESSAGE;
}
- gce.cbSize = sizeof(GCEVENT);
- gce.pDest = &gcd;
- if (db_get_ts(NULL, SKYPE_PROTONAME, "Nick", &dbv)) gce.ptszNick=TranslateT("Me");
- else gce.ptszNick = dbv.ptszVal;
+ if (db_get_ts(NULL, SKYPE_PROTONAME, "Nick", &dbv))
+ gce.ptszNick = TranslateT("Me");
+ else
+ gce.ptszNick = dbv.ptszVal;
db_get_ts(NULL, SKYPE_PROTONAME, SKYPE_NAME, &dbv2);
gce.ptszUID = dbv2.ptszVal;
gce.time = (DWORD)time(NULL);
- gce.dwFlags = GCEF_ADDTOLOG | GC_TCHAR;
+ gce.dwFlags = GCEF_ADDTOLOG;
gce.bIsMe = TRUE;
CallService(MS_GC_EVENT, 0, (LPARAM)&gce);
if (dbv.pszVal) db_free(&dbv);
@@ -864,11 +828,7 @@ INT_PTR GCOnLeaveChat(WPARAM wParam,LPARAM lParam) if (db_get_ts(hContact, SKYPE_PROTONAME, "ChatRoomID", &dbv) == 0)
{
- GCDEST gcd = {0};
-
- gcd.pszModule = SKYPE_PROTONAME;
- gcd.iType = GC_EVENT_CONTROL;
- gcd.ptszID = dbv.ptszVal;
+ GCDEST gcd = { SKYPE_PROTONAME, dbv.ptszVal, GC_EVENT_CONTROL };
KillChatSession(&gcd);
db_free(&dbv);
}
diff --git a/protocols/SkypeClassic/src/skype.cpp b/protocols/SkypeClassic/src/skype.cpp index 9803ef549f..2c2d6ef737 100644 --- a/protocols/SkypeClassic/src/skype.cpp +++ b/protocols/SkypeClassic/src/skype.cpp @@ -820,18 +820,16 @@ int OnModulesLoaded(WPARAM wParam, LPARAM lParam) { add_contextmenu(NULL);
if ( ServiceExists( MS_GC_REGISTER ))
{
- GCREGISTER gcr = {0};
static COLORREF crCols[1] = {0};
char szEvent[MAXMODULELABELLENGTH];
- gcr.cbSize = sizeof( GCREGISTER );
- gcr.dwFlags = GC_CHANMGR | GC_TCHAR; // |GC_ACKMSG; // TODO: Not implemented yet
- gcr.ptszModuleDispName = _T("Skype protocol");
+ GCREGISTER gcr = { sizeof(gcr) };
+ gcr.dwFlags = GC_CHANMGR; // |GC_ACKMSG; // TODO: Not implemented yet
+ gcr.ptszDispName = _T("Skype protocol");
gcr.pszModule = SKYPE_PROTONAME;
if (CallService(MS_GC_REGISTER, 0, (LPARAM)&gcr))
- {
OUTPUT(_T("Unable to register with Groupchat module!"));
- }
+
_snprintf (szEvent, sizeof(szEvent), "%s\\ChatInit", SKYPE_PROTONAME);
hInitChat = CreateHookableEvent(szEvent);
hEvInitChat = HookEvent(szEvent, ChatInit);
@@ -925,20 +923,14 @@ void FetchMessageThread(fetchmsg_arg *pargs) { }
if (!strcmp(type,"KICKED"))
{
- GCDEST gcd = {0};
- GCEVENT gce = {0};
- CONTACTINFO ci = {0};
-
if (!hChat) __leave;
- gcd.pszModule = SKYPE_PROTONAME;
- gcd.ptszID = make_nonutf_tchar_string((const unsigned char*)chat);
- gcd.iType = GC_EVENT_KICK;
- gce.cbSize = sizeof(GCEVENT);
- gce.pDest = &gcd;
- gce.dwFlags = GCEF_ADDTOLOG | GC_TCHAR;
+ GCDEST gcd = { SKYPE_PROTONAME, make_nonutf_tchar_string((const unsigned char*)chat), GC_EVENT_KICK };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ gce.dwFlags = GCEF_ADDTOLOG;
gce.time = timestamp;
if (users=SkypeGetErr (cmdMessage, args.msgnum, "USERS")) {
+ CONTACTINFO ci = {0};
ci.hContact = find_contact(users);
gce.ptszUID= make_nonutf_tchar_string((const unsigned char*)users);
if (who=SkypeGetErr (cmdMessage, args.msgnum, szPartnerHandle)) {
@@ -961,9 +953,6 @@ void FetchMessageThread(fetchmsg_arg *pargs) { }
if (!strcmp(type,"SETROLE"))
{
- GCDEST gcd = {0};
- GCEVENT gce = {0};
- CONTACTINFO ci = {0};
gchat_contact *gcContact;
char *pszRole;
@@ -971,17 +960,15 @@ void FetchMessageThread(fetchmsg_arg *pargs) { // USERS - Wessen Rolle wurde gesetzt
// ROLE - Die neue Rolle
if (!hChat) __leave;
- gcd.pszModule = SKYPE_PROTONAME;
- gcd.ptszID = make_nonutf_tchar_string((const unsigned char*)chat);
- gcd.iType = GC_EVENT_REMOVESTATUS;
- gce.cbSize = sizeof(GCEVENT);
- gce.pDest = &gcd;
- gce.dwFlags = GCEF_ADDTOLOG | GC_TCHAR;
+ GCDEST gcd = { SKYPE_PROTONAME, make_nonutf_tchar_string((const unsigned char*)chat), GC_EVENT_REMOVESTATUS };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ gce.dwFlags = GCEF_ADDTOLOG;
gce.time = timestamp;
if (users=SkypeGetErr (cmdMessage, args.msgnum, "USERS")) {
gce.ptszUID= make_nonutf_tchar_string((const unsigned char*)users);
if (who=SkypeGetErr (cmdMessage, args.msgnum, szPartnerHandle)) {
+ CONTACTINFO ci = {0};
ci.cbSize = sizeof(ci);
ci.szProto = SKYPE_PROTONAME;
ci.dwFlag = CNF_DISPLAY | CNF_TCHAR;
@@ -1019,19 +1006,13 @@ void FetchMessageThread(fetchmsg_arg *pargs) { }
if (!strcmp(type,"SETTOPIC"))
{
- GCDEST gcd = {0};
- GCEVENT gce = {0};
- CONTACTINFO ci = {0};
-
LOG(("FetchMessageThread CHAT SETTOPIC"));
- gcd.pszModule = SKYPE_PROTONAME;
- gcd.ptszID = make_nonutf_tchar_string((const unsigned char*)chat);
- gcd.iType = GC_EVENT_TOPIC;
- gce.cbSize = sizeof(GCEVENT);
- gce.pDest = &gcd;
- gce.dwFlags = GCEF_ADDTOLOG | GC_TCHAR;
+ GCDEST gcd = { SKYPE_PROTONAME, make_nonutf_tchar_string((const unsigned char*)chat), GC_EVENT_TOPIC };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ gce.dwFlags = GCEF_ADDTOLOG;
gce.time = timestamp;
if (who=SkypeGetErr (cmdMessage, args.msgnum, szPartnerHandle)) {
+ CONTACTINFO ci = {0};
ci.hContact = find_contact(who);
gce.ptszUID = make_nonutf_tchar_string((const unsigned char*)who);
ci.cbSize = sizeof(ci);
@@ -1059,19 +1040,13 @@ void FetchMessageThread(fetchmsg_arg *pargs) { }
if (!strcmp(type,"LEFT") || (bAddedMembers = strcmp(type,"ADDEDMEMBERS")==0))
{
- GCDEST gcd = {0};
- GCEVENT gce = {0};
- CONTACTINFO ci = {0};
char *pszInvited = Translate("invited ");
LOG(("FetchMessageThread CHAT LEFT or ADDEDMEMBERS"));
if (bAddedMembers) {
- gcd.pszModule = SKYPE_PROTONAME;
- gcd.ptszID = make_nonutf_tchar_string((const unsigned char*)chat);
- gcd.iType = GC_EVENT_ACTION;
- gce.cbSize = sizeof(GCEVENT);
- gce.pDest = &gcd;
- gce.dwFlags = GCEF_ADDTOLOG | GC_TCHAR;
+ GCDEST gcd = { SKYPE_PROTONAME, make_nonutf_tchar_string((const unsigned char*)chat), GC_EVENT_ACTION };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ gce.dwFlags = GCEF_ADDTOLOG;
gce.time = timestamp;
if (users=SkypeGetErr (cmdMessage, args.msgnum, "USERS")) {
// We assume that users buffer has enough room for "invited" string
@@ -1080,18 +1055,22 @@ void FetchMessageThread(fetchmsg_arg *pargs) { gce.ptszText= make_tchar_string((const unsigned char*)users);
if (who=SkypeGetErr (cmdMessage, args.msgnum, szPartnerHandle)) {
DBVARIANT dbv;
-
if (db_get_s(NULL, SKYPE_PROTONAME, SKYPE_NAME, &dbv)==0) {
gce.bIsMe = strcmp(who, dbv.pszVal)==0;
db_free(&dbv);
}
- if (!gce.bIsMe) ci.hContact = find_contact(who);
- gce.ptszUID= make_nonutf_tchar_string((const unsigned char*)who);
+ gce.ptszUID = make_nonutf_tchar_string((const unsigned char*)who);
+
+ CONTACTINFO ci = {0};
ci.cbSize = sizeof(ci);
+ if (!gce.bIsMe)
+ ci.hContact = find_contact(who);
ci.szProto = SKYPE_PROTONAME;
ci.dwFlag = CNF_DISPLAY | CNF_TCHAR;
- if (!CallService(MS_CONTACT_GETCONTACTINFO,0,(LPARAM)&ci)) gce.ptszNick=ci.pszVal;
- else gce.ptszNick=gce.ptszUID;
+ if (!CallService(MS_CONTACT_GETCONTACTINFO,0,(LPARAM)&ci))
+ gce.ptszNick = ci.pszVal;
+ else
+ gce.ptszNick = gce.ptszUID;
CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
free_nonutf_tchar_string((void*)gce.ptszUID);
@@ -1251,36 +1230,31 @@ void FetchMessageThread(fetchmsg_arg *pargs) { bHasPartList) || msgptr[0]==0) __leave;
if (isGroupChat && bUseGroupChat) {
- GCDEST gcd = {0};
- GCEVENT gce = {0};
DBVARIANT dbv = {0};
- CONTACTINFO ci = {0};
LOG(("FetchMessageThread This is a group chat message"));
if (!hChat) ChatStart(chat, FALSE);
- gcd.pszModule = SKYPE_PROTONAME;
- gcd.ptszID = make_nonutf_tchar_string((const unsigned char*)chat);
- gcd.iType = bEmoted?GC_EVENT_ACTION:GC_EVENT_MESSAGE;
- gce.cbSize = sizeof(GCEVENT);
- gce.pDest = &gcd;
- if ((gce.bIsMe = (direction&DBEF_SENT)?TRUE:FALSE) &&
- db_get_s(NULL, SKYPE_PROTONAME, SKYPE_NAME, &dbv)==0)
+ GCDEST gcd = { SKYPE_PROTONAME, make_nonutf_tchar_string((const unsigned char*)chat), bEmoted ? GC_EVENT_ACTION : GC_EVENT_MESSAGE };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ if ((gce.bIsMe = (direction&DBEF_SENT)?TRUE:FALSE) && db_get_s(NULL, SKYPE_PROTONAME, SKYPE_NAME, &dbv)==0)
{
free(who);
who = _strdup(dbv.pszVal);
db_free(&dbv);
}
gce.ptszUID = make_nonutf_tchar_string((const unsigned char*)who);
+ gce.ptszNick = gce.ptszUID;
+
+ CONTACTINFO ci = {0};
ci.cbSize = sizeof(ci);
ci.szProto = SKYPE_PROTONAME;
ci.dwFlag = CNF_DISPLAY | CNF_TCHAR;
- ci.hContact = !gce.bIsMe?hContact:NULL;
- gce.ptszNick=gce.ptszUID;
- if (!CallService(MS_CONTACT_GETCONTACTINFO,0,(LPARAM)&ci)) gce.ptszNick=ci.pszVal;
- gce.time = timestamp>0?timestamp:(DWORD)SkypeTime(NULL);
- gce.pszText = msgptr;
- if (pre.flags & PREF_UNICODE) gce.pszText += msglen;
- gce.dwFlags = GCEF_ADDTOLOG | GC_TCHAR;
+ ci.hContact = !gce.bIsMe ? hContact : NULL;
+ if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci))
+ gce.ptszNick = ci.pszVal;
+ gce.time = timestamp > 0 ? timestamp : (DWORD)SkypeTime(NULL);
+ gce.ptszText = (TCHAR*)(msgptr+msglen);
+ gce.dwFlags = GCEF_ADDTOLOG;
CallService(MS_GC_EVENT, 0, (LPARAM)&gce);
MsgList_Add (pre.lParam, INVALID_HANDLE_VALUE); // Mark as groupchat
if (ci.pszVal) mir_free (ci.pszVal);
@@ -2119,19 +2093,12 @@ LONG APIENTRY WndProc(HWND hWndDlg, UINT message, UINT wParam, LONG lParam) *ptr=0;
if (hContact = find_chatA(szSkypeMsg+5))
{
- GCDEST gcd = {0};
- GCEVENT gce = {0};
-
if (db_get_w(hContact, SKYPE_PROTONAME, "Status", ID_STATUS_OFFLINE) !=
ID_STATUS_OFFLINE)
{
- gcd.pszModule = SKYPE_PROTONAME;
- gcd.ptszID = make_nonutf_tchar_string((const unsigned char*)szSkypeMsg+5);
- gcd.iType = GC_EVENT_CHANGESESSIONAME;
- gce.cbSize = sizeof(GCEVENT);
- gce.pDest = &gcd;
+ GCDEST gcd = { SKYPE_PROTONAME, make_nonutf_tchar_string((const unsigned char*)szSkypeMsg+5), GC_EVENT_CHANGESESSIONAME };
+ GCEVENT gce = { sizeof(gce), &gcd };
gce.ptszText = make_tchar_string((const unsigned char*)ptr+14);
- gce.dwFlags = GC_TCHAR;
if (gce.ptszText) {
CallService(MS_GC_EVENT, 0, (LPARAM)&gce);
db_set_ts (hContact, SKYPE_PROTONAME, "Nick", gce.ptszText);
diff --git a/protocols/SkypeClassic/src/skypeopt.cpp b/protocols/SkypeClassic/src/skypeopt.cpp index db077b8b74..75b90967f2 100644 --- a/protocols/SkypeClassic/src/skypeopt.cpp +++ b/protocols/SkypeClassic/src/skypeopt.cpp @@ -416,8 +416,10 @@ INT_PTR CALLBACK OptionsProxyDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPA case WM_COMMAND: {
switch (LOWORD(wParam)) {
case IDC_USES2S:
- for (i=0; i<sizeof(Skype2SocketControls)/sizeof(Skype2SocketControls[0]); i++) EnableWindow(GetDlgItem(hwndDlg, Skype2SocketControls[i]), SendMessage(GetDlgItem(hwndDlg, LOWORD(wParam)), BM_GETCHECK,0,0));
- if (SendMessage(GetDlgItem(hwndDlg, LOWORD(wParam)), BM_GETCHECK,0,0)) SendMessage(hwndDlg, WM_COMMAND, IDC_REQPASS, 0);
+ for (i=0; i < SIZEOF(Skype2SocketControls); i++)
+ EnableWindow(GetDlgItem(hwndDlg, Skype2SocketControls[i]), SendMessage(GetDlgItem(hwndDlg, LOWORD(wParam)), BM_GETCHECK,0,0));
+ if (SendMessage(GetDlgItem(hwndDlg, LOWORD(wParam)), BM_GETCHECK,0,0))
+ SendMessage(hwndDlg, WM_COMMAND, IDC_REQPASS, 0);
break;
case IDC_REQPASS:
EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), SendMessage(GetDlgItem(hwndDlg, LOWORD(wParam)), BM_GETCHECK,0,0));
diff --git a/protocols/Twitter/src/chat.cpp b/protocols/Twitter/src/chat.cpp index e657414295..cddcbcefca 100644 --- a/protocols/Twitter/src/chat.cpp +++ b/protocols/Twitter/src/chat.cpp @@ -22,16 +22,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. void TwitterProto::UpdateChat(const twitter_user &update)
{
- GCDEST gcd = { m_szModuleName };
- gcd.ptszID = const_cast<TCHAR*>(m_tszUserName);
- gcd.iType = GC_EVENT_MESSAGE;
-
- GCEVENT gce = {sizeof(gce)};
- gce.pDest = &gcd;
- gce.dwFlags = GC_TCHAR|GCEF_ADDTOLOG;
- gce.pDest = &gcd;
- gce.ptszUID = mir_a2t(update.username.c_str());
- gce.bIsMe = (update.username == twit_.get_username());
+ GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_MESSAGE };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ gce.pDest = &gcd;
+ gce.bIsMe = (update.username == twit_.get_username());
+ gce.dwFlags = GCEF_ADDTOLOG;
+ gce.ptszUID = mir_a2t(update.username.c_str());
//TODO: write code here to replace % with %% in update.status.text (which is a std::string)
std::string chatText = update.status.text;
@@ -93,18 +89,12 @@ int TwitterProto::OnChatOutgoing(WPARAM wParam,LPARAM lParam) // TODO: remove nick?
void TwitterProto::AddChatContact(const char *name,const char *nick)
{
- GCDEST gcd = { m_szModuleName };
- gcd.ptszID = const_cast<TCHAR*>(m_tszUserName);
- gcd.iType = GC_EVENT_JOIN;
-
- GCEVENT gce = {sizeof(gce)};
- gce.pDest = &gcd;
- gce.dwFlags = GC_TCHAR;
- gce.ptszNick = mir_a2t(nick ? nick:name);
- gce.ptszUID = mir_a2t(name);
- gce.bIsMe = false;
+ GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_JOIN };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ gce.time = DWORD(time(0));
+ gce.ptszNick = mir_a2t(nick ? nick:name);
+ gce.ptszUID = mir_a2t(name);
gce.ptszStatus = _T("Normal");
- gce.time = static_cast<DWORD>(time(0));
CallServiceSync(MS_GC_EVENT,0,reinterpret_cast<LPARAM>(&gce));
mir_free(const_cast<TCHAR*>(gce.ptszNick));
@@ -113,16 +103,11 @@ void TwitterProto::AddChatContact(const char *name,const char *nick) void TwitterProto::DeleteChatContact(const char *name)
{
- GCDEST gcd = { m_szModuleName };
- gcd.ptszID = const_cast<TCHAR*>(m_tszUserName);
- gcd.iType = GC_EVENT_PART;
-
- GCEVENT gce = {sizeof(gce)};
- gce.pDest = &gcd;
- gce.dwFlags = GC_TCHAR;
- gce.ptszNick = mir_a2t(name);
- gce.ptszUID = gce.ptszNick;
- gce.time = static_cast<DWORD>(time(0));
+ GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_PART };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ gce.time = DWORD(time(0));
+ gce.ptszNick = mir_a2t(name);
+ gce.ptszUID = gce.ptszNick;
CallServiceSync(MS_GC_EVENT,0,reinterpret_cast<LPARAM>(&gce));
mir_free(const_cast<TCHAR*>(gce.ptszNick));
@@ -130,28 +115,20 @@ void TwitterProto::DeleteChatContact(const char *name) INT_PTR TwitterProto::OnJoinChat(WPARAM,LPARAM suppress)
{
- GCSESSION gcw = {sizeof(gcw)};
-
// ***** Create the group chat session
- gcw.dwFlags = GC_TCHAR;
- gcw.iType = GCW_CHATROOM;
+ GCSESSION gcw = { sizeof(gcw) };
+ gcw.iType = GCW_CHATROOM;
gcw.pszModule = m_szModuleName;
- gcw.ptszName = m_tszUserName;
- gcw.ptszID = m_tszUserName;
+ gcw.ptszName = m_tszUserName;
+ gcw.ptszID = m_tszUserName;
CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM)&gcw);
if(m_iStatus != ID_STATUS_ONLINE)
return 0;
// ***** Create a group
- GCDEST gcd = { m_szModuleName };
- gcd.ptszID = const_cast<TCHAR*>(m_tszUserName);
-
- GCEVENT gce = {sizeof(gce)};
- gce.pDest = &gcd;
- gce.dwFlags = GC_TCHAR;
-
- gcd.iType = GC_EVENT_ADDGROUP;
+ GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_ADDGROUP };
+ GCEVENT gce = { sizeof(gce), &gcd };
gce.ptszStatus = _T("Normal");
CallServiceSync(MS_GC_EVENT,0,reinterpret_cast<LPARAM>(&gce));
@@ -170,29 +147,18 @@ INT_PTR TwitterProto::OnLeaveChat(WPARAM,LPARAM) {
in_chat_ = false;
- GCDEST gcd = { m_szModuleName };
- gcd.ptszID = const_cast<TCHAR*>(m_tszUserName);
- gcd.iType = GC_EVENT_CONTROL;
-
- GCEVENT gce = {sizeof(gce)};
- gce.dwFlags = GC_TCHAR;
- gce.pDest = &gcd;
+ GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_CONTROL };
+ GCEVENT gce = { sizeof(gce), &gcd };
CallServiceSync(MS_GC_EVENT,SESSION_OFFLINE, reinterpret_cast<LPARAM>(&gce));
CallServiceSync(MS_GC_EVENT,SESSION_TERMINATE,reinterpret_cast<LPARAM>(&gce));
-
return 0;
}
void TwitterProto::SetChatStatus(int status)
{
- GCDEST gcd = { m_szModuleName };
- gcd.ptszID = const_cast<TCHAR*>(m_tszUserName);
- gcd.iType = GC_EVENT_CONTROL;
-
- GCEVENT gce = {sizeof(gce)};
- gce.dwFlags = GC_TCHAR;
- gce.pDest = &gcd;
+ GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_CONTROL };
+ GCEVENT gce = { sizeof(gce), &gcd };
if(status == ID_STATUS_ONLINE)
{
diff --git a/protocols/Twitter/src/proto.cpp b/protocols/Twitter/src/proto.cpp index d90c67b6e1..35ca3af92f 100644 --- a/protocols/Twitter/src/proto.cpp +++ b/protocols/Twitter/src/proto.cpp @@ -374,9 +374,9 @@ int TwitterProto::OnModulesLoaded(WPARAM,LPARAM) twit_.set_handle(this, m_hNetlibUser);
- GCREGISTER gcr = {sizeof(gcr)};
+ GCREGISTER gcr = { sizeof(gcr) };
gcr.pszModule = m_szModuleName;
- gcr.pszModuleDispName = m_szModuleName;
+ gcr.ptszDispName = m_tszUserName;
gcr.iMaxText = 159;
CallService(MS_GC_REGISTER,0,reinterpret_cast<LPARAM>(&gcr));
diff --git a/protocols/WhatsApp/src/chat.cpp b/protocols/WhatsApp/src/chat.cpp index e978c9f0ee..63551a953f 100644 --- a/protocols/WhatsApp/src/chat.cpp +++ b/protocols/WhatsApp/src/chat.cpp @@ -43,13 +43,9 @@ int WhatsAppProto::OnChatOutgoing(WPARAM wParam, LPARAM lParam) // #TODO Move to SendMsgWorker, otherwise all messages are "acknowledged" by Miranda
- GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_MESSAGE };
- gcd.ptszID = hook->pDest->ptszID;
-
- GCEVENT gce = {0};
- gce.cbSize = sizeof(GCEVENT);
- gce.dwFlags = GC_TCHAR | GCEF_ADDTOLOG;
- gce.pDest = &gcd;
+ GCDEST gcd = { m_szModuleName, hook->pDest->ptszID, GC_EVENT_MESSAGE };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ gce.dwFlags = GCEF_ADDTOLOG;
gce.ptszNick = mir_a2t(this->nick.c_str());
gce.ptszUID = mir_a2t(this->jid.c_str());
gce.time = time(NULL);
diff --git a/protocols/WhatsApp/src/proto.cpp b/protocols/WhatsApp/src/proto.cpp index 69f5931026..892ad9e373 100644 --- a/protocols/WhatsApp/src/proto.cpp +++ b/protocols/WhatsApp/src/proto.cpp @@ -38,13 +38,9 @@ WhatsAppProto::WhatsAppProto(const char* proto_name, const TCHAR* username) : def_avatar_folder_ = std::tstring( VARST( _T("%miranda_avatarcache%"))) + _T("\\") + m_tszUserName;
// Register group chat
- GCREGISTER gcr = {0};
- gcr.cbSize = sizeof(GCREGISTER);
- gcr.dwFlags = GC_TYPNOTIF | GC_CHANMGR | GC_TCHAR;
- gcr.iMaxText = 0;
- gcr.nColors = 0;
- gcr.pColors = NULL; //(COLORREF*)crCols;
- gcr.ptszModuleDispName = m_tszUserName;
+ GCREGISTER gcr = { sizeof(gcr) };
+ gcr.dwFlags = GC_TYPNOTIF | GC_CHANMGR;
+ gcr.ptszDispName = m_tszUserName;
gcr.pszModule = m_szModuleName;
CallServiceSync(MS_GC_REGISTER, 0, (LPARAM)&gcr);
diff --git a/protocols/Yahoo/src/chat.cpp b/protocols/Yahoo/src/chat.cpp index e4edd7cc3d..0b22d5e23f 100644 --- a/protocols/Yahoo/src/chat.cpp +++ b/protocols/Yahoo/src/chat.cpp @@ -180,13 +180,11 @@ static const COLORREF crCols[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; void CYahooProto::ChatRegister(void)
{
- GCREGISTER gcr = {0};
- gcr.cbSize = sizeof(gcr);
- gcr.dwFlags = GC_TYPNOTIF | GC_CHANMGR | GC_TCHAR;
- gcr.iMaxText = 0;
+ GCREGISTER gcr = { sizeof(gcr) };
+ gcr.dwFlags = GC_TYPNOTIF | GC_CHANMGR;
gcr.nColors = 16;
gcr.pColors = (COLORREF*)crCols;
- gcr.ptszModuleDispName = m_tszUserName;
+ gcr.ptszDispName = m_tszUserName;
gcr.pszModule = m_szModuleName;
CallServiceSync(MS_GC_REGISTER, 0, (LPARAM)&gcr);
@@ -198,22 +196,15 @@ void CYahooProto::ChatStart(const char* room) {
TCHAR* idt = mir_a2t(room);
- GCSESSION gcw = {0};
- gcw.cbSize = sizeof(gcw);
- gcw.dwFlags = GC_TCHAR;
+ GCSESSION gcw = { sizeof(gcw) };
gcw.iType = GCW_CHATROOM;
gcw.pszModule = m_szModuleName;
gcw.ptszName = idt;
gcw.ptszID = idt;
CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM)&gcw);
- GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_ADDGROUP };
- gcd.ptszID = idt;
-
- GCEVENT gce = {0};
- gce.cbSize = sizeof(gce);
- gce.dwFlags = GC_TCHAR;
- gce.pDest = &gcd;
+ GCDEST gcd = { m_szModuleName, idt, GC_EVENT_ADDGROUP };
+ GCEVENT gce = { sizeof(gce), &gcd };
gce.ptszStatus = TranslateT("Me");
CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
@@ -233,13 +224,9 @@ void CYahooProto::ChatLeave(const char* room) {
TCHAR* idt = mir_a2t(room);
- GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_CONTROL };
- gcd.ptszID = idt;
-
- GCEVENT gce = {0};
- gce.cbSize = sizeof(GCEVENT);
- gce.dwFlags = GC_TCHAR | GCEF_REMOVECONTACT;
- gce.pDest = &gcd;
+ GCDEST gcd = { m_szModuleName, idt, GC_EVENT_CONTROL };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ gce.dwFlags = GCEF_REMOVECONTACT;
CallServiceSync(MS_GC_EVENT, SESSION_OFFLINE, (LPARAM)&gce);
CallServiceSync(MS_GC_EVENT, SESSION_TERMINATE, (LPARAM)&gce);
@@ -260,13 +247,9 @@ void CYahooProto::ChatEvent(const char* room, const char* who, int evt, const TC HANDLE hContact = getbuddyH(who);
TCHAR* nick = hContact ? (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, WPARAM(hContact), GCDNF_TCHAR) : snt;
- GCDEST gcd = { m_szModuleName, { NULL }, evt };
- gcd.ptszID = idt;
-
- GCEVENT gce = {0};
- gce.cbSize = sizeof(gce);
- gce.dwFlags = GC_TCHAR | GCEF_ADDTOLOG;
- gce.pDest = &gcd;
+ GCDEST gcd = { m_szModuleName, idt, evt };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ gce.dwFlags = GCEF_ADDTOLOG;
gce.ptszNick = nick;
gce.ptszUID = snt;
gce.bIsMe = _stricmp(who, m_yahoo_id) == 0;
|