summaryrefslogtreecommitdiff
path: root/protocols/Tox/src
diff options
context:
space:
mode:
authoraunsane <aunsane@gmail.com>2018-01-17 22:34:45 +0300
committeraunsane <aunsane@gmail.com>2018-01-17 22:34:45 +0300
commitbf928bd6cfa3df39b4cfda0ff5a5825105cf4a56 (patch)
tree3c7ce179ea9f6a43e671c96186fcbec804170c9a /protocols/Tox/src
parent5f96f1919d2d8210c4a67fe5a4fd9c0f84f9ee27 (diff)
Tox: updated libtox to 0.2.0
- support of message correction - version bump
Diffstat (limited to 'protocols/Tox/src')
-rw-r--r--protocols/Tox/src/resource.h26
-rw-r--r--protocols/Tox/src/stdafx.h4
-rw-r--r--protocols/Tox/src/tox_connection.cpp4
-rw-r--r--protocols/Tox/src/tox_icons.cpp11
-rw-r--r--protocols/Tox/src/tox_messages.cpp44
-rw-r--r--protocols/Tox/src/tox_proto.cpp3
-rw-r--r--protocols/Tox/src/tox_proto.h3
-rw-r--r--protocols/Tox/src/tox_search.cpp4
-rw-r--r--protocols/Tox/src/version.h2
9 files changed, 79 insertions, 22 deletions
diff --git a/protocols/Tox/src/resource.h b/protocols/Tox/src/resource.h
index 4ea9d24d31..0b62cff30d 100644
--- a/protocols/Tox/src/resource.h
+++ b/protocols/Tox/src/resource.h
@@ -3,18 +3,20 @@
// Used by D:\Projects\c++\miranda-ng\protocols\Tox\res\resource.rc
//
#define IDI_TOX 100
-#define IDD_USER_INFO 101
-#define IDD_PASSWORD_ENTER 102
-#define IDD_PASSWORD_CHANGE 103
-#define IDD_ACCOUNT_MANAGER 104
-#define IDD_SEARCH 105
-#define IDD_OPTIONS_MAIN 106
-#define IDD_OPTIONS_NODES 107
-#define IDD_PASSWORD_CHANGE2 107
-#define IDD_ADDNODE 108
-#define IDD_NODE_EDITOR 109
-#define IDD_PASSWORD_CREATE 110
-#define IDC_EDITSCR 174
+#define IDI_ME 101
+#define IDI_EDIT 102
+#define IDD_USER_INFO 150
+#define IDD_PASSWORD_ENTER 151
+#define IDD_PASSWORD_CHANGE 152
+#define IDD_ACCOUNT_MANAGER 153
+#define IDD_SEARCH 154
+#define IDD_OPTIONS_MAIN 155
+#define IDD_OPTIONS_NODES 156
+#define IDD_PASSWORD_CHANGE2 157
+#define IDD_ADDNODE 158
+#define IDD_NODE_EDITOR 159
+#define IDD_PASSWORD_CREATE 160
+#define IDC_EDITSCR 1000
#define IDC_TOXID 1001
#define IDC_CLIPBOARD 1002
#define IDC_SEARCH 1003
diff --git a/protocols/Tox/src/stdafx.h b/protocols/Tox/src/stdafx.h
index 5e4af6b0c9..a136f910a7 100644
--- a/protocols/Tox/src/stdafx.h
+++ b/protocols/Tox/src/stdafx.h
@@ -83,7 +83,9 @@ extern HINSTANCE g_hInstance;
#define TOX_SETTINGS_NODE_PKEY TOX_SETTINGS_NODE_PREFIX"%d_PubKey"
#define TOX_SETTINGS_NODE_COUNT TOX_SETTINGS_NODE_PREFIX"Count"
-#define DB_EVENT_ACTION 10001
+#define DB_EVENT_ACTION 1000 + TOX_MESSAGE_TYPE_ACTION
+#define DB_EVENT_CORRECTION 1000 + TOX_MESSAGE_TYPE_CORRECTION
+
#define TOX_MAX_AVATAR_SIZE 1 << 16 // 2 ^ 16 bytes
extern HANDLE hProfileFolderPath;
diff --git a/protocols/Tox/src/tox_connection.cpp b/protocols/Tox/src/tox_connection.cpp
index 392f7bbbb6..24371e3233 100644
--- a/protocols/Tox/src/tox_connection.cpp
+++ b/protocols/Tox/src/tox_connection.cpp
@@ -57,7 +57,7 @@ void CToxProto::CheckConnection(Tox *tox, int &retriesCount)
void CToxProto::CheckingThread(void *arg)
{
- Thread_SetName("TOX: CheckingThread");
+ Thread_SetName(MODULE ": CheckingThread");
debugLogA(__FUNCTION__": entering");
@@ -77,7 +77,7 @@ void CToxProto::CheckingThread(void *arg)
void CToxProto::PollingThread(void*)
{
- Thread_SetName("TOX: PollingThread");
+ Thread_SetName(MODULE ": PollingThread");
debugLogA(__FUNCTION__": entering");
diff --git a/protocols/Tox/src/tox_icons.cpp b/protocols/Tox/src/tox_icons.cpp
index 928685ebf3..5e95d49c24 100644
--- a/protocols/Tox/src/tox_icons.cpp
+++ b/protocols/Tox/src/tox_icons.cpp
@@ -2,7 +2,9 @@
IconItemT CToxProto::Icons[] =
{
- { LPGENW("Protocol icon"), "main", IDI_TOX },
+ { LPGENW("Protocol icon"), "main", IDI_TOX },
+ { LPGENW("Action icon"), "main", IDI_ME },
+ { LPGENW("Correction icon"), "edit", IDI_EDIT },
};
void CToxProto::InitIcons()
@@ -15,6 +17,13 @@ HANDLE CToxProto::GetIconHandle(int iconId)
for (size_t i = 0; i < _countof(Icons); i++)
if (Icons[i].defIconID == iconId)
return Icons[i].hIcolib;
+ return nullptr;
+}
+HICON CToxProto::GetIcon(int iconId)
+{
+ for (size_t i = 0; i < _countof(Icons); i++)
+ if (Icons[i].defIconID == iconId)
+ return IcoLib_GetIconByHandle(Icons[i].hIcolib);
return nullptr;
}
diff --git a/protocols/Tox/src/tox_messages.cpp b/protocols/Tox/src/tox_messages.cpp
index 0d7ad78b04..6ab66e8186 100644
--- a/protocols/Tox/src/tox_messages.cpp
+++ b/protocols/Tox/src/tox_messages.cpp
@@ -9,6 +9,34 @@ void CToxProto::InitCustomDbEvents()
dbEventType.eventType = DB_EVENT_ACTION;
dbEventType.descr = Translate("Action");
DbEvent_RegisterType(&dbEventType);
+
+ dbEventType.eventType = DB_EVENT_CORRECTION;
+ dbEventType.descr = Translate("Correction");
+ DbEvent_RegisterType(&dbEventType);
+}
+
+INT_PTR CToxProto::EventGetIcon(WPARAM wParam, LPARAM lParam)
+{
+ DBEVENTINFO *dbei = (DBEVENTINFO*)lParam;
+ HICON icon = nullptr;
+
+ switch (dbei->eventType) {
+ case DB_EVENT_ACTION:
+ icon = GetIcon(IDI_ME);
+ break;
+
+ case DB_EVENT_CORRECTION:
+ icon = GetIcon(IDI_EDIT);
+ break;
+
+ default:
+ icon = Skin_LoadIcon(SKINICON_EVENT_MESSAGE);
+ break;
+ }
+
+ return (INT_PTR)((wParam & LR_SHARED)
+ ? icon
+ : CopyIcon(icon));
}
/* MESSAGE RECEIVING */
@@ -34,7 +62,17 @@ void CToxProto::OnFriendMessage(Tox *tox, uint32_t friendNumber, TOX_MESSAGE_TYP
PROTORECVEVENT recv = { 0 };
recv.timestamp = time(nullptr);
recv.szMessage = rawMessage;
- recv.lParam = type == TOX_MESSAGE_TYPE_NORMAL ? EVENTTYPE_MESSAGE : DB_EVENT_ACTION;
+ switch (type) {
+ case TOX_MESSAGE_TYPE_NORMAL:
+ recv.lParam = EVENTTYPE_MESSAGE;
+ break;
+ case TOX_MESSAGE_TYPE_ACTION:
+ recv.lParam = DB_EVENT_ACTION;
+ break;
+ case TOX_MESSAGE_TYPE_CORRECTION:
+ recv.lParam = DB_EVENT_CORRECTION;
+ break;
+ }
ProtoChainRecvMsg(hContact, &recv);
CallService(MS_PROTO_CONTACTISTYPING, hContact, (LPARAM)PROTOTYPE_CONTACTTYPING_OFF);
@@ -52,7 +90,7 @@ struct SendMessageParam
void CToxProto::SendMessageAsync(void *arg)
{
- Thread_SetName("TOX: SendMessageAsync");
+ Thread_SetName(MODULE ": SendMessageThread");
SendMessageParam *param = (SendMessageParam*)arg;
@@ -138,7 +176,7 @@ int CToxProto::OnPreCreateMessage(WPARAM, LPARAM lParam)
/* STATUS MESSAGE */
void CToxProto::GetStatusMessageAsync(void* arg)
{
- Thread_SetName("TOX: GetStatusMessageAsync");
+ Thread_SetName(MODULE ": GetStatusMessageThread");
MCONTACT hContact = (UINT_PTR)arg;
diff --git a/protocols/Tox/src/tox_proto.cpp b/protocols/Tox/src/tox_proto.cpp
index 7711d1e62a..f5c435b89a 100644
--- a/protocols/Tox/src/tox_proto.cpp
+++ b/protocols/Tox/src/tox_proto.cpp
@@ -27,6 +27,9 @@ CToxProto::CToxProto(const char* protoName, const wchar_t* userName)
// nick
CreateProtoService(PS_SETMYNICKNAME, &CToxProto::SetMyNickname);
+ // events
+ CreateServiceFunction(MODULE "/GetEventIcon", &CToxProto::EventGetIcon);
+
hTerminateEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
}
diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h
index 8ab41afa48..97acbe5dac 100644
--- a/protocols/Tox/src/tox_proto.h
+++ b/protocols/Tox/src/tox_proto.h
@@ -135,6 +135,7 @@ private:
// icons
static IconItemT Icons[];
static HANDLE GetIconHandle(int iconId);
+ static HICON GetIcon(int iconId);
// menus
static HGENMENU ContactMenuItems[CMI_MAX];
@@ -197,6 +198,8 @@ private:
void InitCustomDbEvents();
+ static INT_PTR EventGetIcon(WPARAM wParam, LPARAM lParam);
+
void __cdecl SendMessageAsync(void *arg);
int OnSendMessage(MCONTACT hContact, const char *message);
diff --git a/protocols/Tox/src/tox_search.cpp b/protocols/Tox/src/tox_search.cpp
index b395c5c649..840436b149 100644
--- a/protocols/Tox/src/tox_search.cpp
+++ b/protocols/Tox/src/tox_search.cpp
@@ -26,7 +26,7 @@ ToxHexAddress ResolveToxAddressFromToxme(HNETLIBUSER hNetlib, const char *query)
void CToxProto::SearchByNameAsync(void *arg)
{
- Thread_SetName("TOX: SearchByNameAsync");
+ Thread_SetName(MODULE ": SearchByNameThread");
char *query = (char*)arg;
char *name = strtok(query, "@");
@@ -51,7 +51,7 @@ void CToxProto::SearchByNameAsync(void *arg)
void CToxProto::SearchFailedAsync(void*)
{
- Thread_SetName("TOX: SearchFailedAsync");
+ Thread_SetName(MODULE ": SearchFailedThread");
ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_FAILED, (HWND)1, 0);
}
diff --git a/protocols/Tox/src/version.h b/protocols/Tox/src/version.h
index c11a7586ee..4789f2f861 100644
--- a/protocols/Tox/src/version.h
+++ b/protocols/Tox/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 11
#define __RELEASE_NUM 3
-#define __BUILD_NUM 0
+#define __BUILD_NUM 1
#include <stdver.h>