summaryrefslogtreecommitdiff
path: root/protocols/VKontakte
diff options
context:
space:
mode:
authorElzorFox <elzorfox@ya.ru>2017-09-07 14:13:13 +0500
committerElzorFox <elzorfox@ya.ru>2017-09-07 14:13:13 +0500
commitd8beb3088e4394614f48636416cc363227194a24 (patch)
treefd867681acec263b5396f0fda10cc1edd442ae28 /protocols/VKontakte
parente7179d7a6ec6299a11e0f51e6c92ae5ba22144d2 (diff)
VKontakte: code cleaning
Diffstat (limited to 'protocols/VKontakte')
-rw-r--r--protocols/VKontakte/src/misc.cpp120
-rw-r--r--protocols/VKontakte/src/vk_avatars.cpp14
-rw-r--r--protocols/VKontakte/src/vk_captcha.cpp2
-rw-r--r--protocols/VKontakte/src/vk_chats.cpp144
-rw-r--r--protocols/VKontakte/src/vk_dialogs.cpp9
-rw-r--r--protocols/VKontakte/src/vk_dialogs.h2
-rw-r--r--protocols/VKontakte/src/vk_feed.cpp88
-rw-r--r--protocols/VKontakte/src/vk_files.cpp8
-rw-r--r--protocols/VKontakte/src/vk_history.cpp18
-rw-r--r--protocols/VKontakte/src/vk_messages.cpp27
-rw-r--r--protocols/VKontakte/src/vk_options.cpp6
-rw-r--r--protocols/VKontakte/src/vk_pollserver.cpp53
-rw-r--r--protocols/VKontakte/src/vk_proto.cpp36
-rw-r--r--protocols/VKontakte/src/vk_proto.h44
-rw-r--r--protocols/VKontakte/src/vk_queue.cpp22
-rw-r--r--protocols/VKontakte/src/vk_search.cpp2
-rw-r--r--protocols/VKontakte/src/vk_status.cpp48
-rw-r--r--protocols/VKontakte/src/vk_struct.cpp20
-rw-r--r--protocols/VKontakte/src/vk_struct.h8
-rw-r--r--protocols/VKontakte/src/vk_thread.cpp58
20 files changed, 370 insertions, 359 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp
index 5232e13b85..6b7f12dad1 100644
--- a/protocols/VKontakte/src/misc.cpp
+++ b/protocols/VKontakte/src/misc.cpp
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
-static const char *szImageTypes[] = { "photo_2560", "photo_1280", "photo_807", "photo_604", "photo_256", "photo_130", "photo_128", "photo_75", "photo_64" , "preview" };
+static const char *szImageTypes[] = { "photo_2560", "photo_1280", "photo_807", "photo_604", "photo_256", "photo_130", "photo_128", "photo_75", "photo_64", "preview" };
static const char *szGiftTypes[] = { "thumb_256", "thumb_96", "thumb_48" };
@@ -29,12 +29,12 @@ JSONNode nullNode(JSON_NULL);
bool IsEmpty(LPCWSTR str)
{
- return (str == NULL || str[0] == 0);
+ return (str == nullptr || str[0] == 0);
}
bool IsEmpty(LPCSTR str)
{
- return (str == NULL || str[0] == 0);
+ return (str == nullptr || str[0] == 0);
}
LPCSTR findHeader(NETLIBHTTPREQUEST *pReq, LPCSTR szField)
@@ -43,7 +43,7 @@ LPCSTR findHeader(NETLIBHTTPREQUEST *pReq, LPCSTR szField)
if (!_stricmp(pReq->headers[i].szName, szField))
return pReq->headers[i].szValue;
- return NULL;
+ return nullptr;
}
bool wlstrstr(wchar_t *_s1, wchar_t *_s2)
@@ -55,7 +55,7 @@ bool wlstrstr(wchar_t *_s1, wchar_t *_s2)
wcsncpy_s(s2, _s2, _TRUNCATE);
CharLowerBuff(s2, _countof(s2));
- return wcsstr(s1, s2) != NULL;
+ return wcsstr(s1, s2) != nullptr;
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -97,8 +97,8 @@ char* ExpUrlEncode(const char *szUrl, bool strict)
{
const char szHexDigits[] = "0123456789ABCDEF";
- if (szUrl == NULL)
- return NULL;
+ if (szUrl == nullptr)
+ return nullptr;
const BYTE *s;
int outputLen;
@@ -113,8 +113,8 @@ char* ExpUrlEncode(const char *szUrl, bool strict)
outputLen += 3;
char *szOutput = (char*)mir_alloc(outputLen + 1);
- if (szOutput == NULL)
- return NULL;
+ if (szOutput == nullptr)
+ return nullptr;
char *d = szOutput;
for (s = (const BYTE*)szUrl; *s; s++)
@@ -132,8 +132,8 @@ char* ExpUrlEncode(const char *szUrl, bool strict)
*d++ = szHexDigits[*s & 0xF];
}
- *d = '\0';
- return szOutput;
+ *d = '\0';
+ return szOutput;
}
@@ -142,8 +142,8 @@ char* ExpUrlEncode(const char *szUrl, bool strict)
void CVkProto::ClearAccessToken()
{
debugLogA("CVkProto::ClearAccessToken");
- setDword("LastAccessTokenTime", (DWORD)time(NULL));
- m_szAccessToken = NULL;
+ setDword("LastAccessTokenTime", (DWORD)time(nullptr));
+ m_szAccessToken = nullptr;
delSetting("AccessToken");
ShutdownSession();
}
@@ -152,7 +152,7 @@ wchar_t* CVkProto::GetUserStoredPassword()
{
debugLogA("CVkProto::GetUserStoredPassword");
ptrA szRawPass(getStringA("Password"));
- return (szRawPass != NULL) ? mir_utf8decodeW(szRawPass) : NULL;
+ return (szRawPass != nullptr) ? mir_utf8decodeW(szRawPass) : nullptr;
}
void CVkProto::SetAllContactStatuses(int iStatus)
@@ -176,7 +176,7 @@ void CVkProto::SetAllContactStatuses(int iStatus)
MCONTACT CVkProto::FindUser(LONG dwUserid, bool bCreate)
{
if (!dwUserid)
- return NULL;
+ return 0;
for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
LONG dbUserid = getDword(hContact, "ID", VK_INVALID_USER);
@@ -188,7 +188,7 @@ MCONTACT CVkProto::FindUser(LONG dwUserid, bool bCreate)
}
if (!bCreate)
- return NULL;
+ return 0;
MCONTACT hNewContact = db_add_contact();
Proto_AddToContact(hNewContact, m_szModuleName);
@@ -202,7 +202,7 @@ MCONTACT CVkProto::FindUser(LONG dwUserid, bool bCreate)
MCONTACT CVkProto::FindChat(LONG dwUserid)
{
if (!dwUserid)
- return NULL;
+ return 0;
for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
LONG dbUserid = getDword(hContact, "vk_chat_id", VK_INVALID_USER);
@@ -213,7 +213,7 @@ MCONTACT CVkProto::FindChat(LONG dwUserid)
return hContact;
}
- return NULL;
+ return 0;
}
bool CVkProto::IsGroupUser(MCONTACT hContact)
@@ -288,19 +288,19 @@ bool CVkProto::CheckJsonResult(AsyncHttpRequest *pReq, const JSONNode &jnNode)
break;
}
- if (time(NULL) - getDword("LastAccessTokenTime", 0) > 60 * 60 * 24) {
+ if (time(nullptr) - getDword("LastAccessTokenTime", 0) > 60 * 60 * 24) {
debugLogA("CVkProto::CheckJsonResult VKERR_ACCESS_DENIED (AccessToken fail?)");
ClearAccessToken();
return false;
}
debugLogA("CVkProto::CheckJsonResult VKERR_ACCESS_DENIED");
- MsgPopup(NULL, TranslateT("Access denied! Data will not be sent or received."), TranslateT("Error"), true);
+ MsgPopup(TranslateT("Access denied! Data will not be sent or received."), TranslateT("Error"), true);
break;
case VKERR_CAPTCHA_NEEDED:
ApplyCaptcha(pReq, jnError);
break;
case VKERR_VALIDATION_REQUIRED: // Validation Required
- MsgPopup(NULL, TranslateT("You have to validate your account before you can use VK in Miranda NG"), TranslateT("Error"), true);
+ MsgPopup(TranslateT("You have to validate your account before you can use VK in Miranda NG"), TranslateT("Error"), true);
if (jnRedirectUri) {
T2Utf szRedirectUri(jnRedirectUri.as_mstring());
AsyncHttpRequest *pRedirectReq = new AsyncHttpRequest(this, REQUEST_GET, szRedirectUri, false, &CVkProto::OnOAuthAuthorize);
@@ -323,25 +323,25 @@ bool CVkProto::CheckJsonResult(AsyncHttpRequest *pReq, const JSONNode &jnNode)
}
else {
CMStringW msg(FORMAT, TranslateT("Error %d. Data will not be sent or received."), iErrorCode);
- MsgPopup(NULL, msg, TranslateT("Error"), true);
+ MsgPopup(msg, TranslateT("Error"), true);
debugLogA("CVkProto::CheckJsonResult SendError");
}
break;
case VKERR_INVALID_PARAMETERS:
- MsgPopup(NULL, TranslateT("One of the parameters specified was missing or invalid"), TranslateT("Error"), true);
+ MsgPopup(TranslateT("One of the parameters specified was missing or invalid"), TranslateT("Error"), true);
break;
case VKERR_ACC_WALL_POST_DENIED:
- MsgPopup(NULL, TranslateT("Access to adding post denied"), TranslateT("Error"), true);
+ MsgPopup(TranslateT("Access to adding post denied"), TranslateT("Error"), true);
break;
case VKERR_CANT_SEND_USER_ON_BLACKLIST:
- MsgPopup(NULL, TranslateT("Can't send messages for users from blacklist"), TranslateT("Error"), true);
+ MsgPopup(TranslateT("Can't send messages for users from blacklist"), TranslateT("Error"), true);
break;
case VKERR_CANT_SEND_USER_WITHOUT_DIALOGS:
- MsgPopup(NULL, TranslateT("Can't send messages for users without dialogs"), TranslateT("Error"), true);
+ MsgPopup(TranslateT("Can't send messages for users without dialogs"), TranslateT("Error"), true);
break;
case VKERR_CANT_SEND_YOU_ON_BLACKLIST:
- MsgPopup(NULL, TranslateT("Can't send messages to this user due to their privacy settings"), TranslateT("Error"), true);
+ MsgPopup(TranslateT("Can't send messages to this user due to their privacy settings"), TranslateT("Error"), true);
break;
case VKERR_COULD_NOT_SAVE_FILE:
case VKERR_INVALID_ALBUM_ID:
@@ -354,9 +354,8 @@ bool CVkProto::CheckJsonResult(AsyncHttpRequest *pReq, const JSONNode &jnNode)
case VKERR_HIMSELF_AS_FRIEND:
case VKERR_YOU_ON_BLACKLIST:
case VKERR_USER_ON_BLACKLIST:
-
- // See also CVkProto::SendFileFiled
break;
+ // See also CVkProto::SendFileFiled
}
return (iErrorCode == 0);
@@ -375,13 +374,13 @@ void CVkProto::OnReceiveSmth(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
static CMStringA getAttr(char *szSrc, LPCSTR szAttrName)
{
char *pEnd = strchr(szSrc, '>');
- if (pEnd == NULL)
+ if (pEnd == nullptr)
return "";
*pEnd = 0;
char *p1 = strstr(szSrc, szAttrName);
- if (p1 == NULL) {
+ if (p1 == nullptr) {
*pEnd = '>';
return "";
}
@@ -395,7 +394,7 @@ static CMStringA getAttr(char *szSrc, LPCSTR szAttrName)
p1 += 2;
char *p2 = strchr(p1, '\"');
*pEnd = '>';
- if (p2 == NULL)
+ if (p2 == nullptr)
return "";
return CMStringA(p1, (int)(p2 - p1));
@@ -407,11 +406,11 @@ bool CVkProto::AutoFillForm(char *pBody, CMStringA &szAction, CMStringA& szResul
szResult.Empty();
char *pFormBeg = strstr(pBody, "<form ");
- if (pFormBeg == NULL)
+ if (pFormBeg == nullptr)
return false;
char *pFormEnd = strstr(pFormBeg, "</form>");
- if (pFormEnd == NULL)
+ if (pFormEnd == nullptr)
return false;
*pFormEnd = 0;
@@ -421,7 +420,7 @@ bool CVkProto::AutoFillForm(char *pBody, CMStringA &szAction, CMStringA& szResul
CMStringA result;
char *pFieldBeg = pFormBeg;
while (true) {
- if ((pFieldBeg = strstr(pFieldBeg + 1, "<input ")) == NULL)
+ if ((pFieldBeg = strstr(pFieldBeg + 1, "<input ")) == nullptr)
break;
CMStringA type = getAttr(pFieldBeg, "type");
@@ -445,8 +444,9 @@ bool CVkProto::AutoFillForm(char *pBody, CMStringA &szAction, CMStringA& szResul
if (pPhonePref && sscanf(pPhonePref, "<span class=\"field_prefix\">%[^<]", szPrefixTel) == 1) {
pPhonePref = strstr(pPhonePref + 1, "<span class=\"field_prefix\">&nbsp;");
if (pPhonePref && sscanf(pPhonePref, "<span class=\"field_prefix\">&nbsp;%[^<]", szSufixTel) == 1) {
- wszTitle.Format(TranslateT("Enter the missing digits between %s and %s of the phone number linked to your account"), ptrW(mir_a2u(szPrefixTel)), ptrW(mir_a2u(szSufixTel)));
- MessageBoxW(NULL, wszTitle, TranslateT("Attention!"), MB_ICONWARNING | MB_OK);
+ wszTitle.Format(TranslateT("Enter the missing digits between %s and %s of the phone number linked to your account"),
+ ptrW(mir_a2u(szPrefixTel)), ptrW(mir_a2u(szSufixTel)));
+ MessageBoxW(nullptr, wszTitle, TranslateT("Attention!"), MB_ICONWARNING | MB_OK);
}
}
@@ -471,7 +471,7 @@ CMStringW CVkProto::RunConfirmationCode(LPCWSTR pwszTitle)
pForm.type = ESF_COMBO;
pForm.recentCount = 0;
pForm.caption = IsEmpty(pwszTitle) ? TranslateT("Enter confirmation code") : pwszTitle;
- pForm.ptszInitVal = NULL;
+ pForm.ptszInitVal = nullptr;
pForm.szModuleName = m_szModuleName;
pForm.szDataPrefix = "confirmcode_";
return (!EnterString(&pForm)) ? CMStringW() : CMStringW(ptrW(pForm.ptszResult));
@@ -554,7 +554,7 @@ void CVkProto::ApplyCookies(AsyncHttpRequest *pReq)
void __cdecl CVkProto::DBAddAuthRequestThread(void *p)
{
CVkDBAddAuthRequestThreadParam *param = (CVkDBAddAuthRequestThreadParam *)p;
- if (param->hContact == NULL || param->hContact == INVALID_CONTACT_ID || !IsOnline())
+ if (param->hContact == 0 || param->hContact == INVALID_CONTACT_ID || !IsOnline())
return;
for (int i = 0; i < MAX_RETRIES && IsEmpty(ptrW(db_get_wsa(param->hContact, m_szModuleName, "Nick"))); i++) {
@@ -575,16 +575,16 @@ void CVkProto::DBAddAuthRequest(const MCONTACT hContact, bool added)
DB_AUTH_BLOB blob(hContact,
T2Utf(ptrW(db_get_wsa(hContact, m_szModuleName, "Nick"))),
T2Utf(ptrW(db_get_wsa(hContact, m_szModuleName, "FirstName"))),
- T2Utf(ptrW(db_get_wsa(hContact, m_szModuleName, "LastName"))), NULL, NULL);
+ T2Utf(ptrW(db_get_wsa(hContact, m_szModuleName, "LastName"))), nullptr, nullptr);
DBEVENTINFO dbei = {};
dbei.szModule = m_szModuleName;
- dbei.timestamp = (DWORD)time(NULL);
+ dbei.timestamp = (DWORD)time(nullptr);
dbei.flags = DBEF_UTF;
dbei.eventType = added ? EVENTTYPE_ADDED : EVENTTYPE_AUTHREQUEST;
dbei.cbBlob = blob.size();
dbei.pBlob = blob;
- db_event_add(NULL, &dbei);
+ db_event_add(0, &dbei);
debugLogA("CVkProto::DBAddAuthRequest %s", blob.get_nick() ? blob.get_nick() : "<null>");
}
@@ -613,7 +613,7 @@ MCONTACT CVkProto::MContactFromDbEvent(MEVENT hDbEvent)
void CVkProto::SetMirVer(MCONTACT hContact, int platform)
{
- if (hContact == NULL || hContact == INVALID_CONTACT_ID)
+ if (hContact == 0 || hContact == INVALID_CONTACT_ID)
return;
if (platform == -1) {
db_unset(hContact, m_szModuleName, "MirVer");
@@ -701,7 +701,7 @@ int CVkProto::IsHystoryMessageExist(MCONTACT hContact)
if (!hDBEvent)
return 0;
- do {
+ do {
DBEVENTINFO dbei = {};
db_event_get(hDBEvent, &dbei);
if (dbei.eventType != VK_USER_DEACTIVATE_ACTION)
@@ -762,9 +762,9 @@ void CVkProto::MarkDialogAsRead(MCONTACT hContact)
if (userID == VK_INVALID_USER || userID == VK_FEED_USER)
return;
- MEVENT hDBEvent = NULL;
+ MEVENT hDBEvent = 0;
MCONTACT hMContact = db_mc_tryMeta(hContact);
- while ((hDBEvent = db_event_firstUnread(hContact)) != NULL)
+ while ((hDBEvent = db_event_firstUnread(hContact)) != 0)
{
DBEVENTINFO dbei = {};
if (!db_event_get(hDBEvent, &dbei) && !mir_strcmp(m_szModuleName, dbei.szModule))
@@ -780,7 +780,7 @@ void CVkProto::MarkDialogAsRead(MCONTACT hContact)
char* CVkProto::GetStickerId(const char *Msg, int &stickerid)
{
stickerid = 0;
- char *retMsg = NULL;
+ char *retMsg = nullptr;
int iRes = 0;
char HeadMsg[32] = { 0 };
@@ -803,9 +803,9 @@ char* CVkProto::GetStickerId(const char *Msg, int &stickerid)
const char* FindVKUrls(const char *Msg)
{
if (IsEmpty(Msg))
- return NULL;
+ return nullptr;
- const char *pos = NULL;
+ const char *pos = nullptr;
for (int i = 0; i < _countof(szVKUrls) && !pos; i++) {
pos = strstr(Msg, szVKUrls[i]);
if (pos)
@@ -813,7 +813,7 @@ const char* FindVKUrls(const char *Msg)
}
if (pos >= (Msg + mir_strlen(Msg)))
- pos = NULL;
+ pos = nullptr;
return pos;
}
@@ -829,7 +829,7 @@ CMStringA CVkProto::GetAttachmentsFromMessage(const char *Msg)
return CMStringA();
const char *nextpos = FindVKUrls(pos);
- const char *pos2 = NULL;
+ const char *pos2 = nullptr;
for (int i = 0; i < _countof(szVKLinkParam) && !pos2; i++) {
pos2 = strstr(pos, szVKLinkParam[i]);
@@ -868,7 +868,7 @@ CMStringA CVkProto::GetAttachmentsFromMessage(const char *Msg)
int CVkProto::OnDbSettingChanged(WPARAM hContact, LPARAM lParam)
{
DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam;
- if (hContact != NULL)
+ if (hContact != 0)
return 0;
if (strcmp(cws->szModule, "ListeningTo"))
@@ -1018,7 +1018,7 @@ CMStringW CVkProto::SetBBCString(LPCWSTR pwszString, BBCSupport iBBC, VKBBCType
if (IsEmpty(pwszString))
return CMStringW();
- wchar_t *pwszFormat = NULL;
+ wchar_t *pwszFormat = nullptr;
for (int i = 0; i < _countof(bbcItem); i++)
if (bbcItem[i].vkBBCType == bbcType && bbcItem[i].vkBBCSettings == iBBC) {
pwszFormat = bbcItem[i].pwszTempate;
@@ -1026,7 +1026,7 @@ CMStringW CVkProto::SetBBCString(LPCWSTR pwszString, BBCSupport iBBC, VKBBCType
}
CMStringW res;
- if (pwszFormat == NULL)
+ if (pwszFormat == nullptr)
return CMStringW(pwszString);
if (bbcType == vkbbcUrl && iBBC != bbcAdvanced)
@@ -1059,7 +1059,7 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport
debugLogA("CVkProto::GetAttachmentDescr");
CMStringW res;
if (!jnAttachments) {
- debugLogA("CVkProto::GetAttachmentDescr pAttachments == NULL");
+ debugLogA("CVkProto::GetAttachmentDescr pAttachments == nullptr");
return res;
}
@@ -1276,7 +1276,7 @@ CMStringW CVkProto::GetFwdMessages(const JSONNode &jnMessages, const JSONNode &j
CMStringW res;
debugLogA("CVkProto::GetFwdMessages");
if (!jnMessages) {
- debugLogA("CVkProto::GetFwdMessages pMessages == NULL");
+ debugLogA("CVkProto::GetFwdMessages pMessages == nullptr");
return res;
}
@@ -1369,7 +1369,7 @@ void CVkProto::SetInvisible(MCONTACT hContact)
db_set_dw(hContact, "BuddyExpectator", "LastStatus", ID_STATUS_INVISIBLE);
debugLogA("CVkProto::SetInvisible %d set ID_STATUS_INVISIBLE", getDword(hContact, "ID", VK_INVALID_USER));
}
- time_t now = time(NULL);
+ time_t now = time(nullptr);
db_set_dw(hContact, "BuddyExpectator", "LastSeen", (DWORD)now);
setDword(hContact, "InvisibleTS", (DWORD)now);
}
@@ -1463,14 +1463,14 @@ void CVkProto::ShowCaptchaInBrowser(HBITMAP hBitmap)
CMStringW wszHTMLPath(FORMAT, L"%s\\miranda_captcha.html", wszTempDir);
FILE *pFile = _wfopen(wszHTMLPath, L"w");
- if (pFile == NULL)
+ if (pFile == nullptr)
return;
FIBITMAP *dib = fii->FI_CreateDIBFromHBITMAP(hBitmap);
FIMEMORY *hMem = fii->FI_OpenMemory(nullptr, 0);
fii->FI_SaveToMemory(FIF_PNG, dib, hMem, 0);
- BYTE *buf = NULL;
+ BYTE *buf = nullptr;
DWORD bufLen;
fii->FI_AcquireMemory(hMem, &buf, &bufLen);
ptrA base64(mir_base64_encode(buf, bufLen));
@@ -1507,7 +1507,7 @@ void CVkProto::AddVkDeactivateEvent(MCONTACT hContact, CMStringW& wszType)
DBEVENTINFO dbei = {};
dbei.szModule = m_szModuleName;
- dbei.timestamp = time(NULL);
+ dbei.timestamp = time(nullptr);
dbei.eventType = VK_USER_DEACTIVATE_ACTION;
dbei.cbBlob = (DWORD)mir_strlen(vkDeactivateEvent[iDEIdx].szDescription) + 1;
dbei.pBlob = (PBYTE)mir_strdup(vkDeactivateEvent[iDEIdx].szDescription);
diff --git a/protocols/VKontakte/src/vk_avatars.cpp b/protocols/VKontakte/src/vk_avatars.cpp
index 10a4ef810a..b569d59b9a 100644
--- a/protocols/VKontakte/src/vk_avatars.cpp
+++ b/protocols/VKontakte/src/vk_avatars.cpp
@@ -28,10 +28,10 @@ void CVkProto::OnReceiveAvatar(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
ai.format = ProtoGetBufferFormat(reply->pData);
FILE *out = _wfopen(ai.filename, L"wb");
- if (out == NULL) {
+ if (out == nullptr) {
ProtoBroadcastAck(param->hContact, ACKTYPE_AVATAR, ACKRESULT_FAILED, &ai);
delete param;
- pReq->pUserInfo = NULL;
+ pReq->pUserInfo = nullptr;
return;
}
@@ -40,7 +40,7 @@ void CVkProto::OnReceiveAvatar(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
setByte(param->hContact, "NeedNewAvatar", 0);
ProtoBroadcastAck(param->hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, &ai);
delete param;
- pReq->pUserInfo = NULL;
+ pReq->pUserInfo = nullptr;
}
INT_PTR CVkProto::SvcGetAvatarCaps(WPARAM wParam, LPARAM lParam)
@@ -82,7 +82,7 @@ INT_PTR CVkProto::SvcGetAvatarInfo(WPARAM, LPARAM lParam)
PROTO_AVATAR_INFORMATION *pai = (PROTO_AVATAR_INFORMATION *)lParam;
ptrA szUrl(getStringA(pai->hContact, "AvatarUrl"));
- if (szUrl == NULL)
+ if (szUrl == nullptr)
return GAIR_NOAVATAR;
wchar_t wszFileName[MAX_PATH];
@@ -142,7 +142,7 @@ void CVkProto::GetAvatarFileName(MCONTACT hContact, wchar_t *pwszDest, size_t cb
ptrW wszUrl(getWStringA(hContact, "AvatarUrl"));
if (wszUrl) {
wchar_t *p = wcsrchr(wszUrl, '.');
- if (p != NULL)
+ if (p != nullptr)
szFileType = p;
}
@@ -159,11 +159,11 @@ void CVkProto::SetAvatarUrl(MCONTACT hContact, CMStringW &wszUrl)
if (wszUrl.IsEmpty()) {
delSetting(hContact, "AvatarUrl");
- ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, NULL);
+ ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, nullptr);
}
else {
setWString(hContact, "AvatarUrl", wszUrl);
- setByte(hContact,"NeedNewAvatar", 1);
+ setByte(hContact, "NeedNewAvatar", 1);
PROTO_AVATAR_INFORMATION ai = { 0 };
ai.hContact = hContact;
GetAvatarFileName(ai.hContact, ai.filename, _countof(ai.filename));
diff --git a/protocols/VKontakte/src/vk_captcha.cpp b/protocols/VKontakte/src/vk_captcha.cpp
index 250ac6efeb..f2da23f78e 100644
--- a/protocols/VKontakte/src/vk_captcha.cpp
+++ b/protocols/VKontakte/src/vk_captcha.cpp
@@ -39,7 +39,7 @@ bool CVkProto::RunCaptchaForm(LPCSTR szUrl, CMStringA &result)
req.flags = VK_NODUMPHEADERS;
NETLIBHTTPREQUEST *reply = Netlib_HttpTransaction(m_hNetlibUser, &req);
- if (reply == NULL)
+ if (reply == nullptr)
return false;
if (reply->resultCode != 200) {
diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp
index 19853e553d..e48e3979e4 100644
--- a/protocols/VKontakte/src/vk_chats.cpp
+++ b/protocols/VKontakte/src/vk_chats.cpp
@@ -32,21 +32,21 @@ CVkChatInfo* CVkProto::AppendChat(int id, const JSONNode &jnDlg)
{
debugLogW(L"CVkProto::AppendChat");
if (id == 0)
- return NULL;
+ return nullptr;
if (jnDlg) {
CMStringW action_chat = jnDlg["action"].as_mstring();
int action_mid = _wtoi(jnDlg["action_mid"].as_mstring());
if ((action_chat == L"chat_kick_user") && (action_mid == m_myUserId))
- return NULL;
+ return nullptr;
}
MCONTACT chatContact = FindChat(id);
if (chatContact && getBool(chatContact, "kicked"))
- return NULL;
+ return nullptr;
CVkChatInfo *c = m_chats.find((CVkChatInfo*)&id);
- if (c != NULL)
+ if (c != nullptr)
return c;
CMStringW wszTitle;
@@ -66,7 +66,7 @@ CVkChatInfo* CVkProto::AppendChat(int id, const JSONNode &jnDlg)
setWString(si->hContact, "Nick", wszTitle);
m_chats.insert(c);
- for (int i = _countof(sttStatuses)-1; i >= 0; i--)
+ for (int i = _countof(sttStatuses) - 1; i >= 0; i--)
Chat_AddGroup(m_szModuleName, sid, TranslateW(sttStatuses[i]));
setDword(si->hContact, "vk_chat_id", id);
@@ -76,10 +76,10 @@ CVkChatInfo* CVkProto::AppendChat(int id, const JSONNode &jnDlg)
db_unset(si->hContact, m_szModuleName, "off");
- if (jnDlg && jnDlg["left"].as_bool()) {
+ if (jnDlg && jnDlg["left"].as_bool()) {
setByte(si->hContact, "off", 1);
m_chats.remove(c);
- return NULL;
+ return nullptr;
}
Chat_Control(m_szModuleName, sid, (m_vkOptions.bHideChats) ? WINDOW_HIDDEN : SESSION_INITDONE);
@@ -145,7 +145,7 @@ void CVkProto::OnReceiveChatInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
bool bNew;
CVkChatUser *cu = cc->m_users.find((CVkChatUser*)&uid);
- if (cu == NULL) {
+ if (cu == nullptr) {
cc->m_users.insert(cu = new CVkChatUser(uid));
bNew = true;
}
@@ -186,7 +186,7 @@ void CVkProto::OnReceiveChatInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
GCEVENT gce = { &gcd };
gce.ptszUID = wszId;
gce.dwFlags = GCEF_NOTNOTIFY;
- gce.time = time(NULL);
+ gce.time = time(nullptr);
gce.ptszNick = mir_wstrdup(CMStringW(FORMAT, L"%s (https://vk.com/id%s)", cu.m_wszNick, wszId));
Chat_Event(&gce);
@@ -256,7 +256,7 @@ void CVkProto::AppendChatMessage(int id, const JSONNode &jnMsg, const JSONNode &
{
debugLogA("CVkProto::AppendChatMessage");
CVkChatInfo *cc = AppendChat(id, nullNode);
- if (cc == NULL)
+ if (cc == nullptr)
return;
int mid = jnMsg["id"].as_int();
@@ -264,7 +264,7 @@ void CVkProto::AppendChatMessage(int id, const JSONNode &jnMsg, const JSONNode &
bool bIsAction = false;
int msgTime = jnMsg["date"].as_int();
- time_t now = time(NULL);
+ time_t now = time(nullptr);
if (!msgTime || msgTime > now)
msgTime = now;
@@ -314,7 +314,7 @@ void CVkProto::AppendChatMessage(int id, const JSONNode &jnMsg, const JSONNode &
int iReadCount = swscanf(wszActionMid, L"%d", &a_uid);
if (iReadCount == 1) {
CVkChatUser *cu = cc->m_users.find((CVkChatUser*)&a_uid);
- if (cu == NULL)
+ if (cu == nullptr)
wszBody.AppendFormat(L"%s (https://vk.com/id%d)", TranslateT("kick user"), a_uid);
else
wszBody.AppendFormat(L"%s %s (https://vk.com/id%d)", TranslateT("kick user"), cu->m_wszNick, a_uid);
@@ -337,7 +337,7 @@ void CVkProto::AppendChatMessage(int id, const JSONNode &jnMsg, const JSONNode &
int iReadCount = swscanf(wszActionMid, L"%d", &a_uid);
if (iReadCount == 1) {
CVkChatUser *cu = cc->m_users.find((CVkChatUser*)&a_uid);
- if (cu == NULL)
+ if (cu == nullptr)
wszBody.AppendFormat(L"%s (https://vk.com/id%d)", TranslateT("invite user"), a_uid);
else
wszBody.AppendFormat(L"%s %s (https://vk.com/id%d)", TranslateT("invite user"), cu->m_wszNick, a_uid);
@@ -371,7 +371,7 @@ void CVkProto::AppendChatMessage(int id, const JSONNode &jnMsg, const JSONNode &
}
else {
CVkChatMessage *cm = cc->m_msgs.find((CVkChatMessage *)&mid);
- if (cm == NULL)
+ if (cm == nullptr)
cc->m_msgs.insert(cm = new CVkChatMessage(mid));
cm->m_uid = uid;
@@ -387,7 +387,7 @@ void CVkProto::AppendChatMessage(CVkChatInfo *cc, int uid, int msgTime, LPCWSTR
debugLogA("CVkProto::AppendChatMessage2");
MCONTACT hContact = FindUser(uid);
CVkChatUser *cu = cc->m_users.find((CVkChatUser*)&uid);
- if (cu == NULL) {
+ if (cu == nullptr) {
cc->m_users.insert(cu = new CVkChatUser(uid));
CMStringW wszNick(ptrW(db_get_wsa(cc->m_hContact, m_szModuleName, CMStringA(FORMAT, "nick%d", cu->m_uid))));
cu->m_wszNick = mir_wstrdup(wszNick.IsEmpty() ? (hContact ? ptrW(db_get_wsa(hContact, m_szModuleName, "Nick")) : TranslateT("Unknown")) : wszNick);
@@ -417,7 +417,7 @@ CVkChatInfo* CVkProto::GetChatById(LPCWSTR pwszId)
if (!mir_wstrcmp(m_chats[i].m_wszId, pwszId))
return &m_chats[i];
- return NULL;
+ return nullptr;
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -425,11 +425,11 @@ CVkChatInfo* CVkProto::GetChatById(LPCWSTR pwszId)
void CVkProto::SetChatStatus(MCONTACT hContact, int iStatus)
{
ptrW wszChatID(getWStringA(hContact, "ChatRoomID"));
- if (wszChatID == NULL)
+ if (wszChatID == nullptr)
return;
CVkChatInfo *cc = GetChatById(wszChatID);
- if (cc != NULL)
+ if (cc != nullptr)
Chat_Control(m_szModuleName, wszChatID, (iStatus == ID_STATUS_OFFLINE) ? SESSION_OFFLINE : SESSION_ONLINE);
}
@@ -438,14 +438,14 @@ void CVkProto::SetChatStatus(MCONTACT hContact, int iStatus)
int CVkProto::OnChatEvent(WPARAM, LPARAM lParam)
{
GCHOOK *gch = (GCHOOK*)lParam;
- if (gch == NULL)
+ if (gch == nullptr)
return 0;
if (mir_strcmpi(gch->pDest->pszModule, m_szModuleName))
return 0;
CVkChatInfo *cc = GetChatById(gch->pDest->ptszID);
- if (cc == NULL)
+ if (cc == nullptr)
return 0;
switch (gch->pDest->iType) {
@@ -461,7 +461,7 @@ int CVkProto::OnChatEvent(WPARAM, LPARAM lParam)
case GC_USER_PRIVMESS:
{
MCONTACT hContact = FindUser(_wtoi(gch->ptszUID));
- if (hContact == NULL) {
+ if (hContact == 0) {
hContact = FindUser(_wtoi(gch->ptszUID), true);
db_set_b(hContact, "CList", "Hidden", 1);
db_set_b(hContact, "CList", "NotOnList", 1);
@@ -499,7 +499,7 @@ void CVkProto::OnSendChatMsg(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
ProtoBroadcastAck(fup->hContact, ACKTYPE_FILE, iResult, (HANDLE)(fup));
if (!pReq->bNeedsRestart || m_bTerminated) {
delete fup;
- pReq->pUserInfo = NULL;
+ pReq->pUserInfo = nullptr;
}
}
@@ -513,7 +513,7 @@ LPTSTR CVkProto::ChangeChatTopic(CVkChatInfo *cc)
pForm.ptszInitVal = cc->m_wszTopic;
pForm.szModuleName = m_szModuleName;
pForm.szDataPrefix = "gctopic_";
- return (!EnterString(&pForm)) ? NULL : pForm.ptszResult;
+ return (!EnterString(&pForm)) ? nullptr : pForm.ptszResult;
}
void CVkProto::LogMenuHook(CVkChatInfo *cc, GCHOOK *gch)
@@ -534,7 +534,7 @@ void CVkProto::LogMenuHook(CVkChatInfo *cc, GCHOOK *gch)
case IDM_INVITE:
{
CVkInviteChatForm dlg(this);
- if (dlg.DoModal() && dlg.m_hContact != NULL) {
+ if (dlg.DoModal() && dlg.m_hContact != 0) {
int uid = getDword(dlg.m_hContact, "ID", VK_INVALID_USER);
if (uid != VK_INVALID_USER)
Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/messages.addChatUser.json", true, &CVkProto::OnReceiveSmth)
@@ -545,10 +545,10 @@ void CVkProto::LogMenuHook(CVkChatInfo *cc, GCHOOK *gch)
break;
case IDM_DESTROY:
- if (IDYES == MessageBoxW(NULL,
+ if (IDYES == MessageBoxW(nullptr,
TranslateT("This chat is going to be destroyed forever with all its contents. This action cannot be undone. Are you sure?"),
TranslateT("Warning"), MB_YESNO | MB_ICONQUESTION)
- )
+ )
Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.DestroyChat", true, &CVkProto::OnChatDestroy)
<< INT_PARAM("chatid", cc->m_chatid)
<< INT_PARAM("userid", m_myUserId)
@@ -561,17 +561,10 @@ void CVkProto::LogMenuHook(CVkChatInfo *cc, GCHOOK *gch)
INT_PTR __cdecl CVkProto::OnJoinChat(WPARAM hContact, LPARAM)
{
debugLogA("CVkProto::OnJoinChat");
- if (!IsOnline())
- return 1;
-
- if (getBool(hContact, "kicked"))
- return 1;
-
- if (!getBool(hContact, "off"))
+ if (!IsOnline() || getBool(hContact, "kicked") || !getBool(hContact, "off"))
return 1;
int chat_id = getDword(hContact, "vk_chat_id", VK_INVALID_USER);
-
if (chat_id == VK_INVALID_USER)
return 1;
@@ -591,11 +584,11 @@ INT_PTR __cdecl CVkProto::OnLeaveChat(WPARAM hContact, LPARAM)
return 1;
ptrW wszChatID(getWStringA(hContact, "ChatRoomID"));
- if (wszChatID == NULL)
+ if (wszChatID == nullptr)
return 1;
CVkChatInfo *cc = GetChatById(wszChatID);
- if (cc == NULL)
+ if (cc == nullptr)
return 1;
Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/messages.removeChatUser.json", true, &CVkProto::OnChatLeave)
@@ -609,7 +602,7 @@ void CVkProto::LeaveChat(int chat_id, bool close_window, bool delete_chat)
{
debugLogA("CVkProto::LeaveChat");
CVkChatInfo *cc = (CVkChatInfo*)m_chats.find((CVkChatInfo*)&chat_id);
- if (cc == NULL)
+ if (cc == nullptr)
return;
if (close_window)
@@ -636,14 +629,14 @@ void CVkProto::KickFromChat(int chat_id, int user_id, const JSONNode &jnMsg, con
LeaveChat(chat_id);
CVkChatInfo *cc = (CVkChatInfo*)m_chats.find((CVkChatInfo*)&chat_id);
- if (cc == NULL)
+ if (cc == nullptr)
return;
MCONTACT hContact = FindUser(user_id, false);
CMStringW msg(jnMsg["body"].as_mstring());
if (msg.IsEmpty()) {
msg = TranslateT("You've been kicked by ");
- if (hContact != NULL)
+ if (hContact != 0)
msg += ptrW(db_get_wsa(hContact, m_szModuleName, "Nick"));
else
msg += TranslateT("(Unknown contact)");
@@ -704,7 +697,7 @@ void CVkProto::NickMenuHook(CVkChatInfo *cc, GCHOOK *gch)
{
CVkChatUser *cu = cc->GetUserById(gch->ptszUID);
MCONTACT hContact;
- if (cu == NULL)
+ if (cu == nullptr)
return;
char szUid[20], szChatId[20];
@@ -714,7 +707,7 @@ void CVkProto::NickMenuHook(CVkChatInfo *cc, GCHOOK *gch)
switch (gch->dwData) {
case IDM_INFO:
hContact = FindUser(cu->m_uid);
- if (hContact == NULL) {
+ if (hContact == 0) {
hContact = FindUser(cu->m_uid, true);
db_set_b(hContact, "CList", "Hidden", 1);
db_set_b(hContact, "CList", "NotOnList", 1);
@@ -725,35 +718,35 @@ void CVkProto::NickMenuHook(CVkChatInfo *cc, GCHOOK *gch)
case IDM_VISIT_PROFILE:
hContact = FindUser(cu->m_uid);
- if (hContact == NULL)
+ if (hContact == 0)
Utils_OpenUrlW(CMStringW(FORMAT, L"https://vk.com/id%d", cu->m_uid));
else
SvcVisitProfile(hContact, 0);
break;
case IDM_CHANGENICK:
- {
- CMStringW wszNewNick = RunRenameNick(cu->m_wszNick);
- if (wszNewNick.IsEmpty() || wszNewNick == cu->m_wszNick)
- break;
-
- GCDEST gcd = { m_szModuleName, cc->m_wszId, GC_EVENT_NICK };
- GCEVENT gce = { &gcd };
-
- wchar_t wszId[20];
- _itow(cu->m_uid, wszId, 10);
-
- gce.ptszNick = mir_wstrdup(cu->m_wszNick);
- gce.bIsMe = (cu->m_uid == m_myUserId);
- gce.ptszUID = wszId;
- gce.ptszText = mir_wstrdup(wszNewNick);
- gce.dwFlags = GCEF_ADDTOLOG;
- gce.time = time(NULL);
- Chat_Event(&gce);
-
- cu->m_wszNick = mir_wstrdup(wszNewNick);
- setWString(cc->m_hContact, CMStringA(FORMAT, "nick%d", cu->m_uid), wszNewNick);
- }
+ {
+ CMStringW wszNewNick = RunRenameNick(cu->m_wszNick);
+ if (wszNewNick.IsEmpty() || wszNewNick == cu->m_wszNick)
+ break;
+
+ GCDEST gcd = { m_szModuleName, cc->m_wszId, GC_EVENT_NICK };
+ GCEVENT gce = { &gcd };
+
+ wchar_t wszId[20];
+ _itow(cu->m_uid, wszId, 10);
+
+ gce.ptszNick = mir_wstrdup(cu->m_wszNick);
+ gce.bIsMe = (cu->m_uid == m_myUserId);
+ gce.ptszUID = wszId;
+ gce.ptszText = mir_wstrdup(wszNewNick);
+ gce.dwFlags = GCEF_ADDTOLOG;
+ gce.time = time(nullptr);
+ Chat_Event(&gce);
+
+ cu->m_wszNick = mir_wstrdup(wszNewNick);
+ setWString(cc->m_hContact, CMStringA(FORMAT, "nick%d", cu->m_uid), wszNewNick);
+ }
break;
case IDM_KICK:
@@ -775,7 +768,7 @@ static gc_item sttLogListItems[] =
{
{ LPGENW("&Invite a user"), IDM_INVITE, MENU_ITEM },
{ LPGENW("View/change &title"), IDM_TOPIC, MENU_ITEM },
- { NULL, 0, MENU_SEPARATOR },
+ { nullptr, 0, MENU_SEPARATOR },
{ LPGENW("&Destroy room"), IDM_DESTROY, MENU_ITEM }
};
@@ -790,10 +783,7 @@ static gc_item sttListItems[] =
int CVkProto::OnGcMenuHook(WPARAM, LPARAM lParam)
{
GCMENUITEMS *gcmi = (GCMENUITEMS*)lParam;
- if (gcmi == NULL)
- return 0;
-
- if (mir_strcmpi(gcmi->pszModule, m_szModuleName))
+ if (gcmi == nullptr || mir_strcmpi(gcmi->pszModule, m_szModuleName))
return 0;
if (gcmi->Type == MENU_ON_LOG)
@@ -822,13 +812,15 @@ void CVkProto::ChatContactTypingThread(void *p)
delete param;
return;
}
+
CVkChatInfo *cc = (CVkChatInfo*)m_chats.find((CVkChatInfo*)&iChatId);
- if (cc == NULL) {
+ if (cc == nullptr) {
delete param;
return;
}
+
CVkChatUser *cu = cc->GetUserById(iUserId);
- if (cu == NULL) {
+ if (cu == nullptr) {
delete param;
return;
}
@@ -836,7 +828,7 @@ void CVkProto::ChatContactTypingThread(void *p)
{
mir_cslock lck(m_csChatTyping);
CVKChatContactTypingParam *cp = (CVKChatContactTypingParam *)m_ChatsTyping.find((CVKChatContactTypingParam *)&iChatId);
- if (cp != NULL)
+ if (cp != nullptr)
m_ChatsTyping.remove(cp);
m_ChatsTyping.insert(param);
@@ -855,17 +847,17 @@ void CVkProto::StopChatContactTyping(int iChatId, int iUserId)
return;
CVkChatInfo *cc = (CVkChatInfo*)m_chats.find((CVkChatInfo*)&iChatId);
- if (cc == NULL)
+ if (cc == nullptr)
return;
CVkChatUser *cu = cc->GetUserById(iUserId);
- if (cu == NULL)
+ if (cu == nullptr)
return;
mir_cslock lck(m_csChatTyping);
CVKChatContactTypingParam *cp = (CVKChatContactTypingParam *)m_ChatsTyping.find((CVKChatContactTypingParam *)&iChatId);
- if (cp != NULL && cp->m_UserId == iUserId) {
+ if (cp != nullptr && cp->m_UserId == iUserId) {
m_ChatsTyping.remove(cp);
Srmm_SetStatusText(hChatContact, nullptr);
}
@@ -877,6 +869,7 @@ INT_PTR CVkProto::SvcCreateChat(WPARAM, LPARAM)
{
if (!IsOnline())
return (INT_PTR)1;
+
CVkGCCreateForm dlg(this);
return (INT_PTR)!dlg.DoModal();
}
@@ -885,6 +878,7 @@ void CVkProto::CreateNewChat(LPCSTR uids, LPCWSTR pwszTitle)
{
if (!IsOnline())
return;
+
Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/messages.createChat.json", true, &CVkProto::OnCreateNewChat)
<< WCHAR_PARAM("title", pwszTitle ? pwszTitle : L"")
<< CHAR_PARAM("user_ids", uids));
diff --git a/protocols/VKontakte/src/vk_dialogs.cpp b/protocols/VKontakte/src/vk_dialogs.cpp
index d52d36f2d2..94ebc96a97 100644
--- a/protocols/VKontakte/src/vk_dialogs.cpp
+++ b/protocols/VKontakte/src/vk_dialogs.cpp
@@ -37,7 +37,7 @@ void CVkCaptchaForm::OnInitDialog()
Window_SetIcon_IcoLib(m_hwnd, GetIconHandle(IDI_KEYS));
m_btnOk.Disable();
- m_btnOpenInBrowser.Enable((m_param->bmp != NULL));
+ m_btnOpenInBrowser.Enable((m_param->bmp != nullptr));
m_instruction.SetText(TranslateT("Enter the text you see"));
}
@@ -51,7 +51,7 @@ INT_PTR CVkCaptchaForm::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
case IDC_TITLE:
return (INT_PTR)GetStockObject(WHITE_BRUSH);
}
- return NULL;
+ return 0;
case WM_PAINT:
if (m_param->bmp) {
@@ -75,7 +75,6 @@ INT_PTR CVkCaptchaForm::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
m_proto->ShowCaptchaInBrowser(m_param->bmp);
}
break;
-
}
return CDlgBase::DlgProc(msg, wParam, lParam);
}
@@ -151,7 +150,7 @@ CVkInviteChatForm::CVkInviteChatForm(CVkProto *proto) :
CVkDlgBase(proto, IDD_INVITE, false),
m_btnOk(this, IDOK),
m_cbxCombo(this, IDC_CONTACT),
- m_hContact(NULL)
+ m_hContact(0)
{
m_btnOk.OnClick = Callback(this, &CVkInviteChatForm::btnOk_OnOk);
}
@@ -233,7 +232,7 @@ void CVkGCCreateForm::ResetListOptions(CCtrlClc *clCList)
if (!clCList)
return;
- clCList->SetBkBitmap(0, NULL);
+ clCList->SetBkBitmap(0, nullptr);
clCList->SetBkColor(GetSysColor(COLOR_WINDOW));
clCList->SetGreyoutFlags(0);
clCList->SetLeftMargin(4);
diff --git a/protocols/VKontakte/src/vk_dialogs.h b/protocols/VKontakte/src/vk_dialogs.h
index 668be666a0..9e65d92daf 100644
--- a/protocols/VKontakte/src/vk_dialogs.h
+++ b/protocols/VKontakte/src/vk_dialogs.h
@@ -61,7 +61,7 @@ struct WALLPOST_FORM_PARAMS
pwszNick(nick),
bFriendsOnly(false)
{
- pwszMsg = pwszUrl = NULL;
+ pwszMsg = pwszUrl = nullptr;
}
~WALLPOST_FORM_PARAMS()
diff --git a/protocols/VKontakte/src/vk_feed.cpp b/protocols/VKontakte/src/vk_feed.cpp
index 9c8c61f073..1ee8c9bae9 100644
--- a/protocols/VKontakte/src/vk_feed.cpp
+++ b/protocols/VKontakte/src/vk_feed.cpp
@@ -58,7 +58,7 @@ void CVkProto::AddFeedEvent(CVKNewsItem& vkNewsItem)
recv.timestamp = vkNewsItem.tDate;
recv.szMessage = pszBody;
recv.lParam = 0;
- recv.pCustomData = NULL;
+ recv.pCustomData = nullptr;
recv.cbCustomDataSize = 0;
if (m_vkOptions.bUseNonStandardNotifications) {
@@ -83,7 +83,7 @@ void CVkProto::AddCListEvent(bool bNews)
cle.pszService = MS_MSG_READMESSAGE;
cle.flags = CLEF_URGENT | CLEF_UNICODE;
cle.hContact = hContact;
- cle.hDbEvent = NULL;
+ cle.hDbEvent = 0;
wchar_t toolTip[255];
mir_snwprintf(toolTip, bNews ? TranslateT("New news") : TranslateT("New notifications"));
cle.szTooltip.w = toolTip;
@@ -96,19 +96,19 @@ CVkUserInfo* CVkProto::GetVkUserInfo(LONG iUserId, OBJLIST<CVkUserInfo> &vkUsers
{
debugLogA("CVkProto::GetVkUserInfo %d", iUserId);
if (iUserId == 0)
- return NULL;
+ return nullptr;
bool bIsGroup = (iUserId < 0);
CVkUserInfo *vkUser = vkUsers.find((CVkUserInfo *)&iUserId);
- if (vkUser == NULL) {
+ if (vkUser == nullptr) {
CMStringW wszNick = TranslateT("Unknown");
CMStringW wszLink(L"https://vk.com/");
if (iUserId) {
wszLink += bIsGroup ? "club" : "id";
wszLink.AppendFormat(L"%d", bIsGroup ? -iUserId : iUserId);
}
- vkUser = new CVkUserInfo(iUserId, bIsGroup, wszNick, wszLink, bIsGroup ? NULL : FindUser(iUserId));
+ vkUser = new CVkUserInfo(iUserId, bIsGroup, wszNick, wszLink, bIsGroup ? 0 : FindUser(iUserId));
vkUsers.insert(vkUser);
}
@@ -128,7 +128,7 @@ void CVkProto::CreateVkUserInfoList(OBJLIST<CVkUserInfo> &vkUsers, const JSONNod
const JSONNode &jnProfile = (*it);
if (!jnProfile["id"])
continue;
- LONG UserId = jnProfile["id"].as_int();
+ LONG UserId = jnProfile["id"].as_int();
CMStringW wszNick(jnProfile["first_name"].as_mstring());
wszNick.AppendChar(' ');
@@ -148,7 +148,7 @@ void CVkProto::CreateVkUserInfoList(OBJLIST<CVkUserInfo> &vkUsers, const JSONNod
const JSONNode &jnProfile = (*it);
if (!jnProfile["id"])
continue;
- LONG UserId = - jnProfile["id"].as_int();
+ LONG UserId = -jnProfile["id"].as_int();
CMStringW wszNick(jnProfile["name"].as_mstring());
CMStringW wszLink = L"https://vk.com/";
@@ -311,7 +311,7 @@ CMStringW CVkProto::GetVkFeedback(const JSONNode &jnFeedback, VKObjType vkFeedba
wszUsers += SetBBCString(vkUser->m_wszUserNick, m_vkOptions.BBCForNews(), vkbbcUrl, vkUser->m_wszLink);
}
wszRes.AppendFormat(L"%s %%s %%s", wszUsers.c_str());
- vkUser = NULL;
+ vkUser = nullptr;
iUserId = 0;
}
@@ -330,7 +330,7 @@ CVKNewsItem* CVkProto::GetVkParent(const JSONNode &jnParent, VKObjType vkParentT
debugLogA("CVkProto::GetVkParent");
CMStringW wszRes;
if (!jnParent || !vkParentType)
- return NULL;
+ return nullptr;
CVKNewsItem *vkNotificationItem = new CVKNewsItem();
@@ -397,7 +397,7 @@ CVKNewsItem* CVkProto::GetVkParent(const JSONNode &jnParent, VKObjType vkParentT
LONG iId = jnParent["id"].as_int();
CMStringW wszTitle(jnParent["title"].as_mstring());
vkNotificationItem->wszId.AppendFormat(L"%d_%d", iOwnerId, iId);
- vkNotificationItem->wszLink.AppendFormat(L"https://vk.com/topic%s%s",
+ vkNotificationItem->wszLink.AppendFormat(L"https://vk.com/topic%s%s",
vkNotificationItem->wszId.c_str(), pwszReplyLink ? pwszReplyLink : L"");
CMStringW wszText(jnParent["text"].as_mstring());
@@ -457,7 +457,7 @@ CVKNewsItem* CVkProto::GetVkNotificationsItem(const JSONNode &jnItem, OBJLIST<CV
{
debugLogA("CVkProto::GetVkNotificationsItem");
if (!jnItem)
- return NULL;
+ return nullptr;
CMStringW wszType(jnItem["type"].as_mstring());
VKObjType vkFeedbackType = vkNull, vkParentType = vkNull;
@@ -468,18 +468,18 @@ CVKNewsItem* CVkProto::GetVkNotificationsItem(const JSONNode &jnItem, OBJLIST<CV
if (m_vkOptions.bNotificationFilterAcceptedFriends && wszType == L"friend_accepted" && jnFeedback && vkFeedbackType == VKObjType::vkUsers) {
OnFriendAccepted(jnFeedback);
- return NULL;
+ return nullptr;
}
if (!jnFeedback || !jnParent)
- return NULL;
+ return nullptr;
- CVkUserInfo *vkUser = NULL;
+ CVkUserInfo *vkUser = nullptr;
CMStringW wszFeedback = GetVkFeedback(jnFeedback, vkFeedbackType, vkUsers, vkUser);
CVKNewsItem *vkNotification = GetVkParent(jnParent, vkParentType);
if (!vkNotification)
- return NULL;
+ return nullptr;
if (vkNotification && !wszFeedback.IsEmpty()) {
CMStringW wszNotificaton;
@@ -505,7 +505,7 @@ CVKNewsItem* CVkProto::GetVkNotificationsItem(const JSONNode &jnItem, OBJLIST<CV
}
delete vkNotification;
- return NULL;
+ return nullptr;
}
void CVkProto::OnFriendAccepted(const JSONNode & jnFeedback)
@@ -530,25 +530,25 @@ CVKNewsItem* CVkProto::GetVkGroupInvates(const JSONNode &jnItem, OBJLIST<CVkUser
{
debugLogA("CVkProto::GetVkGroupInvates");
if (!jnItem)
- return NULL;
+ return nullptr;
CMStringW wszType(jnItem["type"].as_mstring());
VKObjType vkFeedbackType = vkNull, vkParentType = vkNull;
CMStringW wszNotificationTranslate = SpanVKNotificationType(wszType, vkFeedbackType, vkParentType);
if (!jnItem["id"])
- return NULL;
+ return nullptr;
LONG iGroupId = jnItem["id"].as_int();
CMStringW wszId(FORMAT, L"%d,", iGroupId);
- CMStringW wszIds(ptrW(db_get_wsa(NULL, m_szModuleName, "InviteGroupIds")));
+ CMStringW wszIds(ptrW(db_get_wsa(0, m_szModuleName, "InviteGroupIds")));
if (wszIds.Find(wszId, 0) != -1)
- return NULL;
+ return nullptr;
LONG iUserId = !jnItem["invited_by"] ? 0 : jnItem["invited_by"].as_int();
CVKNewsItem *vkNotification = new CVKNewsItem();
- vkNotification->tDate = time(NULL);
+ vkNotification->tDate = time(nullptr);
vkNotification->vkUser = GetVkUserInfo(iUserId, vkUsers);
vkNotification->wszType = wszType;
vkNotification->wszId = wszId;
@@ -560,10 +560,12 @@ CVKNewsItem* CVkProto::GetVkGroupInvates(const JSONNode &jnItem, OBJLIST<CVkUser
CMStringW wszGLink(FORMAT, L"https://vk.com/%s", jnItem["screen_name"].as_mstring().c_str());
wszGroupName = SetBBCString(wszGName, m_vkOptions.BBCForNews(), vkbbcUrl, wszGLink);
- CMStringW wszUsers = SetBBCString(iUserId ? vkNotification->vkUser->m_wszUserNick : TranslateT("Unknown"), m_vkOptions.BBCForNews(), vkbbcUrl, iUserId ? vkNotification->vkUser->m_wszLink : L"https://vk.com/");
+ CMStringW wszUsers = SetBBCString(iUserId ? vkNotification->vkUser->m_wszUserNick : TranslateT("Unknown"), m_vkOptions.BBCForNews(),
+ vkbbcUrl, iUserId ? vkNotification->vkUser->m_wszLink : L"https://vk.com/");
vkNotification->wszText.AppendFormat(L"%s %s %s", wszUsers.c_str(), wszNotificationTranslate.c_str(), wszGroupName.c_str());
- vkNotification->wszPopupTitle.AppendFormat(L"%s %s %s", iUserId ? vkNotification->vkUser->m_wszUserNick.c_str() : TranslateT("Unknown"), wszNotificationTranslate.c_str(), wszGName.c_str());
+ vkNotification->wszPopupTitle.AppendFormat(L"%s %s %s", iUserId ? vkNotification->vkUser->m_wszUserNick.c_str() : TranslateT("Unknown"),
+ wszNotificationTranslate.c_str(), wszGName.c_str());
wszIds += wszId;
setWString("InviteGroupIds", wszIds);
@@ -579,8 +581,8 @@ void CVkProto::RetrieveUnreadNews(time_t tLastNewsTime)
if (!IsOnline())
return;
- time_t tLastNewsReqTime = getDword("LastNewsReqTime", time(NULL) - 24 * 60 * 60);
- if (time(NULL) - tLastNewsReqTime < 3 * 60)
+ time_t tLastNewsReqTime = getDword("LastNewsReqTime", time(nullptr) - 24 * 60 * 60);
+ if (time(nullptr) - tLastNewsReqTime < 3 * 60)
return;
CMStringA szFilter;
@@ -625,7 +627,7 @@ void CVkProto::RetrieveUnreadNews(time_t tLastNewsTime)
<< CHAR_PARAM("filters", szFilter)
<< CHAR_PARAM("source_ids", szSource));
- setDword("LastNewsReqTime", (DWORD)time(NULL));
+ setDword("LastNewsReqTime", (DWORD)time(nullptr));
}
static int sttCompareVKNewsItems(const CVKNewsItem *p1, const CVKNewsItem *p2)
@@ -649,7 +651,7 @@ static int sttCompareVKNotificationItems(const CVKNewsItem *p1, const CVKNewsIte
void CVkProto::OnReceiveUnreadNews(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
{
debugLogA("CVkProto::OnReceiveUnreadNews %d", reply->resultCode);
- db_unset(NULL, m_szModuleName, "LastNewsReqTime");
+ db_unset(0, m_szModuleName, "LastNewsReqTime");
if (reply->resultCode != 200)
return;
@@ -670,7 +672,7 @@ void CVkProto::OnReceiveUnreadNews(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *p
if (!vkNewsItem)
continue;
CVKNewsItem *vkNewsFoundItem = vkNews.find(vkNewsItem);
- if (vkNewsFoundItem == NULL)
+ if (vkNewsFoundItem == nullptr)
vkNews.insert(vkNewsItem);
else if (vkNewsFoundItem->wszType == L"wall_photo" && vkNewsItem->wszType == L"post") {
vkNews.remove(vkNewsFoundItem);
@@ -690,7 +692,7 @@ void CVkProto::OnReceiveUnreadNews(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *p
if (bNewsAdded)
AddCListEvent(true);
- setDword("LastNewsTime", time(NULL));
+ setDword("LastNewsTime", time(nullptr));
vkNews.destroy();
vkUsers.destroy();
@@ -704,8 +706,8 @@ void CVkProto::RetrieveUnreadNotifications(time_t tLastNotificationsTime)
if (!IsOnline())
return;
- time_t tLastNotificationsReqTime = getDword("LastNotificationsReqTime", time(NULL) - 24 * 60 * 60);
- if (time(NULL) - tLastNotificationsReqTime < 3 * 60)
+ time_t tLastNotificationsReqTime = getDword("LastNotificationsReqTime", time(nullptr) - 24 * 60 * 60);
+ if (time(nullptr) - tLastNotificationsReqTime < 3 * 60)
return;
CMStringW code(FORMAT, L"return{\"notifications\":API.notifications.get({\"count\": 100, \"start_time\":%d})%s",
@@ -716,7 +718,7 @@ void CVkProto::RetrieveUnreadNotifications(time_t tLastNotificationsTime)
<< WCHAR_PARAM("code", code)
);
- setDword("LastNotificationsReqTime", (DWORD)time(NULL));
+ setDword("LastNotificationsReqTime", (DWORD)time(nullptr));
}
bool CVkProto::FilterNotification(CVKNewsItem* vkNotificationItem, bool& isCommented)
@@ -754,7 +756,7 @@ void CVkProto::NotificationMarkAsViewed()
void CVkProto::OnReceiveUnreadNotifications(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
{
debugLogA("CVkProto::OnReceiveUnreadNotifications %d", reply->resultCode);
- db_unset(NULL, m_szModuleName, "LastNotificationsReqTime");
+ db_unset(0, m_szModuleName, "LastNotificationsReqTime");
if (reply->resultCode != 200)
return;
@@ -780,7 +782,7 @@ void CVkProto::OnReceiveUnreadNotifications(NETLIBHTTPREQUEST *reply, AsyncHttpR
CVKNewsItem *vkNotificationItem = GetVkNotificationsItem((*it), vkUsers);
if (!vkNotificationItem)
continue;
- if (vkNotification.find(vkNotificationItem) == NULL)
+ if (vkNotification.find(vkNotificationItem) == nullptr)
vkNotification.insert(vkNotificationItem);
else
delete vkNotificationItem;
@@ -795,7 +797,7 @@ void CVkProto::OnReceiveUnreadNotifications(NETLIBHTTPREQUEST *reply, AsyncHttpR
CVKNewsItem *vkNotificationItem = GetVkGroupInvates((*it), vkUsers);
if (!vkNotificationItem)
continue;
- if (vkNotification.find(vkNotificationItem) == NULL)
+ if (vkNotification.find(vkNotificationItem) == nullptr)
vkNotification.insert(vkNotificationItem);
else
delete vkNotificationItem;
@@ -815,7 +817,7 @@ void CVkProto::OnReceiveUnreadNotifications(NETLIBHTTPREQUEST *reply, AsyncHttpR
if (bNotificationAdded)
AddCListEvent(false);
- setDword("LastNotificationsTime", time(NULL));
+ setDword("LastNotificationsTime", time(nullptr));
if (m_vkOptions.bNotificationsMarkAsViewed && bNotificationCommentAdded)
NotificationMarkAsViewed();
@@ -829,12 +831,12 @@ void CVkProto::RetrieveUnreadEvents()
if (!IsOnline() || (!m_vkOptions.bNotificationsEnabled && !m_vkOptions.bNewsEnabled))
return;
- time_t tLastNotificationsTime = getDword("LastNotificationsTime", time(NULL) - 24 * 60 * 60);
- if (time(NULL) - tLastNotificationsTime - m_vkOptions.iNotificationsInterval * 60 >= -3 && m_vkOptions.bNotificationsEnabled)
+ time_t tLastNotificationsTime = getDword("LastNotificationsTime", time(nullptr) - 24 * 60 * 60);
+ if (time(nullptr) - tLastNotificationsTime - m_vkOptions.iNotificationsInterval * 60 >= -3 && m_vkOptions.bNotificationsEnabled)
RetrieveUnreadNotifications(tLastNotificationsTime);
- time_t tLastNewsTime = getDword("LastNewsTime", time(NULL) - 24 * 60 * 60);
- if (time(NULL) - tLastNewsTime - m_vkOptions.iNewsInterval * 60 >= -3 && m_vkOptions.bNewsEnabled)
+ time_t tLastNewsTime = getDword("LastNewsTime", time(nullptr) - 24 * 60 * 60);
+ if (time(nullptr) - tLastNewsTime - m_vkOptions.iNewsInterval * 60 >= -3 && m_vkOptions.bNewsEnabled)
RetrieveUnreadNews(tLastNewsTime);
NewsClearHistory();
@@ -851,7 +853,7 @@ INT_PTR CVkProto::SvcLoadVKNews(WPARAM, LPARAM)
AddFeedSpecialUser();
}
- time_t tLastNewsTime = getDword("LastNewsTime", time(NULL) - 24 * 60 * 60);
+ time_t tLastNewsTime = getDword("LastNewsTime", time(nullptr) - 24 * 60 * 60);
RetrieveUnreadNews(tLastNewsTime);
return 0;
@@ -861,10 +863,10 @@ void CVkProto::NewsClearHistory()
{
debugLogA("CVkProto::NewsClearHistory");
MCONTACT hContact = FindUser(VK_FEED_USER);
- if (hContact == NULL || !m_vkOptions.bNewsAutoClearHistory)
+ if (hContact == 0 || !m_vkOptions.bNewsAutoClearHistory)
return;
- time_t tTime = time(NULL) - m_vkOptions.iNewsAutoClearHistoryInterval;
+ time_t tTime = time(nullptr) - m_vkOptions.iNewsAutoClearHistoryInterval;
MEVENT hDBEvent = db_event_first(hContact);
while (hDBEvent) {
MEVENT hDBEventNext = db_event_next(hContact, hDBEvent);
diff --git a/protocols/VKontakte/src/vk_files.cpp b/protocols/VKontakte/src/vk_files.cpp
index e77a166cc4..0df2946cf3 100644
--- a/protocols/VKontakte/src/vk_files.cpp
+++ b/protocols/VKontakte/src/vk_files.cpp
@@ -118,7 +118,7 @@ void CVkProto::SendFileFiled(CVkFileUploadParam *fup, int ErrorCode)
}
ProtoBroadcastAck(fup->hContact, ACKTYPE_FILE, ErrorCode == VKERR_AUDIO_DEL_COPYRIGHT ? ACKRESULT_DENIED : ACKRESULT_FAILED, (HANDLE)fup);
debugLogW(L"CVkProto::SendFileFiled error code = %d (%s)", ErrorCode, wszError.c_str());
- MsgPopup(NULL, wszError, TranslateT("File upload error"), true);
+ MsgPopup(wszError, TranslateT("File upload error"), true);
delete fup;
}
@@ -151,7 +151,7 @@ void CVkProto::OnReciveUploadServer(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *
}
FILE *pFile = _wfopen(fup->FileName, L"rb");
- if (pFile == NULL) {
+ if (pFile == nullptr) {
SendFileFiled(fup, VKERR_ERR_OPEN_FILE);
return;
}
@@ -176,7 +176,7 @@ void CVkProto::OnReciveUploadServer(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *
// Boundary
int iboundary;
Utils_GetRandom(&iboundary, sizeof(iboundary));
- boundary.AppendFormat("Miranda%dNG%d", iboundary, time(NULL));
+ boundary.AppendFormat("Miranda%dNG%d", iboundary, time(nullptr));
// Header
header.AppendFormat("multipart/form-data; boundary=%s", boundary.c_str());
pUploadReq->AddHeader("Content-Type", header);
@@ -354,7 +354,7 @@ void CVkProto::OnReciveUploadFile(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pR
}
CVkChatInfo *cc = GetChatById(wszChatID);
- if (cc == NULL) {
+ if (cc == nullptr) {
SendFileFiled(fup, VKERR_INVALID_USER);
return;
}
diff --git a/protocols/VKontakte/src/vk_history.cpp b/protocols/VKontakte/src/vk_history.cpp
index 9d9a1d8d6f..ebecc4fc69 100644
--- a/protocols/VKontakte/src/vk_history.cpp
+++ b/protocols/VKontakte/src/vk_history.cpp
@@ -29,7 +29,7 @@ INT_PTR __cdecl CVkProto::SvcGetAllServerHistoryForContact(WPARAM hContact, LPAR
return 0;
LPCWSTR str = TranslateT("Are you sure to reload all messages from vk.com?\nLocal contact history will be deleted and reloaded from the server.\nIt may take a long time.\nDo you want to continue?");
- if (IDNO == MessageBoxW(NULL, str, TranslateT("Attention!"), MB_ICONWARNING | MB_YESNO))
+ if (IDNO == MessageBoxW(nullptr, str, TranslateT("Attention!"), MB_ICONWARNING | MB_YESNO))
return 0;
LONG userID = getDword(hContact, "ID", VK_INVALID_USER);
@@ -58,7 +58,7 @@ INT_PTR __cdecl CVkProto::SvcGetAllServerHistory(WPARAM, LPARAM)
if (!IsOnline())
return 0;
LPCWSTR str = TranslateT("Are you sure you want to reload all messages for all contacts from vk.com?\nLocal contact history will be deleted and reloaded from the server.\nIt may take a very long time and/or corrupt Miranda database.\nWe recommend check your database before reloading messages and after it (Miranda32.exe /svc:dbchecker or Miranda64.exe /svc:dbchecker).\nDo you want to continue?");
- if (IDNO == MessageBoxW(NULL, str, TranslateT("Attention!"), MB_ICONWARNING | MB_YESNO))
+ if (IDNO == MessageBoxW(nullptr, str, TranslateT("Attention!"), MB_ICONWARNING | MB_YESNO))
return 0;
for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
@@ -102,7 +102,7 @@ void CVkProto::GetServerHistoryLastNDay(MCONTACT hContact, int NDay)
return;
setByte(hContact, "ActiveHistoryTask", 1);
- time_t tTime = time(NULL) - 60 * 60 * 24 * NDay;
+ time_t tTime = time(nullptr) - 60 * 60 * 24 * NDay;
MEVENT hDBEvent = db_event_first(hContact);
while (hDBEvent) {
@@ -182,10 +182,10 @@ void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpReque
if (m_iLoadHistoryTask > 0)
m_iLoadHistoryTask--;
debugLogW(L"CVkProto::OnReceiveHistoryMessages error m_iLoadHistoryTask=%d", m_iLoadHistoryTask);
- MsgPopup(NULL, TranslateT("Error loading message history from server."), TranslateT("Error"), true);
+ MsgPopup(TranslateT("Error loading message history from server."), TranslateT("Error"), true);
if (m_iLoadHistoryTask == 0 && m_bNotifyForEndLoadingHistoryAllContact) {
- MsgPopup(NULL, TranslateT("Loading messages for all contacts is completed."), TranslateT("Loading history"));
+ MsgPopup(TranslateT("Loading messages for all contacts is completed."), TranslateT("Loading history"));
m_bNotifyForEndLoadingHistoryAllContact = m_bNotifyForEndLoadingHistory = false;
}
if (pReq->pUserInfo)
@@ -210,12 +210,12 @@ void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpReque
debugLogW(L"CVkProto::OnReceiveHistoryMessages error for %s m_iLoadHistoryTask=%d", pwszNick, m_iLoadHistoryTask);
if (m_iLoadHistoryTask == 0 && m_bNotifyForEndLoadingHistoryAllContact) {
- MsgPopup(NULL, TranslateT("Loading messages for all contacts is completed."), TranslateT("Loading history"));
+ MsgPopup(TranslateT("Loading messages for all contacts is completed."), TranslateT("Loading history"));
m_bNotifyForEndLoadingHistoryAllContact = m_bNotifyForEndLoadingHistory = false;
}
delete param;
- pReq->pUserInfo = NULL;
+ pReq->pUserInfo = nullptr;
}
return;
}
@@ -311,7 +311,7 @@ void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpReque
MsgPopup(param->hContact, str, TranslateT("Loading history"));
if (m_iLoadHistoryTask == 0 && m_bNotifyForEndLoadingHistoryAllContact) {
- MsgPopup(NULL, TranslateT("Loading messages for all contacts is completed."), TranslateT("Loading history"));
+ MsgPopup(TranslateT("Loading messages for all contacts is completed."), TranslateT("Loading history"));
m_bNotifyForEndLoadingHistoryAllContact = m_bNotifyForEndLoadingHistory = false;
}
setByte(param->hContact, "ActiveHistoryTask", 0);
@@ -319,6 +319,6 @@ void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpReque
if (!pReq->bNeedsRestart || m_bTerminated) {
delete param;
- pReq->pUserInfo = NULL;
+ pReq->pUserInfo = nullptr;
}
} \ No newline at end of file
diff --git a/protocols/VKontakte/src/vk_messages.cpp b/protocols/VKontakte/src/vk_messages.cpp
index 7e09d051d6..87ab49a0b5 100644
--- a/protocols/VKontakte/src/vk_messages.cpp
+++ b/protocols/VKontakte/src/vk_messages.cpp
@@ -55,9 +55,10 @@ int CVkProto::SendMsg(MCONTACT hContact, int, const char *szMsg)
ptrA pszRetMsg(GetStickerId(szMsg, StickerId));
ULONG uMsgId = ::InterlockedIncrement(&m_msgId);
- AsyncHttpRequest *pReq = new AsyncHttpRequest(this, REQUEST_POST, "/method/messages.send.json", true, bIsChat ? &CVkProto::OnSendChatMsg : &CVkProto::OnSendMessage, AsyncHttpRequest::rpHigh)
+ AsyncHttpRequest *pReq = new AsyncHttpRequest(this, REQUEST_POST, "/method/messages.send.json", true,
+ bIsChat ? &CVkProto::OnSendChatMsg : &CVkProto::OnSendMessage, AsyncHttpRequest::rpHigh)
<< INT_PARAM(bIsChat ? "chat_id" : "peer_id", iUserID)
- << INT_PARAM("random_id", ((LONG)time(NULL)) * 100 + uMsgId % 100);
+ << INT_PARAM("random_id", ((LONG)time(nullptr)) * 100 + uMsgId % 100);
pReq->AddHeader("Content-Type", "application/x-www-form-urlencoded");
if (StickerId)
@@ -92,8 +93,8 @@ int CVkProto::SendMsg(MCONTACT hContact, int, const char *szMsg)
void CVkProto::OnSendMessage(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
{
int iResult = ACKRESULT_FAILED;
- if (pReq->pUserInfo == NULL) {
- debugLogA("CVkProto::OnSendMessage failed! (pUserInfo == NULL)");
+ if (pReq->pUserInfo == nullptr) {
+ debugLogA("CVkProto::OnSendMessage failed! (pUserInfo == nullptr)");
return;
}
CVkSendMsgParam *param = (CVkSendMsgParam *)pReq->pUserInfo;
@@ -143,7 +144,7 @@ void CVkProto::OnSendMessage(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
if (!pReq->bNeedsRestart || m_bTerminated) {
delete param;
- pReq->pUserInfo = NULL;
+ pReq->pUserInfo = nullptr;
}
}
@@ -239,7 +240,7 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
for (auto it = jnMsgs.begin(); it != jnMsgs.end(); ++it) {
const JSONNode &jnMsg = (*it);
if (!jnMsg) {
- debugLogA("CVkProto::OnReceiveMessages pMsg == NULL");
+ debugLogA("CVkProto::OnReceiveMessages pMsg == nullptr");
break;
}
@@ -271,7 +272,7 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
wszBody += SetBBCString(TranslateT("Message link"), m_vkOptions.BBCForAttachments(), vkbbcUrl,
CMStringW(FORMAT, L"https://vk.com/im?sel=%d&msgid=%d", uid, mid));
- MCONTACT hContact = NULL;
+ MCONTACT hContact = 0;
int chat_id = jnMsg["chat_id"].as_int();
if (chat_id == 0)
hContact = FindUser(uid, true);
@@ -305,11 +306,11 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
recv.flags |= PREF_CREATEREAD;
if (isOut)
recv.flags |= PREF_SENT;
- else if (m_vkOptions.bUserForceInvisibleOnActivity && time(NULL) - datetime < 60 * m_vkOptions.iInvisibleInterval)
+ else if (m_vkOptions.bUserForceInvisibleOnActivity && time(nullptr) - datetime < 60 * m_vkOptions.iInvisibleInterval)
SetInvisible(hContact);
T2Utf pszBody(wszBody);
- recv.timestamp = m_vkOptions.bUseLocalTime ? time(NULL) : datetime;
+ recv.timestamp = m_vkOptions.bUseLocalTime ? time(nullptr) : datetime;
recv.szMessage = pszBody;
recv.lParam = isOut;
recv.pCustomData = szMid;
@@ -328,7 +329,7 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
}
else if (m_vkOptions.bLoadSentAttachments && !wszAttachmentDescr.IsEmpty() && isOut) {
T2Utf pszAttach(wszAttachmentDescr);
- recv.timestamp = time(NULL); // only local time
+ recv.timestamp = time(nullptr); // only local time
recv.szMessage = pszAttach;
ProtoChainRecvMsg(hContact, &recv);
}
@@ -390,11 +391,11 @@ void CVkProto::OnReceiveDlgs(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
break;
int numUnread = (*it)["unread"].as_int();
const JSONNode &jnDlg = (*it)["message"];
- if (jnDlg == NULL)
+ if (jnDlg == nullptr)
break;
int uid = 0;
- MCONTACT hContact(NULL);
+ MCONTACT hContact(0);
int chatid = jnDlg["chat_id"].as_int();
@@ -427,7 +428,7 @@ void CVkProto::OnReceiveDlgs(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
if (chatid) {
debugLogA("CVkProto::OnReceiveDlgs chatid = %d", chatid);
- if (m_chats.find((CVkChatInfo*)&chatid) == NULL)
+ if (m_chats.find((CVkChatInfo*)&chatid) == nullptr)
AppendChat(chatid, jnDlg);
}
else if (m_vkOptions.iSyncHistoryMetod) {
diff --git a/protocols/VKontakte/src/vk_options.cpp b/protocols/VKontakte/src/vk_options.cpp
index e30cf57948..f79632158d 100644
--- a/protocols/VKontakte/src/vk_options.cpp
+++ b/protocols/VKontakte/src/vk_options.cpp
@@ -110,7 +110,7 @@ int CVkProto::OnOptionsInit(WPARAM wParam, LPARAM)
////////////////////// Account page //////////////////////////////////////////
static CVKLang vkLangCodes[] = {
- { NULL, LPGENW("Account language") },
+ { nullptr, LPGENW("Account language") },
{ L"en", LPGENW("English") },
{ L"ru", LPGENW("Russian") },
{ L"be", LPGENW("Belarusian") },
@@ -204,7 +204,7 @@ void CVkOptionAccountForm::OnApply()
ptrW pwszGroupName(m_edtGroupName.GetText());
if (mir_wstrcmp(m_pwszOldGroup, pwszGroupName)) {
- Clist_GroupCreate(NULL, pwszGroupName);
+ Clist_GroupCreate(0, pwszGroupName);
m_pwszOldGroup = pwszGroupName;
}
@@ -503,7 +503,7 @@ CVkOptionMenuForm::CVkOptionMenuForm(CVkProto *proto) :
void CVkOptionMenuForm::OnApply()
{
- if (MessageBoxW(NULL,
+ if (MessageBoxW(nullptr,
TranslateT("These changes will take effect after Miranda NG restart.\nWould you like to restart it now?"),
TranslateT("VKontakte protocol"), MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2) == IDYES)
CallServiceSync(MS_SYSTEM_RESTART, 1, 0);
diff --git a/protocols/VKontakte/src/vk_pollserver.cpp b/protocols/VKontakte/src/vk_pollserver.cpp
index e2b9332781..56a9d85715 100644
--- a/protocols/VKontakte/src/vk_pollserver.cpp
+++ b/protocols/VKontakte/src/vk_pollserver.cpp
@@ -39,7 +39,7 @@ void CVkProto::OnReceivePollingInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *
if (!jnResponse) {
if (!pReq->bNeedsRestart) {
debugLogA("CVkProto::OnReceivePollingInfo PollingThread not start (getLongPollServer error)");
- m_pollingConn = NULL;
+ m_pollingConn = nullptr;
ShutdownSession();
}
return;
@@ -53,24 +53,24 @@ void CVkProto::OnReceivePollingInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *
m_pollingServer = mir_u2a(jnResponse["server"].as_mstring());
if (!m_hPollingThread) {
- debugLogA("CVkProto::OnReceivePollingInfo m_hPollingThread is NULL");
+ debugLogA("CVkProto::OnReceivePollingInfo m_hPollingThread is nullptr");
debugLogA("CVkProto::OnReceivePollingInfo m_pollingTs = '%s' m_pollingKey = '%s' m_pollingServer = '%s'",
- m_pollingTs ? m_pollingTs : "<NULL>",
- m_pollingKey ? m_pollingKey : "<NULL>",
- m_pollingServer ? m_pollingServer : "<NULL>");
- if (m_pollingTs != NULL && m_pollingKey != NULL && m_pollingServer != NULL) {
+ m_pollingTs ? m_pollingTs : "<nullptr>",
+ m_pollingKey ? m_pollingKey : "<nullptr>",
+ m_pollingServer ? m_pollingServer : "<nullptr>");
+ if (m_pollingTs != nullptr && m_pollingKey != nullptr && m_pollingServer != nullptr) {
debugLogA("CVkProto::OnReceivePollingInfo PollingThread starting...");
- m_hPollingThread = ForkThreadEx(&CVkProto::PollingThread, NULL, NULL);
+ m_hPollingThread = ForkThreadEx(&CVkProto::PollingThread, nullptr, nullptr);
}
else {
debugLogA("CVkProto::OnReceivePollingInfo PollingThread not start");
- m_pollingConn = NULL;
+ m_pollingConn = nullptr;
ShutdownSession();
return;
}
}
else
- debugLogA("CVkProto::OnReceivePollingInfo m_hPollingThread is not NULL");
+ debugLogA("CVkProto::OnReceivePollingInfo m_hPollingThread is not nullptr");
}
void CVkProto::PollUpdates(const JSONNode &jnUpdates)
@@ -91,10 +91,10 @@ void CVkProto::PollUpdates(const JSONNode &jnUpdates)
uid = jnChild[3].as_int();
hContact = FindUser(uid);
- if (hContact != NULL && (flags & VKFLAG_MSGUNREAD) && !CheckMid(m_incIds, msgid)) {
- setDword(hContact, "LastMsgReadTime", time(NULL));
+ if (hContact != 0 && (flags & VKFLAG_MSGUNREAD) && !CheckMid(m_incIds, msgid)) {
+ setDword(hContact, "LastMsgReadTime", time(nullptr));
if (ServiceExists(MS_MESSAGESTATE_UPDATE)) {
- MessageReadData data(time(NULL), MRD_TYPE_READTIME);
+ MessageReadData data(time(nullptr), MRD_TYPE_READTIME);
CallService(MS_MESSAGESTATE_UPDATE, hContact, (LPARAM)&data);
}
else
@@ -122,14 +122,15 @@ void CVkProto::PollUpdates(const JSONNode &jnUpdates)
case VKPOLL_READ_ALL_OUT:
uid = jnChild[1].as_int();
hContact = FindUser(uid);
- if (hContact != NULL) {
- setDword(hContact, "LastMsgReadTime", time(NULL));
+ if (hContact != 0) {
+ setDword(hContact, "LastMsgReadTime", time(nullptr));
if (ServiceExists(MS_MESSAGESTATE_UPDATE)) {
- MessageReadData data(time(NULL), MRD_TYPE_READTIME);
+ MessageReadData data(time(nullptr), MRD_TYPE_READTIME);
CallService(MS_MESSAGESTATE_UPDATE, hContact, (LPARAM)&data);
}
else
SetSrmmReadStatus(hContact);
+
if (m_vkOptions.bUserForceInvisibleOnActivity)
SetInvisible(hContact);
}
@@ -137,13 +138,13 @@ void CVkProto::PollUpdates(const JSONNode &jnUpdates)
case VKPOLL_READ_ALL_IN:
uid = jnChild[1].as_int();
hContact = FindUser(uid);
- if (hContact != NULL && m_vkOptions.bSyncReadMessageStatusFromServer)
+ if (hContact != 0 && m_vkOptions.bSyncReadMessageStatusFromServer)
MarkDialogAsRead(hContact);
break;
case VKPOLL_USR_ONLINE:
uid = -jnChild[1].as_int();
- if ((hContact = FindUser(uid)) != NULL) {
+ if ((hContact = FindUser(uid)) != 0) {
setWord(hContact, "Status", ID_STATUS_ONLINE);
platform = jnChild[2].as_int();
SetMirVer(hContact, platform);
@@ -152,7 +153,7 @@ void CVkProto::PollUpdates(const JSONNode &jnUpdates)
case VKPOLL_USR_OFFLINE:
uid = -jnChild[1].as_int();
- if ((hContact = FindUser(uid)) != NULL) {
+ if ((hContact = FindUser(uid)) != 0) {
setWord(hContact, "Status", ID_STATUS_OFFLINE);
db_unset(hContact, m_szModuleName, "ListeningTo");
SetMirVer(hContact, -1);
@@ -162,7 +163,7 @@ void CVkProto::PollUpdates(const JSONNode &jnUpdates)
case VKPOLL_USR_UTN:
uid = jnChild[1].as_int();
hContact = FindUser(uid);
- if (hContact != NULL) {
+ if (hContact != 0) {
ForkThread(&CVkProto::ContactTypingThread, (void *)hContact);
if (m_vkOptions.bUserForceInvisibleOnActivity)
SetInvisible(hContact);
@@ -190,7 +191,7 @@ int CVkProto::PollServer()
debugLogA("CVkProto::PollServer");
if (!IsOnline()) {
debugLogA("CVkProto::PollServer is dead (not online)");
- m_pollingConn = NULL;
+ m_pollingConn = nullptr;
ShutdownSession();
return 0;
}
@@ -208,9 +209,9 @@ int CVkProto::PollServer()
req.timeout = 30000;
req.nlc = m_pollingConn;
- while ((reply = Netlib_HttpTransaction(m_hNetlibUser, &req)) == NULL) {
+ while ((reply = Netlib_HttpTransaction(m_hNetlibUser, &req)) == nullptr) {
debugLogA("CVkProto::PollServer is dead");
- m_pollingConn = NULL;
+ m_pollingConn = nullptr;
if (iPollConnRetry && !m_bTerminated) {
iPollConnRetry--;
debugLogA("CVkProto::PollServer restarting %d", MAX_RETRIES - iPollConnRetry);
@@ -232,7 +233,7 @@ int CVkProto::PollServer()
retVal = -1;
debugLogA("Polling key expired, restarting polling thread");
}
- else if (CheckJsonResult(NULL, jnRoot)) {
+ else if (CheckJsonResult(nullptr, jnRoot)) {
char ts[32];
itoa(jnRoot["ts"].as_int(), ts, 10);
m_pollingTs = mir_strdup(ts);
@@ -245,7 +246,7 @@ int CVkProto::PollServer()
else if ((reply->resultCode >= 400 && reply->resultCode <= 417)
|| (reply->resultCode >= 500 && reply->resultCode <= 509)) {
debugLogA("CVkProto::PollServer is dead. Error code - %d", reply->resultCode);
- m_pollingConn = NULL;
+ m_pollingConn = nullptr;
Netlib_FreeHttpRequest(reply);
ShutdownSession();
return 0;
@@ -266,11 +267,11 @@ void CVkProto::PollingThread(void*)
if (PollServer() == -1 || !m_hPollingThread)
break;
- m_pollingConn = NULL;
+ m_pollingConn = nullptr;
debugLogA("CVkProto::PollingThread: leaving");
if (m_hPollingThread) {
CloseHandle(m_hPollingThread);
- m_hPollingThread = NULL;
+ m_hPollingThread = nullptr;
}
} \ No newline at end of file
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp
index 2b9145bd74..fbfea1b4c1 100644
--- a/protocols/VKontakte/src/vk_proto.cpp
+++ b/protocols/VKontakte/src/vk_proto.cpp
@@ -45,8 +45,8 @@ CVkProto::CVkProto(const char *szModuleName, const wchar_t *pwszUserName) :
m_iLoadHistoryTask(0),
m_bNotifyForEndLoadingHistory(false),
m_bNotifyForEndLoadingHistoryAllContact(false),
- m_hAPIConnection(NULL),
- m_pollingConn(NULL),
+ m_hAPIConnection(nullptr),
+ m_pollingConn(nullptr),
m_bSetBroadcast(false),
m_bNeedSendOnline(false),
m_vkOptions(this)
@@ -70,10 +70,10 @@ CVkProto::CVkProto(const char *szModuleName, const wchar_t *pwszUserName) :
nlu.szDescriptiveName.w = descr;
m_hNetlibUser = Netlib_RegisterUser(&nlu);
- Clist_GroupCreate(NULL, m_vkOptions.pwszDefaultGroup);
+ Clist_GroupCreate(0, m_vkOptions.pwszDefaultGroup);
CMStringA szListeningTo(FORMAT, "%sEnabled", m_szModuleName);
- db_set_b(NULL, "ListeningTo", szListeningTo, m_vkOptions.iMusicSendMetod == 0 ? 0 : 1);
+ db_set_b(0, "ListeningTo", szListeningTo, m_vkOptions.iMusicSendMetod == 0 ? 0 : 1);
delSetting("InviteGroupIds");
db_set_resident(m_szModuleName, "ActiveHistoryTask");
@@ -90,7 +90,7 @@ CVkProto::~CVkProto()
{
debugLogA("CVkProto::~CVkProto");
Netlib_CloseHandle(m_hNetlibUser);
- m_hNetlibUser = NULL;
+ m_hNetlibUser = nullptr;
UninitQueue();
UnInitMenus();
if (m_hPopupClassError)
@@ -130,7 +130,7 @@ int CVkProto::OnModulesLoaded(WPARAM, LPARAM)
}
/////////////////////////////////////////////////////////////////////////////////////////
-// Menu support
+// Menu support
void CVkProto::InitMenus()
{
@@ -229,7 +229,7 @@ void CVkProto::InitMenus()
}
// Contact Menu Items
- mi.root = NULL;
+ mi.root = nullptr;
mi.flags = CMIF_UNICODE;
mi.pszService = PS_VISITPROFILE;
@@ -392,7 +392,7 @@ void CVkProto::UnInitMenus()
}
/////////////////////////////////////////////////////////////////////////////////////////
-// PopUp support
+// PopUp support
LRESULT CALLBACK PopupDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
@@ -401,7 +401,7 @@ LRESULT CALLBACK PopupDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
case WM_CONTEXTMENU:
{
CVkSendMsgParam *pd = (CVkSendMsgParam *)PUGetPluginData(hwnd);
- if (pd != NULL && pd->hContact != NULL)
+ if (pd != nullptr && pd->hContact != 0)
CallServiceSync(MS_MSG_SENDMESSAGE, (WPARAM)pd->hContact, 0);
PUDeletePopup(hwnd);
}
@@ -466,10 +466,14 @@ void CVkProto::MsgPopup(MCONTACT hContact, const wchar_t *wszMsg, const wchar_t
}
else {
DWORD mtype = MB_OK | MB_SETFOREGROUND | (err ? MB_ICONERROR : MB_ICONINFORMATION);
- MessageBoxW(NULL, wszMsg, wszTitle, mtype);
+ MessageBoxW(nullptr, wszMsg, wszTitle, mtype);
}
}
+void CVkProto::MsgPopup(const wchar_t *wszMsg, const wchar_t *wszTitle, bool err)
+{
+ MsgPopup(0, wszMsg, wszTitle, err);
+}
//////////////////////////////////////////////////////////////////////////////
void CVkProto::InitDBCustomEvents()
@@ -502,7 +506,8 @@ DWORD_PTR CVkProto::GetCaps(int type, MCONTACT)
{
switch (type) {
case PFLAGNUM_1:
- return PF1_IM | PF1_CHAT | PF1_SERVERCLIST | PF1_AUTHREQ | PF1_BASICSEARCH | PF1_SEARCHBYNAME | PF1_SEARCHBYEMAIL | PF1_MODEMSG | PF1_FILESEND | PF1_FILERESUME;
+ return PF1_IM | PF1_CHAT | PF1_SERVERCLIST | PF1_AUTHREQ | PF1_BASICSEARCH
+ | PF1_SEARCHBYNAME | PF1_SEARCHBYEMAIL | PF1_MODEMSG | PF1_FILESEND | PF1_FILERESUME;
case PFLAGNUM_2:
return PF2_ONLINE | PF2_INVISIBLE | PF2_ONTHEPHONE | PF2_IDLE;
@@ -511,7 +516,8 @@ DWORD_PTR CVkProto::GetCaps(int type, MCONTACT)
return PF2_ONLINE;
case PFLAGNUM_4:
- return PF4_AVATARS | PF4_SUPPORTTYPING | PF4_NOAUTHDENYREASON | PF4_IMSENDOFFLINE | PF4_OFFLINEFILES | PF4_READNOTIFY | PF4_GROUPCHATFILES;
+ return PF4_AVATARS | PF4_SUPPORTTYPING | PF4_NOAUTHDENYREASON | PF4_IMSENDOFFLINE
+ | PF4_OFFLINEFILES | PF4_READNOTIFY | PF4_GROUPCHATFILES;
case PFLAGNUM_5:
return PF2_ONTHEPHONE;
@@ -554,7 +560,7 @@ MCONTACT CVkProto::AddToList(int, PROTOSEARCHRESULT *psr)
int uid = _wtoi(psr->id.w);
if (!uid)
- return NULL;
+ return 0;
MCONTACT hContact = FindUser(uid, true);
RetrieveUserInfo(uid);
@@ -618,7 +624,7 @@ void CVkProto::OnReceiveAuthRequest(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *
if (param && (!pReq->bNeedsRestart || m_bTerminated)) {
delete param;
- pReq->pUserInfo = NULL;
+ pReq->pUserInfo = nullptr;
}
}
@@ -631,7 +637,7 @@ int CVkProto::Authorize(MEVENT hDbEvent)
if (hContact == INVALID_CONTACT_ID)
return 1;
- return AuthRequest(hContact, NULL);
+ return AuthRequest(hContact, nullptr);
}
int CVkProto::AuthDeny(MEVENT hDbEvent, const wchar_t*)
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h
index 0518978a9a..4e3868fdec 100644
--- a/protocols/VKontakte/src/vk_proto.h
+++ b/protocols/VKontakte/src/vk_proto.h
@@ -48,15 +48,15 @@ struct CVkProto : public PROTO<CVkProto>
CVkProto(const char*, const wchar_t*);
~CVkProto();
-//====================================================================================
-// PROTO_INTERFACE
-//====================================================================================
+ //====================================================================================
+ // PROTO_INTERFACE
+ //====================================================================================
virtual MCONTACT __cdecl AddToList(int flags, PROTOSEARCHRESULT *psr);
virtual int __cdecl Authorize(MEVENT hDbEvent);
virtual int __cdecl AuthDeny(MEVENT hDbEvent, const wchar_t *szReason);
virtual int __cdecl AuthRequest(MCONTACT hContact, const wchar_t *szMessage);
- virtual DWORD_PTR __cdecl GetCaps(int type, MCONTACT hContact = NULL);
+ virtual DWORD_PTR __cdecl GetCaps(int type, MCONTACT hContact = 0);
virtual int __cdecl GetInfo(MCONTACT hContact, int infoType);
virtual HANDLE __cdecl SearchBasic(const wchar_t *id);
virtual HANDLE __cdecl SearchByEmail(const wchar_t *email);
@@ -68,7 +68,7 @@ struct CVkProto : public PROTO<CVkProto>
virtual int __cdecl UserIsTyping(MCONTACT hContact, int type);
virtual int __cdecl OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM lParam);
-//==== Events ========================================================================
+ //==== Events ========================================================================
int __cdecl OnModulesLoaded(WPARAM, LPARAM);
int __cdecl OnOptionsInit(WPARAM, LPARAM);
@@ -76,7 +76,7 @@ struct CVkProto : public PROTO<CVkProto>
void OnOAuthAuthorize(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
void OnReceiveAvatar(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
-//==== Services ======================================================================
+ //==== Services ======================================================================
INT_PTR __cdecl SvcCreateAccMgrUI(WPARAM, LPARAM);
INT_PTR __cdecl SvcGetAvatarInfo(WPARAM, LPARAM);
@@ -84,7 +84,7 @@ struct CVkProto : public PROTO<CVkProto>
INT_PTR __cdecl SvcGetMyAvatar(WPARAM, LPARAM);
INT_PTR __cdecl SvcSetListeningTo(WPARAM, LPARAM);
-//==== Menus ==========================================================================
+ //==== Menus ==========================================================================
INT_PTR __cdecl SvcVisitProfile(WPARAM hContact, LPARAM);
INT_PTR __cdecl SvcAddAsFriend(WPARAM hContact, LPARAM);
@@ -98,7 +98,7 @@ struct CVkProto : public PROTO<CVkProto>
INT_PTR __cdecl SvcMarkMessagesAsRead(WPARAM hContact, LPARAM);
INT_PTR __cdecl SvcSetStatusMsg(WPARAM, LPARAM);
-//==== History Menus ==================================================================
+ //==== History Menus ==================================================================
template <unsigned short Days>
INT_PTR __cdecl SvcGetServerHistoryLastNDay(WPARAM hContact, LPARAM)
@@ -112,7 +112,8 @@ struct CVkProto : public PROTO<CVkProto>
INT_PTR __cdecl SvcGetAllServerHistoryForContact(WPARAM hContact, LPARAM);
INT_PTR __cdecl SvcGetAllServerHistory(WPARAM, LPARAM);
-//=====================================================================================
+
+ //=====================================================================================
void CreateNewChat(LPCSTR uids, LPCWSTR pwszTitle);
__forceinline bool IsOnline() const { return m_bOnline; }
@@ -129,7 +130,7 @@ private:
friend struct AsyncHttpRequest;
-//==== Enums =========================================================================
+ //==== Enums =========================================================================
enum CLMenuIndexes {
CMI_VISITPROFILE,
@@ -168,7 +169,7 @@ private:
PMI_COUNT
};
-//====================================================================================
+ //====================================================================================
bool
m_prevError,
@@ -224,26 +225,27 @@ private:
m_hContactHistoryMenuItems[CHMI_COUNT],
m_hProtoMenuItems[PMI_COUNT];
-//==== Menus =========================================================================
+ //==== Menus =========================================================================
void InitMenus();
void UnInitMenus();
int __cdecl OnPreBuildContactMenu(WPARAM hContact, LPARAM);
-//==== PopUps ========================================================================
+ //==== PopUps ========================================================================
void InitPopups(void);
void MsgPopup(MCONTACT hContact, const wchar_t *wszMsg, const wchar_t *wszTitle, bool err = false);
+ void MsgPopup(const wchar_t *wszMsg, const wchar_t *wszTitle, bool err = false);
void InitDBCustomEvents();
-//==== Hooks =========================================================================
+ //==== Hooks =========================================================================
int __cdecl OnProcessSrmmEvent(WPARAM, LPARAM);
int __cdecl OnDbEventRead(WPARAM, LPARAM);
int __cdecl OnDbSettingChanged(WPARAM, LPARAM);
-//==== Search ========================================================================
+ //==== Search ========================================================================
void __cdecl SearchBasicThread(void *id);
void __cdecl SearchByMailThread(void *email);
@@ -252,14 +254,14 @@ private:
void OnSearch(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
void OnSearchByMail(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
-//==== Files Upload ==================================================================
+ //==== Files Upload ==================================================================
void SendFileFiled(CVkFileUploadParam *fup, int ErrorCode);
void OnReciveUploadServer(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
void OnReciveUpload(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
void OnReciveUploadFile(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
-//==== Feed ==========================================================================
+ //==== Feed ==========================================================================
void AddFeedSpecialUser();
void AddFeedEvent(CVKNewsItem& vkNewsItem);
@@ -271,7 +273,7 @@ private:
CVKNewsItem* GetVkNotificationsItem(const JSONNode &jnItem, OBJLIST<CVkUserInfo> &vkUsers);
void OnFriendAccepted(const JSONNode &jnFeedback);
CMStringW GetVkFeedback(const JSONNode &jnFeedback, VKObjType vkFeedbackType, OBJLIST<CVkUserInfo> &vkUsers, CVkUserInfo *vkUser);
- CVKNewsItem* GetVkParent(const JSONNode &jnParent, VKObjType vkParentType, LPCWSTR pwszReplyText = NULL, LPCWSTR pwszReplyLink = NULL);
+ CVKNewsItem* GetVkParent(const JSONNode &jnParent, VKObjType vkParentType, LPCWSTR pwszReplyText = nullptr, LPCWSTR pwszReplyLink = nullptr);
void RetrieveUnreadNews(time_t tLastNewsTime);
void OnReceiveUnreadNews(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
void RetrieveUnreadNotifications(time_t tLastNotificationsTime);
@@ -282,7 +284,7 @@ private:
void NewsClearHistory();
INT_PTR __cdecl SvcLoadVKNews(WPARAM, LPARAM);
-//====================================================================================
+ //====================================================================================
void SetServerStatus(int);
void RetrieveUsersInfo(bool flag = false, bool bRepeat = false);
@@ -321,7 +323,7 @@ private:
void OnReceiveAuthRequest(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
void OnReceiveDeleteFriend(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
-//==== Misc ==========================================================================
+ //==== Misc ==========================================================================
void SetAllContactStatuses(int status);
MCONTACT FindUser(LONG userid, bool bCreate = false);
@@ -348,7 +350,7 @@ private:
CMStringA GetAttachmentsFromMessage(const char * Msg);
CMStringW SpanVKNotificationType(CMStringW& wszType, VKObjType& vkFeedback, VKObjType& vkParent);
CMStringW GetVkPhotoItem(const JSONNode &jnPhoto, BBCSupport iBBC);
- CMStringW SetBBCString(LPCWSTR wszString, BBCSupport iBBC, VKBBCType bbcType, LPCWSTR wszAddString = NULL);
+ CMStringW SetBBCString(LPCWSTR wszString, BBCSupport iBBC, VKBBCType bbcType, LPCWSTR wszAddString = nullptr);
CMStringW& ClearFormatNick(CMStringW& wszText);
CMStringW GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport iBBC = bbcNo);
CMStringW GetFwdMessages(const JSONNode &jnMessages, const JSONNode &jnFUsers, BBCSupport iBBC = bbcNo);
diff --git a/protocols/VKontakte/src/vk_queue.cpp b/protocols/VKontakte/src/vk_queue.cpp
index 37fd228d72..0d0960e854 100644
--- a/protocols/VKontakte/src/vk_queue.cpp
+++ b/protocols/VKontakte/src/vk_queue.cpp
@@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
void CVkProto::InitQueue()
{
debugLogA("CVkProto::InitQueue");
- m_evRequestsQueue = CreateEvent(NULL, FALSE, FALSE, NULL);
+ m_evRequestsQueue = CreateEvent(nullptr, false, false, nullptr);
}
void CVkProto::UninitQueue()
@@ -56,9 +56,9 @@ void CVkProto::ExecuteRequest(AsyncHttpRequest *pReq)
debugLogA("CVkProto::ExecuteRequest \n====\n%s\n====\n", pReq->szUrl);
NETLIBHTTPREQUEST *reply = Netlib_HttpTransaction(m_hNetlibUser, pReq);
- if (reply != NULL) {
- if (pReq->m_pFunc != NULL)
- (this->*(pReq->m_pFunc))(reply, pReq); // may be set pReq->bNeedsRestart
+ if (reply != nullptr) {
+ if (pReq->m_pFunc != nullptr)
+ (this->*(pReq->m_pFunc))(reply, pReq); // may be set pReq->bNeedsRestart
if (pReq->m_bApiReq)
m_hAPIConnection = reply->nlc;
@@ -70,7 +70,7 @@ void CVkProto::ExecuteRequest(AsyncHttpRequest *pReq)
ConnectionFailed(LOGINERR_NONETWORK);
else if (pReq->m_iRetry && !m_bTerminated) {
pReq->bNeedsRestart = true;
- Sleep(1000); //Pause for fix err
+ Sleep(1000); //Pause for fix err
pReq->m_iRetry--;
debugLogA("CVkProto::ExecuteRequest restarting (retry = %d)", MAX_RETRIES - pReq->m_iRetry);
}
@@ -82,7 +82,7 @@ void CVkProto::ExecuteRequest(AsyncHttpRequest *pReq)
debugLogA("CVkProto::ExecuteRequest pReq->bNeedsRestart = %d", (int)pReq->bNeedsRestart);
if (!reply && pReq->m_bApiReq)
- m_hAPIConnection = NULL;
+ m_hAPIConnection = nullptr;
} while (pReq->bNeedsRestart && !m_bTerminated);
delete pReq;
@@ -122,10 +122,10 @@ void CVkProto::WorkerThread(void*)
if (szAccessScore != Score) {
setString("AccessScore", Score);
delSetting("AccessToken");
- m_szAccessToken = NULL;
+ m_szAccessToken = nullptr;
}
- if (m_szAccessToken != NULL)
+ if (m_szAccessToken != nullptr)
// try to receive a response from server
RetrieveMyInfo();
else {
@@ -143,7 +143,7 @@ void CVkProto::WorkerThread(void*)
Push(pReq);
}
- m_hAPIConnection = NULL;
+ m_hAPIConnection = nullptr;
while (true) {
WaitForSingleObject(m_evRequestsQueue, 1000);
@@ -193,14 +193,14 @@ void CVkProto::WorkerThread(void*)
debugLogA("CVkProto::WorkerThread: Netlib_CloseHandle(m_hAPIConnection) beg");
Netlib_CloseHandle(m_hAPIConnection);
debugLogA("CVkProto::WorkerThread: Netlib_CloseHandle(m_hAPIConnection) end");
- m_hAPIConnection = NULL;
+ m_hAPIConnection = nullptr;
}
debugLogA("CVkProto::WorkerThread: leaving m_bTerminated = %d", m_bTerminated ? 1 : 0);
if (m_hWorkerThread) {
CloseHandle(m_hWorkerThread);
- m_hWorkerThread = NULL;
+ m_hWorkerThread = nullptr;
}
}
diff --git a/protocols/VKontakte/src/vk_search.cpp b/protocols/VKontakte/src/vk_search.cpp
index 942d544149..b5c1462849 100644
--- a/protocols/VKontakte/src/vk_search.cpp
+++ b/protocols/VKontakte/src/vk_search.cpp
@@ -49,7 +49,7 @@ void CVkProto::SearchBasicThread(void *id)
AsyncHttpRequest *pReq = new AsyncHttpRequest(this, REQUEST_GET, "/method/users.get.json", true, &CVkProto::OnSearch)
<< WCHAR_PARAM("user_ids", (wchar_t *)id)
<< CHAR_PARAM("fields", "nickname, domain");
- pReq->pUserInfo = NULL;
+ pReq->pUserInfo = nullptr;
Push(pReq);
}
diff --git a/protocols/VKontakte/src/vk_status.cpp b/protocols/VKontakte/src/vk_status.cpp
index 6ae160a4fe..f26804e0ea 100644
--- a/protocols/VKontakte/src/vk_status.cpp
+++ b/protocols/VKontakte/src/vk_status.cpp
@@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
int CVkProto::SetStatus(int iNewStatus)
{
debugLogA("CVkProto::SetStatus iNewStatus = %d, m_iStatus = %d, m_iDesiredStatus = %d m_hWorkerThread = %d",
- iNewStatus, m_iStatus, m_iDesiredStatus, m_hWorkerThread == NULL ? 0 : 1);
+ iNewStatus, m_iStatus, m_iDesiredStatus, m_hWorkerThread == nullptr ? 0 : 1);
mir_cslock lck(m_csSetStatus);
@@ -38,28 +38,34 @@ int CVkProto::SetStatus(int iNewStatus)
}
m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE;
- ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus);
- debugLogA("CVkProto::SetStatus (1) iNewStatus = %d, m_iStatus = %d, m_iDesiredStatus = %d oldStatus = %d", iNewStatus, m_iStatus, m_iDesiredStatus, oldStatus);
+ ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus);
+ debugLogA("CVkProto::SetStatus (1) iNewStatus = %d, m_iStatus = %d, m_iDesiredStatus = %d oldStatus = %d",
+ iNewStatus, m_iStatus, m_iDesiredStatus, oldStatus);
}
- else if (m_hWorkerThread == NULL && !IsStatusConnecting(m_iStatus)) {
+ else if (m_hWorkerThread == nullptr && !IsStatusConnecting(m_iStatus)) {
m_iStatus = ID_STATUS_CONNECTING;
- ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus);
- debugLogA("CVkProto::SetStatus (2) iNewStatus = %d, m_iStatus = %d, m_iDesiredStatus = %d oldStatus = %d", iNewStatus, m_iStatus, m_iDesiredStatus, oldStatus);
- m_hWorkerThread = ForkThreadEx(&CVkProto::WorkerThread, 0, NULL);
+ ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus);
+ debugLogA("CVkProto::SetStatus (2) iNewStatus = %d, m_iStatus = %d, m_iDesiredStatus = %d oldStatus = %d",
+ iNewStatus, m_iStatus, m_iDesiredStatus, oldStatus);
+ m_hWorkerThread = ForkThreadEx(&CVkProto::WorkerThread, 0, nullptr);
}
else if (IsOnline()) {
- debugLogA("CVkProto::SetStatus (3) iNewStatus = %d, m_iStatus = %d, m_iDesiredStatus = %d oldStatus = %d", iNewStatus, m_iStatus, m_iDesiredStatus, oldStatus);
+ debugLogA("CVkProto::SetStatus (3) iNewStatus = %d, m_iStatus = %d, m_iDesiredStatus = %d oldStatus = %d",
+ iNewStatus, m_iStatus, m_iDesiredStatus, oldStatus);
SetServerStatus(iNewStatus);
}
else {
- debugLogA("CVkProto::SetStatus (4) iNewStatus = %d, m_iStatus = %d, m_iDesiredStatus = %d oldStatus = %d", iNewStatus, m_iStatus, m_iDesiredStatus, oldStatus);
- ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus);
+ debugLogA("CVkProto::SetStatus (4) iNewStatus = %d, m_iStatus = %d, m_iDesiredStatus = %d oldStatus = %d",
+ iNewStatus, m_iStatus, m_iDesiredStatus, oldStatus);
+ ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus);
if (!IsStatusConnecting(m_iStatus))
m_iDesiredStatus = m_iStatus;
- debugLogA("CVkProto::SetStatus (5) iNewStatus = %d, m_iStatus = %d, m_iDesiredStatus = %d oldStatus = %d", iNewStatus, m_iStatus, m_iDesiredStatus, oldStatus);
+ debugLogA("CVkProto::SetStatus (5) iNewStatus = %d, m_iStatus = %d, m_iDesiredStatus = %d oldStatus = %d",
+ iNewStatus, m_iStatus, m_iDesiredStatus, oldStatus);
}
- debugLogA("CVkProto::SetStatus (ret) iNewStatus = %d, m_iStatus = %d, m_iDesiredStatus = %d oldStatus = %d", iNewStatus, m_iStatus, m_iDesiredStatus, oldStatus);
+ debugLogA("CVkProto::SetStatus (ret) iNewStatus = %d, m_iStatus = %d, m_iDesiredStatus = %d oldStatus = %d",
+ iNewStatus, m_iStatus, m_iDesiredStatus, oldStatus);
return 0;
}
@@ -70,8 +76,8 @@ void CVkProto::SetServerStatus(int iNewStatus)
return;
int iOldStatus = m_iStatus;
- CMStringW oldStatusMsg(ptrW(db_get_wsa(NULL, m_szModuleName, "OldStatusMsg")));
- ptrW pwszListeningToMsg(db_get_wsa(NULL, m_szModuleName, "ListeningTo"));
+ CMStringW oldStatusMsg(ptrW(db_get_wsa(0, m_szModuleName, "OldStatusMsg")));
+ ptrW pwszListeningToMsg(db_get_wsa(0, m_szModuleName, "ListeningTo"));
if (iNewStatus == ID_STATUS_OFFLINE) {
m_bNeedSendOnline = false;
@@ -100,7 +106,7 @@ void CVkProto::SetServerStatus(int iNewStatus)
Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/account.setOffline.json", true, &CVkProto::OnReceiveSmth));
}
- ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)iOldStatus, m_iStatus);
+ ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)iOldStatus, m_iStatus);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -111,7 +117,7 @@ INT_PTR __cdecl CVkProto::SvcSetStatusMsg(WPARAM, LPARAM)
if (!IsOnline())
return 1;
- MsgPopup(NULL, TranslateT("Loading status message from vk.com.\nThis may take some time."), TranslateT("Waiting..."));
+ MsgPopup(TranslateT("Loading status message from vk.com.\nThis may take some time."), TranslateT("Waiting..."));
Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/status.get.json", true, &CVkProto::OnReceiveStatusMsg));
@@ -126,7 +132,7 @@ void CVkProto::OnReceiveStatusMsg(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pR
OnReceiveStatus(reply, pReq);
- ptrW pwszOldStatusMsg(db_get_wsa(NULL, m_szModuleName, "OldStatusMsg"));
+ ptrW pwszOldStatusMsg(db_get_wsa(0, m_szModuleName, "OldStatusMsg"));
CMStringW wszOldStatusMsg(pwszOldStatusMsg);
ENTER_STRING pForm = { sizeof(pForm) };
@@ -211,15 +217,15 @@ INT_PTR __cdecl CVkProto::SvcSetListeningTo(WPARAM, LPARAM lParam)
LISTENINGTOINFO *pliInfo = (LISTENINGTOINFO*)lParam;
CMStringW wszListeningTo;
- if (pliInfo == NULL || pliInfo->cbSize != sizeof(LISTENINGTOINFO))
- db_unset(NULL, m_szModuleName, "ListeningTo");
+ if (pliInfo == nullptr || pliInfo->cbSize != sizeof(LISTENINGTOINFO))
+ db_unset(0, m_szModuleName, "ListeningTo");
else if (pliInfo->dwFlags & LTI_UNICODE) {
if (ServiceExists(MS_LISTENINGTO_GETPARSEDTEXT))
wszListeningTo = ptrW((LPWSTR)CallService(MS_LISTENINGTO_GETPARSEDTEXT, (WPARAM)L"%artist% - %title%", (LPARAM)pliInfo));
else
wszListeningTo.Format(L"%s - %s",
- pliInfo->ptszArtist ? pliInfo->ptszArtist : L"",
- pliInfo->ptszTitle ? pliInfo->ptszTitle : L"");
+ pliInfo->ptszArtist ? pliInfo->ptszArtist : L"",
+ pliInfo->ptszTitle ? pliInfo->ptszTitle : L"");
setWString("ListeningTo", wszListeningTo);
}
RetrieveStatusMusic(wszListeningTo);
diff --git a/protocols/VKontakte/src/vk_struct.cpp b/protocols/VKontakte/src/vk_struct.cpp
index 793e3c0833..750b0bc5b8 100644
--- a/protocols/VKontakte/src/vk_struct.cpp
+++ b/protocols/VKontakte/src/vk_struct.cpp
@@ -26,12 +26,12 @@ AsyncHttpRequest::AsyncHttpRequest()
cbSize = sizeof(NETLIBHTTPREQUEST);
m_bApiReq = true;
AddHeader("Connection", "keep-alive");
- pUserInfo = NULL;
+ pUserInfo = nullptr;
m_iRetry = MAX_RETRIES;
m_iErrorCode = 0;
bNeedsRestart = false;
bIsMainConn = false;
- m_pFunc = NULL;
+ m_pFunc = nullptr;
bExpUrlEncode = true;
m_reqNum = ::InterlockedIncrement(&m_reqCount);
m_priority = rpLow;
@@ -61,7 +61,7 @@ AsyncHttpRequest::AsyncHttpRequest(CVkProto *ppro, int iRequestType, LPCSTR _url
requestType = iRequestType;
m_pFunc = pFunc;
- pUserInfo = NULL;
+ pUserInfo = nullptr;
m_iRetry = MAX_RETRIES;
m_iErrorCode = 0;
bNeedsRestart = false;
@@ -102,8 +102,8 @@ CVkFileUploadParam::CVkFileUploadParam(MCONTACT _hContact, const wchar_t *_desc,
hContact(_hContact),
Desc(mir_wstrdup(_desc)),
FileName(mir_wstrdup(_files[0])),
- atr(NULL),
- fname(NULL),
+ atr(nullptr),
+ fname(nullptr),
filetype(typeInvalid)
{}
@@ -239,15 +239,15 @@ CVKOptions::CVKOptions(PROTO_INTERFACE *proto) :
pwszDefaultGroup(proto, "ProtoGroup", L"VKontakte"),
pwszReturnChatMessage(proto, "ReturnChatMessage", TranslateT("I'm back")),
- pwszVKLang(proto, "VKLang", NULL)
+ pwszVKLang(proto, "VKLang", nullptr)
{
// Note: Delete this code after next stable build
- int iAutoClean = db_get_b(NULL, proto->m_szModuleName, "AutoClean", -1);
+ int iAutoClean = db_get_b(0, proto->m_szModuleName, "AutoClean", -1);
if (iAutoClean != -1) {
bLoadOnlyFriends = (BYTE)iAutoClean;
- db_set_b(NULL, proto->m_szModuleName, "LoadOnlyFriends", bLoadOnlyFriends);
- db_unset(NULL, proto->m_szModuleName, "AutoClean");
+ db_set_b(0, proto->m_szModuleName, "LoadOnlyFriends", bLoadOnlyFriends);
+ db_unset(0, proto->m_szModuleName, "AutoClean");
}
// Note
-}
+} \ No newline at end of file
diff --git a/protocols/VKontakte/src/vk_struct.h b/protocols/VKontakte/src/vk_struct.h
index 59e41e58c7..b687018bcf 100644
--- a/protocols/VKontakte/src/vk_struct.h
+++ b/protocols/VKontakte/src/vk_struct.h
@@ -102,7 +102,7 @@ struct CVkSendMsgParam : public MZeroedObject
hContact(_hContact),
iMsgID(_iMsgID),
iCount(_iCount),
- pFUP(NULL)
+ pFUP(nullptr)
{}
CVkSendMsgParam(MCONTACT _hContact, CVkFileUploadParam *_pFUP) :
@@ -185,7 +185,7 @@ struct CVkUserInfo : public MZeroedObject {
m_bIsGroup(false)
{}
- CVkUserInfo(LONG _UserId, bool _bIsGroup, CMStringW& _wszUserNick, CMStringW& _wszLink, MCONTACT _hContact = NULL) :
+ CVkUserInfo(LONG _UserId, bool _bIsGroup, CMStringW& _wszUserNick, CMStringW& _wszLink, MCONTACT _hContact = 0) :
m_UserId(_UserId),
m_bIsGroup(_bIsGroup),
m_wszUserNick(_wszUserNick),
@@ -210,8 +210,8 @@ struct CVKNotification {
struct CVKNewsItem : public MZeroedObject {
CVKNewsItem() :
- tDate(NULL),
- vkUser(NULL),
+ tDate(0),
+ vkUser(nullptr),
bIsGroup(false),
bIsRepost(false),
vkFeedbackType(vkNull),
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp
index bc7eaf9eb4..4a2f33f133 100644
--- a/protocols/VKontakte/src/vk_thread.cpp
+++ b/protocols/VKontakte/src/vk_thread.cpp
@@ -24,8 +24,8 @@ char szBlankUrl[] = "https://oauth.vk.com/blank.html";
static char VK_TOKEN_BEG[] = "access_token=";
static char VK_LOGIN_DOMAIN[] = "https://m.vk.com";
static char fieldsName[] = "id, first_name, last_name, photo_100, bdate, sex, timezone, "
-"contacts, last_seen, online, status, country, city, relation, interests, activities, "
-"music, movies, tv, books, games, quotes, about, domain";
+ "contacts, last_seen, online, status, country, city, relation, interests, activities, "
+ "music, movies, tv, books, games, quotes, about, domain";
/////////////////////////////////////////////////////////////////////////////////////////
@@ -42,7 +42,7 @@ void CVkProto::ConnectionFailed(int iReason)
{
delSetting("AccessToken");
- ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, iReason);
+ ProtoBroadcastAck(0, ACKTYPE_LOGIN, ACKRESULT_FAILED, nullptr, iReason);
debugLogA("CVkProto::ConnectionFailed ShutdownSession");
ShutdownSession();
}
@@ -64,14 +64,14 @@ static void CALLBACK VKSetTimer(void*)
mir_cslock lck(CVkProto::m_csTimer);
if (CVkProto::m_timer)
return;
- CVkProto::m_timer = SetTimer(NULL, 0, 60000, TimerProc);
+ CVkProto::m_timer = SetTimer(nullptr, 0, 60000, TimerProc);
}
static void CALLBACK VKUnsetTimer(void*)
{
mir_cslock lck(CVkProto::m_csTimer);
if (CVkProto::m_timer)
- KillTimer(NULL, CVkProto::m_timer);
+ KillTimer(nullptr, CVkProto::m_timer);
CVkProto::m_timer = 0;
}
@@ -93,8 +93,8 @@ void CVkProto::OnLoggedIn()
// initialize online timer
CallFunctionAsync(VKSetTimer, this);
- db_unset(NULL, m_szModuleName, "LastNewsReqTime");
- db_unset(NULL, m_szModuleName, "LastNotificationsReqTime");
+ db_unset(0, m_szModuleName, "LastNewsReqTime");
+ db_unset(0, m_szModuleName, "LastNotificationsReqTime");
}
void CVkProto::OnLoggedOut()
@@ -104,12 +104,12 @@ void CVkProto::OnLoggedOut()
if (m_hPollingThread) {
CloseHandle(m_hPollingThread);
- m_hPollingThread = NULL;
+ m_hPollingThread = nullptr;
}
if (m_hWorkerThread) {
CloseHandle(m_hWorkerThread);
- m_hWorkerThread = NULL;
+ m_hWorkerThread = nullptr;
}
if (m_hAPIConnection)
@@ -118,7 +118,7 @@ void CVkProto::OnLoggedOut()
if (m_pollingConn)
Netlib_Shutdown(m_pollingConn);
- ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)m_iStatus, ID_STATUS_OFFLINE);
+ ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)m_iStatus, ID_STATUS_OFFLINE);
m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE;
bool bOnline = false;
@@ -144,7 +144,7 @@ void CVkProto::OnOAuthAuthorize(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq
LPCSTR pszLocation = findHeader(reply, "Location");
if (pszLocation) {
if (!_strnicmp(pszLocation, szBlankUrl, sizeof(szBlankUrl) - 1)) {
- m_szAccessToken = NULL;
+ m_szAccessToken = nullptr;
LPCSTR p = strstr(pszLocation, VK_TOKEN_BEG);
if (p) {
p += sizeof(VK_TOKEN_BEG) - 1;
@@ -154,7 +154,7 @@ void CVkProto::OnOAuthAuthorize(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq
break;
}
}
- if (m_szAccessToken == NULL)
+ if (m_szAccessToken == nullptr)
m_szAccessToken = mir_strdup(p);
setString("AccessToken", m_szAccessToken);
RetrieveMyInfo();
@@ -198,7 +198,7 @@ void CVkProto::OnOAuthAuthorize(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq
char *p2 = strchr(pMsgWarning, '<');
if (p1 && p2 && (p1 + 1 < p2)) {
CMStringA szMsg(p1 + 1, (int)(p2 - p1 - 1));
- MsgPopup(NULL, ptrW(mir_utf8decodeW(szMsg)), TranslateT("Service message"), true);
+ MsgPopup(ptrW(mir_utf8decodeW(szMsg)), TranslateT("Service message"), true);
debugLogA("CVkProto::OnOAuthAuthorize %s", szMsg.c_str());
}
ConnectionFailed(LOGINERR_WRONGPASSWORD);
@@ -275,26 +275,26 @@ void CVkProto::OnReceiveMyInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
MCONTACT CVkProto::SetContactInfo(const JSONNode &jnItem, bool flag, bool self)
{
if (!jnItem) {
- debugLogA("CVkProto::SetContactInfo pItem == NULL");
+ debugLogA("CVkProto::SetContactInfo pItem == nullptr");
return INVALID_CONTACT_ID;
}
LONG userid = jnItem["id"].as_int();
debugLogA("CVkProto::SetContactInfo %d", userid);
if (userid == 0 || userid == VK_FEED_USER)
- return NULL;
+ return 0;
MCONTACT hContact = FindUser(userid, flag);
if (userid == m_myUserId) {
- if (hContact != NULL)
+ if (hContact != 0)
if (self)
- hContact = NULL;
+ hContact = 0;
else
SetContactInfo(jnItem, flag, true);
}
- else if (hContact == NULL)
- return NULL;
+ else if (hContact == 0)
+ return 0;
CMStringW wszNick, wszValue;
int iValue;
@@ -364,7 +364,7 @@ MCONTACT CVkProto::SetContactInfo(const JSONNode &jnItem, bool flag, bool self)
setWord(hContact, "Status", iNewStatus);
if (iNewStatus == ID_STATUS_ONLINE) {
- db_set_dw(hContact, "BuddyExpectator", "LastSeen", (DWORD)time(NULL));
+ db_set_dw(hContact, "BuddyExpectator", "LastSeen", (DWORD)time(nullptr));
db_set_dw(hContact, "BuddyExpectator", "LastStatus", ID_STATUS_ONLINE);
int online_app = _wtoi(jnItem["online_app"].as_mstring());
@@ -615,7 +615,7 @@ void CVkProto::OnReceiveUserInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
int iContactStatus = getWord(hContact, "Status", ID_STATUS_OFFLINE);
if ((iContactStatus == ID_STATUS_ONLINE)
- || (iContactStatus == ID_STATUS_INVISIBLE && time(NULL) - getDword(hContact, "InvisibleTS", 0) >= m_vkOptions.iInvisibleInterval * 60LL)) {
+ || (iContactStatus == ID_STATUS_INVISIBLE && time(nullptr) - getDword(hContact, "InvisibleTS", 0) >= m_vkOptions.iInvisibleInterval * 60LL)) {
setWord(hContact, "Status", ID_STATUS_OFFLINE);
SetMirVer(hContact, -1);
db_unset(hContact, m_szModuleName, "ListeningTo");
@@ -730,7 +730,7 @@ void CVkProto::RetrieveFriends(bool bCleanNonFriendContacts)
return;
Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/friends.get.json", true, &CVkProto::OnReceiveFriends)
<< INT_PARAM("count", m_vkOptions.iMaxFriendsCount > 5000 ? 1000 : m_vkOptions.iMaxFriendsCount)
- << CHAR_PARAM("fields", fieldsName))->pUserInfo = new CVkSendMsgParam(NULL, bCleanNonFriendContacts ? 1 : 0);
+ << CHAR_PARAM("fields", fieldsName))->pUserInfo = new CVkSendMsgParam(0, bCleanNonFriendContacts ? 1 : 0);
}
void CVkProto::OnReceiveFriends(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
@@ -765,7 +765,7 @@ void CVkProto::OnReceiveFriends(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq
for (auto it = jnItems.begin(); it != jnItems.end(); ++it) {
MCONTACT hContact = SetContactInfo((*it), true);
- if (hContact == NULL || hContact == INVALID_CONTACT_ID)
+ if (hContact == 0 || hContact == INVALID_CONTACT_ID)
continue;
arContacts.remove((HANDLE)hContact);
@@ -800,7 +800,7 @@ INT_PTR __cdecl CVkProto::SvcAddAsFriend(WPARAM hContact, LPARAM)
INT_PTR CVkProto::SvcWipeNonFriendContacts(WPARAM, LPARAM)
{
debugLogA("CVkProto::SvcWipeNonFriendContacts");
- if (IDNO == MessageBoxW(NULL, TranslateT("Are you sure to wipe local contacts missing in your friend list?"),
+ if (IDNO == MessageBoxW(nullptr, TranslateT("Are you sure to wipe local contacts missing in your friend list?"),
TranslateT("Attention!"), MB_ICONWARNING | MB_YESNO))
return 0;
@@ -819,7 +819,7 @@ INT_PTR __cdecl CVkProto::SvcDeleteFriend(WPARAM hContact, LPARAM flag)
CMStringW pwszMsg;
if (flag == 0) {
pwszMsg.AppendFormat(TranslateT("Are you sure to delete %s from your friend list?"), IsEmpty(pwszNick) ? TranslateT("(Unknown contact)") : pwszNick);
- if (IDNO == MessageBoxW(NULL, pwszMsg, TranslateT("Attention!"), MB_ICONWARNING | MB_YESNO))
+ if (IDNO == MessageBoxW(nullptr, pwszMsg, TranslateT("Attention!"), MB_ICONWARNING | MB_YESNO))
return 1;
}
Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/friends.delete.json", true, &CVkProto::OnReceiveDeleteFriend)
@@ -864,7 +864,7 @@ void CVkProto::OnReceiveDeleteFriend(NETLIBHTTPREQUEST *reply, AsyncHttpRequest
if (param && (!pReq->bNeedsRestart || m_bTerminated)) {
delete param;
- pReq->pUserInfo = NULL;
+ pReq->pUserInfo = nullptr;
}
}
@@ -914,7 +914,7 @@ INT_PTR __cdecl CVkProto::SvcBanUser(WPARAM hContact, LPARAM)
wszVarWarning.IsEmpty() ? L" " : TranslateT("\nIt will also"),
wszVarWarning.IsEmpty() ? L"\n" : wszVarWarning);
- if (IDNO == MessageBoxW(NULL, pwszMsg, TranslateT("Attention!"), MB_ICONWARNING | MB_YESNO))
+ if (IDNO == MessageBoxW(nullptr, pwszMsg, TranslateT("Attention!"), MB_ICONWARNING | MB_YESNO))
return 1;
Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.json", true, &CVkProto::OnReceiveSmth)
@@ -935,7 +935,7 @@ INT_PTR __cdecl CVkProto::SvcReportAbuse(WPARAM hContact, LPARAM)
CMStringW wszNick(ptrW(db_get_wsa(hContact, m_szModuleName, "Nick"))),
pwszMsg(FORMAT, TranslateT("Are you sure to report abuse on %s?"), wszNick.IsEmpty() ? TranslateT("(Unknown contact)") : wszNick);
- if (IDNO == MessageBoxW(NULL, pwszMsg, TranslateT("Attention!"), MB_ICONWARNING | MB_YESNO))
+ if (IDNO == MessageBoxW(nullptr, pwszMsg, TranslateT("Attention!"), MB_ICONWARNING | MB_YESNO))
return 1;
Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/users.report.json", true, &CVkProto::OnReceiveSmth)
@@ -977,4 +977,4 @@ INT_PTR __cdecl CVkProto::SvcVisitProfile(WPARAM hContact, LPARAM)
Utils_OpenUrlW(wszUrl);
return 0;
-}
+} \ No newline at end of file