summaryrefslogtreecommitdiff
path: root/protocols/MinecraftDynmap/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-02-25 21:02:11 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-02-25 21:02:11 +0300
commit45bf5f51cc788cb8f19e1b8fcd5b8818dc7a2e00 (patch)
tree40a087f36b75b4c1fb7218bd06052df2968bf2d2 /protocols/MinecraftDynmap/src
parent8ba9e423e683d570702476dd93571cea26a27c1a (diff)
GCEVENT::GCEF_UTF8 - flag for direct communication with utf8-encoded chat events (UTF16LE by default)
Diffstat (limited to 'protocols/MinecraftDynmap/src')
-rw-r--r--protocols/MinecraftDynmap/src/chat.cpp48
-rw-r--r--protocols/MinecraftDynmap/src/proto.cpp1
-rw-r--r--protocols/MinecraftDynmap/src/proto.h3
3 files changed, 21 insertions, 31 deletions
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);