diff options
author | MikalaiR <nikolay.romanovich@narod.ru> | 2015-11-22 14:42:55 +0000 |
---|---|---|
committer | MikalaiR <nikolay.romanovich@narod.ru> | 2015-11-22 14:42:55 +0000 |
commit | fe55aaa9b4f0c93acbab6e7205b28e0117ee7145 (patch) | |
tree | 6c8d648962d6afc061749245e5023fae1fca5a62 /plugins/Dropbox | |
parent | e83fad2db3e2a5acea5ddb34a096a68859857a33 (diff) |
Dropbox: account quota to statusmsg
git-svn-id: http://svn.miranda-ng.org/main/trunk@15755 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Dropbox')
-rw-r--r-- | plugins/Dropbox/src/dropbox.cpp | 22 | ||||
-rw-r--r-- | plugins/Dropbox/src/dropbox.h | 2 | ||||
-rw-r--r-- | plugins/Dropbox/src/dropbox_transfers.cpp | 2 |
3 files changed, 18 insertions, 8 deletions
diff --git a/plugins/Dropbox/src/dropbox.cpp b/plugins/Dropbox/src/dropbox.cpp index 6ac4ee8d1b..c8c6b6eb81 100644 --- a/plugins/Dropbox/src/dropbox.cpp +++ b/plugins/Dropbox/src/dropbox.cpp @@ -60,13 +60,15 @@ bool CDropbox::HasAccessToken() return db_get_sa(NULL, MODULE, "TokenSecret") != NULL;
}
-void CDropbox::RequestAccountInfo()
+void CDropbox::RequestAccountInfo(void *p)
{
- MCONTACT hContact = CDropbox::GetDefaultContact();
+ CDropbox *self = (CDropbox*)p;
+
+ MCONTACT hContact = self->GetDefaultContact();
ptrA token(db_get_sa(NULL, MODULE, "TokenSecret"));
GetAccountInfoRequest request(token);
- NLHR_PTR response(request.Send(hNetlibConnection));
+ NLHR_PTR response(request.Send(self->hNetlibConnection));
HandleHttpResponseError(response);
JSONNode root = JSONNode::parse(response->pData);
@@ -111,9 +113,15 @@ void CDropbox::RequestAccountInfo() JSONNode quota_info = root.at("quota_info");
if (!quota_info.empty())
{
- db_set_dw(hContact, MODULE, "SharedQuota", quota_info.at("shared").as_int());
- db_set_dw(hContact, MODULE, "NormalQuota", quota_info.at("normal").as_int());
- db_set_dw(hContact, MODULE, "TotalQuota", quota_info.at("quota").as_int());
+ ULONG lTotalQuota = quota_info.at("quota").as_int();
+ ULONG lNormalQuota = quota_info.at("normal").as_int();
+ ULONG lSharedQuota = quota_info.at("shared").as_int();
+
+ db_set_dw(hContact, MODULE, "SharedQuota", lSharedQuota);
+ db_set_dw(hContact, MODULE, "NormalQuota", lNormalQuota);
+ 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)));
}
}
@@ -194,7 +202,7 @@ UINT CDropbox::RequestAccessTokenAsync(void *owner, void *param) try
{
- instance->RequestAccountInfo();
+ RequestAccountInfo(instance);
}
catch (TransferException &ex)
{
diff --git a/plugins/Dropbox/src/dropbox.h b/plugins/Dropbox/src/dropbox.h index 709ea649fe..d9af25ae73 100644 --- a/plugins/Dropbox/src/dropbox.h +++ b/plugins/Dropbox/src/dropbox.h @@ -81,7 +81,7 @@ private: static UINT RequestAccessTokenAsync(void *owner, void *param);
// account info
- void RequestAccountInfo();
+ static void __cdecl RequestAccountInfo(void*);
// transfers
void SendFile(const char *path, const char *data, size_t size);
diff --git a/plugins/Dropbox/src/dropbox_transfers.cpp b/plugins/Dropbox/src/dropbox_transfers.cpp index 66333980a0..b658731249 100644 --- a/plugins/Dropbox/src/dropbox_transfers.cpp +++ b/plugins/Dropbox/src/dropbox_transfers.cpp @@ -203,6 +203,8 @@ UINT CDropbox::SendFilesAsync(void *owner, void *arg) ProtoBroadcastAck(MODULE, ftp->pfts.hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, ftp->hProcess, 0);
+ mir_forkthread(&CDropbox::RequestAccountInfo, instance);
+
return 0;
}
|