diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2016-02-22 21:12:25 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2016-02-22 21:12:25 +0000 |
commit | 0b82b879821c7e73b86f189be747c5634c8b46b7 (patch) | |
tree | 28c7e3b06c25a7b9fbd49a33972e7fae07dd2e56 /plugins/Dropbox/src/dropbox.cpp | |
parent | 477664ed5c4b018562e9419428175ae938cf2761 (diff) |
Dropbox:
- updated api to v2
- version bump
git-svn-id: http://svn.miranda-ng.org/main/trunk@16326 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Dropbox/src/dropbox.cpp')
-rw-r--r-- | plugins/Dropbox/src/dropbox.cpp | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/plugins/Dropbox/src/dropbox.cpp b/plugins/Dropbox/src/dropbox.cpp index 880f8a07c8..46d8d5fa8c 100644 --- a/plugins/Dropbox/src/dropbox.cpp +++ b/plugins/Dropbox/src/dropbox.cpp @@ -65,9 +65,9 @@ void CDropbox::RequestAccountInfo(void *p) MCONTACT hContact = self->GetDefaultContact();
ptrA token(db_get_sa(NULL, MODULE, "TokenSecret"));
- GetAccountInfoRequest request(token);
+ GetCurrentAccountRequest request(token);
NLHR_PTR response(request.Send(self->hNetlibConnection));
- HandleHttpResponseError(response);
+ HandleJsonResponseError(response);
JSONNode root = JSONNode::parse(response->pData);
if (root.empty())
@@ -77,18 +77,27 @@ void CDropbox::RequestAccountInfo(void *p) if (!referral_link.empty())
db_set_s(hContact, MODULE, "Homepage", referral_link.as_string().c_str());
- JSONNode display_name = root.at("display_name");
- if (!display_name.empty()) {
- CMString tszDisplayName(display_name.as_mstring());
- int pos = tszDisplayName.ReverseFind(' ');
- if (pos != -1) {
- db_set_ts(hContact, MODULE, "LastName", tszDisplayName.Mid(pos + 1));
- db_set_ts(hContact, MODULE, "FirstName", tszDisplayName.Left(pos));
- }
- else {
- db_set_ts(hContact, MODULE, "FirstName", tszDisplayName);
- db_unset(hContact, MODULE, "LastName");
- }
+ JSONNode email = root.at("email");
+ if (!email.empty())
+ db_set_s(hContact, MODULE, "e-mail", email.as_string().c_str());
+
+ JSONNode name = root.at("name");
+ if (!name.empty()) {
+ db_set_s(hContact, MODULE, "FirstName", name.at("given_name").as_string().c_str());
+ db_set_s(hContact, MODULE, "LastName", name.at("surname").as_string().c_str());
+ /*JSONNode display_name = root.at("display_name");
+ if (!display_name.empty()) {
+ CMString tszDisplayName(display_name.as_mstring());
+ int pos = tszDisplayName.ReverseFind(' ');
+ if (pos != -1) {
+ db_set_ts(hContact, MODULE, "LastName", tszDisplayName.Mid(pos + 1));
+ db_set_ts(hContact, MODULE, "FirstName", tszDisplayName.Left(pos));
+ }
+ else {
+ db_set_ts(hContact, MODULE, "FirstName", tszDisplayName);
+ db_unset(hContact, MODULE, "LastName");
+ }
+ }*/
}
JSONNode country = root.at("country");
@@ -103,7 +112,7 @@ void CDropbox::RequestAccountInfo(void *p) }
}
- JSONNode quota_info = root.at("quota_info");
+ /*JSONNode quota_info = root.at("quota_info");
if (!quota_info.empty()) {
ULONG lTotalQuota = quota_info.at("quota").as_int();
ULONG lNormalQuota = quota_info.at("normal").as_int();
@@ -114,13 +123,13 @@ void CDropbox::RequestAccountInfo(void *p) db_set_dw(hContact, MODULE, "TotalQuota", lTotalQuota);
db_set_s(hContact, "CList", "StatusMsg", CMStringA(FORMAT, Translate("Free %ld of %ld MB"), (lTotalQuota - lNormalQuota) / (1024 * 1024), lTotalQuota / (1024 * 1024)));
- }
+ }*/
}
void CDropbox::DestroyAccessToken()
{
- DisableAccessTokenRequest request;
- NLHR_PTR response(request.Send(hNetlibConnection));
+ //DisableAccessTokenRequest request;
+ //NLHR_PTR response(request.Send(hNetlibConnection));
db_unset(NULL, MODULE, "TokenSecret");
MCONTACT hContact = CDropbox::GetDefaultContact();
@@ -191,7 +200,7 @@ UINT CDropbox::RequestAccessTokenAsync(void *owner, void *param) try {
RequestAccountInfo(instance);
}
- catch (TransferException &ex) {
+ catch (DropboxException &ex) {
Netlib_Logf(instance->hNetlibConnection, "%s: %s", MODULE, ex.what());
return 0;
}
|