From 9fca9c4c344cb330434e9e72e7934e207bcfaa4d Mon Sep 17 00:00:00 2001 From: Sergey Bolhovskoy Date: Fri, 5 Dec 2014 07:53:53 +0000 Subject: VKontakte: code cleanup git-svn-id: http://svn.miranda-ng.org/main/trunk@11248 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/VKontakte/src/misc.cpp | 22 ++++----- protocols/VKontakte/src/vk_avatars.cpp | 6 +-- protocols/VKontakte/src/vk_captcha.cpp | 10 ++-- protocols/VKontakte/src/vk_chats.cpp | 12 ++--- protocols/VKontakte/src/vk_files.cpp | 48 +++++++++---------- protocols/VKontakte/src/vk_history.cpp | 2 +- protocols/VKontakte/src/vk_options.cpp | 4 +- protocols/VKontakte/src/vk_proto.cpp | 16 +++---- protocols/VKontakte/src/vk_proto.h | 2 +- protocols/VKontakte/src/vk_queue.cpp | 8 ++-- protocols/VKontakte/src/vk_search.cpp | 20 ++++---- protocols/VKontakte/src/vk_thread.cpp | 87 +++++++++++++++++----------------- 12 files changed, 119 insertions(+), 118 deletions(-) diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index d2201f680f..cd5c8ea838 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -20,7 +20,7 @@ along with this program. If not, see . TCHAR* CVkProto::GetUserStoredPassword() { debugLogA("CVkProto::GetUserStoredPassword"); - ptrA szRawPass( getStringA("Password")); + ptrA szRawPass(getStringA("Password")); return (szRawPass != NULL) ? mir_utf8decodeT(szRawPass) : NULL; } @@ -123,7 +123,7 @@ bool CVkProto::CheckJsonResult(AsyncHttpRequest *pReq, NETLIBHTTPREQUEST *reply, debugLogA("CVkProto::CheckJsonResult %d", iErrorCode); CVkFileUploadParam * fup = (CVkFileUploadParam *)pReq->pUserInfo; CVkSendMsgParam *param = (CVkSendMsgParam*)pReq->pUserInfo; - switch (iErrorCode){ + switch (iErrorCode) { case VKERR_AUTHORIZATION_FAILED: ConnectionFailed(LOGINERR_WRONGPASSWORD); break; @@ -146,13 +146,13 @@ bool CVkProto::CheckJsonResult(AsyncHttpRequest *pReq, NETLIBHTTPREQUEST *reply, case VKERR_UNKNOWN: case VKERR_TOO_MANY_REQ_PER_SEC: case VKERR_INTERNAL_SERVER_ERR: - if (pReq->m_iRetry > 0){ + if (pReq->m_iRetry > 0) { pReq->bNeedsRestart = true; Sleep(500); //Pause for fix err debugLogA("CVkProto::CheckJsonResult Retry = %d", pReq->m_iRetry); pReq->m_iRetry--; } - else{ + else { CMString msg, msgformat = TranslateT("Error %d. Data will not be sent or received."); msg.AppendFormat(msgformat, iErrorCode); MsgPopup(NULL, msg.GetBuffer(), TranslateT("Error"), true); @@ -225,7 +225,7 @@ static CMStringA getAttr(char *szSrc, LPCSTR szAttrName) } p1 += mir_strlen(szAttrName); - if (p1[0] != '=' || p1[1] != '\"'){ + if (p1[0] != '=' || p1[1] != '\"') { *pEnd = '>'; return ""; } @@ -363,7 +363,7 @@ void CVkProto::GrabCookies(NETLIBHTTPREQUEST *nhr) CMStringA szValue = nhr->headers[i].szValue, szCookieName, szCookieVal, szDomain; int iStart = 0; while (true) { - bool bFirstToken = iStart == 0; + bool bFirstToken = (iStart == 0); CMStringA szToken = szValue.Tokenize(";", iStart).Trim(); if (iStart == -1) break; @@ -386,7 +386,7 @@ void CVkProto::GrabCookies(NETLIBHTTPREQUEST *nhr) } } if (k == m_cookies.getCount()) - m_cookies.insert( new Cookie(szCookieName, szCookieVal, szDomain)); + m_cookies.insert(new Cookie(szCookieName, szCookieVal, szDomain)); } } } @@ -477,7 +477,7 @@ void CVkProto::SetMirVer(MCONTACT hContact, int platform) { if (hContact == NULL || hContact == INVALID_CONTACT_ID) return; - if (platform == -1){ + if (platform == -1) { db_unset(hContact, m_szModuleName, "MirVer"); return; } @@ -486,7 +486,7 @@ void CVkProto::SetMirVer(MCONTACT hContact, int platform) OldMirVer = db_get_sa(hContact, m_szModuleName, "MirVer"); bool bSetFlag = true; - switch (platform){ + switch (platform) { case VK_APP_ID: MirVer = "Miranda NG VKontakte"; break; @@ -591,7 +591,7 @@ char* CVkProto::GetStickerId(const char* Msg, int &stickerid) char HeadMsg[32] = { 0 }; char* retMsg = NULL; iRes = sscanf(Msg, "[sticker:%d]", &stickerid); - if (iRes == 1){ + if (iRes == 1) { mir_snprintf(HeadMsg, 32, "[sticker:%d]", stickerid); size_t retLen = mir_strlen(HeadMsg); if (retLen < mir_strlen(Msg)) @@ -613,7 +613,7 @@ int CVkProto::OnDbSettingChanged(WPARAM hContact, LPARAM lParam) CMStringA szListeningTo(m_szModuleName); szListeningTo += "Enabled"; - if (!strcmp(cws->szSetting, szListeningTo.GetBuffer())){ + if (!strcmp(cws->szSetting, szListeningTo.GetBuffer())) { int iOldMusicSendMetod = getByte("OldMusicSendMetod", 3); if (cws->value.bVal == 0) diff --git a/protocols/VKontakte/src/vk_avatars.cpp b/protocols/VKontakte/src/vk_avatars.cpp index d9dbcc6476..264c4924f2 100644 --- a/protocols/VKontakte/src/vk_avatars.cpp +++ b/protocols/VKontakte/src/vk_avatars.cpp @@ -62,7 +62,7 @@ INT_PTR CVkProto::SvcGetAvatarCaps(WPARAM wParam, LPARAM lParam) void CVkProto::ReloadAvatarInfo(MCONTACT hContact) { - if (!hContact){ + if (!hContact) { CallService(MS_AV_REPORTMYAVATARCHANGED, (WPARAM)m_szModuleName, 0); return; } @@ -88,7 +88,7 @@ INT_PTR CVkProto::SvcGetAvatarInfo(WPARAM wParam, LPARAM lParam) if (::_taccess(AI->filename, 0) == 0 && !getBool(AI->hContact, "NeedNewAvatar", 0)) return GAIR_SUCCESS; - if ( IsOnline()) { + if (IsOnline()) { AsyncHttpRequest *pReq = new AsyncHttpRequest(); pReq->flags = NLHRF_NODUMP | NLHRF_REDIRECT; pReq->m_szUrl = szUrl; @@ -165,4 +165,4 @@ void CVkProto::SetAvatarUrl(MCONTACT hContact, CMString &tszUrl) AI.format = ProtoGetAvatarFormat(AI.filename); ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, (HANDLE)&AI, 0); } -} +} \ No newline at end of file diff --git a/protocols/VKontakte/src/vk_captcha.cpp b/protocols/VKontakte/src/vk_captcha.cpp index cd5a9eab89..d5a148fbc6 100644 --- a/protocols/VKontakte/src/vk_captcha.cpp +++ b/protocols/VKontakte/src/vk_captcha.cpp @@ -34,8 +34,8 @@ static INT_PTR CALLBACK CaptchaFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam switch (msg) { case WM_INITDIALOG: { TranslateDialogDefault(hwndDlg); - SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)Skin_GetIconByHandle( GetIconHandle(IDI_KEYS), TRUE)); - SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)Skin_GetIconByHandle( GetIconHandle(IDI_KEYS))); + SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)Skin_GetIconByHandle(GetIconHandle(IDI_KEYS), TRUE)); + SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)Skin_GetIconByHandle(GetIconHandle(IDI_KEYS))); params = (CAPTCHA_FORM_PARAMS*)lParam; SetDlgItemText(hwndDlg, IDC_INSTRUCTION, TranslateT("Enter the text you see")); @@ -44,7 +44,7 @@ static INT_PTR CALLBACK CaptchaFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam return TRUE; } case WM_CTLCOLORSTATIC: - switch(GetWindowLongPtr((HWND)lParam, GWL_ID)) { + switch (GetWindowLongPtr((HWND)lParam, GWL_ID)) { case IDC_WHITERECT: case IDC_INSTRUCTION: case IDC_TITLE: @@ -149,8 +149,8 @@ bool CVkProto::ApplyCaptcha(AsyncHttpRequest *pReq, JSONNODE *pErrorNode) if (!IsOnline()) return false; - char *szUrl = NEWSTR_ALLOCA( _T2A( json_as_string( json_get(pErrorNode, "captcha_img")))); - char *szSid = NEWSTR_ALLOCA( _T2A( json_as_string( json_get(pErrorNode, "captcha_sid")))); + char *szUrl = NEWSTR_ALLOCA(_T2A(json_as_string(json_get(pErrorNode, "captcha_img")))); + char *szSid = NEWSTR_ALLOCA(_T2A(json_as_string(json_get(pErrorNode, "captcha_sid")))); if (szUrl == NULL || szSid == NULL) return false; diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp index 575feedb72..457f475218 100644 --- a/protocols/VKontakte/src/vk_chats.cpp +++ b/protocols/VKontakte/src/vk_chats.cpp @@ -79,7 +79,7 @@ CVkChatInfo* CVkProto::AppendChat(int id, JSONNODE *pDlg) setDword(gci.hContact, "vk_chat_id", id); db_unset(gci.hContact, m_szModuleName, "off"); - if (json_as_int(json_get(pDlg, "left")) == 1){ + if (json_as_int(json_get(pDlg, "left")) == 1) { setByte(gci.hContact, "off", 1); m_chats.remove(c); return NULL; @@ -115,7 +115,7 @@ void CVkProto::RetrieveChatInfo(CVkChatInfo *cc) return; Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.json", true, &CVkProto::OnReceiveChatInfo) << CHAR_PARAM("code", szQuery) - << VER_API )->pUserInfo = cc; + << VER_API)->pUserInfo = cc; } void CVkProto::OnReceiveChatInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) @@ -145,7 +145,7 @@ void CVkProto::OnReceiveChatInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe gce.ptszText = tszTitle; CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce); } - if ((json_as_int(json_get(info, "left")) == 1) || (json_as_int(json_get(info, "kicked")) == 1)){ + if ((json_as_int(json_get(info, "left")) == 1) || (json_as_int(json_get(info, "kicked")) == 1)) { setByte(cc->m_hContact, "kicked", (int)true); LeaveChat(cc->m_chatid); return; @@ -215,7 +215,7 @@ void CVkProto::OnReceiveChatInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe if (msgs != NULL) { int numMessages = json_as_int(json_get(msgs, "count")); msgs = json_get(msgs, "items"); - if (msgs != NULL){ + if (msgs != NULL) { for (int i = 0; i < numMessages; i++) { JSONNODE *pMsg = json_at(msgs, i); if (pMsg == NULL) @@ -561,7 +561,7 @@ void CVkProto::KickFromChat(int chat_id, int user_id, JSONNODE* pMsg) MCONTACT chatContact = FindChat(chat_id); bool off = false; if (chatContact) - if(getBool(chatContact, "off", false)) + if (getBool(chatContact, "off", false)) return; if (user_id == m_myUserId) @@ -817,4 +817,4 @@ void CVkProto::OnCreateNewChat(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) int chat_id = json_as_int(pResponse); if (chat_id != NULL) AppendChat(chat_id, NULL); -} +} \ No newline at end of file diff --git a/protocols/VKontakte/src/vk_files.cpp b/protocols/VKontakte/src/vk_files.cpp index 8dd2add311..23c6c9451e 100644 --- a/protocols/VKontakte/src/vk_files.cpp +++ b/protocols/VKontakte/src/vk_files.cpp @@ -53,15 +53,15 @@ CVkFileUploadParam::VKFileType CVkFileUploadParam::GetType() fn.AppendFormat("%s%s", mir_utf8encodeT(FNAME), mir_utf8encodeT(EXT)); fname = mir_strdup(fn.GetBuffer()); - if (tlstrstr(img, EXT)){ + if (tlstrstr(img, EXT)) { filetype = CVkFileUploadParam::typeImg; atr = mir_strdup("photo"); } - else if (tlstrstr(audio, EXT)){ + else if (tlstrstr(audio, EXT)) { filetype = CVkFileUploadParam::typeAudio; atr = mir_strdup("file"); } - else{ + else { filetype = CVkFileUploadParam::typeDoc; atr = mir_strdup("file"); } @@ -84,7 +84,7 @@ void CVkProto::SendFileFiled(CVkFileUploadParam *fup, TCHAR *reason) debugLog(_T("CVkProto::SendFileFiled <%s> Error code <%d>"), reason, fup->iErrorCode); ProtoBroadcastAck(fup->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, (HANDLE)fup, 0); CMString tszError; - switch (fup->iErrorCode){ + switch (fup->iErrorCode) { case VKERR_COULD_NOT_SAVE_FILE: tszError = TranslateT("Couldn't save file"); break; @@ -120,17 +120,17 @@ void CVkProto::SendFileThread(void *p) { CVkFileUploadParam *fup = (CVkFileUploadParam *)p; debugLog(_T("CVkProto::SendFileThread %d %s"), fup->GetType(), fup->fileName()); - if (!IsOnline()){ + if (!IsOnline()) { SendFileFiled(fup, _T("NotOnline")); return; } - if (!fup->IsAccess()){ + if (!fup->IsAccess()) { SendFileFiled(fup, _T("FileIsNotAccess")); return; } AsyncHttpRequest *pReq; - switch (fup->GetType()){ + switch (fup->GetType()) { case CVkFileUploadParam::typeImg: pReq = new AsyncHttpRequest(this, REQUEST_GET, "/method/photos.getMessagesUploadServer.json", true, &CVkProto::OnReciveUploadServer) << VER_API; @@ -154,32 +154,32 @@ void CVkProto::SendFileThread(void *p) void CVkProto::OnReciveUploadServer(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) { CVkFileUploadParam *fup = (CVkFileUploadParam *)pReq->pUserInfo; - if (!IsOnline()){ + if (!IsOnline()) { SendFileFiled(fup, _T("NotOnline")); return; } debugLogA("CVkProto::OnReciveUploadServer %d", reply->resultCode); - if (reply->resultCode != 200){ + if (reply->resultCode != 200) { SendFileFiled(fup, _T("NotUploadServer")); return; } JSONROOT pRoot; JSONNODE *pResponse = CheckJsonResponse(pReq, reply, pRoot); - if (pResponse == NULL){ + if (pResponse == NULL) { SendFileFiled(fup); return; } CMStringA uri = json_as_string(json_get(pResponse, "upload_url")); - if (uri.IsEmpty()){ + if (uri.IsEmpty()) { SendFileFiled(fup); return; } FILE *pFile = _tfopen(fup->FileName, _T("rb")); - if (pFile == NULL){ + if (pFile == NULL) { SendFileFiled(fup, _T("ErrorOpenFile")); return; } @@ -238,13 +238,13 @@ void CVkProto::OnReciveUploadServer(NETLIBHTTPREQUEST *reply, AsyncHttpRequest * void CVkProto::OnReciveUpload(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) { CVkFileUploadParam *fup = (CVkFileUploadParam *)pReq->pUserInfo; - if (!IsOnline()){ + if (!IsOnline()) { SendFileFiled(fup, _T("NotOnline")); return; } debugLogA("CVkProto::OnReciveUploadServer %d", reply->resultCode); - if (reply->resultCode != 200){ + if (reply->resultCode != 200) { SendFileFiled(fup); return; } @@ -258,10 +258,10 @@ void CVkProto::OnReciveUpload(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) AsyncHttpRequest *pUploadReq; - switch (fup->GetType()){ + switch (fup->GetType()) { case CVkFileUploadParam::typeImg: upload = json_as_string(json_get(pRoot, "photo")); - if (upload == _T("[]")){ + if (upload == _T("[]")) { SendFileFiled(fup, _T("NotUpload Photo")); } pUploadReq = new AsyncHttpRequest(this, REQUEST_GET, "/method/photos.saveMessagesPhoto.json", true, &CVkProto::OnReciveUploadFile) @@ -272,7 +272,7 @@ void CVkProto::OnReciveUpload(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) break; case CVkFileUploadParam::typeAudio: upload = json_as_string(json_get(pRoot, "audio")); - if (upload == _T("[]")){ + if (upload == _T("[]")) { SendFileFiled(fup, _T("NotUpload Audio")); return; } @@ -284,7 +284,7 @@ void CVkProto::OnReciveUpload(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) break; case CVkFileUploadParam::typeDoc: upload = json_as_string(json_get(pRoot, "file")); - if (upload.IsEmpty()){ + if (upload.IsEmpty()) { SendFileFiled(fup, _T("NotUpload Doc")); return; } @@ -305,34 +305,34 @@ void CVkProto::OnReciveUpload(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) void CVkProto::OnReciveUploadFile(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) { CVkFileUploadParam *fup = (CVkFileUploadParam *)pReq->pUserInfo; - if (!IsOnline()){ + if (!IsOnline()) { SendFileFiled(fup, _T("NotOnline")); return; } debugLogA("CVkProto::OnReciveUploadFile %d", reply->resultCode); - if (reply->resultCode != 200){ + if (reply->resultCode != 200) { SendFileFiled(fup); return; } JSONROOT pRoot; JSONNODE *pResponse = CheckJsonResponse(pReq, reply, pRoot); - if (pResponse == NULL){ + if (pResponse == NULL) { SendFileFiled(fup); return; } int id = json_as_int(json_get(fup->GetType() == CVkFileUploadParam::typeAudio ? pResponse : json_at(pResponse, 0), "id")); int owner_id = json_as_int(json_get(fup->GetType() == CVkFileUploadParam::typeAudio ? pResponse : json_at(pResponse, 0), "owner_id")); - if ((id == 0) || (owner_id == 0)){ + if ((id == 0) || (owner_id == 0)) { SendFileFiled(fup); return; } CMString Attachment; - switch (fup->GetType()){ + switch (fup->GetType()) { case CVkFileUploadParam::typeImg: Attachment.AppendFormat(_T("photo%d_%d"), owner_id, id); break; @@ -348,7 +348,7 @@ void CVkProto::OnReciveUploadFile(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pR } LONG userID = getDword(fup->hContact, "ID", -1); - if (userID == -1){ + if (userID == -1) { SendFileFiled(fup); return; } diff --git a/protocols/VKontakte/src/vk_history.cpp b/protocols/VKontakte/src/vk_history.cpp index 5b95d2e8f3..2ce58429ee 100644 --- a/protocols/VKontakte/src/vk_history.cpp +++ b/protocols/VKontakte/src/vk_history.cpp @@ -145,7 +145,7 @@ void CVkProto::GetHistoryDlg(MCONTACT hContact, int iLastMsg) { debugLogA("CVkProto::GetHistoryDlg %d", iLastMsg); int lastmsgid = -1; - switch (m_iSyncHistoryMetod){ + switch (m_iSyncHistoryMetod) { case syncAuto: lastmsgid = getDword(hContact, "lastmsgid", -1); if (lastmsgid == -1 || !IsOnline()) { diff --git a/protocols/VKontakte/src/vk_options.cpp b/protocols/VKontakte/src/vk_options.cpp index 00885964d4..57882073d7 100644 --- a/protocols/VKontakte/src/vk_options.cpp +++ b/protocols/VKontakte/src/vk_options.cpp @@ -29,7 +29,7 @@ INT_PTR CALLBACK VKAccountProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lP TranslateDialogDefault(hwndDlg); ppro = (CVkProto*)lParam; - SetWindowLongPtr( hwndDlg, GWLP_USERDATA, lParam ); + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)Skin_GetIconByHandle(ppro->m_hProtoIcon, 1)); SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)Skin_GetIconByHandle(ppro->m_hProtoIcon)); @@ -67,7 +67,7 @@ INT_PTR CALLBACK VKAccountProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lP ppro->setTString("Login", str); GetDlgItemText(hwndDlg, IDC_PASSWORD, str, SIZEOF(str)); - ptrA szRawPasswd( mir_utf8encodeT(str)); + ptrA szRawPasswd(mir_utf8encodeT(str)); if (szRawPasswd != NULL) ppro->setString("Password", szRawPasswd); } diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index 37d9016602..38a9e274bb 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -366,7 +366,7 @@ int CVkProto::OnPreShutdown(WPARAM wParam, LPARAM lParam) DWORD_PTR CVkProto::GetCaps(int type, MCONTACT hContact) { - switch(type) { + 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; @@ -451,7 +451,7 @@ int CVkProto::SendMsg(MCONTACT hContact, int flags, const char *msg) if (!m_bServerDelivery) ForkThread(&CVkProto::SendMsgAck, new TFakeAckParams(hContact, msgId)); - if (retMsg){ + if (retMsg) { int _flags = flags | PREF_UTF; Sleep(330); SendMsg(hContact, _flags, retMsg); @@ -480,7 +480,7 @@ void CVkProto::OnSendMessage(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) } } - if (param->iMsgID == -1){ + if (param->iMsgID == -1) { CVkFileUploadParam *fup = (CVkFileUploadParam *)param->iCount; ProtoBroadcastAck(fup->hContact, ACKTYPE_FILE, iResult, (HANDLE)fup, 0); delete fup; @@ -532,7 +532,7 @@ int CVkProto::SetStatus(int iNewStatus) int CVkProto::OnEvent(PROTOEVENTTYPE event, WPARAM wParam, LPARAM lParam) { - switch(event) { + switch (event) { case EV_PROTO_ONLOAD: return OnModulesLoaded(wParam,lParam); @@ -587,13 +587,13 @@ void CVkProto::OnReceiveAuthRequest(NETLIBHTTPREQUEST *reply, AsyncHttpRequest * { debugLogA("CVkProto::OnReceiveAuthRequest %d", reply->resultCode); CVkSendMsgParam *param = (CVkSendMsgParam*)pReq->pUserInfo; - if (reply->resultCode == 200){ + if (reply->resultCode == 200) { JSONROOT pRoot; JSONNODE *pResponse = CheckJsonResponse(pReq, reply, pRoot); if (pResponse != NULL) { int iRet = json_as_int(pResponse); setByte(param->hContact, "Auth", 0); - if (iRet == 2){ + if (iRet == 2) { CMString msg, msgformat = TranslateT("User %s added as friend"), tszNick = db_get_tsa(param->hContact, m_szModuleName, "Nick"); @@ -603,8 +603,8 @@ void CVkProto::OnReceiveAuthRequest(NETLIBHTTPREQUEST *reply, AsyncHttpRequest * MsgPopup(param->hContact, msg.GetBuffer(), tszNick.GetBuffer()); } } - else{ - switch (param->iCount){ + else { + switch (param->iCount) { case VKERR_HIMSELF_AS_FRIEND: MsgPopup(param->hContact, TranslateT("You cannot add yourself as friend"), TranslateT("Error"), true); break; diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index 78147f7eca..168de24f92 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -500,4 +500,4 @@ private: void SetChatStatus(MCONTACT hContact, int iStatus); CVkChatInfo* GetChatById(LPCTSTR ptszId); INT_PTR __cdecl SvcCreateChat(WPARAM, LPARAM); -}; +}; \ No newline at end of file diff --git a/protocols/VKontakte/src/vk_queue.cpp b/protocols/VKontakte/src/vk_queue.cpp index 0740c14ce6..737779411b 100644 --- a/protocols/VKontakte/src/vk_queue.cpp +++ b/protocols/VKontakte/src/vk_queue.cpp @@ -58,13 +58,13 @@ void CVkProto::ExecuteRequest(AsyncHttpRequest *pReq) else if (pReq->bIsMainConn) { if (m_iStatus >= ID_STATUS_CONNECTING && m_iStatus < ID_STATUS_CONNECTING + MAX_CONNECT_RETRIES) ConnectionFailed(LOGINERR_NONETWORK); - else if (pReq->m_iRetry && !m_bTerminated){ + else if (pReq->m_iRetry && !m_bTerminated) { pReq->bNeedsRestart = true; Sleep(1000); //Pause for fix err pReq->m_iRetry--; debugLogA("CVkProto::ExecuteRequest restarting retry = %d", MAX_RETRIES - pReq->m_iRetry); } - else{ + else { debugLogA("CVkProto::ExecuteRequest ShutdownSession"); ShutdownSession(); } @@ -110,14 +110,14 @@ void CVkProto::WorkerThread(void*) << VER_API)->m_bApiReq = false;; } - while(true) { + while (true) { WaitForSingleObject(m_evRequestsQueue, 1000); if (m_bTerminated) break; AsyncHttpRequest *pReq; bool need_sleep = false; - while(true) { + while (true) { { mir_cslock lck(m_csRequestsQueue); if (m_arRequestsQueue.getCount() == 0) diff --git a/protocols/VKontakte/src/vk_search.cpp b/protocols/VKontakte/src/vk_search.cpp index 2acfaedd1e..ee756ada51 100644 --- a/protocols/VKontakte/src/vk_search.cpp +++ b/protocols/VKontakte/src/vk_search.cpp @@ -93,8 +93,8 @@ void CVkProto::OnSearch(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) { PROTOSEARCHBYNAME *pParam = (PROTOSEARCHBYNAME *)pReq->pUserInfo; debugLogA("CVkProto::OnSearch %d", reply->resultCode); - if (reply->resultCode != 200){ - if (pParam){ + if (reply->resultCode != 200) { + if (pParam) { mir_free(pParam->pszFirstName); mir_free(pParam->pszLastName); mir_free(pParam->pszNick); @@ -106,8 +106,8 @@ void CVkProto::OnSearch(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) JSONROOT pRoot; JSONNODE *pResponse = CheckJsonResponse(pReq, reply, pRoot); - if (pResponse == NULL){ - if (pParam){ + if (pResponse == NULL) { + if (pParam) { mir_free(pParam->pszFirstName); mir_free(pParam->pszLastName); mir_free(pParam->pszNick); @@ -119,7 +119,7 @@ void CVkProto::OnSearch(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) int iCount = json_as_int(json_get(pResponse, "count")); JSONNODE *pItems = json_get(pResponse, "items"); - if (!pItems){ + if (!pItems) { pItems = pResponse; iCount = 1; } @@ -140,7 +140,7 @@ void CVkProto::OnSearch(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) psr.nick = mir_wstrdup(json_as_string(json_get(pRecord, "domain"))); bool filter = true; - if (pParam){ + if (pParam) { if (psr.firstName&&pParam->pszFirstName) filter = tlstrstr(psr.firstName, pParam->pszFirstName) && filter; if (psr.lastName&&pParam->pszLastName) @@ -154,7 +154,7 @@ void CVkProto::OnSearch(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) } ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)1, 0); - if (pParam){ + if (pParam) { mir_free(pParam->pszFirstName); mir_free(pParam->pszLastName); mir_free(pParam->pszNick); @@ -165,20 +165,20 @@ void CVkProto::OnSearch(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) void CVkProto::OnSearchByMail(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) { debugLogA("CVkProto::OnSearch %d", reply->resultCode); - if (reply->resultCode != 200){ + if (reply->resultCode != 200) { ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)1, 0); return; } JSONROOT pRoot; JSONNODE *pResponse = CheckJsonResponse(pReq, reply, pRoot); - if (pResponse == NULL){ + if (pResponse == NULL) { ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)1, 0); return; } JSONNODE *pItems = json_get(pResponse, "found"); - if (!pItems){ + if (!pItems) { ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)1, 0); return; } diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index de191a61e3..b8be081719 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -51,7 +51,7 @@ void CVkProto::ConnectionFailed(int iReason) static VOID CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD) { for (int i = 0; i < vk_Instances.getCount(); i++) - if (vk_Instances[i]->IsOnline()){ + if (vk_Instances[i]->IsOnline()) { vk_Instances[i]->SetServerStatus(vk_Instances[i]->m_iDesiredStatus); vk_Instances[i]->RetrieveUsersInfo(true); } @@ -97,7 +97,7 @@ void CVkProto::OnLoggedOut() bool bOnline = false; for (int i = 0; i < vk_Instances.getCount(); i++) bOnline = bOnline || vk_Instances[i]->IsOnline(); - if(!bOnline) + if (!bOnline) CallFunctionAsync(VKUnsetTimer, this); SetAllContactStatuses(ID_STATUS_OFFLINE); m_chats.destroy(); @@ -184,7 +184,7 @@ void CVkProto::OnOAuthAuthorize(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq return; } - if (reply->resultCode != 200 || !strstr(reply->pData, "form method=\"post\"")){ // something went wrong + if (reply->resultCode != 200 || !strstr(reply->pData, "form method=\"post\"")) { // something went wrong ConnectionFailed(LOGINERR_NOSERVER); return; } @@ -197,7 +197,7 @@ void CVkProto::OnOAuthAuthorize(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq CMStringA szAction, szBody; bool bSuccess = AutoFillForm(reply->pData, szAction, szBody); if (!bSuccess || szAction.IsEmpty() || szBody.IsEmpty()) { - if (m_prevError){ + if (m_prevError) { ConnectionFailed(LOGINERR_NOSERVER); return; } @@ -250,7 +250,7 @@ void CVkProto::OnReceiveMyInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) MCONTACT CVkProto::SetContactInfo(JSONNODE* pItem, bool flag, bool self) { - if (pItem == NULL){ + if (pItem == NULL) { debugLogA("CVkProto::SetContactInfo pItem == NULL"); return INVALID_CONTACT_ID; } @@ -262,7 +262,7 @@ MCONTACT CVkProto::SetContactInfo(JSONNODE* pItem, bool flag, bool self) MCONTACT hContact = FindUser(userid, flag); - if (userid == m_myUserId){ + if (userid == m_myUserId) { if (hContact != NULL) if (self) hContact = NULL; @@ -308,7 +308,7 @@ MCONTACT CVkProto::SetContactInfo(JSONNODE* pItem, bool flag, bool self) } tszValue = json_as_string(json_get(pItem, "photo_100")); - if (!tszValue.IsEmpty()){ + if (!tszValue.IsEmpty()) { SetAvatarUrl(hContact, tszValue); ReloadAvatarInfo(hContact); } @@ -317,7 +317,7 @@ MCONTACT CVkProto::SetContactInfo(JSONNODE* pItem, bool flag, bool self) if (getWord(hContact, "Status", 0) != iNewStatus) setWord(hContact, "Status", iNewStatus); - if (iNewStatus == ID_STATUS_ONLINE){ + if (iNewStatus == ID_STATUS_ONLINE) { int online_app = _ttoi(json_as_string(json_get(pItem, "online_app"))); int online_mobile = json_as_int(json_get(pItem, "online_mobile")); @@ -344,7 +344,7 @@ MCONTACT CVkProto::SetContactInfo(JSONNODE* pItem, bool flag, bool self) tszValue = json_as_string(json_get(pItem, "status")); CMString tszOldStatus(db_get_tsa(hContact, hContact ? "CList" : m_szModuleName, "StatusMsg")); - if (tszValue != tszOldStatus){ + if (tszValue != tszOldStatus) { db_set_ts(hContact, hContact ? "CList" : m_szModuleName, "StatusMsg", tszValue.GetBuffer()); db_unset(hContact, m_szModuleName, "AudioUrl"); JSONNODE* pAudio = json_get(pItem, "status_audio"); @@ -395,7 +395,7 @@ void CVkProto::RetrieveUsersInfo(bool flag) return; CMString userIDs, code; - for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)){ + for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { LONG userID = getDword(hContact, "ID", -1); if (userID == -1) continue; @@ -446,11 +446,11 @@ void CVkProto::OnReceiveUserInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe if (hContact) arContacts.remove((HANDLE)hContact); - for (int i = 0; i < arContacts.getCount(); i++){ + for (int i = 0; i < arContacts.getCount(); i++) { hContact = (MCONTACT)arContacts[i]; if (getDword(hContact, "ID", -1) == m_myUserId) continue; - if (getWord(hContact, "Status", 0) != ID_STATUS_OFFLINE){ + if (getWord(hContact, "Status", 0) != ID_STATUS_OFFLINE) { setWord(hContact, "Status", ID_STATUS_OFFLINE); SetMirVer(hContact, -1); } @@ -472,7 +472,7 @@ void CVkProto::OnReceiveUserInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe if (userid == 0) break; hContact = FindUser(userid, true); - if (!getBool(hContact, "ReqAuth", false)){ + if (!getBool(hContact, "ReqAuth", false)) { RetrieveUserInfo(userid); setByte(hContact, "ReqAuth", 1); Sleep(1000); @@ -506,7 +506,7 @@ void CVkProto::OnReceiveFriends(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq bool bCleanContacts = getBool("AutoClean", false); LIST arContacts(10, PtrKeySortT); - for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)){ + for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { if (!isChatRoom(hContact)) setByte(hContact, "Auth", 1); db_unset(hContact, m_szModuleName, "ReqAuth"); @@ -633,7 +633,7 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe char szMid[40]; _itoa(mid, szMid, 10); - if (m_iMarkMessageReadOn == markOnReceive || chat_id != 0){ + if (m_iMarkMessageReadOn == markOnReceive || chat_id != 0) { if (!mids.IsEmpty()) mids.AppendChar(','); mids.Append(szMid); @@ -664,7 +664,7 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe recv.pCustomData = szMid; recv.cbCustomDataSize = (int)mir_strlen(szMid); Sleep(100); - if (!CheckMid(mid)){ + if (!CheckMid(mid)) { ProtoChainRecvMsg(hContact, &recv); if (mid>getDword(hContact, "lastmsgid", -1)) setDword(hContact, "lastmsgid", mid); @@ -766,11 +766,11 @@ void CVkProto::OnReceivePollingInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest * m_pollingTs ? m_pollingTs : "", m_pollingKey ? m_pollingKey : "", m_pollingServer ? m_pollingServer : ""); - if (m_pollingTs != NULL && m_pollingKey != NULL && m_pollingServer != NULL){ + if (m_pollingTs != NULL && m_pollingKey != NULL && m_pollingServer != NULL) { debugLogA("CVkProto::OnReceivePollingInfo PollingThread starting..."); m_hPollingThread = ForkThreadEx(&CVkProto::PollingThread, NULL, NULL); } - else{ + else { debugLogA("CVkProto::OnReceivePollingInfo PollingThread not start"); m_pollingConn = NULL; ShutdownSession(); @@ -796,7 +796,7 @@ void CVkProto::PollUpdates(JSONNODE *pUpdates) uid = json_as_int(json_at(pChild, 3)); hContact = FindUser(uid); if (hContact != NULL) { - if (flags&VKFLAG_MSGUNREAD){ + if (flags & VKFLAG_MSGUNREAD) { setDword(hContact, "LastMsgReadTime", time(NULL)); SetSrmmReadStatus(hContact); } @@ -822,7 +822,7 @@ void CVkProto::PollUpdates(JSONNODE *pUpdates) case VKPOLL_READ_ALL_OUT: uid = json_as_int(json_at(pChild, 1)); hContact = FindUser(uid); - if (hContact != NULL){ + if (hContact != NULL) { setDword(hContact, "LastMsgReadTime", time(NULL)); SetSrmmReadStatus(hContact); if (m_bUserForceOnlineOnActivity) @@ -847,7 +847,7 @@ void CVkProto::PollUpdates(JSONNODE *pUpdates) case VKPOLL_USR_UTN: uid = json_as_int(json_at(pChild, 1)); hContact = FindUser(uid); - if (hContact != NULL){ + if (hContact != NULL) { ForkThread(&CVkProto::ContactTypingThread, (void *)hContact); if (m_bUserForceOnlineOnActivity) setWord(hContact, "Status", ID_STATUS_ONLINE); @@ -869,7 +869,7 @@ void CVkProto::PollUpdates(JSONNODE *pUpdates) int CVkProto::PollServer() { debugLogA("CVkProto::PollServer"); - if (!IsOnline()){ + if (!IsOnline()) { debugLogA("CVkProto::PollServer is dead (not online)"); m_pollingConn = NULL; ShutdownSession(); @@ -892,7 +892,7 @@ int CVkProto::PollServer() while ((reply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)&req)) == NULL) { debugLogA("CVkProto::PollServer is dead"); m_pollingConn = NULL; - if (iPollConnRetry && !m_bTerminated){ + if (iPollConnRetry && !m_bTerminated) { iPollConnRetry--; debugLogA("CVkProto::PollServer restarting %d", MAX_RETRIES - iPollConnRetry); Sleep(1000); @@ -964,8 +964,9 @@ void CVkProto::OnReceiveStatus(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) JSONNODE *pResponse = CheckJsonResponse(pReq, reply, pRoot); if (pResponse == NULL) return; + JSONNODE *pAudio = json_get(pResponse, "audio"); - if (pAudio == NULL){ + if (pAudio == NULL) { CMString StatusText = json_as_string(json_get(pResponse, "text")); if (StatusText.GetBuffer()[0] != TCHAR(9835)) setTString("OldStatusMsg", StatusText.GetBuffer()); @@ -991,33 +992,33 @@ void CVkProto::RetrieveStatusMusic(const CMString &StatusMsg) CMString code; CMString oldStatusMsg = db_get_tsa(0, m_szModuleName, "OldStatusMsg"); - if (StatusMsg.IsEmpty()){ + if (StatusMsg.IsEmpty()) { if (m_iMusicSendMetod == sendBroadcastOnly) code = "API.audio.setBroadcast();return null;"; - else{ + else { CMString codeformat("API.status.set({text:\"%s\"});return null;"); code.AppendFormat(codeformat, oldStatusMsg); } } else { - if (m_iMusicSendMetod == sendBroadcastOnly){ + if (m_iMusicSendMetod == sendBroadcastOnly) { CMString codeformat("var StatusMsg=\"%s\";var CntLmt=100;var OldMsg=API.status.get();" "var Tracks=API.audio.search({\"q\":StatusMsg,\"count\":CntLmt,\"search_own\":1});" "var Cnt=Tracks.count;if(Cnt>CntLmt){Cnt=CntLmt;}" "if(Cnt==0){API.audio.setBroadcast();}" "else{var i=0;var j=0;var Track=\" \";" - "while (iCntLmt){Cnt=CntLmt;}" @@ -1078,7 +1079,7 @@ INT_PTR __cdecl CVkProto::SvcDeleteFriend(WPARAM hContact, LPARAM flag) CMString formatstr = TranslateT("Are you sure to delete %s from your friend list?"), tszNick = db_get_tsa(hContact, m_szModuleName, "Nick"), ptszMsg; - if (flag == 0){ + if (flag == 0) { ptszMsg.AppendFormat(formatstr, tszNick.IsEmpty() ? TranslateT("(Unknown contact)") : tszNick); if (IDNO == MessageBox(NULL, ptszMsg.GetBuffer(), TranslateT("Attention!"), MB_ICONWARNING | MB_YESNO)) return 1; @@ -1094,7 +1095,7 @@ void CVkProto::OnReceiveDeleteFriend(NETLIBHTTPREQUEST* reply, AsyncHttpRequest* { debugLogA("CVkProto::OnReceiveDeleteFriend %d", reply->resultCode); CVkSendMsgParam *param = (CVkSendMsgParam*)pReq->pUserInfo; - if (reply->resultCode == 200){ + if (reply->resultCode == 200) { JSONROOT pRoot; JSONNODE *pResponse = CheckJsonResponse(pReq, reply, pRoot); if (pResponse != NULL) { @@ -1103,7 +1104,7 @@ void CVkProto::OnReceiveDeleteFriend(NETLIBHTTPREQUEST* reply, AsyncHttpRequest* tszNick = TranslateT("(Unknown contact)"); CMString msgformat, msg; int iRet = json_as_int(pResponse); - switch (iRet){ + switch (iRet) { case 1: msgformat = TranslateT("User %s was deleted from your friend list"); break; @@ -1134,26 +1135,26 @@ INT_PTR __cdecl CVkProto::SvcBanUser(WPARAM hContact, LPARAM) code.AppendFormat("var userID=\"%d\";API.account.banUser({\"user_id\":userID});", userID); CMString tszVarWarning; - if (m_bReportAbuse){ + if (m_bReportAbuse) { debugLogA("CVkProto::SvcBanUser m_bReportAbuse = true"); code += "API.users.report({\"user_id\":userID,type:\"spam\"});"; tszVarWarning = TranslateT(" report abuse on him/her"); } - if (m_bClearServerHistory){ + if (m_bClearServerHistory) { debugLogA("CVkProto::SvcBanUser m_bClearServerHistory = true"); code += "API.messages.deleteDialog({\"user_id\":userID,count:10000});"; if (!tszVarWarning.IsEmpty()) tszVarWarning.AppendChar(L','); tszVarWarning += TranslateT(" clear server history with him/her"); } - if (m_bRemoveFromFrendlist){ + if (m_bRemoveFromFrendlist) { debugLogA("CVkProto::SvcBanUser m_bRemoveFromFrendlist = true"); code += "API.friends.delete({\"user_id\":userID});"; if (!tszVarWarning.IsEmpty()) tszVarWarning.AppendChar(L','); tszVarWarning += TranslateT(" remove him/her from your friend list"); } - if (m_bRemoveFromClist){ + if (m_bRemoveFromClist) { debugLogA("CVkProto::SvcBanUser m_bRemoveFromClist = true"); if (!tszVarWarning.IsEmpty()) tszVarWarning.AppendChar(L','); @@ -1286,8 +1287,8 @@ CMString CVkProto::GetAttachmentDescr(JSONNODE *pAttachments) continue; ptrT ptszTitle(json_as_string(json_get(pVideo, "title"))); - int vid = json_as_int(json_get(pVideo, "id")); - int ownerID = json_as_int(json_get(pVideo, "owner_id")); + int vid = json_as_int(json_get(pVideo, "id")); + int ownerID = json_as_int(json_get(pVideo, "owner_id")); res.AppendFormat(_T("%s: %s - http://vk.com/video%d_%d"), TranslateT("Video"), ptszTitle, ownerID, vid); } else if (!mir_tstrcmp(ptszType, _T("doc"))) { @@ -1305,8 +1306,8 @@ CMString CVkProto::GetAttachmentDescr(JSONNODE *pAttachments) continue; ptrT ptszText(json_as_string(json_get(pWall, "text"))); - int id = json_as_int(json_get(pWall, "id")); - int fromID = json_as_int(json_get(pWall, "from_id")); + int id = json_as_int(json_get(pWall, "id")); + int fromID = json_as_int(json_get(pWall, "from_id")); res.AppendFormat(_T("%s: %s - http://vk.com/wall%d_%d"), TranslateT("Wall post"), ptszText ? ptszText : _T(" "), fromID, id); } else if (!mir_tstrcmp(ptszType, _T("sticker"))) { @@ -1315,8 +1316,8 @@ CMString CVkProto::GetAttachmentDescr(JSONNODE *pAttachments) continue; res.Empty(); // sticker is not really an attachment, so we don't want all that heading info - if (m_bStikersAsSmyles){ - int id = json_as_int(json_get(pSticker, "id")); + if (m_bStikersAsSmyles) { + int id = json_as_int(json_get(pSticker, "id")); res.AppendFormat(_T("[sticker:%d]"), id); } else { -- cgit v1.2.3