diff options
author | George Hazan <george.hazan@gmail.com> | 2015-12-22 17:13:27 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-12-22 17:13:27 +0000 |
commit | 020323a39b43152782541fd3897e3d2f6c72cfd1 (patch) | |
tree | b62f0effdf2f6dc2e992e1441f7d6f3dd46b2dff /plugins/Dropbox/src/dropbox.cpp | |
parent | 8508d083487e03f6dd0371ab2c67ec0168c7b746 (diff) |
Dropbox:
- contact menu to verify PF1_IMSEND flag to disable it for protocols that don't support sending IMs;
- code cleaning;
- version bump
git-svn-id: http://svn.miranda-ng.org/main/trunk@15930 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Dropbox/src/dropbox.cpp')
-rw-r--r-- | plugins/Dropbox/src/dropbox.cpp | 50 |
1 files changed, 18 insertions, 32 deletions
diff --git a/plugins/Dropbox/src/dropbox.cpp b/plugins/Dropbox/src/dropbox.cpp index c8c6b6eb81..880f8a07c8 100644 --- a/plugins/Dropbox/src/dropbox.cpp +++ b/plugins/Dropbox/src/dropbox.cpp @@ -40,11 +40,9 @@ MCONTACT CDropbox::GetDefaultContact() if (!hDefaultContact)
hDefaultContact = db_find_first(MODULE);
- if (!hDefaultContact)
- {
+ if (!hDefaultContact) {
hDefaultContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
- if (!Proto_AddToContact(hDefaultContact, MODULE))
- {
+ if (!Proto_AddToContact(hDefaultContact, MODULE)) {
db_set_s(NULL, MODULE, "Nick", MODULE);
db_set_s(hDefaultContact, MODULE, "Nick", MODULE);
db_set_ws(hDefaultContact, "CList", "MyHandle", L"Dropbox");
@@ -80,48 +78,42 @@ void CDropbox::RequestAccountInfo(void *p) db_set_s(hContact, MODULE, "Homepage", referral_link.as_string().c_str());
JSONNode display_name = root.at("display_name");
- if (!display_name.empty())
- {
+ 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));
+ if (pos != -1) {
+ db_set_ts(hContact, MODULE, "LastName", tszDisplayName.Mid(pos + 1));
db_set_ts(hContact, MODULE, "FirstName", tszDisplayName.Left(pos));
}
- else
- {
+ else {
db_set_ts(hContact, MODULE, "FirstName", tszDisplayName);
db_unset(hContact, MODULE, "LastName");
}
}
JSONNode country = root.at("country");
- if (!country.empty())
- {
+ if (!country.empty()) {
std::string isocode = country.as_string();
if (isocode.empty())
db_unset(hContact, MODULE, "Country");
- else
- {
+ else {
char *szCountry = (char *)CallService(MS_UTILS_GETCOUNTRYBYISOCODE, (WPARAM)isocode.c_str(), 0);
db_set_s(hContact, MODULE, "Country", szCountry);
}
}
JSONNode quota_info = root.at("quota_info");
- if (!quota_info.empty())
- {
+ if (!quota_info.empty()) {
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)));
+
+ db_set_s(hContact, "CList", "StatusMsg", CMStringA(FORMAT, Translate("Free %ld of %ld MB"), (lTotalQuota - lNormalQuota) / (1024 * 1024), lTotalQuota / (1024 * 1024)));
}
}
@@ -156,8 +148,7 @@ UINT CDropbox::RequestAccessTokenAsync(void *owner, void *param) GetAccessTokenRequest request(requestToken);
NLHR_PTR response(request.Send(instance->hNetlibConnection));
- if (response == NULL)
- {
+ if (response == NULL) {
Netlib_Logf(instance->hNetlibConnection, "%s: %s", MODULE, HttpStatusToText(HTTP_STATUS_ERROR));
if (hwndDlg)
SetDlgItemText(hwndDlg, IDC_AUTH_STATUS, TranslateT("server does not respond"));
@@ -167,8 +158,7 @@ UINT CDropbox::RequestAccessTokenAsync(void *owner, void *param) }
JSONNode root = JSONNode::parse(response->pData);
- if (root.empty())
- {
+ if (root.empty()) {
Netlib_Logf(instance->hNetlibConnection, "%s: %s", MODULE, HttpStatusToText((HTTP_STATUS)response->resultCode));
if (hwndDlg)
SetDlgItemText(hwndDlg, IDC_AUTH_STATUS, TranslateT("server does not respond"));
@@ -178,8 +168,7 @@ UINT CDropbox::RequestAccessTokenAsync(void *owner, void *param) }
JSONNode node = root.at("error_description");
- if (node != JSONNULL)
- {
+ if (node != JSONNULL) {
ptrT error_description(mir_a2t_cp(node.as_string().c_str(), CP_UTF8));
Netlib_Logf(instance->hNetlibConnection, "%s: %s", MODULE, HttpStatusToText((HTTP_STATUS)response->resultCode));
if (hwndDlg)
@@ -194,18 +183,15 @@ UINT CDropbox::RequestAccessTokenAsync(void *owner, void *param) ProtoBroadcastAck(MODULE, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)ID_STATUS_OFFLINE, (WPARAM)ID_STATUS_ONLINE);
MCONTACT hContact = instance->GetDefaultContact();
- if (hContact)
- {
+ if (hContact) {
if (db_get_w(hContact, MODULE, "Status", ID_STATUS_OFFLINE) != ID_STATUS_ONLINE)
db_set_w(hContact, MODULE, "Status", ID_STATUS_ONLINE);
}
- try
- {
+ try {
RequestAccountInfo(instance);
}
- catch (TransferException &ex)
- {
+ catch (TransferException &ex) {
Netlib_Logf(instance->hNetlibConnection, "%s: %s", MODULE, ex.what());
return 0;
}
|