diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2014-08-18 21:02:24 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2014-08-18 21:02:24 +0000 |
commit | a93391bc7442c024d5e795e207b8422883e7bfdf (patch) | |
tree | 62226bdafa41fd80ab7122fd8ed67fbb71a29ef5 | |
parent | e39da35942db7d2bd7c192336f4d3c33e44d0ba4 (diff) |
Tox:
- save our id in database
- first approach of user info support
git-svn-id: http://svn.miranda-ng.org/main/trunk@10233 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | protocols/Tox/src/common.h | 2 | ||||
-rw-r--r-- | protocols/Tox/src/tox_account.cpp | 5 | ||||
-rw-r--r-- | protocols/Tox/src/tox_events.cpp | 37 | ||||
-rw-r--r-- | protocols/Tox/src/tox_options.cpp | 4 | ||||
-rw-r--r-- | protocols/Tox/src/tox_proto.cpp | 2 | ||||
-rw-r--r-- | protocols/Tox/src/tox_proto.h | 1 |
6 files changed, 47 insertions, 4 deletions
diff --git a/protocols/Tox/src/common.h b/protocols/Tox/src/common.h index d47f2401bf..745216b542 100644 --- a/protocols/Tox/src/common.h +++ b/protocols/Tox/src/common.h @@ -23,6 +23,7 @@ #include <m_netlib.h>
#include <m_popup.h>
#include <m_icolib.h>
+#include <m_userinfo.h>
#include "tox\tox.h"
@@ -35,7 +36,6 @@ extern HINSTANCE g_hInstance; #define MODULE "Tox"
#define TOX_SETTINGS_ID "ToxID"
-#define TOX_SETTINGS_ADDRES "ToxAddress"
#define TOX_SETTINGS_GROUP "DefaultGroup"
#endif //_COMMON_H_
\ No newline at end of file diff --git a/protocols/Tox/src/tox_account.cpp b/protocols/Tox/src/tox_account.cpp index 6ca734d0e4..40ded847e6 100644 --- a/protocols/Tox/src/tox_account.cpp +++ b/protocols/Tox/src/tox_account.cpp @@ -41,6 +41,11 @@ void CToxProto::InitToxCore() tox_get_self_name(tox, &username[0]);
std::string nick(username.begin(), username.end());
setWString("Nick", ptrW(Utf8DecodeW(nick.c_str())));
+
+ std::vector<uint8_t> address(TOX_FRIEND_ADDRESS_SIZE);
+ tox_get_address(tox, &address[0]);
+ std::string toxId = DataToHexString(address);
+ setString(TOX_SETTINGS_ID, toxId.c_str());
}
void CToxProto::UninitToxCore()
diff --git a/protocols/Tox/src/tox_events.cpp b/protocols/Tox/src/tox_events.cpp index 38f6d1d493..cef4bb7cc2 100644 --- a/protocols/Tox/src/tox_events.cpp +++ b/protocols/Tox/src/tox_events.cpp @@ -3,6 +3,7 @@ int CToxProto::OnAccountLoaded(WPARAM, LPARAM)
{
HookEventObj(ME_OPT_INITIALISE, OnOptionsInit, this);
+ HookEventObj(ME_USERINFO_INITIALISE, OnUserInfoInit, this);
HookEventObj(ME_PROTO_ACCLISTCHANGED, OnAccountListChanged, this);
InitNetlib();
@@ -70,6 +71,42 @@ int CToxProto::OnOptionsInit(void *obj, WPARAM wParam, LPARAM) return 0;
}
+int CToxProto::OnUserInfoInit(void *obj, WPARAM wParam, LPARAM hContact)
+{
+ return 0;
+
+ CToxProto *proto = (CToxProto*)obj;
+
+ if ((!proto->IsProtoContact(hContact) && hContact))
+ return 0;
+
+ OPTIONSDIALOGPAGE odp = { sizeof(odp) };
+ odp.flags = ODPF_TCHAR | ODPF_USERINFOTAB | ODPF_DONTTRANSLATE;
+ odp.hInstance = g_hInstance;
+ odp.dwInitParam = (LPARAM)obj;
+ odp.position = -1900000000;
+ odp.ptszTitle = proto->m_tszUserName;
+
+ if (hContact)
+ {
+ char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, hContact, 0);
+ if (szProto != NULL && !strcmp(szProto, proto->m_szModuleName)) {
+ //odp.pfnDlgProc = SkypeDlgProc;
+ //odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_SKYPE);
+ UserInfo_AddPage(wParam, &odp);
+ }
+ }
+ else
+ {
+ //odp.pfnDlgProc = ContactSkypeDlgProc;
+ //odp.pszTemplate = MAKEINTRESOURCEA(IDD_OWNINFO_CONTACT);
+ odp.ptszTab = LPGENT("Contacts");
+ UserInfo_AddPage(wParam, &odp);
+ }
+
+ return 0;
+}
+
int CToxProto::OnContactDeleted(MCONTACT hContact, LPARAM lParam)
{
if (hContact)
diff --git a/protocols/Tox/src/tox_options.cpp b/protocols/Tox/src/tox_options.cpp index 61df8854e9..ddbed584a6 100644 --- a/protocols/Tox/src/tox_options.cpp +++ b/protocols/Tox/src/tox_options.cpp @@ -86,7 +86,7 @@ INT_PTR CALLBACK CToxProto::MainOptionsProc(HWND hwnd, UINT uMsg, WPARAM wParam, INT_PTR CALLBACK CToxProto::ToxProfileManagerProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
CToxProto *proto = (CToxProto*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
- TCHAR *profilePath = (TCHAR*)GetWindowLongPtr(hwnd, DWL_USER);
+ TCHAR *profilePath = (TCHAR*)GetWindowLongPtr(hwnd, DWLP_USER);
switch (uMsg)
{
@@ -97,7 +97,7 @@ INT_PTR CALLBACK CToxProto::ToxProfileManagerProc(HWND hwnd, UINT uMsg, WPARAM w SetWindowLongPtr(hwnd, GWLP_USERDATA, lParam);
profilePath = (TCHAR*)mir_calloc(sizeof(TCHAR) * MAX_PATH);
- SetWindowLongPtr(hwnd, DWL_USER, (LONG_PTR)profilePath);
+ SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)profilePath);
CheckDlgButton(hwnd, IDC_CREATE_NEW, TRUE);
}
diff --git a/protocols/Tox/src/tox_proto.cpp b/protocols/Tox/src/tox_proto.cpp index eedddf74fc..0326b365a4 100644 --- a/protocols/Tox/src/tox_proto.cpp +++ b/protocols/Tox/src/tox_proto.cpp @@ -46,7 +46,7 @@ DWORD_PTR __cdecl CToxProto::GetCaps(int type, MCONTACT hContact) case PFLAGNUM_4:
return PF4_IMSENDUTF | PF4_NOAUTHDENYREASON | PF4_FORCEAUTH | PF4_FORCEADDED;
case PFLAG_UNIQUEIDTEXT:
- return (INT_PTR)MODULE" ID";
+ return (INT_PTR)"Tox ID";
case PFLAG_UNIQUEIDSETTING:
return (DWORD_PTR)TOX_SETTINGS_ID;
case PFLAG_MAXLENOFMESSAGE:
diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h index 0be0115561..08db44767e 100644 --- a/protocols/Tox/src/tox_proto.h +++ b/protocols/Tox/src/tox_proto.h @@ -105,6 +105,7 @@ private: INT_PTR __cdecl OnAccountManagerInit(WPARAM, LPARAM);
static int __cdecl OnAccountListChanged(void *obj, WPARAM wParam, LPARAM lParam);
static int __cdecl OnOptionsInit(void *obj, WPARAM wParam, LPARAM lParam);
+ static int __cdecl OnUserInfoInit(void *obj, WPARAM wParam, LPARAM lParam);
static void OnFriendRequest(Tox *tox, const uint8_t *userId, const uint8_t *message, const uint16_t messageSize, void *arg);
static void OnFriendMessage(Tox *tox, const int friendnumber, const uint8_t *message, const uint16_t messageSize, void *arg);
|