summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
Diffstat (limited to 'protocols')
-rw-r--r--protocols/Discord/src/dispatch.cpp28
-rw-r--r--protocols/Discord/src/guilds.cpp5
-rw-r--r--protocols/Discord/src/server.cpp7
-rw-r--r--protocols/FacebookRM/src/chat.cpp64
-rw-r--r--protocols/Gadu-Gadu/src/core.cpp18
-rw-r--r--protocols/Gadu-Gadu/src/groupchat.cpp261
-rw-r--r--protocols/ICQ-WIM/src/groupchats.cpp16
-rw-r--r--protocols/ICQ-WIM/src/server.cpp7
-rw-r--r--protocols/IRCG/src/commandmonitor.cpp11
-rw-r--r--protocols/IRCG/src/tools.cpp16
-rw-r--r--protocols/JabberG/src/jabber_chat.cpp77
-rw-r--r--protocols/JabberG/src/jabber_groupchat.cpp41
-rw-r--r--protocols/MSN/src/msn_chat.cpp54
-rw-r--r--protocols/MinecraftDynmap/src/chat.cpp48
-rw-r--r--protocols/MinecraftDynmap/src/proto.cpp1
-rw-r--r--protocols/MinecraftDynmap/src/proto.h3
-rw-r--r--protocols/Omegle/src/chat.cpp34
-rw-r--r--protocols/Sametime/src/conference.cpp34
-rw-r--r--protocols/SkypeWeb/src/skype_chatrooms.cpp240
-rw-r--r--protocols/SkypeWeb/src/skype_history_sync.cpp2
-rw-r--r--protocols/SkypeWeb/src/skype_proto.h14
-rw-r--r--protocols/Twitter/src/chat.cpp45
-rw-r--r--protocols/Twitter/src/proto.cpp3
-rw-r--r--protocols/Twitter/src/proto.h2
-rw-r--r--protocols/VKontakte/src/vk_chats.cpp34
25 files changed, 504 insertions, 561 deletions
diff --git a/protocols/Discord/src/dispatch.cpp b/protocols/Discord/src/dispatch.cpp
index 57b78c4df9..13441bcf08 100644
--- a/protocols/Discord/src/dispatch.cpp
+++ b/protocols/Discord/src/dispatch.cpp
@@ -143,8 +143,9 @@ void CDiscordProto::OnCommandChannelUpdated(const JSONNode &pRoot)
CMStringW wszTopic = pRoot["topic"].as_mstring();
Chat_SetStatusbarText(m_szModuleName, pUser->wszUsername, wszTopic);
- GCEVENT gce = { m_szModuleName, pUser->wszUsername, GC_EVENT_TOPIC };
- gce.ptszText = wszTopic;
+ GCEVENT gce = { m_szModuleName, 0, GC_EVENT_TOPIC };
+ gce.pszID.w = pUser->wszUsername;
+ gce.pszText.w = wszTopic;
gce.time = time(0);
Chat_Event(&gce);
}
@@ -226,9 +227,10 @@ void CDiscordProto::OnCommandGuildMemberRemoved(const JSONNode &pRoot)
if (pUser->pGuild != pGuild)
continue;
- GCEVENT gce = { m_szModuleName, pUser->wszUsername, GC_EVENT_PART };
+ GCEVENT gce = { m_szModuleName, 0, GC_EVENT_PART };
+ gce.pszUID.w = pUser->wszUsername;
gce.time = time(0);
- gce.ptszUID = wszUserId;
+ gce.pszUID.w = wszUserId;
Chat_Event(&gce);
}
}
@@ -260,11 +262,12 @@ void CDiscordProto::OnCommandGuildMemberUpdated(const JSONNode &pRoot)
wszOldNick = ui->pszNick;
}
- GCEVENT gce = { m_szModuleName, it->wszUsername, GC_EVENT_NICK };
+ GCEVENT gce = { m_szModuleName, 0, GC_EVENT_NICK };
+ gce.pszID.w = it->wszUsername;
gce.time = time(0);
- gce.ptszUID = wszUserId;
- gce.ptszNick = wszOldNick;
- gce.ptszText = gm->wszNick;
+ gce.pszUID.w = wszUserId;
+ gce.pszNick.w = wszOldNick;
+ gce.pszText.w = gm->wszNick;
Chat_Event(&gce);
}
}
@@ -417,15 +420,16 @@ void CDiscordProto::OnCommandMessage(const JSONNode &pRoot, bool bIsNew)
ParseSpecialChars(si, wszText);
- GCEVENT gce = { m_szModuleName, pUser->wszUsername, GC_EVENT_MESSAGE };
+ GCEVENT gce = { m_szModuleName, 0, GC_EVENT_MESSAGE };
+ gce.pszID.w = pUser->wszUsername;
gce.dwFlags = GCEF_ADDTOLOG;
- gce.ptszUID = wszUserId;
- gce.ptszText = wszText;
+ gce.pszUID.w = wszUserId;
+ gce.pszText.w = wszText;
gce.time = (DWORD)StringToDate(pRoot["timestamp"].as_mstring());
gce.bIsMe = bOurMessage;
Chat_Event(&gce);
- debugLogW(L"New channel %s message from %s: %s", si->ptszID, gce.ptszUID, gce.ptszText);
+ debugLogW(L"New channel %s message from %s: %s", si->ptszID, gce.pszUID.w, gce.pszText.w);
}
}
diff --git a/protocols/Discord/src/guilds.cpp b/protocols/Discord/src/guilds.cpp
index 76fafb1918..5cda9d41e8 100644
--- a/protocols/Discord/src/guilds.cpp
+++ b/protocols/Discord/src/guilds.cpp
@@ -112,9 +112,10 @@ void CDiscordProto::CreateChat(CDiscordGuild *pGuild, CDiscordUser *pUser)
if (!pUser->wszTopic.IsEmpty()) {
Chat_SetStatusbarText(m_szModuleName, pUser->wszUsername, pUser->wszTopic);
- GCEVENT gce = { m_szModuleName, pUser->wszUsername, GC_EVENT_TOPIC };
+ GCEVENT gce = { m_szModuleName, 0, GC_EVENT_TOPIC };
+ gce.pszID.w = pUser->wszUsername;
gce.time = time(0);
- gce.ptszText = pUser->wszTopic;
+ gce.pszText.w = pUser->wszTopic;
Chat_Event(&gce);
}
}
diff --git a/protocols/Discord/src/server.cpp b/protocols/Discord/src/server.cpp
index f1d1db3a5e..661e313290 100644
--- a/protocols/Discord/src/server.cpp
+++ b/protocols/Discord/src/server.cpp
@@ -117,10 +117,11 @@ void CDiscordProto::OnReceiveHistory(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest
else {
ParseSpecialChars(si, wszText);
- GCEVENT gce = { m_szModuleName, pUser->wszUsername, GC_EVENT_MESSAGE };
+ GCEVENT gce = { m_szModuleName, 0, GC_EVENT_MESSAGE };
+ gce.pszID.w = pUser->wszUsername;
gce.dwFlags = GCEF_ADDTOLOG;
- gce.ptszUID = wszUserId;
- gce.ptszText = wszText;
+ gce.pszUID.w = wszUserId;
+ gce.pszText.w = wszText;
gce.time = dwTimeStamp;
gce.bIsMe = authorid == m_ownId;
Chat_Event(&gce);
diff --git a/protocols/FacebookRM/src/chat.cpp b/protocols/FacebookRM/src/chat.cpp
index c732567407..30db7ca1dd 100644
--- a/protocols/FacebookRM/src/chat.cpp
+++ b/protocols/FacebookRM/src/chat.cpp
@@ -50,23 +50,18 @@ void FacebookProto::UpdateChat(const char *chat_id, const char *id, const char *
std::string smessage = message;
utils::text::replace_all(&smessage, "%", "%%");
- ptrW tid(mir_a2u(id));
- ptrW tnick(mir_a2u_cp(name, CP_UTF8));
- ptrW ttext(mir_a2u_cp(smessage.c_str(), CP_UTF8));
- ptrW tchat_id(mir_a2u(chat_id));
-
- GCEVENT gce = { m_szModuleName, tchat_id, GC_EVENT_MESSAGE };
- gce.ptszText = ttext;
+ GCEVENT gce = { m_szModuleName, chat_id, GC_EVENT_MESSAGE };
+ gce.pszText.a = smessage.c_str();
gce.time = timestamp ? timestamp : ::time(0);
if (id != nullptr)
gce.bIsMe = !mir_strcmp(id, facy.self_.user_id.c_str());
- gce.dwFlags |= GCEF_ADDTOLOG;
+ gce.dwFlags = GCEF_ADDTOLOG | GCEF_UTF8;
if (is_old) {
gce.dwFlags |= GCEF_NOTNOTIFY;
gce.dwFlags &= ~GCEF_ADDTOLOG;
}
- gce.ptszNick = tnick;
- gce.ptszUID = tid;
+ gce.pszNick.a = name;
+ gce.pszUID.a = id;
Chat_Event(&gce);
facy.erase_reader(ChatIDToHContact(chat_id));
@@ -74,9 +69,7 @@ void FacebookProto::UpdateChat(const char *chat_id, const char *id, const char *
void FacebookProto::RenameChat(const char *chat_id, const char *name)
{
- ptrW tchat_id(mir_a2u(chat_id));
- ptrW tname(mir_a2u_cp(name, CP_UTF8));
- Chat_ChangeSessionName(m_szModuleName, tchat_id, tname);
+ Chat_ChangeSessionName(m_szModuleName, _A2T(chat_id), Utf2T(name));
}
int FacebookProto::OnGCEvent(WPARAM, LPARAM lParam)
@@ -172,30 +165,26 @@ void FacebookProto::AddChatContact(const char *chat_id, const chatroom_participa
if (IsChatContact(chat_id, user.user_id.c_str()))
return;
- ptrW tchat_id(mir_a2u(chat_id));
- ptrW tnick(mir_a2u_cp(user.nick.c_str(), CP_UTF8));
- ptrW tid(mir_a2u(user.user_id.c_str()));
-
- GCEVENT gce = { m_szModuleName, tchat_id, GC_EVENT_JOIN };
- gce.dwFlags = addToLog ? GCEF_ADDTOLOG : 0;
- gce.ptszNick = tnick;
- gce.ptszUID = tid;
+ GCEVENT gce = { m_szModuleName, chat_id, GC_EVENT_JOIN };
+ gce.dwFlags = GCEF_UTF8 + (addToLog ? GCEF_ADDTOLOG : 0);
+ gce.pszNick.a = user.nick.c_str();
+ gce.pszUID.a = user.user_id.c_str();
gce.time = ::time(0);
gce.bIsMe = (user.role == ROLE_ME);
if (user.is_former) {
- gce.ptszStatus = TranslateT("Former");
+ gce.pszStatus.a = TranslateU("Former");
}
else {
switch (user.role) {
case ROLE_ME:
- gce.ptszStatus = TranslateT("Myself");
+ gce.pszStatus.a = TranslateU("Myself");
break;
case ROLE_FRIEND:
- gce.ptszStatus = TranslateT("Friend");
+ gce.pszStatus.a = TranslateU("Friend");
break;
case ROLE_NONE:
- gce.ptszStatus = TranslateT("User");
+ gce.pszStatus.a = TranslateU("User");
break;
}
}
@@ -205,14 +194,10 @@ void FacebookProto::AddChatContact(const char *chat_id, const chatroom_participa
void FacebookProto::RemoveChatContact(const char *chat_id, const char *id, const char *name)
{
- ptrW tchat_id(mir_a2u(chat_id));
- ptrW tnick(mir_a2u_cp(name, CP_UTF8));
- ptrW tid(mir_a2u(id));
-
- GCEVENT gce = { m_szModuleName, tchat_id, GC_EVENT_PART };
- gce.dwFlags = GCEF_ADDTOLOG;
- gce.ptszNick = tnick;
- gce.ptszUID = tid;
+ GCEVENT gce = { m_szModuleName, chat_id, GC_EVENT_PART };
+ gce.dwFlags = GCEF_UTF8 + GCEF_ADDTOLOG;
+ gce.pszNick.a = name;
+ gce.pszUID.a = id;
gce.time = ::time(0);
gce.bIsMe = false;
@@ -387,16 +372,13 @@ void FacebookProto::UpdateNotificationsChatRoom(facebook_notification *notificat
std::string message = text.str();
utils::text::replace_all(&message, "%", "%%");
- ptrW idT(mir_wstrdup(_A2W(FACEBOOK_NOTIFICATIONS_CHATROOM)));
- ptrW messageT(mir_a2u_cp(message.c_str(), CP_UTF8));
-
- GCEVENT gce = { m_szModuleName, _A2W(FACEBOOK_NOTIFICATIONS_CHATROOM), GC_EVENT_MESSAGE };
- gce.ptszText = messageT;
+ GCEVENT gce = { m_szModuleName, FACEBOOK_NOTIFICATIONS_CHATROOM, GC_EVENT_MESSAGE };
+ gce.pszText.a = message.c_str();
gce.time = notification->time ? notification->time : ::time(0);
gce.bIsMe = false;
- gce.dwFlags |= GCEF_ADDTOLOG;
- gce.ptszNick = TranslateT("Notifications");
- gce.ptszUID = idT;
+ gce.dwFlags = GCEF_UTF8 + GCEF_ADDTOLOG;
+ gce.pszNick.a = TranslateU("Notifications");
+ gce.pszUID.a = FACEBOOK_NOTIFICATIONS_CHATROOM;
Chat_Event(&gce);
}
diff --git a/protocols/Gadu-Gadu/src/core.cpp b/protocols/Gadu-Gadu/src/core.cpp
index d9c96a6a97..a65719ad25 100644
--- a/protocols/Gadu-Gadu/src/core.cpp
+++ b/protocols/Gadu-Gadu/src/core.cpp
@@ -814,12 +814,13 @@ retry:
wchar_t id[32];
UIN2IDT(e->event.msg.sender, id);
- GCEVENT gce = { m_szModuleName, chat, GC_EVENT_MESSAGE };
+ GCEVENT gce = { m_szModuleName, 0, GC_EVENT_MESSAGE };
time_t t = time(0);
- gce.ptszUID = id;
+ gce.pszID.w = chat;
+ gce.pszUID.w = id;
wchar_t* messageT = mir_utf8decodeW(e->event.msg.message);
- gce.ptszText = messageT;
- gce.ptszNick = (wchar_t*)Clist_GetContactDisplayName(getcontact(e->event.msg.sender, 1, 0, nullptr));
+ gce.pszText.w = messageT;
+ gce.pszNick.w = (wchar_t*)Clist_GetContactDisplayName(getcontact(e->event.msg.sender, 1, 0, nullptr));
gce.time = (!(e->event.msg.msgclass & GG_CLASS_OFFLINE) || e->event.msg.time > (t - timeDeviation)) ? t : e->event.msg.time;
gce.dwFlags = GCEF_ADDTOLOG;
debugLogW(L"mainthread() (%x): Conference message to room %s & id %s.", this, chat, id);
@@ -875,10 +876,11 @@ retry:
wchar_t id[32];
UIN2IDT(getDword(GG_KEY_UIN, 0), id);
- GCEVENT gce = { m_szModuleName, chat, GC_EVENT_MESSAGE };
- gce.ptszUID = id;
+ GCEVENT gce = { m_szModuleName, 0, GC_EVENT_MESSAGE };
+ gce.pszID.w = chat;
+ gce.pszUID.w = id;
wchar_t* messageT = mir_utf8decodeW(e->event.multilogon_msg.message);
- gce.ptszText = messageT;
+ gce.pszText.w = messageT;
wchar_t* nickT;
if (!getWString(GG_KEY_NICK, &dbv)) {
nickT = mir_wstrdup(dbv.pwszVal);
@@ -887,7 +889,7 @@ retry:
else
nickT = mir_wstrdup(TranslateT("Me"));
- gce.ptszNick = nickT;
+ gce.pszNick.w = nickT;
gce.time = e->event.multilogon_msg.time;
gce.bIsMe = 1;
gce.dwFlags = GCEF_ADDTOLOG;
diff --git a/protocols/Gadu-Gadu/src/groupchat.cpp b/protocols/Gadu-Gadu/src/groupchat.cpp
index aab963f4e9..648bb662a0 100644
--- a/protocols/Gadu-Gadu/src/groupchat.cpp
+++ b/protocols/Gadu-Gadu/src/groupchat.cpp
@@ -82,8 +82,7 @@ void GaduProto::gc_menus_init(HGENMENU hRoot)
int GaduProto::gc_destroy()
{
list_t l;
- for (l = chats; l; l = l->next)
- {
+ for (l = chats; l; l = l->next) {
GGGC *chat = (GGGC *)l->data;
free(chat->recipients);
}
@@ -97,8 +96,7 @@ GGGC* GaduProto::gc_lookup(const wchar_t *id)
GGGC *chat;
list_t l;
- for (l = chats; l; l = l->next)
- {
+ for (l = chats; l; l = l->next) {
chat = (GGGC *)l->data;
if (chat && !mir_wstrcmp(chat->id, id))
return chat;
@@ -123,8 +121,7 @@ int GaduProto::gc_event(WPARAM, LPARAM lParam)
return 0;
// Window terminated (Miranda exit)
- if (gch->iType == SESSION_TERMINATE)
- {
+ if (gch->iType == SESSION_TERMINATE) {
debugLogW(L"gc_event(): Terminating chat %x, id %s from chat window...", chat, gch->ptszID);
// Destroy chat entry
free(chat->recipients);
@@ -150,9 +147,10 @@ int GaduProto::gc_event(WPARAM, LPARAM lParam)
UIN2IDT(uin, id);
DBVARIANT dbv;
- GCEVENT gce = { m_szModuleName, gch->ptszID, GC_EVENT_MESSAGE };
- gce.ptszUID = id;
- gce.ptszText = gch->ptszText;
+ GCEVENT gce = { m_szModuleName, 0, GC_EVENT_MESSAGE };
+ gce.pszID.w = gch->ptszID;
+ gce.pszUID.w = id;
+ gce.pszText.w = gch->ptszText;
wchar_t* nickT;
if (!getWString(GG_KEY_NICK, &dbv)) {
nickT = mir_wstrdup(dbv.pwszVal);
@@ -161,7 +159,7 @@ int GaduProto::gc_event(WPARAM, LPARAM lParam)
else
nickT = mir_wstrdup(TranslateT("Me"));
- gce.ptszNick = nickT;
+ gce.pszNick.w = nickT;
// Get rid of CRLF at back
int lc = (int)mir_wstrlen(gch->ptszText) - 1;
@@ -183,8 +181,7 @@ int GaduProto::gc_event(WPARAM, LPARAM lParam)
}
// Privmessage selected
- if (gch->iType == GC_USER_PRIVMESS)
- {
+ if (gch->iType == GC_USER_PRIVMESS) {
MCONTACT hContact = NULL;
if ((uin = _wtoi(gch->ptszUID)) && (hContact = getcontact(uin, 1, 0, nullptr)))
CallService(MS_MSG_SENDMESSAGE, hContact, 0);
@@ -215,18 +212,15 @@ wchar_t* GaduProto::gc_getchat(uin_t sender, uin_t *recipients, int recipients_c
return nullptr;
// Look for existing chat
- for (l = chats; l; l = l->next)
- {
+ for (l = chats; l; l = l->next) {
chat = (GGGC *)l->data;
if (!chat) continue;
- if (chat->recipients_count == recipients_count + (sender ? 1 : 0))
- {
+ if (chat->recipients_count == recipients_count + (sender ? 1 : 0)) {
int sok = (sender == 0);
if (!sok) {
for (int i = 0; i < chat->recipients_count; i++) {
- if (sender == chat->recipients[i])
- {
+ if (sender == chat->recipients[i]) {
sok = 1;
break;
}
@@ -241,8 +235,7 @@ wchar_t* GaduProto::gc_getchat(uin_t sender, uin_t *recipients, int recipients_c
++found;
// Found all recipients
- if (found == recipients_count)
- {
+ if (found == recipients_count) {
if (chat->ignore)
debugLogW(L"gc_getchat(): Ignoring existing id %s, size %d.", chat->id, chat->recipients_count);
else
@@ -258,8 +251,7 @@ wchar_t* GaduProto::gc_getchat(uin_t sender, uin_t *recipients, int recipients_c
chat->ignore = FALSE;
// Check groupchat policy (new) / only for incoming
- if (sender)
- {
+ if (sender) {
int unknown = (getcontact(sender, 0, 0, nullptr) == NULL),
unknownSender = unknown;
for (int i = 0; i < recipients_count; i++)
@@ -270,8 +262,7 @@ wchar_t* GaduProto::gc_getchat(uin_t sender, uin_t *recipients, int recipients_c
(getWord(GG_KEY_GC_POLICY_TOTAL, GG_KEYDEF_GC_POLICY_TOTAL) == 2 &&
recipients_count >= getWord(GG_KEY_GC_COUNT_TOTAL, GG_KEYDEF_GC_COUNT_TOTAL)) ||
(getWord(GG_KEY_GC_POLICY_UNKNOWN, GG_KEYDEF_GC_POLICY_UNKNOWN) == 2 &&
- unknown >= getWord(GG_KEY_GC_COUNT_UNKNOWN, GG_KEYDEF_GC_COUNT_UNKNOWN)))
- {
+ unknown >= getWord(GG_KEY_GC_COUNT_UNKNOWN, GG_KEYDEF_GC_COUNT_UNKNOWN))) {
chat->ignore = TRUE;
}
@@ -279,8 +270,7 @@ wchar_t* GaduProto::gc_getchat(uin_t sender, uin_t *recipients, int recipients_c
(getWord(GG_KEY_GC_POLICY_TOTAL, GG_KEYDEF_GC_POLICY_TOTAL) == 1 &&
recipients_count >= getWord(GG_KEY_GC_COUNT_TOTAL, GG_KEYDEF_GC_COUNT_TOTAL)) ||
(getWord(GG_KEY_GC_POLICY_UNKNOWN, GG_KEYDEF_GC_POLICY_UNKNOWN) == 1 &&
- unknown >= getWord(GG_KEY_GC_COUNT_UNKNOWN, GG_KEYDEF_GC_COUNT_UNKNOWN))))
- {
+ unknown >= getWord(GG_KEY_GC_COUNT_UNKNOWN, GG_KEYDEF_GC_COUNT_UNKNOWN)))) {
wchar_t *senderName = unknownSender ?
TranslateT("Unknown") : Clist_GetContactDisplayName(getcontact(sender, 0, 0, nullptr));
wchar_t error[256];
@@ -289,8 +279,7 @@ wchar_t* GaduProto::gc_getchat(uin_t sender, uin_t *recipients, int recipients_c
chat->ignore = MessageBox(nullptr, error, m_tszUserName, MB_OKCANCEL | MB_ICONEXCLAMATION) != IDOK;
}
- if (chat->ignore)
- {
+ if (chat->ignore) {
// Copy recipient list
chat->recipients_count = recipients_count + 1;
chat->recipients = (uin_t *)calloc(chat->recipients_count, sizeof(uin_t));
@@ -307,13 +296,11 @@ wchar_t* GaduProto::gc_getchat(uin_t sender, uin_t *recipients, int recipients_c
// Create new chat window
wchar_t status[256];
wchar_t *senderName;
- if (sender)
- {
+ if (sender) {
senderName = Clist_GetContactDisplayName(getcontact(sender, 1, 0, nullptr));
mir_snwprintf(status, TranslateT("%s initiated the conference."), senderName);
}
- else
- {
+ else {
senderName = nullptr;
mir_snwprintf(status, TranslateT("This is my own conference."));
}
@@ -331,25 +318,25 @@ wchar_t* GaduProto::gc_getchat(uin_t sender, uin_t *recipients, int recipients_c
wchar_t id[32];
- GCEVENT gce = { m_szModuleName, chat->id, GC_EVENT_JOIN };
- gce.ptszUID = id;
+ GCEVENT gce = { m_szModuleName, 0, GC_EVENT_JOIN };
+ gce.pszID.w = chat->id;
+ gce.pszUID.w = id;
gce.dwFlags = GCEF_ADDTOLOG;
// Add myself
uin_t uin = getDword(GG_KEY_UIN, 0);
- if (uin)
- {
+ if (uin) {
UIN2IDT(uin, id);
ptrW nickT(getWStringA(GG_KEY_NICK));
if (nickT == NULL)
nickT = mir_wstrdup(TranslateT("Me"));
- gce.ptszNick = nickT;
+ gce.pszNick.w = nickT;
gce.bIsMe = 1;
Chat_Event(&gce);
mir_free(nickT);
- debugLogW(L"gc_getchat(): Myself %s: %s (%s) to the list...", gce.ptszUID, gce.ptszNick, gce.ptszStatus);
+ debugLogW(L"gc_getchat(): Myself %s: %s (%s) to the list...", gce.pszUID.w, gce.pszNick.w, gce.pszStatus.w);
}
else
debugLogA("gc_getchat(): Myself adding failed with uin %d !!!", uin);
@@ -368,12 +355,12 @@ wchar_t* GaduProto::gc_getchat(uin_t sender, uin_t *recipients, int recipients_c
MCONTACT hContact = getcontact(chat->recipients[i], 1, 0, nullptr);
UIN2IDT(chat->recipients[i], id);
if (hContact)
- gce.ptszNick = Clist_GetContactDisplayName(hContact);
+ gce.pszNick.w = Clist_GetContactDisplayName(hContact);
else
- gce.ptszNick = TranslateT("'Unknown'");
+ gce.pszNick.w = TranslateT("'Unknown'");
gce.bIsMe = 0;
gce.dwFlags = 0;
- debugLogW(L"gc_getchat(): Added %s: %s (%s) to the list...", gce.ptszUID, gce.ptszNick, gce.ptszStatus);
+ debugLogW(L"gc_getchat(): Added %s: %s (%s) to the list...", gce.pszUID.w, gce.pszNick.w, gce.pszStatus.w);
Chat_Event(&gce);
}
@@ -423,78 +410,67 @@ static int gg_gc_countcheckmarks(HWND hwndList)
static INT_PTR CALLBACK gg_gc_openconfdlg(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
- switch (message)
- {
+ switch (message) {
case WM_INITDIALOG:
- {
- CLCINFOITEM cii = { 0 };
- HANDLE hMetaContactsEvent;
-
- SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)lParam);
- TranslateDialogDefault(hwndDlg);
- Window_SetIcon_IcoLib(hwndDlg, GetIconHandle(IDI_CONFERENCE));
- gg_gc_resetclistopts(GetDlgItem(hwndDlg, IDC_CLIST));
-
- // Hook MetaContacts event (if available)
- hMetaContactsEvent = HookEventMessage(ME_MC_SUBCONTACTSCHANGED, hwndDlg, HM_SUBCONTACTSCHANGED);
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)hMetaContactsEvent);
- }
- return TRUE;
+ {
+ SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)lParam);
+ TranslateDialogDefault(hwndDlg);
+ Window_SetIcon_IcoLib(hwndDlg, GetIconHandle(IDI_CONFERENCE));
+ gg_gc_resetclistopts(GetDlgItem(hwndDlg, IDC_CLIST));
+
+ // Hook MetaContacts event (if available)
+ HANDLE hMetaContactsEvent = HookEventMessage(ME_MC_SUBCONTACTSCHANGED, hwndDlg, HM_SUBCONTACTSCHANGED);
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)hMetaContactsEvent);
+ }
+ return TRUE;
case WM_COMMAND:
- {
- switch (LOWORD(wParam))
- {
- case IDOK:
{
- HWND hwndList = GetDlgItem(hwndDlg, IDC_CLIST);
- GaduProto* gg = (GaduProto*)GetWindowLongPtr(hwndDlg, DWLP_USER);
- int count = 0, i = 0;
- // Check if connected
- if (!gg->isonline())
- {
- MessageBox(nullptr,
- TranslateT("You have to be connected to open new conference."),
- gg->m_tszUserName, MB_OK | MB_ICONSTOP);
- }
- else if (hwndList && (count = gg_gc_countcheckmarks(hwndList)) >= 2)
- {
- // Create new participiants table
- uin_t* participants = (uin_t*)calloc(count, sizeof(uin_t));
- gg->debugLogA("gg_gc_openconfdlg(): WM_COMMAND IDOK Opening new conference for %d contacts.", count);
- for (auto &hContact : Contacts()) {
- HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, hContact, 0);
- if (hItem && SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)hItem, 0)) {
- MCONTACT hMetaContact = gg_getsubcontact(gg, hContact); // MetaContacts support
- participants[i++] = db_get_dw(hMetaContact ? hMetaContact : hContact, gg->m_szModuleName, GG_KEY_UIN, 0);
+ switch (LOWORD(wParam)) {
+ case IDOK:
+ {
+ HWND hwndList = GetDlgItem(hwndDlg, IDC_CLIST);
+ GaduProto* gg = (GaduProto*)GetWindowLongPtr(hwndDlg, DWLP_USER);
+ int count = 0, i = 0;
+ // Check if connected
+ if (!gg->isonline()) {
+ MessageBox(nullptr,
+ TranslateT("You have to be connected to open new conference."),
+ gg->m_tszUserName, MB_OK | MB_ICONSTOP);
}
- }
- if (count > i)
- i = count;
+ else if (hwndList && (count = gg_gc_countcheckmarks(hwndList)) >= 2) {
+ // Create new participiants table
+ uin_t* participants = (uin_t*)calloc(count, sizeof(uin_t));
+ gg->debugLogA("gg_gc_openconfdlg(): WM_COMMAND IDOK Opening new conference for %d contacts.", count);
+ for (auto &hContact : Contacts()) {
+ HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, hContact, 0);
+ if (hItem && SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)hItem, 0)) {
+ MCONTACT hMetaContact = gg_getsubcontact(gg, hContact); // MetaContacts support
+ participants[i++] = db_get_dw(hMetaContact ? hMetaContact : hContact, gg->m_szModuleName, GG_KEY_UIN, 0);
+ }
+ }
+ if (count > i)
+ i = count;
- wchar_t *chat = gg->gc_getchat(0, participants, count);
- if (chat)
- Chat_Control(gg->m_szModuleName, chat, WINDOW_VISIBLE);
+ wchar_t *chat = gg->gc_getchat(0, participants, count);
+ if (chat)
+ Chat_Control(gg->m_szModuleName, chat, WINDOW_VISIBLE);
- free(participants);
+ free(participants);
+ }
+ }
+ // fall through
+ case IDCANCEL:
+ DestroyWindow(hwndDlg);
+ break;
}
}
- // fall through
- case IDCANCEL:
- DestroyWindow(hwndDlg);
- break;
- }
break;
- }
case WM_NOTIFY:
- {
- switch (((NMHDR*)lParam)->idFrom)
- {
+ switch (((NMHDR*)lParam)->idFrom) {
case IDC_CLIST:
- {
- switch (((NMHDR*)lParam)->code)
- {
+ switch (((NMHDR*)lParam)->code) {
case CLN_OPTIONSCHANGED:
gg_gc_resetclistopts(GetDlgItem(hwndDlg, IDC_CLIST));
break;
@@ -502,34 +478,34 @@ static INT_PTR CALLBACK gg_gc_openconfdlg(HWND hwndDlg, UINT message, WPARAM wPa
case CLN_NEWCONTACT:
case CLN_CONTACTMOVED:
case CLN_LISTREBUILT:
- {
- char* szProto;
- uin_t uin;
- GaduProto* gg = (GaduProto*)GetWindowLongPtr(hwndDlg, DWLP_USER);
+ {
+ char* szProto;
+ uin_t uin;
+ GaduProto* gg = (GaduProto*)GetWindowLongPtr(hwndDlg, DWLP_USER);
- if (!gg)
- break;
+ if (!gg)
+ break;
- // Delete non-gg contacts
- for (auto &hContact : Contacts()) {
- MCONTACT hItem = (MCONTACT)SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, hContact, 0);
- if (hItem) {
- MCONTACT hMetaContact = gg_getsubcontact(gg, hContact); // MetaContacts support
- if (hMetaContact) {
- szProto = gg->m_szModuleName;
- uin = (uin_t)gg->getDword(hMetaContact, GG_KEY_UIN, 0);
- }
- else {
- szProto = GetContactProto(hContact);
- uin = (uin_t)gg->getDword(hContact, GG_KEY_UIN, 0);
+ // Delete non-gg contacts
+ for (auto &hContact : Contacts()) {
+ MCONTACT hItem = (MCONTACT)SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, hContact, 0);
+ if (hItem) {
+ MCONTACT hMetaContact = gg_getsubcontact(gg, hContact); // MetaContacts support
+ if (hMetaContact) {
+ szProto = gg->m_szModuleName;
+ uin = (uin_t)gg->getDword(hMetaContact, GG_KEY_UIN, 0);
+ }
+ else {
+ szProto = GetContactProto(hContact);
+ uin = (uin_t)gg->getDword(hContact, GG_KEY_UIN, 0);
+ }
+
+ if (szProto == nullptr || mir_strcmp(szProto, gg->m_szModuleName) || !uin || uin == gg->getDword(GG_KEY_UIN, 0))
+ SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_DELETEITEM, (WPARAM)hItem, 0);
}
-
- if (szProto == nullptr || mir_strcmp(szProto, gg->m_szModuleName) || !uin || uin == gg->getDword(GG_KEY_UIN, 0))
- SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_DELETEITEM, (WPARAM)hItem, 0);
}
}
- }
- break;
+ break;
case CLN_CHECKCHANGED:
EnableWindow(GetDlgItem(hwndDlg, IDOK), gg_gc_countcheckmarks(GetDlgItem(hwndDlg, IDC_CLIST)) >= 2);
@@ -537,31 +513,27 @@ static INT_PTR CALLBACK gg_gc_openconfdlg(HWND hwndDlg, UINT message, WPARAM wPa
}
break;
}
- }
break;
- }
case HM_SUBCONTACTSCHANGED:
- {
- HWND hwndList = GetDlgItem(hwndDlg, IDC_CLIST);
- SendMessage(hwndList, CLM_AUTOREBUILD, 0, 0);
- EnableWindow(GetDlgItem(hwndDlg, IDOK), gg_gc_countcheckmarks(hwndList) >= 2);
+ {
+ HWND hwndList = GetDlgItem(hwndDlg, IDC_CLIST);
+ SendMessage(hwndList, CLM_AUTOREBUILD, 0, 0);
+ EnableWindow(GetDlgItem(hwndDlg, IDOK), gg_gc_countcheckmarks(hwndList) >= 2);
+ }
break;
- }
case WM_CLOSE:
DestroyWindow(hwndDlg);
break;
case WM_DESTROY:
- {
HANDLE hMetaContactsEvent = (HANDLE)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
if (hMetaContactsEvent)
UnhookEvent(hMetaContactsEvent);
Window_FreeIcon_IcoLib(hwndDlg);
break;
}
- }
return FALSE;
}
@@ -570,12 +542,10 @@ INT_PTR GaduProto::gc_clearignored(WPARAM, LPARAM)
{
list_t l = chats;
BOOL cleared = FALSE;
- while (l)
- {
+ while (l) {
GGGC *chat = (GGGC *)l->data;
l = l->next;
- if (chat->ignore)
- {
+ if (chat->ignore) {
free(chat->recipients);
list_remove(&chats, chat, 1);
cleared = TRUE;
@@ -585,8 +555,7 @@ INT_PTR GaduProto::gc_clearignored(WPARAM, LPARAM)
cleared ?
TranslateT("All ignored conferences are now unignored and the conference policy will act again.") :
TranslateT("There are no ignored conferences."),
- m_tszUserName, MB_OK | MB_ICONINFORMATION
- );
+ m_tszUserName, MB_OK | MB_ICONINFORMATION);
return 0;
}
@@ -594,12 +563,10 @@ INT_PTR GaduProto::gc_clearignored(WPARAM, LPARAM)
INT_PTR GaduProto::gc_openconf(WPARAM, LPARAM)
{
// Check if connected
- if (!isonline())
- {
+ if (!isonline()) {
MessageBox(nullptr,
TranslateT("You have to be connected to open new conference."),
- m_tszUserName, MB_OK | MB_ICONSTOP
- );
+ m_tszUserName, MB_OK | MB_ICONSTOP);
return 0;
}
@@ -620,14 +587,14 @@ int GaduProto::gc_changenick(MCONTACT hContact, wchar_t *ptszNick)
if (chat->recipients && chat->recipients_count)
for (int i = 0; i < chat->recipients_count; i++)
// Rename this window if it's exising in the chat
- if (chat->recipients[i] == uin)
- {
+ if (chat->recipients[i] == uin) {
wchar_t id[32];
UIN2IDT(uin, id);
- GCEVENT gce = { m_szModuleName, chat->id, GC_EVENT_NICK };
- gce.ptszUID = id;
- gce.ptszText = ptszNick;
+ GCEVENT gce = { m_szModuleName, 0, GC_EVENT_NICK };
+ gce.pszID.w = chat->id;
+ gce.pszUID.w = id;
+ gce.pszText.w = ptszNick;
debugLogW(L"gc_changenick(): Found room %s with uin %d, sending nick change %s.", chat->id, uin, id);
Chat_Event(&gce);
diff --git a/protocols/ICQ-WIM/src/groupchats.cpp b/protocols/ICQ-WIM/src/groupchats.cpp
index 7d61b15407..5f5854b6b6 100644
--- a/protocols/ICQ-WIM/src/groupchats.cpp
+++ b/protocols/ICQ-WIM/src/groupchats.cpp
@@ -35,13 +35,14 @@ void CIcqProto::LoadChatInfo(SESSION_INFO *si)
CMStringW role((*node)["role"].as_mstring());
CMStringW sn((*node)["sn"].as_mstring());
- GCEVENT gce = { m_szModuleName, si->ptszID, GC_EVENT_JOIN };
+ GCEVENT gce = { m_szModuleName, 0, GC_EVENT_JOIN };
gce.dwFlags = GCEF_SILENT;
- gce.ptszNick = nick;
- gce.ptszUID = sn;
+ gce.pszID.w = si->ptszID;
+ gce.pszNick.w = nick;
+ gce.pszUID.w = sn;
gce.time = ::time(0);
gce.bIsMe = sn == m_szOwnId;
- gce.ptszStatus = TranslateW(role);
+ gce.pszStatus.w = TranslateW(role);
Chat_Event(&gce);
json_delete(node);
@@ -279,7 +280,8 @@ void CIcqProto::ProcessGroupChat(const JSONNode &ev)
continue;
CMStringW method(it["method"].as_mstring());
- GCEVENT gce = { m_szModuleName, si->ptszID, (method == "add_members") ? GC_EVENT_JOIN : GC_EVENT_PART };
+ GCEVENT gce = { m_szModuleName, 0, (method == "add_members") ? GC_EVENT_JOIN : GC_EVENT_PART };
+ gce.pszID.w = si->ptszID;
int iStart = 0;
CMStringW members(it["members"].as_mstring());
@@ -292,8 +294,8 @@ void CIcqProto::ProcessGroupChat(const JSONNode &ev)
if (pCache == nullptr)
continue;
- gce.ptszNick = Clist_GetContactDisplayName(pCache->m_hContact);
- gce.ptszUID = member;
+ gce.pszNick.w = Clist_GetContactDisplayName(pCache->m_hContact);
+ gce.pszUID.w = member;
gce.time = ::time(0);
gce.bIsMe = member == m_szOwnId;
Chat_Event(&gce);
diff --git a/protocols/ICQ-WIM/src/server.cpp b/protocols/ICQ-WIM/src/server.cpp
index b086a9bd53..6567e8a390 100644
--- a/protocols/ICQ-WIM/src/server.cpp
+++ b/protocols/ICQ-WIM/src/server.cpp
@@ -351,10 +351,11 @@ void CIcqProto::ParseMessage(MCONTACT hContact, __int64 &lastMsgId, const JSONNo
CMStringW wszSender(it["chat"]["sender"].as_mstring());
CMStringW wszChatId(getMStringW(hContact, "ChatRoomID"));
- GCEVENT gce = { m_szModuleName, wszChatId, GC_EVENT_MESSAGE };
+ GCEVENT gce = { m_szModuleName, 0, GC_EVENT_MESSAGE };
+ gce.pszID.w = wszChatId;
gce.dwFlags = GCEF_ADDTOLOG;
- gce.ptszUID = wszSender;
- gce.ptszText = wszText;
+ gce.pszUID.w = wszSender;
+ gce.pszText.w = wszText;
gce.time = iMsgTime;
gce.bIsMe = wszSender == m_szOwnId;
Chat_Event(&gce);
diff --git a/protocols/IRCG/src/commandmonitor.cpp b/protocols/IRCG/src/commandmonitor.cpp
index fcc1da7901..d1b42d6434 100644
--- a/protocols/IRCG/src/commandmonitor.cpp
+++ b/protocols/IRCG/src/commandmonitor.cpp
@@ -1298,11 +1298,12 @@ bool CIrcProto::OnIrc_ENDNAMES(const CIrcMessage *pmsg)
while (PrefixToStatus(sTemp[0]) != pwszNormal)
sTemp.Delete(0, 1);
- GCEVENT gce = { m_szModuleName, sID, GC_EVENT_JOIN };
- gce.ptszUID = sTemp;
- gce.ptszNick = sTemp;
- gce.ptszStatus = sStat;
- gce.bIsMe = (!mir_wstrcmpi(gce.ptszNick, m_info.sNick)) ? TRUE : FALSE;
+ GCEVENT gce = { m_szModuleName, 0, GC_EVENT_JOIN };
+ gce.pszID.w = sID;
+ gce.pszUID.w = sTemp;
+ gce.pszNick.w = sTemp;
+ gce.pszStatus.w = sStat;
+ gce.bIsMe = (!mir_wstrcmpi(gce.pszNick.w, m_info.sNick)) ? TRUE : FALSE;
if (gce.bIsMe) {
char BitNr = -1;
switch (sTemp2[0]) {
diff --git a/protocols/IRCG/src/tools.cpp b/protocols/IRCG/src/tools.cpp
index 740a331842..02ca2c5b6d 100644
--- a/protocols/IRCG/src/tools.cpp
+++ b/protocols/IRCG/src/tools.cpp
@@ -377,21 +377,21 @@ INT_PTR CIrcProto::DoEvent(int iEvent, const wchar_t* pszWindow, const wchar_t*
sID = pszWindow + (CMStringW)L" - " + m_info.sNetwork;
else
sID = pszWindow;
- gce.ptszID = (wchar_t*)sID.c_str();
+ gce.pszID.w = (wchar_t*)sID.c_str();
}
- else gce.ptszID = nullptr;
+ else gce.pszID.w = nullptr;
- gce.ptszStatus = pszStatus;
+ gce.pszStatus.w = pszStatus;
gce.dwFlags = (bAddToLog) ? GCEF_ADDTOLOG : 0;
- gce.ptszNick = pszNick;
- gce.ptszUID = pszNick;
+ gce.pszNick.w = pszNick;
+ gce.pszUID.w = pszNick;
if (iEvent == GC_EVENT_TOPIC)
- gce.ptszUserInfo = pszUserInfo;
+ gce.pszUserInfo.w = pszUserInfo;
else
- gce.ptszUserInfo = m_showAddresses ? pszUserInfo : nullptr;
+ gce.pszUserInfo.w = m_showAddresses ? pszUserInfo : nullptr;
if (!sText.IsEmpty())
- gce.ptszText = sText.c_str();
+ gce.pszText.w = sText.c_str();
gce.dwItemData = dwItemData;
if (timestamp == 1)
diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp
index 70dd3e66cc..e29c2a9d75 100644
--- a/protocols/JabberG/src/jabber_chat.cpp
+++ b/protocols/JabberG/src/jabber_chat.cpp
@@ -97,7 +97,7 @@ static TRoleOrAffiliationInfo sttRoleItems[] =
/////////////////////////////////////////////////////////////////////////////////////////
// JabberGcInit - initializes the new chat
-static const wchar_t *sttStatuses[] = { LPGENW("Visitors"), LPGENW("Participants"), LPGENW("Moderators"), LPGENW("Owners") };
+static const char *sttStatuses[] = { LPGEN("Owners"), LPGEN("Moderators"), LPGEN("Participants"), LPGEN("Visitors") };
int JabberGcGetStatus(JABBER_GC_AFFILIATION a, JABBER_GC_ROLE r)
{
@@ -162,7 +162,7 @@ int CJabberProto::GcInit(JABBER_LIST_ITEM *item)
item->bChatActive = true;
for (int i = _countof(sttStatuses) - 1; i >= 0; i--)
- Chat_AddGroup(si, TranslateW(sttStatuses[i]));
+ Chat_AddGroup(si, TranslateW(Utf2T(sttStatuses[i])));
Chat_Control(m_szModuleName, wszJid, (item->bAutoJoin && m_bAutoJoinHidden) ? WINDOW_HIDDEN : SESSION_INITDONE);
Chat_Control(m_szModuleName, wszJid, SESSION_ONLINE);
@@ -173,69 +173,67 @@ void CJabberProto::GcLogShowInformation(JABBER_LIST_ITEM *item, pResourceStatus
{
if (!item || !user || (item->bChatActive != 2)) return;
- CMStringW buf;
- Utf2T wszRoomJid(item->jid), wszUserId(user->m_szResourceName);
+ CMStringA buf;
switch (type) {
case INFO_BAN:
if (m_bGcLogBans)
- buf.Format(TranslateT("User %s is now banned."), wszUserId.get());
+ buf.Format(TranslateU("User %s is now banned."), user->m_szResourceName);
break;
case INFO_STATUS:
if (m_bGcLogStatuses) {
wchar_t *ptszDescr = Clist_GetStatusModeDescription(user->m_iStatus, 0);
if (user->m_szStatusMessage)
- buf.Format(TranslateT("User %s changed status to %s with message: %s"), wszUserId.get(), ptszDescr, user->m_szStatusMessage);
+ buf.Format(TranslateU("User %s changed status to %s with message: %s"), user->m_szResourceName, ptszDescr, user->m_szStatusMessage);
else
- buf.Format(TranslateT("User %s changed status to %s"), wszUserId.get(), ptszDescr);
+ buf.Format(TranslateU("User %s changed status to %s"), user->m_szResourceName, ptszDescr);
}
break;
case INFO_CONFIG:
if (m_bGcLogConfig)
- buf.Format(TranslateT("Room configuration was changed."));
+ buf.Append(TranslateU("Room configuration was changed."));
break;
case INFO_AFFILIATION:
if (m_bGcLogAffiliations) {
- wchar_t *name = nullptr;
+ const char *name = nullptr;
switch (user->m_affiliation) {
- case AFFILIATION_NONE: name = TranslateT("None"); break;
- case AFFILIATION_MEMBER: name = TranslateT("Member"); break;
- case AFFILIATION_ADMIN: name = TranslateT("Admin"); break;
- case AFFILIATION_OWNER: name = TranslateT("Owner"); break;
- case AFFILIATION_OUTCAST: name = TranslateT("Outcast"); break;
+ case AFFILIATION_NONE: name = TranslateU("None"); break;
+ case AFFILIATION_MEMBER: name = TranslateU("Member"); break;
+ case AFFILIATION_ADMIN: name = TranslateU("Admin"); break;
+ case AFFILIATION_OWNER: name = TranslateU("Owner"); break;
+ case AFFILIATION_OUTCAST: name = TranslateU("Outcast"); break;
}
if (name)
- buf.Format(TranslateT("Affiliation of %s was changed to '%s'."), wszUserId.get(), name);
+ buf.Format(TranslateU("Affiliation of %s was changed to '%s'."), user->m_szResourceName, name);
}
break;
case INFO_ROLE:
if (m_bGcLogRoles) {
- wchar_t *name = nullptr;
+ const char *name = nullptr;
switch (user->m_role) {
- case ROLE_NONE: name = TranslateT("None"); break;
- case ROLE_VISITOR: name = TranslateT("Visitor"); break;
- case ROLE_PARTICIPANT: name = TranslateT("Participant"); break;
- case ROLE_MODERATOR: name = TranslateT("Moderator"); break;
+ case ROLE_NONE: name = TranslateU("None"); break;
+ case ROLE_VISITOR: name = TranslateU("Visitor"); break;
+ case ROLE_PARTICIPANT: name = TranslateU("Participant"); break;
+ case ROLE_MODERATOR: name = TranslateU("Moderator"); break;
}
if (name)
- buf.Format(TranslateT("Role of %s was changed to '%s'."), wszUserId.get(), name);
+ buf.Format(Translate("Role of %s was changed to '%s'."), user->m_szResourceName, name);
}
break;
}
if (!buf.IsEmpty()) {
- buf.Replace(L"%", L"%%");
+ buf.Replace("%", "%%");
- GCEVENT gce = { m_szModuleName, wszRoomJid, GC_EVENT_INFORMATION };
- gce.ptszNick = wszUserId;
- gce.ptszUID = wszUserId;
- gce.ptszText = buf;
- gce.dwFlags = GCEF_ADDTOLOG;
+ GCEVENT gce = { m_szModuleName, item->jid, GC_EVENT_INFORMATION };
+ gce.dwFlags = GCEF_UTF8 + GCEF_ADDTOLOG;
+ gce.pszNick.a = gce.pszUID.a = user->m_szResourceName;
+ gce.pszText.a = buf;
gce.time = time(0);
Chat_Event(&gce);
}
@@ -257,12 +255,12 @@ void CJabberProto::GcLogUpdateMemberStatus(JABBER_LIST_ITEM *item, const char *r
if (myNick == nullptr)
myNick = JabberNickFromJID(m_szJabberJID);
- Utf2T wszRoomJid(item->jid), wszNick(nick), wszUserId(resource), wszText(szReason), wszUserInfo(jid);
- GCEVENT gce = { m_szModuleName, wszRoomJid };
- gce.ptszNick = wszNick;
- gce.ptszUID = wszUserId;
- gce.ptszUserInfo = wszUserInfo;
- gce.ptszText = wszText;
+ GCEVENT gce = { m_szModuleName, item->jid, 0 };
+ gce.dwFlags = GCEF_UTF8;
+ gce.pszNick.a = nick;
+ gce.pszUID.a = resource;
+ gce.pszUserInfo.a = jid;
+ gce.pszText.a = szReason;
if (item->bChatActive == 2) {
gce.dwFlags |= GCEF_ADDTOLOG;
gce.time = time(0);
@@ -271,7 +269,7 @@ void CJabberProto::GcLogUpdateMemberStatus(JABBER_LIST_ITEM *item, const char *r
switch (gce.iType = action) {
case GC_EVENT_PART: break;
case GC_EVENT_KICK:
- gce.ptszStatus = TranslateT("Moderator");
+ gce.pszStatus.a = TranslateU("Moderator");
break;
default:
@@ -285,27 +283,26 @@ void CJabberProto::GcLogUpdateMemberStatus(JABBER_LIST_ITEM *item, const char *r
case GC_EVENT_REMOVESTATUS:
gce.dwFlags &= ~GCEF_ADDTOLOG;
}
- gce.ptszText = TranslateT("Moderator");
+ gce.pszText.a = TranslateU("Moderator");
}
- gce.ptszStatus = TranslateW(sttStatuses[JabberGcGetStatus(JS)]);
+ gce.pszStatus.a = TranslateU(sttStatuses[JabberGcGetStatus(JS)]);
gce.bIsMe = (mir_strcmp(nick, myNick) == 0);
statusToSet = JS->m_iStatus;
break;
}
}
}
-
Chat_Event(&gce);
if (statusToSet != 0) {
int flags = GC_SSE_ONLYLISTED;
if (statusToSet == ID_STATUS_AWAY || statusToSet == ID_STATUS_NA || statusToSet == ID_STATUS_DND)
flags += GC_SSE_ONLINE;
- Chat_SetStatusEx(m_szModuleName, wszRoomJid, flags, wszNick);
+ Chat_SetStatusEx(m_szModuleName, Utf2T(item->jid), flags, Utf2T(nick));
gce.iType = GC_EVENT_SETCONTACTSTATUS;
- gce.ptszText = wszNick;
- gce.ptszUID = wszUserId;
+ gce.pszText.a = nick;
+ gce.pszUID.a = resource;
gce.dwItemData = statusToSet;
Chat_Event(&gce);
}
diff --git a/protocols/JabberG/src/jabber_groupchat.cpp b/protocols/JabberG/src/jabber_groupchat.cpp
index 682de9e84a..2719ba4690 100644
--- a/protocols/JabberG/src/jabber_groupchat.cpp
+++ b/protocols/JabberG/src/jabber_groupchat.cpp
@@ -788,15 +788,16 @@ void CJabberProto::RenameParticipantNick(JABBER_LIST_ITEM *item, const char *old
setUString(hContact, "MyNick", newNick);
}
- Utf2T wszRoomId(item->jid), wszOld(oldNick), wszNew(newNick), wszInfo(jid);
- Chat_ChangeUserId(m_szModuleName, wszRoomId, wszOld, wszNew);
+ Chat_ChangeUserId(m_szModuleName, Utf2T(item->jid), Utf2T(oldNick), Utf2T(newNick));
- GCEVENT gce = { m_szModuleName, wszRoomId, GC_EVENT_NICK };
- gce.ptszUserInfo = wszInfo;
+ GCEVENT gce = { m_szModuleName, item->jid, GC_EVENT_NICK };
+ gce.dwFlags = GCEF_UTF8;
+ gce.pszID.a = item->jid;
+ gce.pszUserInfo.a = jid;
gce.time = time(0);
- gce.ptszNick = wszOld;
- gce.ptszUID = wszNew;
- gce.ptszText = wszNew;
+ gce.pszNick.a = oldNick;
+ gce.pszUID.a = newNick;
+ gce.pszText.a = newNick;
Chat_Event(&gce);
}
@@ -1010,7 +1011,7 @@ void CJabberProto::GroupchatProcessPresence(const TiXmlElement *node)
void CJabberProto::GroupchatProcessMessage(const TiXmlElement *node)
{
const TiXmlElement *n, *m;
- const char *from, *type, *p, *nick, *resource;
+ const char *from, *type, *p, *nick;
JABBER_LIST_ITEM *item;
CMStringW imgLink;
@@ -1022,12 +1023,10 @@ void CJabberProto::GroupchatProcessMessage(const TiXmlElement *node)
if (!mir_strcmp(type, "error"))
return;
- Utf2T roomJid(item->jid);
- GCEVENT gce = { m_szModuleName, roomJid, 0 };
+ GCEVENT gce = { m_szModuleName, item->jid, 0 };
+ gce.dwFlags = GCEF_UTF8;
- const char *msgText = nullptr;
-
- resource = strchr(from, '/');
+ const char *resource = strchr(from, '/'), *msgText;
if (resource != nullptr && *++resource == '\0')
resource = nullptr;
@@ -1051,6 +1050,7 @@ void CJabberProto::GroupchatProcessMessage(const TiXmlElement *node)
resource = tmpnick;
}
}
+
item->getTemp()->m_szStatusMessage = mir_strdup(msgText);
}
else {
@@ -1093,15 +1093,14 @@ void CJabberProto::GroupchatProcessMessage(const TiXmlElement *node)
}
else nick = nullptr;
- CMStringW tszText(Utf2T(msgText).get());
- tszText.Replace(L"%", L"%%");
- tszText += imgLink;
+ CMStringA szText(msgText);
+ szText.Replace("%", "%%");
+ szText += imgLink;
- Utf2T wszUserId(resource), wszNick(nick);
- gce.ptszUID = wszUserId;
- gce.ptszNick = wszNick;
+ gce.pszUID.a = resource;
+ gce.pszNick.a = nick;
gce.time = msgTime;
- gce.ptszText = tszText;
+ gce.pszText.a = szText;
gce.bIsMe = nick == nullptr ? FALSE : (mir_strcmp(resource, item->nick) == 0);
if (!isHistory)
@@ -1115,7 +1114,7 @@ void CJabberProto::GroupchatProcessMessage(const TiXmlElement *node)
item->bChatActive = 2;
if (gce.iType == GC_EVENT_TOPIC)
- Chat_SetStatusbarText(m_szModuleName, roomJid, tszText);
+ Chat_SetStatusbarText(m_szModuleName, Utf2T(item->jid), Utf2T(szText));
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/MSN/src/msn_chat.cpp b/protocols/MSN/src/msn_chat.cpp
index d23b5c1f5e..b18124501a 100644
--- a/protocols/MSN/src/msn_chat.cpp
+++ b/protocols/MSN/src/msn_chat.cpp
@@ -166,20 +166,22 @@ void CMsnProto::MSN_GCProcessThreadActivity(ezxml_t xmli, const wchar_t *mChatID
{
if (!mir_strcmp(xmli->name, "topicupdate")) {
ezxml_t initiator = ezxml_child(xmli, "initiator");
- GCEVENT gce = { m_szModuleName, mChatID, GC_EVENT_TOPIC };
+ GCEVENT gce = { m_szModuleName, 0, GC_EVENT_TOPIC };
+ gce.pszID.w = mChatID;
gce.dwFlags = GCEF_ADDTOLOG;
gce.time = MsnTSToUnixtime(ezxml_txt(ezxml_child(xmli, "eventtime")));
- gce.ptszUID = initiator ? mir_a2u(initiator->txt) : nullptr;
+ gce.pszUID.w = initiator ? mir_a2u(initiator->txt) : nullptr;
MCONTACT hContInitiator = MSN_HContactFromEmail(initiator ? initiator->txt : nullptr);
- gce.ptszNick = GetContactNameT(hContInitiator);
- gce.ptszText = mir_a2u(ezxml_txt(ezxml_child(xmli, "value")));
+ gce.pszNick.w = GetContactNameT(hContInitiator);
+ gce.pszText.w = mir_a2u(ezxml_txt(ezxml_child(xmli, "value")));
Chat_Event(&gce);
- mir_free((wchar_t*)gce.ptszUID);
- mir_free((wchar_t*)gce.ptszText);
+ mir_free((wchar_t*)gce.pszUID.w);
+ mir_free((wchar_t*)gce.pszText.w);
}
else if (ezxml_t target = ezxml_child(xmli, "target")) {
MCONTACT hContInitiator = NULL;
- GCEVENT gce = { m_szModuleName, mChatID, 0 };
+ GCEVENT gce = { m_szModuleName, 0, 0 };
+ gce.pszID.w = mChatID;
gce.dwFlags = GCEF_ADDTOLOG;
if (!mir_strcmp(xmli->name, "deletemember")) {
@@ -187,7 +189,7 @@ void CMsnProto::MSN_GCProcessThreadActivity(ezxml_t xmli, const wchar_t *mChatID
if (ezxml_t initiator = ezxml_child(xmli, "initiator")) {
if (mir_strcmp(initiator->txt, target->txt)) {
hContInitiator = MSN_HContactFromEmail(initiator->txt);
- gce.ptszStatus = GetContactNameT(hContInitiator);
+ gce.pszStatus.w = GetContactNameT(hContInitiator);
gce.iType = GC_EVENT_KICK;
}
}
@@ -199,9 +201,9 @@ void CMsnProto::MSN_GCProcessThreadActivity(ezxml_t xmli, const wchar_t *mChatID
gce.iType = GC_EVENT_ADDSTATUS;
if (ezxml_t initiator = ezxml_child(xmli, "initiator")) {
hContInitiator = MSN_HContactFromEmail(initiator->txt);
- gce.ptszText= GetContactNameT(hContInitiator);
+ gce.pszText.w= GetContactNameT(hContInitiator);
}
- gce.ptszStatus = L"admin";
+ gce.pszStatus.w = L"admin";
}
if (gce.iType) {
@@ -211,7 +213,7 @@ void CMsnProto::MSN_GCProcessThreadActivity(ezxml_t xmli, const wchar_t *mChatID
while (target) {
switch (gce.iType) {
case GC_EVENT_JOIN:
- gce.ptszStatus = MSN_GCGetRole(MSN_GetThreadByChatId(mChatID), target->txt);
+ gce.pszStatus.w = MSN_GCGetRole(MSN_GetThreadByChatId(mChatID), target->txt);
__fallthrough;
case GC_EVENT_KICK:
@@ -227,11 +229,11 @@ void CMsnProto::MSN_GCProcessThreadActivity(ezxml_t xmli, const wchar_t *mChatID
char *szEmail, *szNet;
parseWLID(NEWSTR_ALLOCA(pszTarget), &szNet, &szEmail, nullptr);
gce.bIsMe = !mir_strcmpi(szEmail, GetMyUsername(atoi(szNet)));
- gce.ptszUID = mir_a2u(pszTarget);
+ gce.pszUID.w = mir_a2u(pszTarget);
MCONTACT hContTarget = MSN_HContactFromEmail(pszTarget);
- gce.ptszNick = GetContactNameT(hContTarget);
+ gce.pszNick.w = GetContactNameT(hContTarget);
Chat_Event(&gce);
- mir_free((wchar_t*)gce.ptszUID);
+ mir_free((wchar_t*)gce.pszUID.w);
if ((gce.iType == GC_EVENT_PART || gce.iType == GC_EVENT_KICK) && gce.bIsMe) {
Chat_Control(m_szModuleName, mChatID, SESSION_OFFLINE);
break;
@@ -263,20 +265,21 @@ void CMsnProto::MSN_GCRefreshThreadsInfo(void)
void CMsnProto::MSN_GCAddMessage(wchar_t *mChatID, MCONTACT hContact, char *email, time_t ts, bool sentMsg, char *msgBody)
{
- GCEVENT gce = { m_szModuleName, mChatID, GC_EVENT_MESSAGE };
+ GCEVENT gce = { m_szModuleName, 0, GC_EVENT_MESSAGE };
+ gce.pszID.w = mChatID;
gce.dwFlags = GCEF_ADDTOLOG;
- gce.ptszUID = mir_a2u(email);
- gce.ptszNick = GetContactNameT(hContact);
+ gce.pszUID.w = mir_a2u(email);
+ gce.pszNick.w = GetContactNameT(hContact);
gce.time = ts;
gce.bIsMe = sentMsg;
wchar_t* p = mir_utf8decodeW(msgBody);
- gce.ptszText = EscapeChatTags(p);
+ gce.pszText.w = EscapeChatTags(p);
mir_free(p);
Chat_Event(&gce);
- mir_free((void*)gce.ptszUID);
- mir_free((void*)gce.ptszText);
+ mir_free((void*)gce.pszUID.w);
+ mir_free((void*)gce.pszText.w);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -482,16 +485,17 @@ int CMsnProto::MSN_GCEventHook(WPARAM, LPARAM lParam)
DBVARIANT dbv;
int bError = getWString("Nick", &dbv);
- GCEVENT gce = { m_szModuleName, gch->ptszID, GC_EVENT_MESSAGE };
+ GCEVENT gce = { m_szModuleName, 0, GC_EVENT_MESSAGE };
+ gce.pszID.w = gch->ptszID;
gce.dwFlags = GCEF_ADDTOLOG;
- gce.ptszNick = bError ? L"" : dbv.pwszVal;
- gce.ptszUID = mir_a2u(MyOptions.szEmail);
+ gce.pszNick.w = bError ? L"" : dbv.pwszVal;
+ gce.pszUID.w = mir_a2u(MyOptions.szEmail);
gce.time = time(0);
- gce.ptszText = gch->ptszText;
+ gce.pszText.w = gch->ptszText;
gce.bIsMe = TRUE;
Chat_Event(&gce);
- mir_free((void*)gce.ptszUID);
+ mir_free((void*)gce.pszUID.w);
if (!bError)
db_free(&dbv);
}
diff --git a/protocols/MinecraftDynmap/src/chat.cpp b/protocols/MinecraftDynmap/src/chat.cpp
index 7e267dda79..be33afe618 100644
--- a/protocols/MinecraftDynmap/src/chat.cpp
+++ b/protocols/MinecraftDynmap/src/chat.cpp
@@ -27,25 +27,22 @@ void MinecraftDynmapProto::UpdateChat(const char *name, const char *message, con
std::string smessage = message;
utils::text::replace_all(&smessage, "%", "%%");
- ptrW tmessage(mir_a2u_cp(smessage.c_str(), CP_UTF8));
- ptrW tname(mir_a2u_cp(name, CP_UTF8));
-
- GCEVENT gce = { m_szModuleName, m_tszUserName, GC_EVENT_MESSAGE };
+ GCEVENT gce = { m_szModuleName, szRoomName, GC_EVENT_MESSAGE };
+ gce.dwFlags = GCEF_UTF8;
gce.time = timestamp;
- gce.ptszText = tmessage;
+ gce.pszText.a = smessage.c_str();
- if (tname == NULL) {
+ if (name == NULL) {
gce.iType = GC_EVENT_INFORMATION;
- tname = mir_wstrdup(TranslateT("Server"));
+ name = TranslateU("Server");
gce.bIsMe = false;
}
else gce.bIsMe = (m_nick == name);
if (addtolog)
- gce.dwFlags |= GCEF_ADDTOLOG;
+ gce.dwFlags |= GCEF_ADDTOLOG;
- gce.ptszNick = tname;
- gce.ptszUID = gce.ptszNick;
+ gce.pszUID.a = gce.pszNick.a = name;
Chat_Event(&gce);
}
@@ -84,34 +81,27 @@ int MinecraftDynmapProto::OnChatEvent(WPARAM, LPARAM lParam)
void MinecraftDynmapProto::AddChatContact(const char *name)
{
- ptrW tname(mir_a2u_cp(name, CP_UTF8));
-
- GCEVENT gce = { m_szModuleName, m_tszUserName, GC_EVENT_JOIN };
+ GCEVENT gce = { m_szModuleName, szRoomName, GC_EVENT_JOIN };
gce.time = DWORD(time(0));
- gce.dwFlags = GCEF_ADDTOLOG;
- gce.ptszNick = tname;
- gce.ptszUID = gce.ptszNick;
+ gce.dwFlags = GCEF_UTF8 + GCEF_ADDTOLOG;
+ gce.pszUID.a = gce.pszNick.a = name;
gce.bIsMe = (m_nick == name);
if (gce.bIsMe)
- gce.ptszStatus = L"Admin";
+ gce.pszStatus.a = "Admin";
else
- gce.ptszStatus = L"Normal";
+ gce.pszStatus.a = "Normal";
Chat_Event(&gce);
}
void MinecraftDynmapProto::DeleteChatContact(const char *name)
{
- ptrW tname(mir_a2u_cp(name, CP_UTF8));
-
- GCEVENT gce = { m_szModuleName, m_tszUserName, GC_EVENT_PART };
- gce.dwFlags = GCEF_ADDTOLOG;
- gce.ptszNick = tname;
- gce.ptszUID = gce.ptszNick;
+ GCEVENT gce = { m_szModuleName, szRoomName, GC_EVENT_PART };
+ gce.dwFlags = GCEF_UTF8 + GCEF_ADDTOLOG;
+ gce.pszUID.a = gce.pszNick.a = name;
gce.time = DWORD(time(0));
gce.bIsMe = (m_nick == name);
-
Chat_Event(&gce);
}
@@ -137,12 +127,10 @@ INT_PTR MinecraftDynmapProto::OnJoinChat(WPARAM,LPARAM suppress)
void MinecraftDynmapProto::SetTopic(const char *topic)
{
- ptrW ttopic(mir_a2u_cp(topic, CP_UTF8));
-
- GCEVENT gce = { m_szModuleName, m_tszUserName, GC_EVENT_TOPIC };
+ GCEVENT gce = { m_szModuleName, szRoomName, GC_EVENT_TOPIC };
+ gce.dwFlags = GCEF_UTF8;
gce.time = ::time(0);
- gce.ptszText = ttopic;
-
+ gce.pszText.a = topic;
Chat_Event( &gce);
}
diff --git a/protocols/MinecraftDynmap/src/proto.cpp b/protocols/MinecraftDynmap/src/proto.cpp
index da4ad2d994..9f1b06b19a 100644
--- a/protocols/MinecraftDynmap/src/proto.cpp
+++ b/protocols/MinecraftDynmap/src/proto.cpp
@@ -58,6 +58,7 @@ MinecraftDynmapProto::MinecraftDynmapProto(const char* proto_name, const wchar_t
// Client instantiation
this->error_count_ = 0;
this->chatHandle_ = nullptr;
+ this->szRoomName = mir_utf8encodeW(username);
}
MinecraftDynmapProto::~MinecraftDynmapProto()
diff --git a/protocols/MinecraftDynmap/src/proto.h b/protocols/MinecraftDynmap/src/proto.h
index 108f80a7ec..495d651071 100644
--- a/protocols/MinecraftDynmap/src/proto.h
+++ b/protocols/MinecraftDynmap/src/proto.h
@@ -24,6 +24,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
class MinecraftDynmapProto : public PROTO<MinecraftDynmapProto>
{
+ ptrA szRoomName;
+
public:
MinecraftDynmapProto(const char *proto_name, const wchar_t *username);
~MinecraftDynmapProto();
@@ -65,7 +67,6 @@ public:
void __cdecl SendMsgWorker(void*);
// Chat handling
- void AddChat(const char *id, const char *name);
void UpdateChat(const char *name, const char *message, const time_t timestamp = time(0), bool addtochat = true);
void AddChatContact(const char *nick);
void DeleteChatContact(const char *name);
diff --git a/protocols/Omegle/src/chat.cpp b/protocols/Omegle/src/chat.cpp
index 0b37532c8d..28e6fff0a7 100644
--- a/protocols/Omegle/src/chat.cpp
+++ b/protocols/Omegle/src/chat.cpp
@@ -48,9 +48,10 @@ void OmegleProto::UpdateChat(const wchar_t *name, const wchar_t *message, bool a
CMStringW smessage(message);
smessage.Replace(L"%", L"%%");
- GCEVENT gce = { m_szModuleName, m_tszUserName, GC_EVENT_MESSAGE };
+ GCEVENT gce = { m_szModuleName, 0, GC_EVENT_MESSAGE };
+ gce.pszID.w = m_tszUserName;
gce.time = ::time(0);
- gce.ptszText = smessage.c_str();
+ gce.pszText.w = smessage.c_str();
if (name == nullptr) {
gce.iType = GC_EVENT_INFORMATION;
@@ -62,8 +63,8 @@ void OmegleProto::UpdateChat(const wchar_t *name, const wchar_t *message, bool a
if (addtolog)
gce.dwFlags |= GCEF_ADDTOLOG;
- gce.ptszNick = name;
- gce.ptszUID = gce.ptszNick;
+ gce.pszNick.w = name;
+ gce.pszUID.w = gce.pszNick.w;
Chat_Event(&gce);
}
@@ -204,11 +205,12 @@ void OmegleProto::SendChatMessage(std::string text)
void OmegleProto::AddChatContact(const wchar_t *name)
{
- GCEVENT gce = { m_szModuleName, m_tszUserName, GC_EVENT_JOIN };
+ GCEVENT gce = { m_szModuleName, 0, GC_EVENT_JOIN };
+ gce.pszID.w = m_tszUserName;
gce.time = DWORD(time(0));
gce.dwFlags = GCEF_ADDTOLOG;
- gce.ptszNick = name;
- gce.ptszUID = gce.ptszNick;
+ gce.pszNick.w = name;
+ gce.pszUID.w = gce.pszNick.w;
if (name == nullptr)
gce.bIsMe = false;
@@ -216,19 +218,20 @@ void OmegleProto::AddChatContact(const wchar_t *name)
gce.bIsMe = mir_wstrcmp(name, this->facy.nick_);
if (gce.bIsMe)
- gce.ptszStatus = L"Admin";
+ gce.pszStatus.w = L"Admin";
else
- gce.ptszStatus = L"Normal";
+ gce.pszStatus.w = L"Normal";
Chat_Event(&gce);
}
void OmegleProto::DeleteChatContact(const wchar_t *name)
{
- GCEVENT gce = { m_szModuleName, m_tszUserName, GC_EVENT_PART };
+ GCEVENT gce = { m_szModuleName, 0, GC_EVENT_PART };
+ gce.pszID.w = m_tszUserName;
gce.dwFlags = GCEF_ADDTOLOG;
- gce.ptszNick = name;
- gce.ptszUID = gce.ptszNick;
+ gce.pszNick.w = name;
+ gce.pszUID.w = gce.pszNick.w;
gce.time = DWORD(time(0));
if (name == nullptr)
gce.bIsMe = false;
@@ -260,13 +263,14 @@ INT_PTR OmegleProto::OnJoinChat(WPARAM, LPARAM suppress)
void OmegleProto::SetTopic(const wchar_t *topic)
{
- GCEVENT gce = { m_szModuleName, m_tszUserName, GC_EVENT_TOPIC };
+ GCEVENT gce = { m_szModuleName, 0, GC_EVENT_TOPIC };
+ gce.pszID.w = m_tszUserName;
gce.time = ::time(0);
if (topic == nullptr)
- gce.ptszText = TranslateT("Omegle is a great way of meeting new friends!");
+ gce.pszText.w = TranslateT("Omegle is a great way of meeting new friends!");
else
- gce.ptszText = topic;
+ gce.pszText.w = topic;
Chat_Event(&gce);
}
diff --git a/protocols/Sametime/src/conference.cpp b/protocols/Sametime/src/conference.cpp
index c08924a9a6..19cfa0cc16 100644
--- a/protocols/Sametime/src/conference.cpp
+++ b/protocols/Sametime/src/conference.cpp
@@ -120,7 +120,8 @@ void mwServiceConf_conf_opened(mwConference* conf, GList* members)
Chat_AddGroup(si, TranslateT("Normal"));
// add users
- GCEVENT gce = { proto->m_szModuleName, tszConfId, GC_EVENT_JOIN };
+ GCEVENT gce = { proto->m_szModuleName, 0, GC_EVENT_JOIN };
+ gce.pszID.w = tszConfId;
GList *user = members;
for (;user; user=user->next) {
@@ -129,8 +130,8 @@ void mwServiceConf_conf_opened(mwConference* conf, GList* members)
ptrW tszUserName(mir_utf8decodeW(((mwLoginInfo*)user->data)->user_name));
ptrW tszUserId(mir_utf8decodeW(((mwLoginInfo*)user->data)->login_id));
gce.dwFlags = GCEF_ADDTOLOG;
- gce.ptszNick = tszUserName;
- gce.ptszUID = tszUserId;
+ gce.pszNick.w = tszUserName;
+ gce.pszUID.w = tszUserId;
gce.bIsMe = (strcmp(((mwLoginInfo*)user->data)->login_id, proto->my_login_info->login_id) == 0);
Chat_Event( &gce);
}
@@ -181,11 +182,12 @@ void mwServiceConf_on_peer_joined(mwConference* conf, mwLoginInfo *user)
ptrW tszUserId(mir_utf8decodeW(user->login_id));
// add user
- GCEVENT gce = { proto->m_szModuleName, tszConfId, GC_EVENT_JOIN };
+ GCEVENT gce = { proto->m_szModuleName, 0, GC_EVENT_JOIN };
+ gce.pszID.w = tszConfId;
gce.dwFlags = GCEF_ADDTOLOG;
- gce.ptszNick = tszUserName;
- gce.ptszUID = tszUserId;
- gce.ptszStatus = L"Normal";
+ gce.pszNick.w = tszUserName;
+ gce.pszUID.w = tszUserId;
+ gce.pszStatus.w = L"Normal";
gce.time = (DWORD)time(0);
Chat_Event( &gce);
@@ -206,11 +208,12 @@ void mwServiceConf_on_peer_parted(mwConference* conf, mwLoginInfo* user)
ptrW tszUserId(mir_utf8decodeW(user->login_id));
// remove user
- GCEVENT gce = { proto->m_szModuleName, tszConfId, GC_EVENT_PART };
+ GCEVENT gce = { proto->m_szModuleName, 0, GC_EVENT_PART };
+ gce.pszID.w = tszConfId;
gce.dwFlags = GCEF_ADDTOLOG;
- gce.ptszNick = tszUserName;
- gce.ptszUID = tszUserId;
- gce.ptszStatus = L"Normal";
+ gce.pszNick.w = tszUserName;
+ gce.pszUID.w = tszUserId;
+ gce.pszStatus.w = L"Normal";
gce.time = (DWORD)time(0);
Chat_Event(&gce);
}
@@ -226,11 +229,12 @@ void mwServiceConf_on_text(mwConference* conf, mwLoginInfo* user, const char* wh
ptrW tszUserId(mir_utf8decodeW(user->login_id));
ptrW tszUserName(mir_utf8decodeW(user->user_name));
- GCEVENT gce = { proto->m_szModuleName, tszConfId, GC_EVENT_MESSAGE };
+ GCEVENT gce = { proto->m_szModuleName, 0, GC_EVENT_MESSAGE };
+ gce.pszID.w = tszConfId;
gce.dwFlags = GCEF_ADDTOLOG;
- gce.ptszText = textT;
- gce.ptszNick = tszUserName;
- gce.ptszUID = tszUserId;
+ gce.pszText.w = textT;
+ gce.pszNick.w = tszUserName;
+ gce.pszUID.w = tszUserId;
gce.time = (DWORD)time(0);
Chat_Event(&gce);
}
diff --git a/protocols/SkypeWeb/src/skype_chatrooms.cpp b/protocols/SkypeWeb/src/skype_chatrooms.cpp
index a95cf6a191..44ee84166b 100644
--- a/protocols/SkypeWeb/src/skype_chatrooms.cpp
+++ b/protocols/SkypeWeb/src/skype_chatrooms.cpp
@@ -96,18 +96,18 @@ int CSkypeProto::OnGroupChatEventHook(WPARAM, LPARAM lParam)
if (mir_strcmp(gch->pszModule, m_szModuleName) != 0)
return 0;
- _T2A chat_id(gch->ptszID);
+ T2Utf chat_id(gch->ptszID), user_id(gch->ptszUID);
switch (gch->iType) {
case GC_USER_MESSAGE:
- OnSendChatMessage(gch->ptszID, gch->ptszText);
+ OnSendChatMessage(chat_id, gch->ptszText);
break;
case GC_USER_PRIVMESS:
{
- MCONTACT hContact = FindContact(_T2A(gch->ptszUID));
+ MCONTACT hContact = FindContact(user_id);
if (hContact == NULL) {
- hContact = AddContact(_T2A(gch->ptszUID), true);
+ hContact = AddContact(user_id, true);
setWord(hContact, "Status", ID_STATUS_ONLINE);
db_set_b(hContact, "CList", "Hidden", 1);
setWString(hContact, "Nick", gch->ptszUID);
@@ -154,62 +154,57 @@ int CSkypeProto::OnGroupChatEventHook(WPARAM, LPARAM lParam)
break;
case GC_USER_NICKLISTMENU:
- {
- _T2A user_id(gch->ptszUID);
-
- switch (gch->dwData) {
- case 10:
- SendRequest(new KickUserRequest(chat_id, user_id, li));
- break;
- case 30:
- SendRequest(new InviteUserToChatRequest(chat_id, user_id, "Admin", li));
- break;
- case 40:
- SendRequest(new InviteUserToChatRequest(chat_id, user_id, "User", li));
- break;
- case 50:
- ptrW tnick_old(GetChatContactNick(chat_id, _T2A(gch->ptszUID), _T2A(gch->ptszText)));
-
- ENTER_STRING pForm = { sizeof(pForm) };
- pForm.type = ESF_COMBO;
- pForm.recentCount = 0;
- pForm.caption = TranslateT("Enter new nickname");
- pForm.ptszInitVal = tnick_old;
- pForm.szModuleName = m_szModuleName;
- pForm.szDataPrefix = "renamenick_";
-
- if (EnterString(&pForm)) {
- MCONTACT hChatContact = FindChatRoom(chat_id);
- if (hChatContact == NULL)
- break; // This probably shouldn't happen, but if chat is NULL for some reason, do nothing
-
- ptrW tnick_new(pForm.ptszResult);
- bool reset = mir_wstrlen(tnick_new) == 0;
- if (reset) {
- // User fill blank name, which means we reset the custom nick
- db_unset(hChatContact, "UsersNicks", _T2A(gch->ptszUID));
- tnick_new = GetChatContactNick(chat_id, _T2A(gch->ptszUID), _T2A(gch->ptszText));
- }
-
- if (!mir_wstrcmp(tnick_old, tnick_new))
- break; // New nick is same, do nothing
-
- GCEVENT gce = { m_szModuleName, gch->ptszID, GC_EVENT_NICK };
- gce.ptszNick = tnick_old;
- gce.bIsMe = IsMe(user_id);
- gce.ptszUID = gch->ptszUID;
- gce.ptszText = tnick_new;
- gce.dwFlags = GCEF_ADDTOLOG;
- gce.time = time(0);
- Chat_Event(&gce);
-
- if (!reset)
- db_set_ws(hChatContact, "UsersNicks", _T2A(gch->ptszUID), tnick_new);
+ switch (gch->dwData) {
+ case 10:
+ SendRequest(new KickUserRequest(chat_id, user_id, li));
+ break;
+ case 30:
+ SendRequest(new InviteUserToChatRequest(chat_id, user_id, "Admin", li));
+ break;
+ case 40:
+ SendRequest(new InviteUserToChatRequest(chat_id, user_id, "User", li));
+ break;
+ case 50:
+ ptrA tnick_old(GetChatContactNick(chat_id, user_id, T2Utf(gch->ptszText)));
+
+ ENTER_STRING pForm = { sizeof(pForm) };
+ pForm.type = ESF_COMBO;
+ pForm.recentCount = 0;
+ pForm.caption = TranslateT("Enter new nickname");
+ pForm.szModuleName = m_szModuleName;
+ pForm.szDataPrefix = "renamenick_";
+
+ if (EnterString(&pForm)) {
+ MCONTACT hChatContact = FindChatRoom(chat_id);
+ if (hChatContact == NULL)
+ break; // This probably shouldn't happen, but if chat is NULL for some reason, do nothing
+
+ ptrA tnick_new(mir_utf8encodeW(pForm.ptszResult));
+ bool reset = mir_strlen(tnick_new) == 0;
+ if (reset) {
+ // User fill blank name, which means we reset the custom nick
+ db_unset(hChatContact, "UsersNicks", user_id);
+ tnick_new = GetChatContactNick(chat_id, user_id, _T2A(gch->ptszText));
}
- break;
+
+ if (!mir_strcmp(tnick_old, tnick_new))
+ break; // New nick is same, do nothing
+
+ GCEVENT gce = { m_szModuleName, chat_id, GC_EVENT_NICK };
+ gce.dwFlags = GCEF_UTF8 + GCEF_ADDTOLOG;
+ gce.pszNick.a = tnick_old;
+ gce.bIsMe = IsMe(user_id);
+ gce.pszUID.a = user_id;
+ gce.pszText.a = tnick_new;
+ gce.time = time(0);
+ Chat_Event(&gce);
+
+ if (!reset)
+ db_set_utf(hChatContact, "UsersNicks", user_id, tnick_new);
}
break;
}
+ break;
}
return 0;
}
@@ -261,7 +256,7 @@ void CSkypeProto::OnChatEvent(const JSONNode &node)
std::string messageType = node["messagetype"].as_string();
if (messageType == "Text" || messageType == "RichText") {
ptrA szClearedContent(messageType == "RichText" ? RemoveHtml(strContent.c_str()) : mir_strdup(strContent.c_str()));
- AddMessageToChat(_A2T(szConversationName), _A2T(szFromSkypename), szClearedContent, nEmoteOffset != NULL, nEmoteOffset, timestamp);
+ AddMessageToChat(szConversationName, szFromSkypename, szClearedContent, nEmoteOffset != NULL, nEmoteOffset, timestamp);
}
else if (messageType == "ThreadActivity/AddMember") {
// <addmember><eventtime>1429186229164</eventtime><initiator>8:initiator</initiator><target>8:user</target></addmember>
@@ -271,7 +266,7 @@ void CSkypeProto::OnChatEvent(const JSONNode &node)
if (auto *pRoot = doc.FirstChildElement("addMember")) {
CMStringA target = ParseUrl(pRoot->FirstChildElement("target")->Value(), "8:");
- AddChatContact(_A2T(szConversationName), target, target, L"User");
+ AddChatContact(szConversationName, target, target, "User");
}
}
else if (messageType == "ThreadActivity/DeleteMember") {
@@ -283,7 +278,7 @@ void CSkypeProto::OnChatEvent(const JSONNode &node)
if (auto *pRoot = doc.FirstChildElement("deletemember")) {
CMStringA target = ParseUrl(pRoot->FirstChildElement("target")->Value(), "8:");
CMStringA initiator = ParseUrl(pRoot->FirstChildElement("initiator")->Value(), "8:");
- RemoveChatContact(_A2T(szConversationName), target, target, true, initiator);
+ RemoveChatContact(szConversationName, target, target, true, initiator);
}
}
else if (messageType == "ThreadActivity/TopicUpdate") {
@@ -315,25 +310,21 @@ void CSkypeProto::OnChatEvent(const JSONNode &node)
CMStringA id = ParseUrl(pTarget->FirstChildElement("id")->Value(), "8:");
const char *role = pTarget->FirstChildElement("role")->Value();
- ptrW tszId(mir_a2u(id));
- ptrW tszRole(mir_a2u(role));
- ptrW tszInitiator(mir_a2u(initiator));
-
- GCEVENT gce = { m_szModuleName, _A2T(szConversationName), !mir_strcmpi(role, "Admin") ? GC_EVENT_ADDSTATUS : GC_EVENT_REMOVESTATUS };
- gce.dwFlags = GCEF_ADDTOLOG;
- gce.ptszNick = tszId;
- gce.ptszUID = tszId;
- gce.ptszText = tszInitiator;
+ GCEVENT gce = { m_szModuleName, szConversationName, !mir_strcmpi(role, "Admin") ? GC_EVENT_ADDSTATUS : GC_EVENT_REMOVESTATUS };
+ gce.dwFlags = GCEF_ADDTOLOG + GCEF_UTF8;
+ gce.pszNick.a = id;
+ gce.pszUID.a = id;
+ gce.pszText.a = initiator;
gce.time = time(0);
gce.bIsMe = IsMe(id);
- gce.ptszStatus = TranslateT("Admin");
+ gce.pszStatus.a = TranslateU("Admin");
Chat_Event(&gce);
}
}
}
}
-void CSkypeProto::OnSendChatMessage(const wchar_t *chat_id, const wchar_t *tszMessage)
+void CSkypeProto::OnSendChatMessage(const char *chat_id, const wchar_t *tszMessage)
{
if (!IsOnline())
return;
@@ -342,33 +333,33 @@ void CSkypeProto::OnSendChatMessage(const wchar_t *chat_id, const wchar_t *tszMe
rtrimw(buf);
Chat_UnescapeTags(buf);
- ptrA szChatId(mir_u2a(chat_id));
ptrA szMessage(mir_utf8encodeW(buf));
if (strncmp(szMessage, "/me ", 4) == 0)
- SendRequest(new SendChatActionRequest(szChatId, time(0), szMessage, li));
+ SendRequest(new SendChatActionRequest(chat_id, time(0), szMessage, li));
else
- SendRequest(new SendChatMessageRequest(szChatId, time(0), szMessage, li));
+ SendRequest(new SendChatMessageRequest(chat_id, time(0), szMessage, li));
}
-void CSkypeProto::AddMessageToChat(const wchar_t *chat_id, const wchar_t *from, const char *content, bool isAction, int emoteOffset, time_t timestamp, bool isLoading)
+void CSkypeProto::AddMessageToChat(const char *chat_id, const char *from, const char *content, bool isAction, int emoteOffset, time_t timestamp, bool isLoading)
{
- ptrW tnick(GetChatContactNick(_T2A(chat_id), _T2A(from), _T2A(from)));
+ ptrA tnick(GetChatContactNick(chat_id, from, from));
GCEVENT gce = { m_szModuleName, chat_id, isAction ? GC_EVENT_ACTION : GC_EVENT_MESSAGE };
- gce.bIsMe = IsMe(_T2A(from));
- gce.ptszNick = tnick;
+ gce.dwFlags = GCEF_UTF8;
+ gce.bIsMe = IsMe(from);
+ gce.pszNick.a = tnick;
gce.time = timestamp;
- gce.ptszUID = from;
+ gce.pszUID.a = from;
- CMStringW tszText(ptrW(mir_utf8decodeW(content)));
- tszText.Replace(L"%", L"%%");
+ CMStringA szText(content);
+ szText.Replace("%", "%%");
if (!isAction) {
- gce.ptszText = tszText;
- gce.dwFlags = GCEF_ADDTOLOG;
+ gce.pszText.a = szText;
+ gce.dwFlags |= GCEF_ADDTOLOG;
}
- else gce.ptszText = &(tszText.GetBuffer())[emoteOffset];
+ else gce.pszText.a = szText.GetBuffer() + emoteOffset;
if (isLoading)
gce.dwFlags |= GCEF_NOTNOTIFY;
@@ -398,8 +389,8 @@ void CSkypeProto::OnGetChatInfo(const NETLIBHTTPREQUEST *response, void *p)
CMStringA username(UrlToSkypename(member["userLink"].as_string().c_str()));
std::string role = member["role"].as_string();
- if (!IsChatContact(_A2T(chatId), username))
- AddChatContact(_A2T(chatId), username, username, _A2T(role.c_str()), true);
+ if (!IsChatContact(chatId, username))
+ AddChatContact(chatId, username, username, role.c_str(), true);
}
PushRequest(new GetHistoryRequest(chatId, 15, true, 0, li), &CSkypeProto::OnGetServerHistory);
}
@@ -413,107 +404,100 @@ void CSkypeProto::RenameChat(const char *chat_id, const char *name)
void CSkypeProto::ChangeChatTopic(const char *chat_id, const char *topic, const char *initiator)
{
- ptrW tchat_id(mir_a2u(chat_id));
- ptrW tname(mir_a2u(initiator));
- ptrW ttopic(mir_utf8decodeW(topic));
-
- GCEVENT gce = { m_szModuleName, tchat_id, GC_EVENT_TOPIC };
- gce.ptszUID = tname;
- gce.ptszNick = tname;
- gce.ptszText = ttopic;
+ GCEVENT gce = { m_szModuleName, chat_id, GC_EVENT_TOPIC };
+ gce.dwFlags = GCEF_UTF8;
+ gce.pszUID.a = initiator;
+ gce.pszNick.a = initiator;
+ gce.pszText.a = topic;
Chat_Event(&gce);
}
-bool CSkypeProto::IsChatContact(const wchar_t *chat_id, const char *id)
+bool CSkypeProto::IsChatContact(const char *chat_id, const char *id)
{
ptrA users(GetChatUsers(chat_id));
return (users != NULL && strstr(users, id) != nullptr);
}
-char *CSkypeProto::GetChatUsers(const wchar_t *chat_id)
+char* CSkypeProto::GetChatUsers(const char *chat_id)
{
+ Utf2T id(chat_id);
+
GC_INFO gci = { 0 };
gci.Flags = GCF_USERS;
gci.pszModule = m_szModuleName;
- gci.pszID = chat_id;
+ gci.pszID = id;
Chat_GetInfo(&gci);
return gci.pszUsers;
}
-wchar_t* CSkypeProto::GetChatContactNick(const char *chat_id, const char *id, const char *name)
+char* CSkypeProto::GetChatContactNick(const char *chat_id, const char *id, const char *name)
{
// Check if there is custom nick for this chat contact
if (chat_id != nullptr) {
- if (wchar_t *tname = db_get_wsa(FindChatRoom(chat_id), "UsersNicks", id))
+ if (char *tname = db_get_utfa(FindChatRoom(chat_id), "UsersNicks", id))
return tname;
}
// Check if we have this contact in database
if (IsMe(id)) {
// Return my nick
- if (wchar_t *tname = getWStringA(NULL, "Nick"))
+ if (char *tname = getUStringA(NULL, "Nick"))
return tname;
}
else {
MCONTACT hContact = FindContact(id);
if (hContact != NULL) {
// Primarily return custom name
- if (wchar_t *tname = db_get_wsa(hContact, "CList", "MyHandle"))
+ if (char *tname = db_get_utfa(hContact, "CList", "MyHandle"))
return tname;
// If not exists, then user nick
- if (wchar_t *tname = getWStringA(hContact, "Nick"))
+ if (char *tname = getUStringA(hContact, "Nick"))
return tname;
}
}
// Return default value as nick - given name or user id
if (name != nullptr)
- return mir_a2u_cp(name, CP_UTF8);
- else
- return mir_a2u(id);
+ return mir_strdup(name);
+ return mir_strdup(id);
}
-void CSkypeProto::AddChatContact(const wchar_t *tchat_id, const char *id, const char *name, const wchar_t *role, bool isChange)
+void CSkypeProto::AddChatContact(const char *chat_id, const char *id, const char *name, const char *role, bool isChange)
{
- if (IsChatContact(tchat_id, id))
+ if (IsChatContact(chat_id, id))
return;
- ptrW tnick(GetChatContactNick(_T2A(tchat_id), id, name));
- ptrW tid(mir_a2u(id));
+ ptrA szNick(GetChatContactNick(chat_id, id, name));
- GCEVENT gce = { m_szModuleName, tchat_id, GC_EVENT_JOIN };
- gce.dwFlags = GCEF_ADDTOLOG;
- gce.ptszNick = tnick;
- gce.ptszUID = tid;
+ GCEVENT gce = { m_szModuleName, chat_id, GC_EVENT_JOIN };
+ gce.dwFlags = GCEF_UTF8 + GCEF_ADDTOLOG;
+ gce.pszNick.a = szNick;
+ gce.pszUID.a = id;
gce.time = !isChange ? time(0) : NULL;
gce.bIsMe = IsMe(id);
- gce.ptszStatus = TranslateW(role);
-
+ gce.pszStatus.a = TranslateU(role);
Chat_Event(&gce);
}
-void CSkypeProto::RemoveChatContact(const wchar_t *tchat_id, const char *id, const char *name, bool isKick, const char *initiator)
+void CSkypeProto::RemoveChatContact(const char *chat_id, const char *id, const char *name, bool isKick, const char *initiator)
{
if (IsMe(id))
return;
- ptrW tnick(GetChatContactNick(_T2A(tchat_id), id, name));
- ptrW tinitiator(GetChatContactNick(_T2A(tchat_id), initiator, initiator));
+ ptrA szNick(GetChatContactNick(chat_id, id, name));
+ ptrA szInitiator(GetChatContactNick(chat_id, initiator, initiator));
ptrW tid(mir_a2u(id));
- GCEVENT gce = { m_szModuleName, tchat_id, isKick ? GC_EVENT_KICK : GC_EVENT_PART };
- if (isKick) {
- gce.ptszUID = tid;
- gce.ptszNick = tnick;
- gce.ptszStatus = tinitiator;
- gce.time = time(0);
- }
+ GCEVENT gce = { m_szModuleName, chat_id, isKick ? GC_EVENT_KICK : GC_EVENT_PART };
+ gce.dwFlags = GCEF_UTF8;
+ gce.pszNick.a = szNick;
+ gce.pszUID.a = id;
+ gce.time = time(0);
+ if (isKick)
+ gce.pszStatus.a = szInitiator;
else {
- gce.dwFlags = GCEF_ADDTOLOG;
- gce.ptszNick = tnick;
- gce.ptszUID = tid;
- gce.time = time(0);
+ gce.dwFlags += GCEF_ADDTOLOG;
gce.bIsMe = IsMe(id);
}
diff --git a/protocols/SkypeWeb/src/skype_history_sync.cpp b/protocols/SkypeWeb/src/skype_history_sync.cpp
index 643114156a..7c68efabbf 100644
--- a/protocols/SkypeWeb/src/skype_history_sync.cpp
+++ b/protocols/SkypeWeb/src/skype_history_sync.cpp
@@ -96,7 +96,7 @@ void CSkypeProto::OnGetServerHistory(const NETLIBHTTPREQUEST *response)
CMStringA chatname(UrlToSkypename(conversationLink.c_str()));
ptrA szMessage(messageType == "RichText" ? RemoveHtml(content.c_str()) : mir_strdup(content.c_str()));
if (messageType == "Text" || messageType == "RichText") {
- AddMessageToChat(_A2T(chatname), _A2T(skypename), szMessage, emoteOffset != NULL, emoteOffset, timestamp, true);
+ AddMessageToChat(chatname, skypename, szMessage, emoteOffset != NULL, emoteOffset, timestamp, true);
}
}
}
diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h
index 043cd49db2..3ca8336a1b 100644
--- a/protocols/SkypeWeb/src/skype_proto.h
+++ b/protocols/SkypeWeb/src/skype_proto.h
@@ -324,13 +324,13 @@ private:
void OnGetChatInfo(const NETLIBHTTPREQUEST *response, void *p);
void OnChatEvent(const JSONNode &node);
- void OnSendChatMessage(const wchar_t *chat_id, const wchar_t * tszMessage);
- char* GetChatUsers(const wchar_t *chat_id);
- bool IsChatContact(const wchar_t *chat_id, const char *id);
- void AddMessageToChat(const wchar_t *chat_id, const wchar_t *from, const char *content, bool isAction, int emoteOffset, time_t timestamp, bool isLoading = false);
- void AddChatContact(const wchar_t *tchat_id, const char *id, const char *name, const wchar_t *role, bool isChange = false);
- void RemoveChatContact(const wchar_t *tchat_id, const char *id, const char *name, bool isKick = false, const char *initiator = "");
- wchar_t* GetChatContactNick(const char *chat_id, const char *id, const char *name);
+ void OnSendChatMessage(const char *chat_id, const wchar_t *tszMessage);
+ char* GetChatUsers(const char *chat_id);
+ bool IsChatContact(const char *chat_id, const char *id);
+ void AddMessageToChat(const char *chat_id, const char *from, const char *content, bool isAction, int emoteOffset, time_t timestamp, bool isLoading = false);
+ void AddChatContact(const char *chat_id, const char *id, const char *name, const char *role, bool isChange = false);
+ void RemoveChatContact(const char *chat_id, const char *id, const char *name, bool isKick = false, const char *initiator = "");
+ char* GetChatContactNick(const char *chat_id, const char *id, const char *name);
void RenameChat(const char *chat_id, const char *name);
void ChangeChatTopic(const char * chat_id, const char *topic, const char *initiator);
diff --git a/protocols/Twitter/src/chat.cpp b/protocols/Twitter/src/chat.cpp
index cbd2ee90aa..49601fc0ac 100644
--- a/protocols/Twitter/src/chat.cpp
+++ b/protocols/Twitter/src/chat.cpp
@@ -24,34 +24,31 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
void TwitterProto::UpdateChat(const twitter_user &update)
{
- GCEVENT gce = { m_szModuleName, m_tszUserName, GC_EVENT_MESSAGE };
+ GCEVENT gce = { m_szModuleName, m_szChatId, GC_EVENT_MESSAGE };
+ gce.dwFlags = GCEF_UTF8 + GCEF_ADDTOLOG;
gce.bIsMe = (update.username == twit_.get_username());
- gce.dwFlags = GCEF_ADDTOLOG;
- gce.ptszUID = mir_a2u(update.username.c_str());
+ gce.pszUID.a = 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;
replaceAll(chatText, "%", "%%");
- gce.ptszText = mir_a2u_cp(chatText.c_str(), CP_UTF8);
- //gce.ptszText = mir_a2u_cp(update.status.text.c_str(),CP_UTF8);
+ gce.pszText.a = chatText.c_str();
gce.time = static_cast<DWORD>(update.status.time);
- DBVARIANT nick;
MCONTACT hContact = UsernameToHContact(update.username.c_str());
- if (hContact && !db_get_s(hContact, "CList", "MyHandle", &nick)) {
- gce.ptszNick = mir_a2u(nick.pszVal);
- db_free(&nick);
- }
+ CMStringA szNick = db_get_sm(hContact, "CList", "MyHandle");
+ if (hContact && !szNick.IsEmpty())
+ gce.pszNick.a = szNick;
else
- gce.ptszNick = mir_a2u(update.username.c_str());
+ gce.pszNick.a = update.username.c_str();
Chat_Event(&gce);
- mir_free(const_cast<wchar_t*>(gce.ptszNick));
- mir_free(const_cast<wchar_t*>(gce.ptszUID));
- mir_free(const_cast<wchar_t*>(gce.ptszText));
+ mir_free(const_cast<wchar_t*>(gce.pszNick.w));
+ mir_free(const_cast<wchar_t*>(gce.pszUID.w));
+ mir_free(const_cast<wchar_t*>(gce.pszText.w));
}
int TwitterProto::OnChatOutgoing(WPARAM, LPARAM lParam)
@@ -88,25 +85,21 @@ int TwitterProto::OnChatOutgoing(WPARAM, LPARAM lParam)
// TODO: remove nick?
void TwitterProto::AddChatContact(const char *name, const char *nick)
{
- ptrW wszId(mir_a2u(name));
- ptrW wszNick(mir_a2u(nick ? nick : name));
-
- GCEVENT gce = { m_szModuleName, m_tszUserName, GC_EVENT_JOIN };
+ GCEVENT gce = { m_szModuleName, m_szChatId, GC_EVENT_JOIN };
+ gce.dwFlags = GCEF_UTF8;
gce.time = DWORD(time(0));
- gce.ptszNick = wszNick;
- gce.ptszUID = wszId;
- gce.ptszStatus = L"Normal";
+ gce.pszNick.a = nick ? nick : name;
+ gce.pszUID.a = name;
+ gce.pszStatus.a = "Normal";
Chat_Event(&gce);
}
void TwitterProto::DeleteChatContact(const char *name)
{
- ptrW wszId(mir_a2u(name));
-
- GCEVENT gce = { m_szModuleName, m_tszUserName, GC_EVENT_PART };
+ GCEVENT gce = { m_szModuleName, m_szChatId, GC_EVENT_PART };
+ gce.dwFlags = GCEF_UTF8;
gce.time = DWORD(time(0));
- gce.ptszNick = wszId;
- gce.ptszUID = gce.ptszNick;
+ gce.pszUID.a = gce.pszNick.a = name;
Chat_Event(&gce);
}
diff --git a/protocols/Twitter/src/proto.cpp b/protocols/Twitter/src/proto.cpp
index 8ef5a20493..7ad53590e0 100644
--- a/protocols/Twitter/src/proto.cpp
+++ b/protocols/Twitter/src/proto.cpp
@@ -27,7 +27,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
static volatile LONG g_msgid = 1;
TwitterProto::TwitterProto(const char *proto_name, const wchar_t *username) :
- PROTO<TwitterProto>(proto_name, username)
+ PROTO<TwitterProto>(proto_name, username),
+ m_szChatId(mir_utf8encodeW(username))
{
CreateProtoService(PS_CREATEACCMGRUI, &TwitterProto::SvcCreateAccMgrUI);
diff --git a/protocols/Twitter/src/proto.h b/protocols/Twitter/src/proto.h
index eb7eec67b2..b7d05b5686 100644
--- a/protocols/Twitter/src/proto.h
+++ b/protocols/Twitter/src/proto.h
@@ -22,6 +22,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
class TwitterProto : public PROTO<TwitterProto>
{
+ ptrA m_szChatId;
+
public:
TwitterProto(const char*,const wchar_t*);
~TwitterProto();
diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp
index 7603de598a..e72a0e0634 100644
--- a/protocols/VKontakte/src/vk_chats.cpp
+++ b/protocols/VKontakte/src/vk_chats.cpp
@@ -166,11 +166,12 @@ void CVkProto::OnReceiveChatInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
cu->m_bUnknown = false;
if (bNew) {
- GCEVENT gce = { m_szModuleName, cc->m_wszId, GC_EVENT_JOIN };
+ GCEVENT gce = { m_szModuleName, 0, GC_EVENT_JOIN };
+ gce.pszID.w = cc->m_wszId;
gce.bIsMe = uid == m_myUserId;
- gce.ptszUID = wszId;
- gce.ptszNick = wszNick;
- gce.ptszStatus = TranslateW(sttStatuses[uid == cc->m_iAdminId]);
+ gce.pszUID.w = wszId;
+ gce.pszNick.w = wszNick;
+ gce.pszStatus.w = TranslateW(sttStatuses[uid == cc->m_iAdminId]);
gce.dwItemData = (INT_PTR)cu;
Chat_Event(&gce);
}
@@ -184,11 +185,12 @@ void CVkProto::OnReceiveChatInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
wchar_t wszId[20];
_itow(cu->m_uid, wszId, 10);
- GCEVENT gce = { m_szModuleName, cc->m_wszId, GC_EVENT_PART };
- gce.ptszUID = wszId;
+ GCEVENT gce = { m_szModuleName, 0, GC_EVENT_PART };
+ gce.pszID.w = cc->m_wszId;
+ gce.pszUID.w = wszId;
gce.dwFlags = GCEF_NOTNOTIFY;
gce.time = time(0);
- gce.ptszNick = mir_wstrdup(CMStringW(FORMAT, L"%s (https://vk.com/id%s)", cu->m_wszNick, wszId));
+ gce.pszNick.w = mir_wstrdup(CMStringW(FORMAT, L"%s (https://vk.com/id%s)", cu->m_wszNick, wszId));
Chat_Event(&gce);
cc->m_users.remove(T.indexOf(&cu));
@@ -397,13 +399,14 @@ void CVkProto::AppendChatMessage(CVkChatInfo *cc, int uid, int msgTime, LPCWSTR
wchar_t wszId[20];
_itow(uid, wszId, 10);
- GCEVENT gce = { m_szModuleName, cc->m_wszId, bIsAction ? GC_EVENT_ACTION : GC_EVENT_MESSAGE };
+ GCEVENT gce = { m_szModuleName, 0, bIsAction ? GC_EVENT_ACTION : GC_EVENT_MESSAGE };
+ gce.pszID.w = cc->m_wszId;
gce.bIsMe = (uid == m_myUserId);
- gce.ptszUID = wszId;
+ gce.pszUID.w = wszId;
gce.time = msgTime;
gce.dwFlags = (bIsHistory) ? GCEF_NOTNOTIFY : GCEF_ADDTOLOG;
- gce.ptszNick = cu->m_wszNick ? mir_wstrdup(cu->m_wszNick) : mir_wstrdup(hContact ? ptrW(db_get_wsa(hContact, m_szModuleName, "Nick")) : TranslateT("Unknown"));
- gce.ptszText = IsEmpty((wchar_t *)pwszBody) ? mir_wstrdup(L"...") : mir_wstrdup(pwszBody);
+ gce.pszNick.w = cu->m_wszNick ? mir_wstrdup(cu->m_wszNick) : mir_wstrdup(hContact ? ptrW(db_get_wsa(hContact, m_szModuleName, "Nick")) : TranslateT("Unknown"));
+ gce.pszText.w = IsEmpty((wchar_t *)pwszBody) ? mir_wstrdup(L"...") : mir_wstrdup(pwszBody);
Chat_Event(&gce);
StopChatContactTyping(cc->m_iChatId, uid);
}
@@ -731,11 +734,12 @@ void CVkProto::NickMenuHook(CVkChatInfo *cc, GCHOOK *gch)
wchar_t wszId[20];
_itow(cu->m_uid, wszId, 10);
- GCEVENT gce = { m_szModuleName, cc->m_wszId, GC_EVENT_NICK };
- gce.ptszNick = mir_wstrdup(cu->m_wszNick);
+ GCEVENT gce = { m_szModuleName, 0, GC_EVENT_NICK };
+ gce.pszID.w = cc->m_wszId;
+ gce.pszNick.w = mir_wstrdup(cu->m_wszNick);
gce.bIsMe = (cu->m_uid == m_myUserId);
- gce.ptszUID = wszId;
- gce.ptszText = mir_wstrdup(wszNewNick);
+ gce.pszUID.w = wszId;
+ gce.pszText.w = mir_wstrdup(wszNewNick);
gce.dwFlags = GCEF_ADDTOLOG;
gce.time = time(0);
Chat_Event(&gce);