diff options
author | George Hazan <george.hazan@gmail.com> | 2024-03-17 13:41:04 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-03-17 13:41:04 +0300 |
commit | 32cd08ae230797bf0287cda1d478265df3f9f61c (patch) | |
tree | 804d44bd2b3d841cb04ce6f3c6c72a1c5ade0f7b /protocols | |
parent | 31705a905d2fa6e81a3c8cc40c45e7c0366d6c49 (diff) |
fixes #4284 (ICQ: support for changing our own first name, last name & about fields)
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/ICQ-WIM/res/resources.rc | 17 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/http.cpp | 9 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/http.h | 2 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/poll.cpp | 7 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/proto.h | 3 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/resource.h | 3 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/server.cpp | 20 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/userinfo.cpp | 33 |
8 files changed, 71 insertions, 23 deletions
diff --git a/protocols/ICQ-WIM/res/resources.rc b/protocols/ICQ-WIM/res/resources.rc index 6be7abd7fa..1715103e9d 100644 --- a/protocols/ICQ-WIM/res/resources.rc +++ b/protocols/ICQ-WIM/res/resources.rc @@ -160,12 +160,16 @@ BEGIN EDITTEXT IDC_UIN,74,6,139,10,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP LTEXT "Nick:",IDC_STATIC,5,21,63,8 EDITTEXT IDC_NICK,74,20,139,10,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP - LTEXT "Last seen:",IDC_STATIC,5,63,63,22 - EDITTEXT IDC_LASTSEEN,74,62,139,10,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP - LTEXT "Online since:",IDC_STATIC,5,49,63,8 - EDITTEXT IDC_ONLINESINCE,74,48,139,10,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP - LTEXT "Phone number:",IDC_STATIC,5,35,63,8 - EDITTEXT IDC_PHONE,74,34,139,10,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP + LTEXT "Last seen:",IDC_STATIC,5,93,63,22 + EDITTEXT IDC_LASTSEEN,74,92,139,10,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP + LTEXT "Online since:",IDC_STATIC,5,79,63,8 + EDITTEXT IDC_ONLINESINCE,74,78,139,10,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP + LTEXT "Phone number:",IDC_STATIC,5,65,63,8 + EDITTEXT IDC_PHONE,74,64,139,10,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP + LTEXT "First name:",IDC_STATIC,5,36,63,8 + EDITTEXT IDC_FIRST_NAME,74,35,139,10,ES_AUTOHSCROLL | NOT WS_BORDER | NOT WS_TABSTOP + LTEXT "Last name:",IDC_STATIC,5,50,63,8 + EDITTEXT IDC_LAST_NAME,74,50,139,10,ES_AUTOHSCROLL | NOT WS_BORDER | NOT WS_TABSTOP END IDD_ABOUT DIALOGEX 0, 0, 222, 132 @@ -299,6 +303,7 @@ IDI_MAIL_NOTIFY ICON "MailNotify.ico" IDI_FORWARD ICON "Forward.ico" + #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // diff --git a/protocols/ICQ-WIM/src/http.cpp b/protocols/ICQ-WIM/src/http.cpp index 680b6d78fc..c5fbdbc836 100644 --- a/protocols/ICQ-WIM/src/http.cpp +++ b/protocols/ICQ-WIM/src/http.cpp @@ -99,12 +99,15 @@ void __cdecl CIcqProto::ServerThread(void*) /////////////////////////////////////////////////////////////////////////////////////////
-AsyncRapiRequest::AsyncRapiRequest(CIcqProto *ppro, const char *pszMethod, MTHttpRequestHandler pFunc) :
- AsyncHttpRequest(CONN_RAPI, REQUEST_POST, ICQ_ROBUST_SERVER, pFunc)
+AsyncRapiRequest::AsyncRapiRequest(CIcqProto *ppro, const char *pszMethod, MTHttpRequestHandler pFunc, int mode) :
+ AsyncHttpRequest(CONN_RAPI, REQUEST_POST, (mode == -1) ? ICQ_ROBUST_SERVER : ICQ_ROBUST_SERVER_NEW, pFunc)
{
params.set_name("params");
- if (ppro->getByte(DB_KEY_PHONEREG)) {
+ if (mode == -1)
+ mode = ppro->getByte(DB_KEY_PHONEREG);
+
+ if (mode) {
m_szUrl.AppendChar('/');
m_szUrl.Append(pszMethod);
diff --git a/protocols/ICQ-WIM/src/http.h b/protocols/ICQ-WIM/src/http.h index 1b201d097a..2191eb1174 100644 --- a/protocols/ICQ-WIM/src/http.h +++ b/protocols/ICQ-WIM/src/http.h @@ -23,7 +23,7 @@ struct AsyncRapiRequest : public AsyncHttpRequest { JSONNode request, params; - AsyncRapiRequest(CIcqProto *ppro, const char *pszMethod, MTHttpRequestHandler pFunc = nullptr); + AsyncRapiRequest(CIcqProto *ppro, const char *pszMethod, MTHttpRequestHandler pFunc = nullptr, int mode = -1); void OnPush() override; }; diff --git a/protocols/ICQ-WIM/src/poll.cpp b/protocols/ICQ-WIM/src/poll.cpp index 4e39a52060..1a7c72b2f0 100644 --- a/protocols/ICQ-WIM/src/poll.cpp +++ b/protocols/ICQ-WIM/src/poll.cpp @@ -283,11 +283,8 @@ void CIcqProto::ProcessImState(const JSONNode &ev) void CIcqProto::ProcessMyInfo(const JSONNode &ev)
{
- if (auto &var = ev["friendly"])
- setWString("Nick", var.as_mstring());
-
- if (auto &var = ev["attachedPhoneNumber"])
- setWString(DB_KEY_PHONE, var.as_mstring());
+ Json2string(0, ev, "friendly", "Nick", true);
+ Json2string(0, ev, "attachedPhoneNumber", DB_KEY_PHONE, true);
CheckAvatarChange(0, ev);
}
diff --git a/protocols/ICQ-WIM/src/proto.h b/protocols/ICQ-WIM/src/proto.h index 514787102a..f198ed76e7 100644 --- a/protocols/ICQ-WIM/src/proto.h +++ b/protocols/ICQ-WIM/src/proto.h @@ -38,6 +38,7 @@ #define ICQ_FILE_SERVER "https://u.icq.net/files/api/v1.1"
#define ICQ_FAKE_EVENT_ID 0xBABAEB
#define ICQ_ROBUST_SERVER "https://u.icq.net/rapi"
+#define ICQ_ROBUST_SERVER_NEW "https://u.icq.net/api/v92/rapi"
#define PS_DUMMY "/DoNothing"
#define PS_GOTO_INBOX "/SvcGotoInbox"
@@ -471,6 +472,8 @@ public: CMOption<uint32_t> m_iStatus2;
void CheckStatus(void);
+ void PatchProfileInfo(const char *pszVariable, const wchar_t *pwszValue);
+
MCONTACT GetRealContact(IcqUser *pUser);
CMStringW GetUserId(MCONTACT);
diff --git a/protocols/ICQ-WIM/src/resource.h b/protocols/ICQ-WIM/src/resource.h index f4bfda4f5b..caf5010db6 100644 --- a/protocols/ICQ-WIM/src/resource.h +++ b/protocols/ICQ-WIM/src/resource.h @@ -28,10 +28,12 @@ #define IDC_ONLINESINCE 1010 #define IDC_ABOUT 1011 #define IDC_NICK 1012 +#define IDC_FIRST_NAME 1013 #define IDC_LASTSEEN 1014 #define IDC_SAVEPASS 1015 #define IDC_MEMBERSINCE2 1015 #define IDC_LIST 1016 +#define IDC_LAST_NAME 1016 #define IDC_DIFF1 1017 #define IDC_SPIN1 1018 #define IDC_STATUS1 1019 @@ -40,7 +42,6 @@ #define IDC_SHOWERRORPOPUPS 1022 #define IDC_DIFF2 1023 #define IDC_SPIN2 1024 -#define IDC_LIST1 1024 #define IDC_STATUS2 1025 #define IDC_GROUPS 1025 #define IDC_UIN_LABEL 1026 diff --git a/protocols/ICQ-WIM/src/server.cpp b/protocols/ICQ-WIM/src/server.cpp index 5d758f6b11..3dca2f8a6c 100644 --- a/protocols/ICQ-WIM/src/server.cpp +++ b/protocols/ICQ-WIM/src/server.cpp @@ -439,6 +439,10 @@ MCONTACT CIcqProto::ParseBuddyInfo(const JSONNode &buddy, MCONTACT hContact, boo Json2string(hContact, it, "country", "Country", bIsPartial);
}
}
+ else {
+ Json2string(hContact, buddy, "firstName", "FirstName", bIsPartial);
+ Json2string(hContact, buddy, "lastName", "LastName", bIsPartial);
+ }
CMStringW str = buddy["statusMsg"].as_mstring();
if (str.IsEmpty())
@@ -1407,6 +1411,22 @@ void CIcqProto::OnSearchResults(MHttpResponse *pReply, AsyncHttpRequest *pReq) }
/////////////////////////////////////////////////////////////////////////////////////////
+
+void CIcqProto::PatchProfileInfo(const char *pszVariable, const wchar_t *pwszValue)
+{
+ if (!mir_wstrlen(pwszValue))
+ return;
+
+ auto *pReq = new AsyncRapiRequest(this, "/profile/update", nullptr, 1);
+ pReq->params << WCHAR_PARAM(pszVariable, pwszValue);
+ Push(pReq);
+
+ char *buf = NEWSTR_ALLOCA(pszVariable);
+ buf[0] = _toupper(buf[0]);
+ setWString(buf, pwszValue);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
// Send message
void CIcqProto::OnSendMessage(MHttpResponse *pReply, AsyncHttpRequest *pReq)
diff --git a/protocols/ICQ-WIM/src/userinfo.cpp b/protocols/ICQ-WIM/src/userinfo.cpp index 2563925ff5..f780202fd2 100644 --- a/protocols/ICQ-WIM/src/userinfo.cpp +++ b/protocols/ICQ-WIM/src/userinfo.cpp @@ -24,10 +24,13 @@ struct IcqUserInfoDlg : public CUserInfoPageDlg {
CIcqProto *ppro;
HANDLE hEvent = 0;
+ CCtrlEdit edtFirstName, edtLastName;
IcqUserInfoDlg(CIcqProto *_ppro) :
CUserInfoPageDlg(g_plugin, IDD_INFO_ICQ),
- ppro(_ppro)
+ ppro(_ppro),
+ edtLastName(this, IDC_LAST_NAME),
+ edtFirstName(this, IDC_FIRST_NAME)
{
}
@@ -37,6 +40,15 @@ struct IcqUserInfoDlg : public CUserInfoPageDlg return true;
}
+ bool OnApply() override
+ {
+ if (edtFirstName.IsChanged())
+ ppro->PatchProfileInfo("firstName", ptrW(edtFirstName.GetText()));
+ if (edtLastName.IsChanged())
+ ppro->PatchProfileInfo("lastName", ptrW(edtLastName.GetText()));
+ return true;
+ }
+
void OnDestroy() override
{
UnhookEvent(hEvent);
@@ -59,6 +71,9 @@ struct IcqUserInfoDlg : public CUserInfoPageDlg SetDlgItemTextW(m_hwnd, IDC_NICK, ppro->getMStringW(m_hContact, DB_KEY_ICQNICK));
SetDlgItemTextW(m_hwnd, IDC_PHONE, ppro->getMStringW(m_hContact, DB_KEY_PHONE));
+ edtLastName.SetText(ppro->getMStringW(m_hContact, "LastName"));
+ edtFirstName.SetText(ppro->getMStringW(m_hContact, "FirstName"));
+
DBVARIANT dbv = {};
if (!db_get(m_hContact, ppro->m_szModuleName, DB_KEY_LASTSEEN, &dbv)) {
SetDlgItemTextW(m_hwnd, IDC_LASTSEEN, time2text(&dbv));
@@ -77,21 +92,25 @@ struct IcqUserInfoDlg : public CUserInfoPageDlg struct IcqAboutDlg : public CUserInfoPageDlg
{
CIcqProto *ppro;
+ CCtrlEdit edtAbout;
IcqAboutDlg(CIcqProto *_ppro) :
CUserInfoPageDlg(g_plugin, IDD_ABOUT),
- ppro(_ppro)
+ ppro(_ppro),
+ edtAbout(this, IDC_ABOUT)
{}
- bool IsEmpty() const override
+ bool OnRefresh() override
{
- return ppro->getMStringW(m_hContact, "About").IsEmpty();
+ edtAbout.SetText(ppro->getMStringW(m_hContact, "About"));
+ return false;
}
- bool OnRefresh() override
+ bool OnApply() override
{
- SetDlgItemTextW(m_hwnd, IDC_ABOUT, ppro->getMStringW(m_hContact, "About"));
- return false;
+ if (edtAbout.IsChanged())
+ ppro->PatchProfileInfo("about", ptrW(edtAbout.GetText()));
+ return true;
}
int Resizer(UTILRESIZECONTROL *urc) override
|