summaryrefslogtreecommitdiff
path: root/protocols/Tlen
diff options
context:
space:
mode:
authorGoraf <22941576+Goraf@users.noreply.github.com>2017-11-13 15:03:31 +0100
committerGoraf <22941576+Goraf@users.noreply.github.com>2017-11-13 15:07:33 +0100
commita7c24ca48995cf2bf436156302f96b91bf135409 (patch)
tree953835509ff1b778833e78fd7b74b05e05e77c84 /protocols/Tlen
parent591ec17b1c99db7f120c22ca9fb20ae05fe78325 (diff)
Code modernize ...
* replace 0/NULL with nullptr [using clang-tidy]
Diffstat (limited to 'protocols/Tlen')
-rw-r--r--protocols/Tlen/src/tlen.cpp26
-rw-r--r--protocols/Tlen/src/tlen_advsearch.cpp16
-rw-r--r--protocols/Tlen/src/tlen_avatar.cpp66
-rw-r--r--protocols/Tlen/src/tlen_file.cpp116
-rw-r--r--protocols/Tlen/src/tlen_iq.cpp12
-rw-r--r--protocols/Tlen/src/tlen_iqid.cpp162
-rw-r--r--protocols/Tlen/src/tlen_list.cpp46
-rw-r--r--protocols/Tlen/src/tlen_misc.cpp14
-rw-r--r--protocols/Tlen/src/tlen_muc.cpp22
-rw-r--r--protocols/Tlen/src/tlen_opt.cpp10
-rw-r--r--protocols/Tlen/src/tlen_p2p_new.cpp46
-rw-r--r--protocols/Tlen/src/tlen_p2p_old.cpp90
-rw-r--r--protocols/Tlen/src/tlen_picture.cpp28
-rw-r--r--protocols/Tlen/src/tlen_presence.cpp60
-rw-r--r--protocols/Tlen/src/tlen_svc.cpp156
-rw-r--r--protocols/Tlen/src/tlen_thread.cpp250
-rw-r--r--protocols/Tlen/src/tlen_userinfo.cpp28
-rw-r--r--protocols/Tlen/src/tlen_util.cpp60
-rw-r--r--protocols/Tlen/src/tlen_voice.cpp100
-rw-r--r--protocols/Tlen/src/tlen_ws.cpp14
-rw-r--r--protocols/Tlen/src/tlen_xml.cpp114
21 files changed, 718 insertions, 718 deletions
diff --git a/protocols/Tlen/src/tlen.cpp b/protocols/Tlen/src/tlen.cpp
index db1a4bbfb1..452a641a0a 100644
--- a/protocols/Tlen/src/tlen.cpp
+++ b/protocols/Tlen/src/tlen.cpp
@@ -86,16 +86,16 @@ HANDLE GetIconHandle(int iconId)
if (iconList[i].defIconID == iconId)
return iconList[i].hIcolib;
- return NULL;
+ return nullptr;
}
HICON GetIcolibIcon(int iconId)
{
HANDLE handle = GetIconHandle(iconId);
- if (handle != NULL)
+ if (handle != nullptr)
return IcoLib_GetIconByHandle(handle);
- return NULL;
+ return nullptr;
}
void ReleaseIcolibIcon(HICON hIcon)
@@ -115,7 +115,7 @@ int TlenProtocol::PrebuildContactMenu(WPARAM hContact, LPARAM)
if (!db_get(hContact, m_szModuleName, "jid", &dbv)) {
TLEN_LIST_ITEM *item = TlenListGetItemPtr(this, LIST_ROSTER, dbv.pszVal);
db_free(&dbv);
- if (item != NULL) {
+ if (item != nullptr) {
Menu_ShowItem(hMenuContactRequestAuth, item->subscription == SUB_NONE || item->subscription == SUB_FROM);
Menu_ShowItem(hMenuContactGrantAuth, item->subscription == SUB_NONE || item->subscription == SUB_TO);
Menu_ShowItem(hMenuContactMUC, item->status != ID_STATUS_OFFLINE);
@@ -171,7 +171,7 @@ INT_PTR TlenProtocol::MenuHandleInbox(WPARAM, LPARAM)
NETLIBHTTPREQUEST req;
NETLIBHTTPHEADER headers[2];
NETLIBHTTPREQUEST *resp;
- char *login = NULL, *password = NULL;
+ char *login = nullptr, *password = nullptr;
char form[1024];
char cookie[1024];
if (!db_get(NULL, m_szModuleName, "LoginName", &dbv)) {
@@ -181,11 +181,11 @@ INT_PTR TlenProtocol::MenuHandleInbox(WPARAM, LPARAM)
if (db_get_b(NULL, m_szModuleName, "SavePassword", TRUE) == TRUE)
password = db_get_sa(NULL, m_szModuleName, "Password");
- else if (threadData != NULL && mir_strlen(threadData->password) > 0)
+ else if (threadData != nullptr && mir_strlen(threadData->password) > 0)
password = mir_strdup(threadData->password);
memset(&cookie, 0, sizeof(cookie));
- if (login != NULL && password != NULL) {
+ if (login != nullptr && password != nullptr) {
mir_snprintf(form, "username=%s&password=%s", login, password);
headers[0].szName = "Content-Type";
headers[0].szValue = "application/x-www-form-urlencoded";
@@ -199,16 +199,16 @@ INT_PTR TlenProtocol::MenuHandleInbox(WPARAM, LPARAM)
req.dataLength = (int)mir_strlen(form);
req.szUrl = "http://poczta.o2.pl/login.html";
resp = Netlib_HttpTransaction(m_hNetlibUser, &req);
- if (resp != NULL) {
+ if (resp != nullptr) {
if (resp->resultCode / 100 == 2 || resp->resultCode == 302) {
int i;
for (i = 0; i < resp->headersCount; i++) {
if (strcmpi(resp->headers[i].szName, "Set-Cookie") == 0) {
char *start = strstr(resp->headers[i].szValue, "ssid=");
- if (start != NULL) {
+ if (start != nullptr) {
char *end = strstr(resp->headers[i].szValue, ";");
start = start + 5;
- if (end == NULL) {
+ if (end == nullptr) {
end = resp->headers[i].szValue + mir_strlen(resp->headers[i].szValue);
}
strncpy(cookie, start, (end - start));
@@ -260,7 +260,7 @@ void TlenProtocol::initMenuItems()
mi.root = hMenuRoot = Menu_CreateRoot(MO_MAIN, m_tszUserName, -1999901009, GetIconHandle(IDI_TLEN));
mi.pszService = text;
- hMenuChats = NULL;
+ hMenuChats = nullptr;
// "Multi-User Conference"
SET_UID(mi,0x4984828, 0x2066, 0x43da, 0x87, 0x9e, 0x71, 0x23, 0xc6, 0xe2, 0x46, 0xd5);
@@ -282,7 +282,7 @@ void TlenProtocol::initMenuItems()
hMenuInbox = Menu_AddMainMenuItem(&mi);
// contact menu items
- mi.root = NULL;
+ mi.root = nullptr;
// "Send picture"
SET_UID(mi, 0x12c66fb1, 0x6e57, 0x4acd, 0x90, 0x16, 0xc, 0x83, 0xae, 0x16, 0xe3, 0x12);
@@ -349,7 +349,7 @@ extern "C" int __declspec(dllexport) Load(void)
DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &hMainThread, THREAD_SET_CONTEXT, FALSE, 0);
- srand((unsigned)time(NULL));
+ srand((unsigned)time(nullptr));
TlenRegisterIcons();
diff --git a/protocols/Tlen/src/tlen_advsearch.cpp b/protocols/Tlen/src/tlen_advsearch.cpp
index 62ee5cde41..a8fe15d789 100644
--- a/protocols/Tlen/src/tlen_advsearch.cpp
+++ b/protocols/Tlen/src/tlen_advsearch.cpp
@@ -32,7 +32,7 @@ static void InitComboBox(HWND hwndCombo, TLEN_FIELD_MAP *fieldMap)
SendMessage(hwndCombo, CB_SETITEMDATA, n, 0);
SendMessage(hwndCombo, CB_SETCURSEL, n, 0);
for (i=0;;i++) {
- if (fieldMap[i].name == NULL)
+ if (fieldMap[i].name == nullptr)
break;
n = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM) TranslateW(fieldMap[i].name));
SendMessage(hwndCombo, CB_SETITEMDATA, n, fieldMap[i].id);
@@ -59,12 +59,12 @@ static void FetchField(HWND hwndDlg, UINT idCtrl, char *fieldName, char **str, i
char text[512];
char *localFieldName, *localText;
- if (hwndDlg == NULL || fieldName == NULL || str == NULL || strSize == NULL)
+ if (hwndDlg == nullptr || fieldName == nullptr || str == nullptr || strSize == nullptr)
return;
GetDlgItemTextA(hwndDlg, idCtrl, text, _countof(text));
if (text[0]) {
- if ((localFieldName=TlenTextEncode(fieldName)) != NULL) {
- if ((localText=TlenTextEncode(text)) != NULL) {
+ if ((localFieldName=TlenTextEncode(fieldName)) != nullptr) {
+ if ((localText=TlenTextEncode(text)) != nullptr) {
TlenStringAppend(str, strSize, "<%s>%s</%s>", localFieldName, localText, localFieldName);
mir_free(localText);
}
@@ -78,11 +78,11 @@ static void FetchCombo(HWND hwndDlg, UINT idCtrl, char *fieldName, char **str, i
int value;
char *localFieldName;
- if (hwndDlg == NULL || fieldName == NULL || str == NULL || strSize == NULL)
+ if (hwndDlg == nullptr || fieldName == nullptr || str == nullptr || strSize == nullptr)
return;
value = (int) SendDlgItemMessage(hwndDlg, idCtrl, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, idCtrl, CB_GETCURSEL, 0, 0), 0);
if (value > 0) {
- if ((localFieldName=TlenTextEncode(fieldName)) != NULL) {
+ if ((localFieldName=TlenTextEncode(fieldName)) != nullptr) {
TlenStringAppend(str, strSize, "<%s>%d</%s>", localFieldName, value, localFieldName);
mir_free(localFieldName);
}
@@ -94,8 +94,8 @@ char *TlenAdvSearchCreateQuery(HWND hwndDlg, int)
char *str;
int strSize;
- if (hwndDlg == NULL) return NULL;
- str = NULL;
+ if (hwndDlg == nullptr) return nullptr;
+ str = nullptr;
FetchField(hwndDlg, IDC_FIRSTNAME, "first", &str, &strSize);
FetchField(hwndDlg, IDC_LASTNAME, "last", &str, &strSize);
FetchField(hwndDlg, IDC_NICK, "nick", &str, &strSize);
diff --git a/protocols/Tlen/src/tlen_avatar.cpp b/protocols/Tlen/src/tlen_avatar.cpp
index 3689a8bb75..998265a326 100644
--- a/protocols/Tlen/src/tlen_avatar.cpp
+++ b/protocols/Tlen/src/tlen_avatar.cpp
@@ -49,15 +49,15 @@ void TlenGetAvatarFileName(TlenProtocol *proto, TLEN_LIST_ITEM *item, wchar_t* p
int format = PA_FORMAT_PNG;
ptszDest[tPathLen++] = '\\';
- if (item != NULL)
+ if (item != nullptr)
format = item->avatarFormat;
- else if (proto->threadData != NULL)
+ else if (proto->threadData != nullptr)
format = proto->threadData->avatarFormat;
else
format = db_get_dw(NULL, proto->m_szModuleName, "AvatarFormat", PA_FORMAT_UNKNOWN);
const wchar_t *tszFileType = ProtoGetAvatarExtension(format);
- if (item != NULL)
+ if (item != nullptr)
mir_snwprintf(ptszDest + tPathLen, MAX_PATH - tPathLen, TEXT("%S%s"), ptrA(TlenSha1(item->jid)), tszFileType);
else
mir_snwprintf(ptszDest + tPathLen, MAX_PATH - tPathLen, TEXT("%S_avatar%s"), proto->m_szModuleName, tszFileType);
@@ -69,12 +69,12 @@ static void RemoveAvatar(TlenProtocol *proto, MCONTACT hContact)
if (hContact == NULL)
proto->threadData->avatarHash[0] = '\0';
- TlenGetAvatarFileName(proto, NULL, tFileName, _countof(tFileName) - 1);
+ TlenGetAvatarFileName(proto, nullptr, tFileName, _countof(tFileName) - 1);
DeleteFile(tFileName);
db_unset(hContact, "ContactPhoto", "File");
db_unset(hContact, proto->m_szModuleName, "AvatarHash");
db_unset(hContact, proto->m_szModuleName, "AvatarFormat");
- ProtoBroadcastAck(proto->m_szModuleName, NULL, ACKTYPE_AVATAR, ACKRESULT_STATUS, NULL, 0);
+ ProtoBroadcastAck(proto->m_szModuleName, NULL, ACKTYPE_AVATAR, ACKRESULT_STATUS, nullptr, 0);
}
static void SetAvatar(TlenProtocol *proto, MCONTACT hContact, TLEN_LIST_ITEM *item, char *data, int len, DWORD format)
@@ -92,7 +92,7 @@ static void SetAvatar(TlenProtocol *proto, MCONTACT hContact, TLEN_LIST_ITEM *it
mir_md5_finish(&ctx, (BYTE*)digest);
sprintf(md5, "%08x%08x%08x%08x", (int)htonl(digest[0]), (int)htonl(digest[1]), (int)htonl(digest[2]), (int)htonl(digest[3])); //!!!!!!!!!!!!!!
- if (item != NULL) {
+ if (item != nullptr) {
char *hash = item->avatarHash;
item->avatarFormat = format;
item->avatarHash = mir_strdup(md5);
@@ -105,7 +105,7 @@ static void SetAvatar(TlenProtocol *proto, MCONTACT hContact, TLEN_LIST_ITEM *it
TlenGetAvatarFileName(proto, item, filename, _countof(filename) - 1);
DeleteFile(filename);
FILE *out = _wfopen(filename, TEXT("wb"));
- if (out != NULL) {
+ if (out != nullptr) {
fwrite(data, len, 1, out);
fclose(out);
db_set_ws(hContact, "ContactPhoto", "File", filename);
@@ -119,36 +119,36 @@ static void SetAvatar(TlenProtocol *proto, MCONTACT hContact, TLEN_LIST_ITEM *it
proto->debugLogW(buffer);
return;
}
- ProtoBroadcastAck(proto->m_szModuleName, hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, NULL, 0);
+ ProtoBroadcastAck(proto->m_szModuleName, hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, nullptr, 0);
}
int TlenProcessAvatarNode(TlenProtocol *proto, XmlNode *avatarNode, TLEN_LIST_ITEM *item)
{
XmlNode *aNode;
- char *oldHash = NULL;
- char *md5 = NULL, *type = NULL;
+ char *oldHash = nullptr;
+ char *md5 = nullptr, *type = nullptr;
MCONTACT hContact = NULL;
- if (item != NULL)
+ if (item != nullptr)
if ((hContact = TlenHContactFromJID(proto, item->jid)) == NULL)
return 0;
- if (item == NULL)
+ if (item == nullptr)
oldHash = proto->threadData->avatarHash;
else
oldHash = item->avatarHash;
- if (avatarNode != NULL) {
+ if (avatarNode != nullptr) {
aNode = TlenXmlGetChild(avatarNode, "a");
- if (aNode != NULL) {
+ if (aNode != nullptr) {
type = TlenXmlGetAttrValue(aNode, "type");
md5 = TlenXmlGetAttrValue(aNode, "md5");
}
}
- if (md5 != NULL) {
+ if (md5 != nullptr) {
/* check contact's avatar hash - md5 */
- if (oldHash == NULL || mir_strcmp(oldHash, md5)) {
- if (item != NULL) {
+ if (oldHash == nullptr || mir_strcmp(oldHash, md5)) {
+ if (item != nullptr) {
item->newAvatarDownloading = TRUE;
}
TlenGetAvatar(proto, hContact);
@@ -157,9 +157,9 @@ int TlenProcessAvatarNode(TlenProtocol *proto, XmlNode *avatarNode, TLEN_LIST_IT
}
else {
/* remove avatar */
- if (oldHash != NULL) {
- if (item != NULL) {
- item->avatarHash = NULL;
+ if (oldHash != nullptr) {
+ if (item != nullptr) {
+ item->avatarHash = nullptr;
mir_free(oldHash);
item->newAvatarDownloading = FALSE;
}
@@ -237,10 +237,10 @@ struct TLENGETAVATARTHREADDATA
static void TlenGetAvatarThread(void *ptr)
{
- TLEN_LIST_ITEM *item = NULL;
+ TLEN_LIST_ITEM *item = nullptr;
TLENGETAVATARTHREADDATA *data = (TLENGETAVATARTHREADDATA *)ptr;
MCONTACT hContact = data->hContact;
- char *login = NULL;
+ char *login = nullptr;
if (hContact != NULL) {
char *jid = TlenJIDFromHContact(data->proto, hContact);
login = TlenNickFromJID(jid);
@@ -248,13 +248,13 @@ static void TlenGetAvatarThread(void *ptr)
mir_free(jid);
}
else {
- if (data->proto->threadData != NULL)
+ if (data->proto->threadData != nullptr)
login = mir_strdup(data->proto->threadData->username);
}
- if ((data->proto->threadData != NULL && hContact == NULL) || item != NULL) {
+ if ((data->proto->threadData != nullptr && hContact == NULL) || item != nullptr) {
DWORD format = PA_FORMAT_UNKNOWN;
- if (item != NULL)
+ if (item != nullptr)
item->newAvatarDownloading = TRUE;
char *request = replaceTokens(data->proto->threadData->tlenConfig.mailBase, data->proto->threadData->tlenConfig.avatarGet, login, data->proto->threadData->avatarToken, 0, 0);
@@ -264,14 +264,14 @@ static void TlenGetAvatarThread(void *ptr)
req.requestType = data->proto->threadData->tlenConfig.avatarGetMthd;
req.flags = 0;
req.headersCount = 0;
- req.headers = NULL;
+ req.headers = nullptr;
req.dataLength = 0;
req.szUrl = request;
NETLIBHTTPREQUEST *resp = Netlib_HttpTransaction(data->proto->m_hNetlibUser, &req);
- if (item != NULL)
+ if (item != nullptr)
item->newAvatarDownloading = FALSE;
- if (resp != NULL) {
+ if (resp != nullptr) {
if (resp->resultCode/100 == 2) {
if (resp->dataLength > 0) {
for (int i=0; i<resp->headersCount; i++ ) {
@@ -326,7 +326,7 @@ static void TlenRemoveAvatarRequestThread(void *ptr) {
mir_free(req->headers);
mir_free(req->pData);
mir_free(req);
- if (resp != NULL) {
+ if (resp != nullptr) {
Netlib_FreeHttpRequest(resp);
RemoveAvatar(data->proto, NULL);
}
@@ -344,7 +344,7 @@ struct TLENUPLOADAVATARTHREADDATA
boolean checkUploadAvatarResponse(TlenProtocol *proto, NETLIBHTTPREQUEST *resp)
{
- if (resp == NULL) {
+ if (resp == nullptr) {
proto->debugLogA("Error while setting avatar on Tlen account (no response)");
PUShowMessageT(TranslateT("Error while setting avatar on Tlen account (no response)"), SM_WARNING);
return false;
@@ -369,7 +369,7 @@ static void TlenUploadAvatarRequestThread(void *ptr)
NETLIBHTTPREQUEST *resp = Netlib_HttpTransaction(data->proto->m_hNetlibUser, req);
if (checkUploadAvatarResponse(data->proto, resp)) {
Netlib_FreeHttpRequest(resp);
- SetAvatar(data->proto, NULL, NULL, data->data, data->length, PA_FORMAT_PNG);
+ SetAvatar(data->proto, NULL, nullptr, data->data, data->length, PA_FORMAT_PNG);
}
mir_free(req->szUrl);
mir_free(req->headers);
@@ -381,7 +381,7 @@ static void TlenUploadAvatarRequestThread(void *ptr)
void TlenRemoveAvatar(TlenProtocol *proto)
{
- if (proto->threadData != NULL) {
+ if (proto->threadData != nullptr) {
TLENREMOVEAVATARTHREADDATA *data = (TLENREMOVEAVATARTHREADDATA *)mir_alloc(sizeof(TLENREMOVEAVATARTHREADDATA));
NETLIBHTTPREQUEST *req = (NETLIBHTTPREQUEST *)mir_alloc(sizeof(NETLIBHTTPREQUEST));
data->proto = proto;
@@ -399,7 +399,7 @@ void TlenUploadAvatar(TlenProtocol *proto, unsigned char *data, int dataLen, int
{
NETLIBHTTPHEADER *headers;
unsigned char *buffer;
- if (proto->threadData != NULL && dataLen > 0 && data != NULL) {
+ if (proto->threadData != nullptr && dataLen > 0 && data != nullptr) {
char *mpartHead = "--AaB03x\r\nContent-Disposition: form-data; name=\"filename\"; filename=\"plik.png\"\r\nContent-Type: image/png\r\n\r\n";
char *mpartTail = "\r\n--AaB03x--\r\n";
int size, sizeHead = (int)mir_strlen(mpartHead), sizeTail = (int)mir_strlen(mpartTail);
diff --git a/protocols/Tlen/src/tlen_file.cpp b/protocols/Tlen/src/tlen_file.cpp
index f97e6f1b19..d80baba3e6 100644
--- a/protocols/Tlen/src/tlen_file.cpp
+++ b/protocols/Tlen/src/tlen_file.cpp
@@ -31,10 +31,10 @@ static void TlenFileReceiveParse(TLEN_FILE_TRANSFER *ft)
{
int i;
char *p;
- TLEN_FILE_PACKET *rpacket = NULL, *packet;
+ TLEN_FILE_PACKET *rpacket = nullptr, *packet;
if (ft->state == FT_CONNECTING) {
rpacket = TlenP2PPacketReceive(ft->s);
- if (rpacket != NULL) {
+ if (rpacket != nullptr) {
p = rpacket->packet;
if (rpacket->type == TLEN_FILE_PACKET_FILE_LIST) { // list of files (length & name)
ft->fileCount = (int)(*((DWORD*)p));
@@ -53,7 +53,7 @@ static void TlenFileReceiveParse(TLEN_FILE_TRANSFER *ft)
p += 256;
}
- if ((packet = TlenP2PPacketCreate(3 * sizeof(DWORD))) == NULL)
+ if ((packet = TlenP2PPacketCreate(3 * sizeof(DWORD))) == nullptr)
ft->state = FT_ERROR;
else {
TlenP2PPacketSetType(packet, TLEN_FILE_PACKET_FILE_LIST_ACK);
@@ -69,7 +69,7 @@ static void TlenFileReceiveParse(TLEN_FILE_TRANSFER *ft)
}
else if (ft->state == FT_INITIALIZING) {
char *fullFileName;
- if ((packet = TlenP2PPacketCreate(3 * sizeof(DWORD))) != NULL) {
+ if ((packet = TlenP2PPacketCreate(3 * sizeof(DWORD))) != nullptr) {
TlenP2PPacketSetType(packet, TLEN_FILE_PACKET_FILE_REQUEST); // file request
TlenP2PPacketPackDword(packet, ft->currentFile);
TlenP2PPacketPackDword(packet, 0);
@@ -101,14 +101,14 @@ static void TlenFileReceiveParse(TLEN_FILE_TRANSFER *ft)
pfts.totalFiles = ft->fileCount;
pfts.currentFileNumber = ft->currentFile;
pfts.totalBytes = ft->allFileTotalSize;
- pfts.szWorkingDir = NULL;
+ pfts.szWorkingDir = nullptr;
pfts.szCurrentFile = ft->files[ft->currentFile];
pfts.currentFileSize = ft->filesSize[ft->currentFile];
pfts.currentFileTime = 0;
ft->proto->debugLogA("Receiving data...");
while (ft->state == FT_RECEIVING) {
rpacket = TlenP2PPacketReceive(ft->s);
- if (rpacket != NULL) {
+ if (rpacket != nullptr) {
p = rpacket->packet;
if (rpacket->type == TLEN_FILE_PACKET_FILE_DATA) { // file data
int writeSize;
@@ -148,7 +148,7 @@ static void TlenFileReceivingConnection(HNETLIBCONN hConnection, DWORD, void * p
{
TlenProtocol *proto = (TlenProtocol *)pExtra;
TLEN_FILE_TRANSFER *ft = TlenP2PEstablishIncomingConnection(proto, hConnection, LIST_FILE, TRUE);
- if (ft != NULL) {
+ if (ft != nullptr) {
HNETLIBCONN slisten = ft->s;
ft->s = hConnection;
ft->proto->debugLogA("Set ft->s to %d (saving %d)", hConnection, slisten);
@@ -166,7 +166,7 @@ static void TlenFileReceivingConnection(HNETLIBCONN hConnection, DWORD, void * p
if (ft->s != hConnection)
Netlib_CloseHandle(hConnection);
- if (ft->hFileEvent != NULL)
+ if (ft->hFileEvent != nullptr)
SetEvent(ft->hFileEvent);
}
else Netlib_CloseHandle(hConnection);
@@ -183,7 +183,7 @@ static void __cdecl TlenFileReceiveThread(void *arg)
nloc.wPort = ft->wPort;
ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_CONNECTING, ft, 0);
HNETLIBCONN s = Netlib_OpenConnection(ft->proto->m_hNetlibUser, &nloc);
- if (s != NULL) {
+ if (s != nullptr) {
ft->s = s;
ft->proto->debugLogA("Entering file receive loop");
TlenP2PEstablishOutgoingConnection(ft, TRUE);
@@ -192,16 +192,16 @@ static void __cdecl TlenFileReceiveThread(void *arg)
if (ft->s) {
Netlib_CloseHandle(s);
- ft->s = NULL;
+ ft->s = nullptr;
}
}
else {
ft->pfnNewConnectionV2 = TlenFileReceivingConnection;
ft->proto->debugLogA("Connection failed - receiving as server");
s = TlenP2PListen(ft);
- if (s != NULL) {
+ if (s != nullptr) {
ft->s = s;
- HANDLE hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+ HANDLE hEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
ft->hFileEvent = hEvent;
ft->currentFile = 0;
ft->state = FT_CONNECTING;
@@ -210,7 +210,7 @@ static void __cdecl TlenFileReceiveThread(void *arg)
mir_free(nick);
ft->proto->debugLogA("Waiting for the file to be received...");
WaitForSingleObject(hEvent, INFINITE);
- ft->hFileEvent = NULL;
+ ft->hFileEvent = nullptr;
CloseHandle(hEvent);
ft->proto->debugLogA("Finish all files");
Netlib_CloseHandle(s);
@@ -245,7 +245,7 @@ static void TlenFileSendParse(TLEN_FILE_TRANSFER *ft)
if (ft->state == FT_CONNECTING) {
char filename[256]; // Must be 256 (0x100)
- if ((packet = TlenP2PPacketCreate(sizeof(DWORD) + (ft->fileCount*(sizeof(filename) + sizeof(DWORD))))) != NULL) {
+ if ((packet = TlenP2PPacketCreate(sizeof(DWORD) + (ft->fileCount*(sizeof(filename) + sizeof(DWORD))))) != nullptr) {
// Must pause a bit, sending these two packets back to back
// will break the session because the receiver cannot take it :)
SleepEx(1000, TRUE);
@@ -258,7 +258,7 @@ static void TlenFileSendParse(TLEN_FILE_TRANSFER *ft)
// TlenP2PPacketPackDword(packet, statbuf.st_size);
TlenP2PPacketPackDword(packet, ft->filesSize[i]);
memset(filename, 0, sizeof(filename));
- if ((t = strrchr(ft->files[i], '\\')) != NULL)
+ if ((t = strrchr(ft->files[i], '\\')) != nullptr)
t++;
else
t = ft->files[i];
@@ -277,7 +277,7 @@ static void TlenFileSendParse(TLEN_FILE_TRANSFER *ft)
else if (ft->state == FT_INITIALIZING) { // FT_INITIALIZING
TLEN_FILE_PACKET *rpacket = TlenP2PPacketReceive(ft->s);
ft->proto->debugLogA("FT_INITIALIZING: recv %d", rpacket);
- if (rpacket == NULL) {
+ if (rpacket == nullptr) {
ft->state = FT_ERROR;
return;
}
@@ -319,12 +319,12 @@ static void TlenFileSendParse(TLEN_FILE_TRANSFER *ft)
pfts.totalFiles = ft->fileCount;
pfts.currentFileNumber = ft->currentFile;
pfts.totalBytes = ft->allFileTotalSize;
- pfts.szWorkingDir = NULL;
+ pfts.szWorkingDir = nullptr;
pfts.szCurrentFile = ft->files[ft->currentFile];
pfts.currentFileSize = ft->filesSize[ft->currentFile]; //statbuf.st_size;
pfts.currentFileTime = 0;
ft->fileReceivedBytes = 0;
- if ((packet = TlenP2PPacketCreate(2 * sizeof(DWORD) + 2048)) == NULL) {
+ if ((packet = TlenP2PPacketCreate(2 * sizeof(DWORD) + 2048)) == nullptr) {
ft->state = FT_ERROR;
}
else {
@@ -384,7 +384,7 @@ static void TlenFileSendingConnection(HNETLIBCONN hConnection, DWORD, void * pEx
TlenProtocol *proto = (TlenProtocol *)pExtra;
TLEN_FILE_TRANSFER *ft = TlenP2PEstablishIncomingConnection(proto, hConnection, LIST_FILE, TRUE);
- if (ft != NULL) {
+ if (ft != nullptr) {
slisten = ft->s;
ft->s = hConnection;
ft->proto->debugLogA("Set ft->s to %d (saving %d)", hConnection, slisten);
@@ -403,7 +403,7 @@ static void TlenFileSendingConnection(HNETLIBCONN hConnection, DWORD, void * pEx
if (ft->s != hConnection)
Netlib_CloseHandle(hConnection);
- if (ft->hFileEvent != NULL)
+ if (ft->hFileEvent != nullptr)
SetEvent(ft->hFileEvent);
}
else Netlib_CloseHandle(hConnection);
@@ -416,19 +416,19 @@ int TlenFileCancelAll(TlenProtocol *proto)
while ((i = TlenListFindNext(proto, LIST_FILE, 0)) >= 0) {
TLEN_LIST_ITEM *item = TlenListGetItemPtrFromIndex(proto, i);
- if (item != NULL) {
+ if (item != nullptr) {
TLEN_FILE_TRANSFER *ft = item->ft;
TlenListRemoveByIndex(proto, i);
- if (ft != NULL) {
+ if (ft != nullptr) {
if (ft->s) {
//ProtoBroadcastAck(m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0);
ft->proto->debugLogA("Closing ft->s = %d", ft->s);
ft->state = FT_ERROR;
Netlib_CloseHandle(ft->s);
- ft->s = NULL;
- if (ft->hFileEvent != NULL) {
+ ft->s = nullptr;
+ if (ft->hFileEvent != nullptr) {
hEvent = ft->hFileEvent;
- ft->hFileEvent = NULL;
+ ft->hFileEvent = nullptr;
SetEvent(hEvent);
}
}
@@ -451,13 +451,13 @@ static void __cdecl TlenFileSendingThread(void *arg)
ft->mode = FT_SEND;
ft->pfnNewConnectionV2 = TlenFileSendingConnection;
HNETLIBCONN s = TlenP2PListen(ft);
- if (s != NULL) {
+ if (s != nullptr) {
ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_CONNECTING, ft, 0);
ft->s = s;
//TlenLog("ft->s = %d", s);
//TlenLog("fileCount = %d", ft->fileCount);
- HANDLE hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+ HANDLE hEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
ft->hFileEvent = hEvent;
ft->currentFile = 0;
ft->state = FT_CONNECTING;
@@ -467,11 +467,11 @@ static void __cdecl TlenFileSendingThread(void *arg)
mir_free(nick);
ft->proto->debugLogA("Waiting for the file to be sent...");
WaitForSingleObject(hEvent, INFINITE);
- ft->hFileEvent = NULL;
+ ft->hFileEvent = nullptr;
CloseHandle(hEvent);
ft->proto->debugLogA("Finish all files");
Netlib_CloseHandle(s);
- ft->s = NULL;
+ ft->s = nullptr;
ft->proto->debugLogA("ft->s is NULL");
if (ft->state == FT_SWITCH) {
@@ -482,7 +482,7 @@ static void __cdecl TlenFileSendingThread(void *arg)
nloc.szHost = ft->hostName;
nloc.wPort = ft->wPort;
HNETLIBCONN hConn = Netlib_OpenConnection(ft->proto->m_hNetlibUser, &nloc);
- if (hConn != NULL) {
+ if (hConn != nullptr) {
ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_CONNECTING, ft, 0);
ft->s = hConn;
TlenP2PEstablishOutgoingConnection(ft, TRUE);
@@ -548,30 +548,30 @@ void TlenProcessF(XmlNode *node, ThreadData *info)
TLEN_LIST_ITEM *item;
// if (!node->name || mir_strcmp(node->name, "f")) return;
- if (info == NULL) return;
+ if (info == nullptr) return;
char *from = TlenXmlGetAttrValue(node, "f");
- if (from != NULL) {
- if (strchr(from, '@') == NULL)
+ if (from != nullptr) {
+ if (strchr(from, '@') == nullptr)
mir_snprintf(jid, "%s@%s", from, info->server);
else
strncpy_s(jid, from, _TRUNCATE);
char *e = TlenXmlGetAttrValue(node, "e");
- if (e != NULL) {
+ if (e != nullptr) {
if (!mir_strcmp(e, "1")) {
// FILE_RECV : e='1' : File transfer request
TLEN_FILE_TRANSFER *ft = TlenFileCreateFT(info->proto, jid);
ft->hContact = TlenHContactFromJID(info->proto, jid);
- if ((p = TlenXmlGetAttrValue(node, "i")) != NULL)
+ if ((p = TlenXmlGetAttrValue(node, "i")) != nullptr)
ft->iqId = mir_strdup(p);
szFilename[0] = '\0';
- if ((p = TlenXmlGetAttrValue(node, "c")) != NULL) {
+ if ((p = TlenXmlGetAttrValue(node, "c")) != nullptr) {
numFiles = atoi(p);
if (numFiles == 1) {
- if ((p = TlenXmlGetAttrValue(node, "n")) != NULL) {
+ if ((p = TlenXmlGetAttrValue(node, "n")) != nullptr) {
p = TlenTextDecode(p);
strncpy(szFilename, p, sizeof(szFilename) - 1);
mir_free(p);
@@ -582,12 +582,12 @@ void TlenProcessF(XmlNode *node, ThreadData *info)
mir_snprintf(szFilename, Translate("%d Files"), numFiles);
}
- if (szFilename[0] != '\0' && ft->iqId != NULL) {
+ if (szFilename[0] != '\0' && ft->iqId != nullptr) {
wchar_t* filenameT = mir_utf8decodeW((char*)szFilename);
PROTORECVFILET pre = { 0 };
pre.dwFlags = PRFF_UNICODE;
pre.fileCount = 1;
- pre.timestamp = time(NULL);
+ pre.timestamp = time(nullptr);
pre.descr.w = filenameT;
pre.files.w = &filenameT;
pre.lParam = (LPARAM)ft;
@@ -606,9 +606,9 @@ void TlenProcessF(XmlNode *node, ThreadData *info)
}
else if (!mir_strcmp(e, "3")) {
// FILE_RECV : e='3' : invalid transfer error
- if ((p = TlenXmlGetAttrValue(node, "i")) != NULL) {
- if ((item = TlenListGetItemPtr(info->proto, LIST_FILE, p)) != NULL) {
- if (item->ft != NULL) {
+ if ((p = TlenXmlGetAttrValue(node, "i")) != nullptr) {
+ if ((item = TlenListGetItemPtr(info->proto, LIST_FILE, p)) != nullptr) {
+ if (item->ft != nullptr) {
ProtoBroadcastAck(info->proto->m_szModuleName, item->ft->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, item->ft, 0);
info->proto->FileCancel(NULL, item->ft);
}
@@ -618,8 +618,8 @@ void TlenProcessF(XmlNode *node, ThreadData *info)
}
else if (!mir_strcmp(e, "4")) {
// FILE_SEND : e='4' : File sending request was denied by the remote client
- if ((p = TlenXmlGetAttrValue(node, "i")) != NULL) {
- if ((item = TlenListGetItemPtr(info->proto, LIST_FILE, p)) != NULL) {
+ if ((p = TlenXmlGetAttrValue(node, "i")) != nullptr) {
+ if ((item = TlenListGetItemPtr(info->proto, LIST_FILE, p)) != nullptr) {
if (!mir_strcmp(item->ft->jid, jid)) {
ProtoBroadcastAck(info->proto->m_szModuleName, item->ft->hContact, ACKTYPE_FILE, ACKRESULT_DENIED, item->ft, 0);
TlenListRemove(info->proto, LIST_FILE, p);
@@ -629,18 +629,18 @@ void TlenProcessF(XmlNode *node, ThreadData *info)
}
else if (!mir_strcmp(e, "5")) {
// FILE_SEND : e='5' : File sending request was accepted
- if ((p = TlenXmlGetAttrValue(node, "i")) != NULL)
- if ((item = TlenListGetItemPtr(info->proto, LIST_FILE, p)) != NULL)
+ if ((p = TlenXmlGetAttrValue(node, "i")) != nullptr)
+ if ((item = TlenListGetItemPtr(info->proto, LIST_FILE, p)) != nullptr)
if (!mir_strcmp(item->ft->jid, jid))
mir_forkthread(TlenFileSendingThread, item->ft);
}
else if (!mir_strcmp(e, "6")) {
// FILE_RECV : e='6' : IP and port information to connect to get file
- if ((p = TlenXmlGetAttrValue(node, "i")) != NULL) {
- if ((item = TlenListGetItemPtr(info->proto, LIST_FILE, p)) != NULL) {
- if ((p = TlenXmlGetAttrValue(node, "a")) != NULL) {
+ if ((p = TlenXmlGetAttrValue(node, "i")) != nullptr) {
+ if ((item = TlenListGetItemPtr(info->proto, LIST_FILE, p)) != nullptr) {
+ if ((p = TlenXmlGetAttrValue(node, "a")) != nullptr) {
item->ft->hostName = mir_strdup(p);
- if ((p = TlenXmlGetAttrValue(node, "p")) != NULL) {
+ if ((p = TlenXmlGetAttrValue(node, "p")) != nullptr) {
item->ft->wPort = atoi(p);
mir_forkthread(TlenFileReceiveThread, item->ft);
}
@@ -651,12 +651,12 @@ void TlenProcessF(XmlNode *node, ThreadData *info)
else if (!mir_strcmp(e, "7")) {
// FILE_RECV : e='7' : IP and port information to connect to send file
// in case the conection to the given server was not successful
- if ((p = TlenXmlGetAttrValue(node, "i")) != NULL) {
- if ((item = TlenListGetItemPtr(info->proto, LIST_FILE, p)) != NULL) {
- if ((p = TlenXmlGetAttrValue(node, "a")) != NULL) {
- if (item->ft->hostName != NULL) mir_free(item->ft->hostName);
+ if ((p = TlenXmlGetAttrValue(node, "i")) != nullptr) {
+ if ((item = TlenListGetItemPtr(info->proto, LIST_FILE, p)) != nullptr) {
+ if ((p = TlenXmlGetAttrValue(node, "a")) != nullptr) {
+ if (item->ft->hostName != nullptr) mir_free(item->ft->hostName);
item->ft->hostName = mir_strdup(p);
- if ((p = TlenXmlGetAttrValue(node, "p")) != NULL) {
+ if ((p = TlenXmlGetAttrValue(node, "p")) != nullptr) {
item->ft->wPort = atoi(p);
item->ft->state = FT_SWITCH;
SetEvent(item->ft->hFileEvent);
@@ -667,10 +667,10 @@ void TlenProcessF(XmlNode *node, ThreadData *info)
}
else if (!mir_strcmp(e, "8")) {
// FILE_RECV : e='8' : transfer error
- if ((p = TlenXmlGetAttrValue(node, "i")) != NULL) {
- if ((item = TlenListGetItemPtr(info->proto, LIST_FILE, p)) != NULL) {
+ if ((p = TlenXmlGetAttrValue(node, "i")) != nullptr) {
+ if ((item = TlenListGetItemPtr(info->proto, LIST_FILE, p)) != nullptr) {
item->ft->state = FT_ERROR;
- if (item->ft->hFileEvent != NULL)
+ if (item->ft->hFileEvent != nullptr)
SetEvent(item->ft->hFileEvent);
else
ProtoBroadcastAck(info->proto->m_szModuleName, item->ft->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, item->ft, 0);
diff --git a/protocols/Tlen/src/tlen_iq.cpp b/protocols/Tlen/src/tlen_iq.cpp
index 19dd956a77..82923570b3 100644
--- a/protocols/Tlen/src/tlen_iq.cpp
+++ b/protocols/Tlen/src/tlen_iq.cpp
@@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
void TlenIqInit(TlenProtocol *proto)
{
- proto->iqList = NULL;
+ proto->iqList = nullptr;
proto->iqCount = 0;
proto->iqAlloced = 0;
}
@@ -34,7 +34,7 @@ void TlenIqInit(TlenProtocol *proto)
void TlenIqUninit(TlenProtocol *proto)
{
if (proto->iqList) mir_free(proto->iqList);
- proto->iqList = NULL;
+ proto->iqList = nullptr;
proto->iqCount = 0;
proto->iqAlloced = 0;
}
@@ -54,7 +54,7 @@ static void TlenIqExpire(TlenProtocol *proto)
time_t expire;
mir_cslock lck(proto->csIqList);
- expire = time(NULL) - 120; // 2 minute
+ expire = time(nullptr) - 120; // 2 minute
i = 0;
while (i < proto->iqCount) {
if (proto->iqList[i].requestTime < expire)
@@ -77,7 +77,7 @@ TLEN_IQ_PFUNC TlenIqFetchFunc(TlenProtocol *proto, int iqId)
TlenIqRemove(proto, i);
}
else {
- res = (TLEN_IQ_PFUNC) NULL;
+ res = (TLEN_IQ_PFUNC) nullptr;
}
return res;
}
@@ -97,11 +97,11 @@ void TlenIqAdd(TlenProtocol *proto, unsigned int iqId, TLEN_IQ_PROCID procId, TL
proto->iqList = (TLEN_IQ_FUNC*)mir_realloc(proto->iqList, sizeof(TLEN_IQ_FUNC)*proto->iqAlloced);
}
- if (proto->iqList != NULL) {
+ if (proto->iqList != nullptr) {
proto->iqList[i].iqId = iqId;
proto->iqList[i].procId = procId;
proto->iqList[i].func = func;
- proto->iqList[i].requestTime = time(NULL);
+ proto->iqList[i].requestTime = time(nullptr);
if (i == proto->iqCount) proto->iqCount++;
}
}
diff --git a/protocols/Tlen/src/tlen_iqid.cpp b/protocols/Tlen/src/tlen_iqid.cpp
index dd749424be..39024a544a 100644
--- a/protocols/Tlen/src/tlen_iqid.cpp
+++ b/protocols/Tlen/src/tlen_iqid.cpp
@@ -32,7 +32,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
void TlenIqResultAuth(TlenProtocol *proto, XmlNode *iqNode)
{
char *type = TlenXmlGetAttrValue(iqNode, "type");
- if (type == NULL)
+ if (type == nullptr)
return;
if (!mir_strcmp(type, "result")) {
@@ -55,9 +55,9 @@ void TlenIqResultAuth(TlenProtocol *proto, XmlNode *iqNode)
TlenSend(proto, "</s>");
mir_snprintf(text, Translate("Authentication failed for %s@%s."), proto->threadData->username, proto->threadData->server);
- MessageBoxA(NULL, text, Translate("Tlen Authentication"), MB_OK | MB_ICONSTOP | MB_SETFOREGROUND);
- ProtoBroadcastAck(proto->m_szModuleName, NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_WRONGPASSWORD);
- proto->threadData = NULL; // To disallow auto reconnect
+ MessageBoxA(nullptr, text, Translate("Tlen Authentication"), MB_OK | MB_ICONSTOP | MB_SETFOREGROUND);
+ ProtoBroadcastAck(proto->m_szModuleName, NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, nullptr, LOGINERR_WRONGPASSWORD);
+ proto->threadData = nullptr; // To disallow auto reconnect
}
}
@@ -71,9 +71,9 @@ void TlenResultSetRoster(TlenProtocol *proto, XmlNode *queryNode) {
XmlNode *itemNode = queryNode->child[i];
if (!mir_strcmp(itemNode->name, "item")) {
char *jid = TlenXmlGetAttrValue(itemNode, "jid");
- if (jid != NULL) {
+ if (jid != nullptr) {
char *str = TlenXmlGetAttrValue(itemNode, "subscription");
- if (str == NULL)
+ if (str == nullptr)
continue;
else if (!mir_strcmp(str, "remove")) {
if ((hContact = TlenHContactFromJID(proto, jid)) != NULL) {
@@ -84,7 +84,7 @@ void TlenResultSetRoster(TlenProtocol *proto, XmlNode *queryNode) {
}
else {
TLEN_LIST_ITEM *item = TlenListAdd(proto, LIST_ROSTER, jid);
- if (item != NULL) {
+ if (item != nullptr) {
if (!mir_strcmp(str, "both"))
item->subscription = SUB_BOTH;
else if (!mir_strcmp(str, "to"))
@@ -93,13 +93,13 @@ void TlenResultSetRoster(TlenProtocol *proto, XmlNode *queryNode) {
item->subscription = SUB_FROM;
else
item->subscription = SUB_NONE;
- if ((name = TlenXmlGetAttrValue(itemNode, "name")) != NULL) {
+ if ((name = TlenXmlGetAttrValue(itemNode, "name")) != nullptr) {
nick = TlenTextDecode(name);
}
else {
nick = TlenLocalNickFromJID(jid);
}
- if (nick != NULL) {
+ if (nick != nullptr) {
if (item->nick) mir_free(item->nick);
item->nick = nick;
@@ -110,7 +110,7 @@ void TlenResultSetRoster(TlenProtocol *proto, XmlNode *queryNode) {
}
db_set_s(hContact, "CList", "MyHandle", nick);
if (item->group) mir_free(item->group);
- if ((groupNode = TlenXmlGetChild(itemNode, "group")) != NULL && groupNode->text != NULL) {
+ if ((groupNode = TlenXmlGetChild(itemNode, "group")) != nullptr && groupNode->text != nullptr) {
item->group = TlenGroupDecode(groupNode->text);
Clist_GroupCreate(0, _A2T(item->group));
// Don't set group again if already correct, or Miranda may show wrong group count in some case
@@ -123,7 +123,7 @@ void TlenResultSetRoster(TlenProtocol *proto, XmlNode *queryNode) {
db_set_s(hContact, "CList", "Group", item->group);
}
else {
- item->group = NULL;
+ item->group = nullptr;
db_unset(hContact, "CList", "Group");
}
}
@@ -139,13 +139,13 @@ void TlenResultSetRoster(TlenProtocol *proto, XmlNode *queryNode) {
void TlenIqResultRoster(TlenProtocol *proto, XmlNode *iqNode)
{
char *type = TlenXmlGetAttrValue(iqNode, "type");
- if (type == NULL) return;
+ if (type == nullptr) return;
XmlNode *queryNode = TlenXmlGetChild(iqNode, "query");
- if (queryNode == NULL) return;
+ if (queryNode == nullptr) return;
if (!mir_strcmp(type, "result")) {
char *str = TlenXmlGetAttrValue(queryNode, "xmlns");
- if (str != NULL && !mir_strcmp(str, "jabber:iq:roster")) {
+ if (str != nullptr && !mir_strcmp(str, "jabber:iq:roster")) {
DBVARIANT dbv;
XmlNode *itemNode, *groupNode;
TLEN_SUBSCRIPTION sub;
@@ -157,19 +157,19 @@ void TlenIqResultRoster(TlenProtocol *proto, XmlNode *iqNode)
itemNode = queryNode->child[i];
if (!mir_strcmp(itemNode->name, "item")) {
str = TlenXmlGetAttrValue(itemNode, "subscription");
- if (str == NULL) sub = SUB_NONE;
+ if (str == nullptr) sub = SUB_NONE;
else if (!mir_strcmp(str, "both")) sub = SUB_BOTH;
else if (!mir_strcmp(str, "to")) sub = SUB_TO;
else if (!mir_strcmp(str, "from")) sub = SUB_FROM;
else sub = SUB_NONE;
//if (str != NULL && (!mir_strcmp(str, "to") || !mir_strcmp(str, "both"))) {
- if ((jid = TlenXmlGetAttrValue(itemNode, "jid")) != NULL) {
- if ((name = TlenXmlGetAttrValue(itemNode, "name")) != NULL)
+ if ((jid = TlenXmlGetAttrValue(itemNode, "jid")) != nullptr) {
+ if ((name = TlenXmlGetAttrValue(itemNode, "name")) != nullptr)
nick = TlenTextDecode(name);
else
nick = TlenLocalNickFromJID(jid);
- if (nick != NULL) {
+ if (nick != nullptr) {
MCONTACT hContact;
item = TlenListAdd(proto, LIST_ROSTER, jid);
if (item->nick) mir_free(item->nick);
@@ -182,7 +182,7 @@ void TlenIqResultRoster(TlenProtocol *proto, XmlNode *iqNode)
}
db_set_s(hContact, "CList", "MyHandle", nick);
if (item->group) mir_free(item->group);
- if ((groupNode = TlenXmlGetChild(itemNode, "group")) != NULL && groupNode->text != NULL) {
+ if ((groupNode = TlenXmlGetChild(itemNode, "group")) != nullptr && groupNode->text != nullptr) {
item->group = TlenGroupDecode(groupNode->text);
Clist_GroupCreate(0, _A2T(item->group));
// Don't set group again if already correct, or Miranda may show wrong group count in some case
@@ -194,7 +194,7 @@ void TlenIqResultRoster(TlenProtocol *proto, XmlNode *iqNode)
else db_set_s(hContact, "CList", "Group", item->group);
}
else {
- item->group = NULL;
+ item->group = nullptr;
db_unset(hContact, "CList", "Group");
}
@@ -238,19 +238,19 @@ void TlenIqResultVcard(TlenProtocol *proto, XmlNode *iqNode)
// TlenLog("<iq/> iqIdGetVcard (tlen)");
char *type = TlenXmlGetAttrValue(iqNode, "type");
- if (type == NULL) return;
+ if (type == nullptr) return;
if (!mir_strcmp(type, "result")) {
DBVARIANT dbv;
XmlNode *queryNode = TlenXmlGetChild(iqNode, "query");
- if (queryNode == NULL) return;
+ if (queryNode == nullptr) return;
XmlNode *itemNode = TlenXmlGetChild(queryNode, "item");
- if (itemNode == NULL) return;
+ if (itemNode == nullptr) return;
char *jid = TlenXmlGetAttrValue(itemNode, "jid");
- if (jid != NULL) {
+ if (jid != nullptr) {
if (db_get(NULL, proto->m_szModuleName, "LoginServer", &dbv)) return;
- if (strchr(jid, '@') != NULL) {
+ if (strchr(jid, '@') != nullptr) {
strncpy_s(text, jid, _TRUNCATE);
}
else {
@@ -273,9 +273,9 @@ void TlenIqResultVcard(TlenProtocol *proto, XmlNode *iqNode)
hasGender = false, hasSchool = false, hasLookFor = false, hasOccupation = false;
for (int i = 0; i < itemNode->numChild; i++) {
XmlNode *n = itemNode->child[i];
- if (n == NULL || n->name == NULL) continue;
+ if (n == nullptr || n->name == nullptr) continue;
if (!mir_strcmp(n->name, "first")) {
- if (n->text != NULL) {
+ if (n->text != nullptr) {
hasFirst = true;
nText = TlenTextDecode(n->text);
db_set_s(hContact, proto->m_szModuleName, "FirstName", nText);
@@ -283,7 +283,7 @@ void TlenIqResultVcard(TlenProtocol *proto, XmlNode *iqNode)
}
}
else if (!mir_strcmp(n->name, "last")) {
- if (n->text != NULL) {
+ if (n->text != nullptr) {
hasLast = true;
nText = TlenTextDecode(n->text);
db_set_s(hContact, proto->m_szModuleName, "LastName", nText);
@@ -291,7 +291,7 @@ void TlenIqResultVcard(TlenProtocol *proto, XmlNode *iqNode)
}
}
else if (!mir_strcmp(n->name, "nick")) {
- if (n->text != NULL) {
+ if (n->text != nullptr) {
hasNick = true;
nText = TlenTextDecode(n->text);
db_set_s(hContact, proto->m_szModuleName, "Nick", nText);
@@ -299,7 +299,7 @@ void TlenIqResultVcard(TlenProtocol *proto, XmlNode *iqNode)
}
}
else if (!mir_strcmp(n->name, "email")) {
- if (n->text != NULL) {
+ if (n->text != nullptr) {
hasEmail = true;
nText = TlenTextDecode(n->text);
db_set_s(hContact, proto->m_szModuleName, "e-mail", nText);
@@ -307,7 +307,7 @@ void TlenIqResultVcard(TlenProtocol *proto, XmlNode *iqNode)
}
}
else if (!mir_strcmp(n->name, "c")) {
- if (n->text != NULL) {
+ if (n->text != nullptr) {
hasCity = true;
nText = TlenTextDecode(n->text);
db_set_s(hContact, proto->m_szModuleName, "City", nText);
@@ -315,20 +315,20 @@ void TlenIqResultVcard(TlenProtocol *proto, XmlNode *iqNode)
}
}
else if (!mir_strcmp(n->name, "b")) {
- if (n->text != NULL) {
+ if (n->text != nullptr) {
WORD nAge = atoi(n->text);
hasAge = true;
db_set_w(hContact, proto->m_szModuleName, "Age", nAge);
}
}
else if (!mir_strcmp(n->name, "s")) {
- if (n->text != NULL && n->text[1] == '\0' && (n->text[0] == '1' || n->text[0] == '2')) {
+ if (n->text != nullptr && n->text[1] == '\0' && (n->text[0] == '1' || n->text[0] == '2')) {
hasGender = true;
db_set_b(hContact, proto->m_szModuleName, "Gender", (BYTE)(n->text[0] == '1' ? 'M' : 'F'));
}
}
else if (!mir_strcmp(n->name, "e")) {
- if (n->text != NULL) {
+ if (n->text != nullptr) {
hasSchool = true;
nText = TlenTextDecode(n->text);
db_set_s(hContact, proto->m_szModuleName, "School", nText);
@@ -336,27 +336,27 @@ void TlenIqResultVcard(TlenProtocol *proto, XmlNode *iqNode)
}
}
else if (!mir_strcmp(n->name, "j")) {
- if (n->text != NULL) {
+ if (n->text != nullptr) {
hasOccupation = true;
WORD nOccupation = atoi(n->text);
db_set_w(hContact, proto->m_szModuleName, "Occupation", nOccupation);
}
}
else if (!mir_strcmp(n->name, "r")) {
- if (n->text != NULL) {
+ if (n->text != nullptr) {
WORD nLookFor = atoi(n->text);
hasLookFor = true;
db_set_w(hContact, proto->m_szModuleName, "LookingFor", nLookFor);
}
}
else if (!mir_strcmp(n->name, "g")) { // voice chat enabled
- if (n->text != NULL) {
+ if (n->text != nullptr) {
BYTE bVoice = atoi(n->text);
db_set_w(hContact, proto->m_szModuleName, "VoiceChat", bVoice);
}
}
else if (!mir_strcmp(n->name, "v")) { // status visibility
- if (n->text != NULL) {
+ if (n->text != nullptr) {
BYTE bPublic = atoi(n->text);
db_set_w(hContact, proto->m_szModuleName, "PublicStatus", bPublic);
}
@@ -397,23 +397,23 @@ void TlenIqResultSearch(TlenProtocol *proto, XmlNode *iqNode)
// TlenLog("<iq/> iqIdGetSearch");
char *type = TlenXmlGetAttrValue(iqNode, "type");
- if (type == NULL)
+ if (type == nullptr)
return;
char *str = TlenXmlGetAttrValue(iqNode, "id");
- if (str == NULL)
+ if (str == nullptr)
return;
int id = atoi(str + mir_strlen(TLEN_IQID));
if (!mir_strcmp(type, "result")) {
- if ((queryNode = TlenXmlGetChild(iqNode, "query")) == NULL) return;
+ if ((queryNode = TlenXmlGetChild(iqNode, "query")) == nullptr) return;
if (!db_get(NULL, proto->m_szModuleName, "LoginServer", &dbv)) {
jsr.hdr.cbSize = sizeof(TLEN_SEARCH_RESULT);
jsr.hdr.flags = PSR_UNICODE;
for (i = 0; i < queryNode->numChild; i++) {
itemNode = queryNode->child[i];
if (!mir_strcmp(itemNode->name, "item")) {
- if ((jid = TlenXmlGetAttrValue(itemNode, "jid")) != NULL) {
- if (strchr(jid, '@') != NULL) {
+ if ((jid = TlenXmlGetAttrValue(itemNode, "jid")) != nullptr) {
+ if (strchr(jid, '@') != nullptr) {
strncpy_s(jsr.jid, jid, _TRUNCATE);
}
else {
@@ -421,7 +421,7 @@ void TlenIqResultSearch(TlenProtocol *proto, XmlNode *iqNode)
}
jsr.jid[sizeof(jsr.jid) - 1] = '\0';
jsr.hdr.id.w = mir_a2u(jid);
- if ((n = TlenXmlGetChild(itemNode, "nick")) != NULL && n->text != NULL) {
+ if ((n = TlenXmlGetChild(itemNode, "nick")) != nullptr && n->text != nullptr) {
char* buf = TlenTextDecode(n->text);
jsr.hdr.nick.w = mir_a2u(buf);
mir_free(buf);
@@ -429,7 +429,7 @@ void TlenIqResultSearch(TlenProtocol *proto, XmlNode *iqNode)
else {
jsr.hdr.nick.w = mir_wstrdup(TEXT(""));
}
- if ((n = TlenXmlGetChild(itemNode, "first")) != NULL && n->text != NULL) {
+ if ((n = TlenXmlGetChild(itemNode, "first")) != nullptr && n->text != nullptr) {
char* buf = TlenTextDecode(n->text);
jsr.hdr.firstName.w = mir_a2u(buf);
mir_free(buf);
@@ -437,7 +437,7 @@ void TlenIqResultSearch(TlenProtocol *proto, XmlNode *iqNode)
else {
jsr.hdr.firstName.w = mir_wstrdup(TEXT(""));
}
- if ((n = TlenXmlGetChild(itemNode, "last")) != NULL && n->text != NULL) {
+ if ((n = TlenXmlGetChild(itemNode, "last")) != nullptr && n->text != nullptr) {
char* buf = TlenTextDecode(n->text);
jsr.hdr.lastName.w = mir_a2u(buf);
mir_free(buf);
@@ -445,7 +445,7 @@ void TlenIqResultSearch(TlenProtocol *proto, XmlNode *iqNode)
else {
jsr.hdr.lastName.w = mir_wstrdup(TEXT(""));
}
- if ((n = TlenXmlGetChild(itemNode, "email")) != NULL && n->text != NULL) {
+ if ((n = TlenXmlGetChild(itemNode, "email")) != nullptr && n->text != nullptr) {
char* buf = TlenTextDecode(n->text);
jsr.hdr.email.w = mir_a2u(buf);
mir_free(buf);
@@ -464,9 +464,9 @@ void TlenIqResultSearch(TlenProtocol *proto, XmlNode *iqNode)
}
}
}
- if (proto->searchJID != NULL) {
+ if (proto->searchJID != nullptr) {
if (!found) {
- if (strchr(proto->searchJID, '@') != NULL)
+ if (strchr(proto->searchJID, '@') != nullptr)
strncpy_s(jsr.jid, proto->searchJID, _TRUNCATE);
else
mir_snprintf(jsr.jid, "%s@%s", proto->searchJID, dbv.pszVal);
@@ -475,7 +475,7 @@ void TlenIqResultSearch(TlenProtocol *proto, XmlNode *iqNode)
ProtoBroadcastAck(proto->m_szModuleName, NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)id, (LPARAM)&jsr);
}
mir_free(proto->searchJID);
- proto->searchJID = NULL;
+ proto->searchJID = nullptr;
}
db_free(&dbv);
}
@@ -501,7 +501,7 @@ void GetConfigItem(XmlNode *node, char *dest, BOOL bMethod, int *methodDest) {
TlenUrlDecode(dest);
if (bMethod) {
char *method = TlenXmlGetAttrValue(node, "method");
- if (method != NULL && !strcmpi(method, "POST")) {
+ if (method != nullptr && !strcmpi(method, "POST")) {
*methodDest = REQUEST_POST;
}
else {
@@ -515,40 +515,40 @@ void TlenIqResultTcfg(TlenProtocol *proto, XmlNode *iqNode)
XmlNode *queryNode, *miniMailNode, *node;
char *type = TlenXmlGetAttrValue(iqNode, "type");
- if (type == NULL) return;
+ if (type == nullptr) return;
if (!mir_strcmp(type, "result")) {
- if ((queryNode = TlenXmlGetChild(iqNode, "query")) == NULL) return;
- if ((miniMailNode = TlenXmlGetChild(queryNode, "mini-mail")) == NULL) return;
- if ((node = TlenXmlGetChild(miniMailNode, "base")) != NULL) {
- GetConfigItem(node, proto->threadData->tlenConfig.mailBase, FALSE, NULL);
+ if ((queryNode = TlenXmlGetChild(iqNode, "query")) == nullptr) return;
+ if ((miniMailNode = TlenXmlGetChild(queryNode, "mini-mail")) == nullptr) return;
+ if ((node = TlenXmlGetChild(miniMailNode, "base")) != nullptr) {
+ GetConfigItem(node, proto->threadData->tlenConfig.mailBase, FALSE, nullptr);
}
- if ((node = TlenXmlGetChild(miniMailNode, "msg")) != NULL) {
+ if ((node = TlenXmlGetChild(miniMailNode, "msg")) != nullptr) {
GetConfigItem(node, proto->threadData->tlenConfig.mailMsg, TRUE, &proto->threadData->tlenConfig.mailMsgMthd);
}
- if ((node = TlenXmlGetChild(miniMailNode, "index")) != NULL) {
+ if ((node = TlenXmlGetChild(miniMailNode, "index")) != nullptr) {
GetConfigItem(node, proto->threadData->tlenConfig.mailIndex, TRUE, &proto->threadData->tlenConfig.mailIndexMthd);
}
- if ((node = TlenXmlGetChild(miniMailNode, "login")) != NULL) {
+ if ((node = TlenXmlGetChild(miniMailNode, "login")) != nullptr) {
GetConfigItem(node, proto->threadData->tlenConfig.mailLogin, TRUE, &proto->threadData->tlenConfig.mailLoginMthd);
}
- if ((node = TlenXmlGetChild(miniMailNode, "compose")) != NULL) {
+ if ((node = TlenXmlGetChild(miniMailNode, "compose")) != nullptr) {
GetConfigItem(node, proto->threadData->tlenConfig.mailCompose, TRUE, &proto->threadData->tlenConfig.mailComposeMthd);
}
- if ((node = TlenXmlGetChild(miniMailNode, "avatar-get")) != NULL) {
+ if ((node = TlenXmlGetChild(miniMailNode, "avatar-get")) != nullptr) {
GetConfigItem(node, proto->threadData->tlenConfig.avatarGet, TRUE, &proto->threadData->tlenConfig.avatarGetMthd);
}
- if ((node = TlenXmlGetChild(miniMailNode, "avatar-upload")) != NULL) {
+ if ((node = TlenXmlGetChild(miniMailNode, "avatar-upload")) != nullptr) {
GetConfigItem(node, proto->threadData->tlenConfig.avatarUpload, TRUE, &proto->threadData->tlenConfig.avatarUploadMthd);
}
- if ((node = TlenXmlGetChild(miniMailNode, "avatar-remove")) != NULL) {
+ if ((node = TlenXmlGetChild(miniMailNode, "avatar-remove")) != nullptr) {
GetConfigItem(node, proto->threadData->tlenConfig.avatarRemove, TRUE, &proto->threadData->tlenConfig.avatarRemoveMthd);
}
//continue connecting
- Menu_ModifyItem(proto->hMenuMUC, NULL, INVALID_HANDLE_VALUE, 0);
- if (proto->hMenuChats != NULL)
- Menu_ModifyItem(proto->hMenuChats, NULL, INVALID_HANDLE_VALUE, 0);
+ Menu_ModifyItem(proto->hMenuMUC, nullptr, INVALID_HANDLE_VALUE, 0);
+ if (proto->hMenuChats != nullptr)
+ Menu_ModifyItem(proto->hMenuChats, nullptr, INVALID_HANDLE_VALUE, 0);
proto->isOnline = TRUE;
proto->debugLogA("Status changed via THREADSTART");
@@ -562,31 +562,31 @@ void TlenIqResultTcfg(TlenProtocol *proto, XmlNode *iqNode)
void TlenIqResultVersion(TlenProtocol *proto, XmlNode *iqNode)
{
XmlNode *queryNode = TlenXmlGetChild(iqNode, "query");
- if (queryNode != NULL) {
+ if (queryNode != nullptr) {
char *from = TlenXmlGetAttrValue(iqNode, "from");
- if (from != NULL) {
+ if (from != nullptr) {
TLEN_LIST_ITEM *item = TlenListGetItemPtr(proto, LIST_ROSTER, from);
- if (item != NULL) {
+ if (item != nullptr) {
XmlNode *n;
if (item->software) mir_free(item->software);
if (item->version) mir_free(item->version);
if (item->system) mir_free(item->system);
- if ((n = TlenXmlGetChild(queryNode, "name")) != NULL && n->text) {
+ if ((n = TlenXmlGetChild(queryNode, "name")) != nullptr && n->text) {
item->software = TlenTextDecode(n->text);
}
else
- item->software = NULL;
- if ((n = TlenXmlGetChild(queryNode, "version")) != NULL && n->text)
+ item->software = nullptr;
+ if ((n = TlenXmlGetChild(queryNode, "version")) != nullptr && n->text)
item->version = TlenTextDecode(n->text);
else
- item->version = NULL;
- if ((n = TlenXmlGetChild(queryNode, "os")) != NULL && n->text)
+ item->version = nullptr;
+ if ((n = TlenXmlGetChild(queryNode, "os")) != nullptr && n->text)
item->system = TlenTextDecode(n->text);
else
- item->system = NULL;
+ item->system = nullptr;
MCONTACT hContact = TlenHContactFromJID(proto, item->jid);
if (hContact != NULL) {
- if (item->software != NULL) {
+ if (item->software != nullptr) {
db_set_s(hContact, proto->m_szModuleName, "MirVer", item->software);
}
else {
@@ -601,17 +601,17 @@ void TlenIqResultVersion(TlenProtocol *proto, XmlNode *iqNode)
void TlenIqResultInfo(TlenProtocol *proto, XmlNode *iqNode)
{
XmlNode *queryNode = TlenXmlGetChild(iqNode, "query");
- if (queryNode != NULL) {
+ if (queryNode != nullptr) {
char *from = TlenXmlGetAttrValue(queryNode, "from");
- if (from != NULL) {
+ if (from != nullptr) {
TLEN_LIST_ITEM *item = TlenListGetItemPtr(proto, LIST_ROSTER, from);
- if (item != NULL) {
+ if (item != nullptr) {
XmlNode *version = TlenXmlGetChild(queryNode, "version");
- if (version != NULL) {
+ if (version != nullptr) {
item->protocolVersion = TlenTextDecode(version->text);
MCONTACT hContact = TlenHContactFromJID(proto, item->jid);
if (hContact != NULL) {
- if (item->software == NULL) {
+ if (item->software == nullptr) {
char str[128];
mir_snprintf(str, "Tlen Protocol %s", item->protocolVersion);
db_set_s(hContact, proto->m_szModuleName, "MirVer", str);
diff --git a/protocols/Tlen/src/tlen_list.cpp b/protocols/Tlen/src/tlen_list.cpp
index 03bad29a52..f7a141cea6 100644
--- a/protocols/Tlen/src/tlen_list.cpp
+++ b/protocols/Tlen/src/tlen_list.cpp
@@ -29,7 +29,7 @@ static void TlenListFreeItemInternal(TLEN_LIST_ITEM *item);
void TlenListInit(TlenProtocol *proto)
{
- proto->lists = NULL;
+ proto->lists = nullptr;
proto->listsCount = 0;
}
@@ -45,9 +45,9 @@ void TlenListWipe(TlenProtocol *proto)
mir_cslock lck(proto->csLists);
for (i=0; i<proto->listsCount; i++)
TlenListFreeItemInternal(&(proto->lists[i]));
- if (proto->lists != NULL) {
+ if (proto->lists != nullptr) {
mir_free(proto->lists);
- proto->lists = NULL;
+ proto->lists = nullptr;
}
proto->listsCount=0;
}
@@ -69,7 +69,7 @@ void TlenListWipeSpecial(TlenProtocol *proto)
static void TlenListFreeItemInternal(TLEN_LIST_ITEM *item)
{
- if (item == NULL)
+ if (item == nullptr)
return;
if (item->jid) mir_free(item->jid);
@@ -96,8 +96,8 @@ static char * GetItemId(TLEN_LIST list, const char *jid)
if (list != LIST_PICTURE) {
_strlwr(s);
// strip resouce name if any
- if ((p=strchr(s, '@')) != NULL) {
- if ((q=strchr(p, '/')) != NULL)
+ if ((p=strchr(s, '@')) != nullptr) {
+ if ((q=strchr(p, '/')) != nullptr)
*q = '\0';
}
}
@@ -132,7 +132,7 @@ TLEN_LIST_ITEM *TlenListAdd(TlenProtocol *proto, TLEN_LIST list, const char *jid
TLEN_LIST_ITEM *item;
mir_cslock lck(proto->csLists);
- if ((item=TlenListGetItemPtr(proto, list, jid)) != NULL) {
+ if ((item=TlenListGetItemPtr(proto, list, jid)) != nullptr) {
return item;
}
@@ -142,20 +142,20 @@ TLEN_LIST_ITEM *TlenListAdd(TlenProtocol *proto, TLEN_LIST list, const char *jid
memset(item, 0, sizeof(TLEN_LIST_ITEM));
item->list = list;
item->jid = s;
- item->nick = NULL;
+ item->nick = nullptr;
item->status = ID_STATUS_OFFLINE;
- item->statusMessage = NULL;
- item->group = NULL;
- item->messageEventIdStr = NULL;
+ item->statusMessage = nullptr;
+ item->group = nullptr;
+ item->messageEventIdStr = nullptr;
item->wantComposingEvent = FALSE;
item->isTyping = FALSE;
// item->type = NULL;
- item->ft = NULL;
- item->roomName = NULL;
- item->version = NULL;
- item->software = NULL;
- item->system = NULL;
- item->avatarHash = NULL;
+ item->ft = nullptr;
+ item->roomName = nullptr;
+ item->version = nullptr;
+ item->software = nullptr;
+ item->system = nullptr;
+ item->avatarHash = nullptr;
item->avatarFormat = PA_FORMAT_UNKNOWN;
item->newAvatarDownloading = FALSE;
item->versionRequested = FALSE;
@@ -213,12 +213,12 @@ void TlenListAddResource(TlenProtocol *proto, TLEN_LIST list, const char *jid, i
}
i--;
- if (proto->lists[i].statusMessage != NULL)
+ if (proto->lists[i].statusMessage != nullptr)
mir_free(proto->lists[i].statusMessage);
if (statusMessage)
proto->lists[i].statusMessage = mir_strdup(statusMessage);
else
- proto->lists[i].statusMessage = NULL;
+ proto->lists[i].statusMessage = nullptr;
}
void TlenListRemoveResource(TlenProtocol *proto, TLEN_LIST list, const char *jid)
@@ -252,7 +252,7 @@ TLEN_LIST_ITEM *TlenListGetItemPtr(TlenProtocol *proto, TLEN_LIST list, const ch
mir_cslock lck(proto->csLists);
i = TlenListExist(proto, list, jid);
if (!i) {
- return NULL;
+ return nullptr;
}
i--;
return &(proto->lists[i]);
@@ -271,14 +271,14 @@ TLEN_LIST_ITEM *TlenListFindItemPtrById2(TlenProtocol *proto, TLEN_LIST list, co
for (i=0; i<proto->listsCount; i++) {
if (proto->lists[i].list == list) {
p = proto->lists[i].id2;
- if (p != NULL) {
+ if (p != nullptr) {
if (!strncmp(p, id, len)) {
return &(proto->lists[i]);
}
}
}
}
- return NULL;
+ return nullptr;
}
TLEN_LIST_ITEM *TlenListGetItemPtrFromIndex(TlenProtocol *proto, int index)
@@ -287,6 +287,6 @@ TLEN_LIST_ITEM *TlenListGetItemPtrFromIndex(TlenProtocol *proto, int index)
if (index >= 0 && index<proto->listsCount) {
return &(proto->lists[index]);
}
- return NULL;
+ return nullptr;
}
diff --git a/protocols/Tlen/src/tlen_misc.cpp b/protocols/Tlen/src/tlen_misc.cpp
index ae38e33bee..4cb071da5a 100644
--- a/protocols/Tlen/src/tlen_misc.cpp
+++ b/protocols/Tlen/src/tlen_misc.cpp
@@ -28,7 +28,7 @@ void TlenDBAddEvent(TlenProtocol *proto, MCONTACT hContact, int eventType, DWORD
{
DBEVENTINFO dbei = {};
dbei.szModule = proto->m_szModuleName;
- dbei.timestamp = (DWORD) time(NULL);
+ dbei.timestamp = (DWORD) time(nullptr);
dbei.flags = flags;
dbei.eventType = eventType;
dbei.cbBlob = cbBlob;
@@ -53,13 +53,13 @@ void TlenDBAddAuthRequest(TlenProtocol *proto, char *jid, char *nick)
db_set_s(hContact, proto->m_szModuleName, "Nick", nick);
proto->debugLogA("auth request: %s, %s", jid, nick);
- DB_AUTH_BLOB blob(hContact, nick, 0, 0, jid, 0);
+ DB_AUTH_BLOB blob(hContact, nick, nullptr, nullptr, jid, nullptr);
TlenDBAddEvent(proto, NULL, EVENTTYPE_AUTHREQUEST, 0, blob, blob.size());
}
char *TlenJIDFromHContact(TlenProtocol *proto, MCONTACT hContact)
{
- char *p = NULL;
+ char *p = nullptr;
DBVARIANT dbv;
if (!db_get(hContact, proto->m_szModuleName, "jid", &dbv)) {
p = mir_strdup(dbv.pszVal);
@@ -72,14 +72,14 @@ MCONTACT TlenHContactFromJID(TlenProtocol *proto, const char *jid)
{
DBVARIANT dbv;
char *p;
- if (jid == NULL)
+ if (jid == nullptr)
return NULL;
for (MCONTACT hContact = db_find_first(proto->m_szModuleName); hContact; hContact = db_find_next(hContact, proto->m_szModuleName)) {
if ( db_get_s(hContact, proto->m_szModuleName, "jid", &dbv))
continue;
- if ((p=dbv.pszVal) != NULL) {
+ if ((p=dbv.pszVal) != nullptr) {
if (!mir_strcmpi(p, jid)) { // exact match (node@domain/resource)
db_free(&dbv);
return hContact;
@@ -94,14 +94,14 @@ MCONTACT TlenHContactFromJID(TlenProtocol *proto, const char *jid)
MCONTACT TlenDBCreateContact(TlenProtocol *proto, char *jid, char *nick, BOOL temporary)
{
MCONTACT hContact;
- if (jid == NULL || jid[0] == '\0')
+ if (jid == nullptr || jid[0] == '\0')
return NULL;
if ((hContact=TlenHContactFromJID(proto, jid)) == NULL) {
hContact = db_add_contact();
Proto_AddToContact(hContact, proto->m_szModuleName);
db_set_s(hContact, proto->m_szModuleName, "jid", jid);
- if (nick != NULL && nick[0] != '\0')
+ if (nick != nullptr && nick[0] != '\0')
db_set_s(hContact, proto->m_szModuleName, "Nick", nick);
if (temporary)
db_set_b(hContact, "CList", "NotOnList", 1);
diff --git a/protocols/Tlen/src/tlen_muc.cpp b/protocols/Tlen/src/tlen_muc.cpp
index a2a0469ff6..475ffa504d 100644
--- a/protocols/Tlen/src/tlen_muc.cpp
+++ b/protocols/Tlen/src/tlen_muc.cpp
@@ -37,8 +37,8 @@ static int isSelf(TlenProtocol *proto, const char *roomID, const char *nick)
int result;
result=0;
item = TlenListGetItemPtr(proto, LIST_CHATROOM, roomID);
- if (item != NULL) {
- if (item->nick == NULL) {
+ if (item != nullptr) {
+ if (item->nick == nullptr) {
if (!mir_strcmp(nick, proto->threadData->username)) result = 1;
} else if (nick[0] == '~') {
if (!mir_strcmp(nick+1, item->nick)) {
@@ -84,7 +84,7 @@ static char *getDisplayName(TlenProtocol *proto, const char *id)
int TlenMUCRecvInvitation(TlenProtocol *proto, const char *roomId, const char*, const char *from, const char*)
{
int ignore, ask, groupChatPolicy;
- if (roomId == NULL) return 1;
+ if (roomId == nullptr) return 1;
groupChatPolicy = db_get_w(NULL, proto->m_szModuleName, "GroupChatPolicy", 0);
ask = TRUE;
ignore = FALSE;
@@ -141,27 +141,27 @@ static int TlenMUCSendPresence(TlenProtocol *proto, const char *roomID, const ch
if (!proto->isOnline) {
return 1;
}
- if (nick != NULL) {
+ if (nick != nullptr) {
mir_snprintf(str, "%s/%s", roomID, nick);
} else {
strncpy_s(str, roomID, _TRUNCATE);
}
- if ((jid = TlenTextEncode(str)) != NULL) {
+ if ((jid = TlenTextEncode(str)) != nullptr) {
switch (desiredStatus) {
case ID_STATUS_ONLINE:
TlenSend(proto, "<p to='%s'/>", jid);
item = TlenListGetItemPtr(proto, LIST_CHATROOM, roomID);
- if (item != NULL) {
- if (item->nick != NULL) mir_free(item->nick);
- item->nick = NULL;
- if (nick != NULL) {
+ if (item != nullptr) {
+ if (item->nick != nullptr) mir_free(item->nick);
+ item->nick = nullptr;
+ if (nick != nullptr) {
item->nick = mir_strdup(nick);
}
}
break;
default:
item = TlenListGetItemPtr(proto, LIST_CHATROOM, roomID);
- if (item != NULL) {
+ if (item != nullptr) {
TlenSend(proto, "<p to='%s'><s>unavailable</s></p>", jid);
TlenListRemove(proto, LIST_CHATROOM, roomID);
}
@@ -185,7 +185,7 @@ static int TlenMUCSendQuery(TlenProtocol *proto, int type, const char *parent, i
item->roomName = mir_strdup(parent);
TlenSend(proto, "<iq to='c' type='3' n='%s' id='%s'/>", parent, serialId);
} else {
- if (parent == NULL) {
+ if (parent == nullptr) {
TlenSend(proto, "<iq to='c' type='%d'/>", type);
} else { // 1 - groups, 2 - chat rooms, 7 - user nicks, 8 - user rooms
if (type == 1 || (type == 2 && page == 0) || type == 7 || type == 8) {
diff --git a/protocols/Tlen/src/tlen_opt.cpp b/protocols/Tlen/src/tlen_opt.cpp
index ec23e45445..2c7486e555 100644
--- a/protocols/Tlen/src/tlen_opt.cpp
+++ b/protocols/Tlen/src/tlen_opt.cpp
@@ -103,7 +103,7 @@ static LRESULT CALLBACK TlenValidateUsernameWndProc(HWND hwndEdit, UINT msg, WPA
{
switch (msg) {
case WM_CHAR:
- if (strchr("\"&'/:<>@", wParam&0xff) != NULL)
+ if (strchr("\"&'/:<>@", wParam&0xff) != nullptr)
return 0;
break;
}
@@ -549,7 +549,7 @@ static INT_PTR CALLBACK TlenAdvOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,
}
db_set_s(NULL, proto->m_szModuleName, "ManualHost", text);
- port = (WORD) GetDlgItemInt(hwndDlg, IDC_HOSTPORT, NULL, FALSE);
+ port = (WORD) GetDlgItemInt(hwndDlg, IDC_HOSTPORT, nullptr, FALSE);
if (db_get_w(NULL, proto->m_szModuleName, "ManualPort", TLEN_DEFAULT_PORT) != port)
reconnectRequired = true;
db_set_w(NULL, proto->m_szModuleName, "ManualPort", port);
@@ -571,7 +571,7 @@ static INT_PTR CALLBACK TlenAdvOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,
GetDlgItemTextA(hwndDlg, IDC_FILE_PROXY_HOST, text, _countof(text));
db_set_s(NULL, proto->m_szModuleName, "FileProxyHost", text);
- db_set_w(NULL, proto->m_szModuleName, "FileProxyPort", (WORD) GetDlgItemInt(hwndDlg, IDC_FILE_PROXY_PORT, NULL, FALSE));
+ db_set_w(NULL, proto->m_szModuleName, "FileProxyPort", (WORD) GetDlgItemInt(hwndDlg, IDC_FILE_PROXY_PORT, nullptr, FALSE));
db_set_b(NULL, proto->m_szModuleName, "FileProxyAuth", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_FILE_PROXY_USE_AUTH));
GetDlgItemTextA(hwndDlg, IDC_FILE_PROXY_USER, text, _countof(text));
@@ -654,7 +654,7 @@ static INT_PTR CALLBACK TlenPopupsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,
} else if (IsDlgButtonChecked(hwndDlg, IDC_DELAY_PERMANENT)) {
delay=-1;
} else {
- delay=GetDlgItemInt(hwndDlg, IDC_DELAY, NULL, FALSE);
+ delay=GetDlgItemInt(hwndDlg, IDC_DELAY, nullptr, FALSE);
}
mir_snwprintf(title, TranslateT("%S mail"), proto->m_szModuleName);
MailPopupPreview((DWORD) SendDlgItemMessage(hwndDlg,IDC_COLORBKG,CPM_GETCOLOUR,0,0),
@@ -676,7 +676,7 @@ static INT_PTR CALLBACK TlenPopupsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,
db_set_b(NULL, proto->m_szModuleName, "MailPopupEnabled", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_ENABLEPOPUP));
db_set_dw(NULL, proto->m_szModuleName, "MailPopupBack", (DWORD) SendDlgItemMessage(hwndDlg,IDC_COLORBKG,CPM_GETCOLOUR,0,0));
db_set_dw(NULL, proto->m_szModuleName, "MailPopupText", (DWORD) SendDlgItemMessage(hwndDlg,IDC_COLORTXT,CPM_GETCOLOUR,0,0));
- db_set_dw(NULL, proto->m_szModuleName, "MailPopupDelay", (DWORD) GetDlgItemInt(hwndDlg,IDC_DELAY, NULL, FALSE));
+ db_set_dw(NULL, proto->m_szModuleName, "MailPopupDelay", (DWORD) GetDlgItemInt(hwndDlg,IDC_DELAY, nullptr, FALSE));
delayMode=0;
if (IsDlgButtonChecked(hwndDlg, IDC_DELAY_CUSTOM)) {
delayMode=1;
diff --git a/protocols/Tlen/src/tlen_p2p_new.cpp b/protocols/Tlen/src/tlen_p2p_new.cpp
index 75e24250cb..f8c8c0d15a 100644
--- a/protocols/Tlen/src/tlen_p2p_new.cpp
+++ b/protocols/Tlen/src/tlen_p2p_new.cpp
@@ -31,7 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static void logInfo(const char *filename, const char *fmt, ...) {
va_list vararg;
FILE *flog=fopen(filename,"at");
- if (flog != NULL) {
+ if (flog != nullptr) {
SYSTEMTIME time;
GetLocalTime(&time);
va_start(vararg, fmt);
@@ -60,10 +60,10 @@ void __cdecl TlenNewFileReceiveThread(TLEN_FILE_TRANSFER *ft)
toad.sin_family = AF_INET;
toad.sin_addr.s_addr = inet_addr(ft->hostName);
toad.sin_port = htons(ft->wPort);
- if (fout != NULL) {
+ if (fout != nullptr) {
fprintf(fout, "START:\n");
}
- if (fout != NULL) {
+ if (fout != nullptr) {
fclose(fout);
}
while (ft->udps != INVALID_SOCKET) {
@@ -78,7 +78,7 @@ void __cdecl TlenNewFileReceiveThread(TLEN_FILE_TRANSFER *ft)
}
logInfo("tlen_recv.dxx", "UDP");
fout = fopen("tlen_recv.dxx", "at");
- if (fout != NULL) {
+ if (fout != nullptr) {
fprintf(fout, "\n|RECV %d bytes from %s:%d|",n, inet_ntoa(cad.sin_addr), cad.sin_port);
for (j = 0; j < n; j++) {
fprintf(fout, "%02X-", buff[j]);
@@ -87,14 +87,14 @@ void __cdecl TlenNewFileReceiveThread(TLEN_FILE_TRANSFER *ft)
if (n == 1) {
alen = sizeof(struct sockaddr);
n = sendto(ft->udps, (char*)buff, n, 0,(struct sockaddr *) &toad, alen);
- if (fout != NULL) {
+ if (fout != nullptr) {
fprintf(fout, "\n|SEND |");
for (j = 0; j < n; j++) {
fprintf(fout, "%02X-", buff[j]);
}
}
}
- if (fout != NULL) {
+ if (fout != nullptr) {
fprintf(fout, "\n");
fclose(fout);
}
@@ -129,7 +129,7 @@ void __cdecl TlenNewFileSendThread(TLEN_FILE_TRANSFER *ft)
toad.sin_addr.s_addr = inet_addr(ft->hostName);
toad.sin_port = htons(ft->wPort);
- if (fout != NULL) {
+ if (fout != nullptr) {
fprintf(fout, "START:");
}
for (step = 0; step < 10; step ++) {
@@ -150,18 +150,18 @@ void __cdecl TlenNewFileSendThread(TLEN_FILE_TRANSFER *ft)
}
n=sendto(ft->udps, (char*)buff, n, 0, (struct sockaddr *)&toad, alen);
logInfo("tlen_send.dxx", "UDP");
- if (fout != NULL) {
+ if (fout != nullptr) {
fprintf(fout, "|send: %d %s %d|",n, inet_ntoa(toad.sin_addr), toad.sin_port);
for (j = 0; j < n; j++) {
fprintf(fout, "%02X-", buff[j]);
}
}
- if (fout != NULL) {
+ if (fout != nullptr) {
fprintf(fout, "\n");
}
SleepEx(1000, TRUE);
}
- if (fout != NULL) {
+ if (fout != nullptr) {
fclose(fout);
}
}
@@ -224,10 +224,10 @@ void __cdecl TlenProcessP2P(XmlNode *node, ThreadData *info) {
TLEN_LIST_ITEM *item;
char *from;
- if (info == NULL) return;
+ if (info == nullptr) return;
queryNode = TlenXmlGetChild(node, "query");
- if ((from=TlenXmlGetAttrValue(node, "from")) != NULL) {
+ if ((from=TlenXmlGetAttrValue(node, "from")) != nullptr) {
XmlNode *fs , *vs, *dcng, *dc;
/* file send */
fs = TlenXmlGetChild(queryNode, "fs");
@@ -235,7 +235,7 @@ void __cdecl TlenProcessP2P(XmlNode *node, ThreadData *info) {
vs = TlenXmlGetChild(queryNode, "vs");
dcng = TlenXmlGetChild(queryNode, "dcng");
dc = TlenXmlGetChild(queryNode, "dc");
- if (fs != NULL) {
+ if (fs != nullptr) {
char *e, *id;
/* e - step in the process (starting with 1)*/
/* i - id of the file */
@@ -244,7 +244,7 @@ void __cdecl TlenProcessP2P(XmlNode *node, ThreadData *info) {
/* v - ??? */
e = TlenXmlGetAttrValue(fs, "e");
id = TlenXmlGetAttrValue(fs, "i");
- if (e != NULL) {
+ if (e != nullptr) {
if (!mir_strcmp(e, "1")) {
TLEN_FILE_TRANSFER * ft = (TLEN_FILE_TRANSFER *) mir_alloc(sizeof(TLEN_FILE_TRANSFER));
memset(ft, 0, sizeof(TLEN_FILE_TRANSFER));
@@ -256,7 +256,7 @@ void __cdecl TlenProcessP2P(XmlNode *node, ThreadData *info) {
ft->iqId = mir_strdup(id);
ft->fileTotalSize = atoi(s);
ft->newP2P = TRUE;
- if ((item=TlenListAdd(ft->proto, LIST_FILE, ft->iqId)) != NULL) {
+ if ((item=TlenListAdd(ft->proto, LIST_FILE, ft->iqId)) != nullptr) {
char fileInfo[128];
item->ft = ft;
mir_snprintf(fileInfo, "%s file(s), %s bytes", c, s);
@@ -264,7 +264,7 @@ void __cdecl TlenProcessP2P(XmlNode *node, ThreadData *info) {
PROTORECVFILET pre = { 0 };
pre.dwFlags = PRFF_UNICODE;
pre.fileCount = 1;
- pre.timestamp = time(NULL);
+ pre.timestamp = time(nullptr);
pre.descr.w = filenameT;
pre.files.w = &filenameT;
pre.lParam = (LPARAM)ft;
@@ -278,16 +278,16 @@ void __cdecl TlenProcessP2P(XmlNode *node, ThreadData *info) {
/* transfer denied */
} else if (!mir_strcmp(e, "5")) {
/* transfer accepted */
- if ((item=TlenListGetItemPtr(info->proto, LIST_FILE, id)) != NULL) {
+ if ((item=TlenListGetItemPtr(info->proto, LIST_FILE, id)) != nullptr) {
item->id2 = mir_strdup("84273372");
item->ft->id2 = mir_strdup("84273372");
TlenSend(info->proto, "<iq to='%s'><query xmlns='p2p'><dcng n='file_send' k='5' v='2' s='1' i='%s' ck='o7a32V9n2UZYCWpBUhSbFw==' ks='16' iv='MhjWEj9WTsovrQc=o7a32V9n2UZYCWpBUhSbFw==' mi='%s'/></query></iq>", from, item->id2, id);
}
}
}
- } else if (vs != NULL) {
+ } else if (vs != nullptr) {
- } else if (dcng != NULL) {
+ } else if (dcng != nullptr) {
info->proto->debugLogA("DCNG");
char *s = TlenXmlGetAttrValue(dcng, "s");
char *id2 = TlenXmlGetAttrValue(dcng, "i");
@@ -304,7 +304,7 @@ void __cdecl TlenProcessP2P(XmlNode *node, ThreadData *info) {
/* v - ? */
char *n = TlenXmlGetAttrValue(dcng, "n"); // n - name (file_send)
if (!mir_strcmp(n, "file_send")) {
- if ((item=TlenListGetItemPtr(info->proto, LIST_FILE, id)) != NULL) {
+ if ((item=TlenListGetItemPtr(info->proto, LIST_FILE, id)) != nullptr) {
item->id2 = mir_strdup(id2);
item->ft->id2 = mir_strdup(id2);
TlenBindUDPSocket(item->ft);
@@ -317,7 +317,7 @@ void __cdecl TlenProcessP2P(XmlNode *node, ThreadData *info) {
info->proto->debugLogA("%s",from);
info->proto->debugLogA("%s",id2);
/* IP and port */
- if ((item=TlenListFindItemPtrById2(info->proto, LIST_FILE, id2)) != NULL) {
+ if ((item=TlenListFindItemPtrById2(info->proto, LIST_FILE, id2)) != nullptr) {
item->ft->hostName = mir_strdup(TlenXmlGetAttrValue(dcng, "pa"));
item->ft->wPort = atoi(TlenXmlGetAttrValue(dcng, "pp"));
TlenBindUDPSocket(item->ft);
@@ -328,7 +328,7 @@ void __cdecl TlenProcessP2P(XmlNode *node, ThreadData *info) {
}
} else if (!mir_strcmp(s, "4")) {
/* IP and port */
- if ((item=TlenListFindItemPtrById2(info->proto, LIST_FILE, id2)) != NULL) {
+ if ((item=TlenListFindItemPtrById2(info->proto, LIST_FILE, id2)) != nullptr) {
info->proto->debugLogA("step = 4");
item->ft->hostName = mir_strdup(TlenXmlGetAttrValue(dcng, "pa"));
item->ft->wPort = atoi(TlenXmlGetAttrValue(dcng, "pp"));
@@ -336,7 +336,7 @@ void __cdecl TlenProcessP2P(XmlNode *node, ThreadData *info) {
}
}
- } else if (dc != NULL) {
+ } else if (dc != nullptr) {
}
}
diff --git a/protocols/Tlen/src/tlen_p2p_old.cpp b/protocols/Tlen/src/tlen_p2p_old.cpp
index 2180bde7a7..d5a71a204e 100644
--- a/protocols/Tlen/src/tlen_p2p_old.cpp
+++ b/protocols/Tlen/src/tlen_p2p_old.cpp
@@ -50,13 +50,13 @@ void TlenP2PFreeFileTransfer(TLEN_FILE_TRANSFER *ft)
TLEN_FILE_PACKET *TlenP2PPacketCreate(int datalen)
{
TLEN_FILE_PACKET *packet=(TLEN_FILE_PACKET *) mir_alloc(sizeof(TLEN_FILE_PACKET));
- if (packet == NULL)
- return NULL;
- packet->packet = NULL;
+ if (packet == nullptr)
+ return nullptr;
+ packet->packet = nullptr;
if (datalen > 0) {
- if ((packet->packet=(char *) mir_alloc(datalen)) == NULL) {
+ if ((packet->packet=(char *) mir_alloc(datalen)) == nullptr) {
mir_free(packet);
- return NULL;
+ return nullptr;
}
}
packet->maxDataLen = datalen;
@@ -67,8 +67,8 @@ TLEN_FILE_PACKET *TlenP2PPacketCreate(int datalen)
void TlenP2PPacketFree(TLEN_FILE_PACKET *packet)
{
- if (packet != NULL) {
- if (packet->packet != NULL)
+ if (packet != nullptr) {
+ if (packet->packet != nullptr)
mir_free(packet->packet);
mir_free(packet);
}
@@ -76,21 +76,21 @@ void TlenP2PPacketFree(TLEN_FILE_PACKET *packet)
void TlenP2PPacketSetType(TLEN_FILE_PACKET *packet, DWORD type)
{
- if (packet != NULL) {
+ if (packet != nullptr) {
packet->type = type;
}
}
void TlenP2PPacketSetLen(TLEN_FILE_PACKET *packet, DWORD len)
{
- if (packet != NULL) {
+ if (packet != nullptr) {
packet->len = len;
}
}
void TlenP2PPacketPackDword(TLEN_FILE_PACKET *packet, DWORD data)
{
- if (packet != NULL && packet->packet != NULL) {
+ if (packet != nullptr && packet->packet != nullptr) {
if (packet->len + sizeof(DWORD) <= packet->maxDataLen) {
(*((DWORD*)((packet->packet)+(packet->len)))) = data;
packet->len += sizeof(DWORD);
@@ -100,7 +100,7 @@ void TlenP2PPacketPackDword(TLEN_FILE_PACKET *packet, DWORD data)
void TlenP2PPacketPackBuffer(TLEN_FILE_PACKET *packet, char *buffer, int len)
{
- if (packet != NULL && packet->packet != NULL) {
+ if (packet != nullptr && packet->packet != nullptr) {
if (packet->len + len <= packet->maxDataLen) {
memcpy((packet->packet)+(packet->len), buffer, len);
packet->len += len;
@@ -117,7 +117,7 @@ void TlenP2PUninit() {
int TlenP2PPacketSend(HNETLIBCONN s, TLEN_FILE_PACKET *packet)
{
DWORD sendResult;
- if (packet != NULL && packet->packet != NULL) {
+ if (packet != nullptr && packet->packet != nullptr) {
Netlib_Send(s, (char *)&packet->type, 4, MSG_NODUMP);
Netlib_Send(s, (char *)&packet->len, 4, MSG_NODUMP);
sendResult=Netlib_Send(s, packet->packet, packet->len, MSG_NODUMP);
@@ -130,9 +130,9 @@ TLEN_FILE_PACKET* TlenP2PPacketReceive(HNETLIBCONN s)
{
DWORD type, len, pos;
DWORD recvResult = Netlib_Recv(s, (char *)&type, 4, MSG_NODUMP);
- if (recvResult == 0 || recvResult == SOCKET_ERROR) return NULL;
+ if (recvResult == 0 || recvResult == SOCKET_ERROR) return nullptr;
recvResult = Netlib_Recv(s, (char *)&len, 4, MSG_NODUMP);
- if (recvResult == 0 || recvResult == SOCKET_ERROR) return NULL;
+ if (recvResult == 0 || recvResult == SOCKET_ERROR) return nullptr;
TLEN_FILE_PACKET *packet = TlenP2PPacketCreate(len);
TlenP2PPacketSetType(packet, type);
TlenP2PPacketSetLen(packet, len);
@@ -141,7 +141,7 @@ TLEN_FILE_PACKET* TlenP2PPacketReceive(HNETLIBCONN s)
recvResult = Netlib_Recv(s, packet->packet+pos, len, MSG_NODUMP);
if (recvResult == 0 || recvResult == SOCKET_ERROR) {
TlenP2PPacketFree(packet);
- return NULL;
+ return nullptr;
}
len -= recvResult;
pos += recvResult;
@@ -157,7 +157,7 @@ void TlenP2PEstablishOutgoingConnection(TLEN_FILE_TRANSFER *ft, BOOL sendAck)
proto->debugLogA("Establishing outgoing connection.");
ft->state = FT_ERROR;
TLEN_FILE_PACKET *packet = TlenP2PPacketCreate(2*sizeof(DWORD) + 20);
- if (packet != NULL) {
+ if (packet != nullptr) {
TlenP2PPacketSetType(packet, TLEN_FILE_PACKET_CONNECTION_REQUEST);
TlenP2PPacketPackDword(packet, 1);
TlenP2PPacketPackDword(packet, (DWORD) atoi(ft->iqId));
@@ -168,7 +168,7 @@ void TlenP2PEstablishOutgoingConnection(TLEN_FILE_TRANSFER *ft, BOOL sendAck)
TlenP2PPacketSend(ft->s, packet);
TlenP2PPacketFree(packet);
packet = TlenP2PPacketReceive(ft->s);
- if (packet != NULL) {
+ if (packet != nullptr) {
if (packet->type == TLEN_FILE_PACKET_CONNECTION_REQUEST_ACK) { // acknowledge
if ((int)(*((DWORD*)packet->packet)) == atoi(ft->iqId)) {
ft->state = FT_CONNECTING;
@@ -192,18 +192,18 @@ TLEN_FILE_TRANSFER* TlenP2PEstablishIncomingConnection(TlenProtocol *proto, HNET
// (DWORD) id
// (BYTE) hash[20]
TLEN_FILE_PACKET *packet = TlenP2PPacketReceive(s);
- if (packet == NULL || packet->type != TLEN_FILE_PACKET_CONNECTION_REQUEST || packet->len<28) {
- if (packet != NULL) {
+ if (packet == nullptr || packet->type != TLEN_FILE_PACKET_CONNECTION_REQUEST || packet->len<28) {
+ if (packet != nullptr) {
TlenP2PPacketFree(packet);
}
- return NULL;
+ return nullptr;
}
iqId = *((DWORD *)(packet->packet+sizeof(DWORD)));
int i = 0;
TLEN_LIST_ITEM *item;
while ((i=TlenListFindNext(proto, list, i)) >= 0) {
item = TlenListGetItemPtrFromIndex(proto, i);
- if (item != NULL) {
+ if (item != nullptr) {
mir_snprintf(str, "%d", iqId);
if (!mir_strcmp(item->ft->iqId, str)) {
char *hash, *nick;
@@ -223,7 +223,7 @@ TLEN_FILE_TRANSFER* TlenP2PEstablishIncomingConnection(TlenProtocol *proto, HNET
}
TlenP2PPacketFree(packet);
if (i >=0) {
- if ((packet=TlenP2PPacketCreate(sizeof(DWORD))) != NULL) {
+ if ((packet=TlenP2PPacketCreate(sizeof(DWORD))) != nullptr) {
// Send connection establishment acknowledgement
TlenP2PPacketSetType(packet, TLEN_FILE_PACKET_CONNECTION_REQUEST_ACK);
TlenP2PPacketPackDword(packet, (DWORD) atoi(item->ft->iqId));
@@ -236,7 +236,7 @@ TLEN_FILE_TRANSFER* TlenP2PEstablishIncomingConnection(TlenProtocol *proto, HNET
return item->ft;
}
}
- return NULL;
+ return nullptr;
}
static void __cdecl TlenFileBindSocks4Thread(TLEN_FILE_TRANSFER* ft)
@@ -252,7 +252,7 @@ static void __cdecl TlenFileBindSocks4Thread(TLEN_FILE_TRANSFER* ft)
status = 0;
}
if (!status) {
- ft->pfnNewConnectionV2(ft->s, 0, NULL);
+ ft->pfnNewConnectionV2(ft->s, 0, nullptr);
} else {
if (ft->state != FT_SWITCH) {
ft->state = FT_ERROR;
@@ -260,7 +260,7 @@ static void __cdecl TlenFileBindSocks4Thread(TLEN_FILE_TRANSFER* ft)
}
ft->proto->debugLogA("Closing connection for this file transfer...");
// Netlib_CloseHandle(ft->s);
- if (ft->hFileEvent != NULL)
+ if (ft->hFileEvent != nullptr)
SetEvent(ft->hFileEvent);
}
@@ -277,7 +277,7 @@ static void __cdecl TlenFileBindSocks5Thread(TLEN_FILE_TRANSFER* ft)
status = 0;
}
if (!status) {
- ft->pfnNewConnectionV2(ft->s, 0, NULL);
+ ft->pfnNewConnectionV2(ft->s, 0, nullptr);
} else {
if (ft->state != FT_SWITCH) {
ft->state = FT_ERROR;
@@ -285,7 +285,7 @@ static void __cdecl TlenFileBindSocks5Thread(TLEN_FILE_TRANSFER* ft)
}
// TlenLog("Closing connection for this file transfer...");
// Netlib_CloseHandle(ft->s);
- if (ft->hFileEvent != NULL)
+ if (ft->hFileEvent != nullptr)
SetEvent(ft->hFileEvent);
}
@@ -301,9 +301,9 @@ static HNETLIBCONN TlenP2PBindSocks4(SOCKSBIND * sb, TLEN_FILE_TRANSFER *ft)
nloc.szHost = sb->szHost;
nloc.wPort = sb->wPort;
HNETLIBCONN s = Netlib_OpenConnection(ft->proto->hFileNetlibUser, &nloc);
- if (s == NULL) {
+ if (s == nullptr) {
// TlenLog("Connection failed (%d), thread ended", WSAGetLastError());
- return NULL;
+ return nullptr;
}
buf[0] = 4; //socks4
buf[1] = 2; //2-bind, 1-connect
@@ -321,19 +321,19 @@ static HNETLIBCONN TlenP2PBindSocks4(SOCKSBIND * sb, TLEN_FILE_TRANSFER *ft)
if (status == SOCKET_ERROR || status < len) {
// TlenLog("Send failed (%d), thread ended", WSAGetLastError());
Netlib_CloseHandle(s);
- return NULL;
+ return nullptr;
}
status = Netlib_Recv(s, (char*)buf, 8, MSG_NODUMP);
if (status == SOCKET_ERROR || status < 8 || buf[1] != 90) {
// TlenLog("SOCKS4 negotiation failed");
Netlib_CloseHandle(s);
- return NULL;
+ return nullptr;
}
status = Netlib_Recv(s, (char*)buf, sizeof(buf), MSG_NODUMP);
if ( status == SOCKET_ERROR || status < 7 || buf[0] != 5 || buf[1] != 0) {
// TlenLog("SOCKS5 request failed");
Netlib_CloseHandle(s);
- return NULL;
+ return nullptr;
}
in.S_un.S_addr = *(PDWORD)(buf+4);
strncpy(sb->szHost, inet_ntoa(in), sizeof(sb->szHost)-1);
@@ -353,9 +353,9 @@ static HNETLIBCONN TlenP2PBindSocks5(SOCKSBIND * sb, TLEN_FILE_TRANSFER *ft)
nloc.szHost = sb->szHost;
nloc.wPort = sb->wPort;
HNETLIBCONN s = Netlib_OpenConnection(ft->proto->hFileNetlibUser, &nloc);
- if (s == NULL) {
+ if (s == nullptr) {
ft->proto->debugLogA("Connection failed (%d), thread ended", WSAGetLastError());
- return NULL;
+ return nullptr;
}
buf[0] = 5; //yep, socks5
buf[1] = 1; //one auth method
@@ -364,13 +364,13 @@ static HNETLIBCONN TlenP2PBindSocks5(SOCKSBIND * sb, TLEN_FILE_TRANSFER *ft)
if (status == SOCKET_ERROR || status < 3) {
ft->proto->debugLogA("Send failed (%d), thread ended", WSAGetLastError());
Netlib_CloseHandle(s);
- return NULL;
+ return nullptr;
}
status = Netlib_Recv(s, (char*)buf, 2, MSG_NODUMP);
if (status == SOCKET_ERROR || status < 2 || (buf[1] != 0 && buf[1] != 2)) {
ft->proto->debugLogA("SOCKS5 negotiation failed");
Netlib_CloseHandle(s);
- return NULL;
+ return nullptr;
}
if (buf[1] == 2) { //rfc1929
int nUserLen, nPassLen;
@@ -389,13 +389,13 @@ static HNETLIBCONN TlenP2PBindSocks5(SOCKSBIND * sb, TLEN_FILE_TRANSFER *ft)
if (status == SOCKET_ERROR || status < 3 + nUserLen+nPassLen) {
ft->proto->debugLogA("Send failed (%d), thread ended", WSAGetLastError());
Netlib_CloseHandle(s);
- return NULL;
+ return nullptr;
}
status = Netlib_Recv(s, (char*)buf, sizeof(buf), MSG_NODUMP);
if (status == SOCKET_ERROR || status < 2 || buf[1] != 0) {
ft->proto->debugLogA("SOCKS5 sub-negotiation failed");
Netlib_CloseHandle(s);
- return NULL;
+ return nullptr;
}
}
@@ -414,14 +414,14 @@ static HNETLIBCONN TlenP2PBindSocks5(SOCKSBIND * sb, TLEN_FILE_TRANSFER *ft)
if (status == SOCKET_ERROR || status < 6 + nHostLen) {
// TlenLog("Send failed (%d), thread ended", WSAGetLastError());
Netlib_CloseHandle(s);
- return NULL;
+ return nullptr;
}
}
status = Netlib_Recv(s, (char*)buf, sizeof(buf), MSG_NODUMP);
if ( status == SOCKET_ERROR || status < 7 || buf[0] != 5 || buf[1] != 0) {
// TlenLog("SOCKS5 request failed");
Netlib_CloseHandle(s);
- return NULL;
+ return nullptr;
}
if (buf[2] == 1) { // domain
len = buf[4];
@@ -443,15 +443,15 @@ static HNETLIBCONN TlenP2PBindSocks5(SOCKSBIND * sb, TLEN_FILE_TRANSFER *ft)
HNETLIBCONN TlenP2PListen(TLEN_FILE_TRANSFER *ft)
{
- HNETLIBCONN s = NULL;
+ HNETLIBCONN s = nullptr;
int useProxy;
DBVARIANT dbv;
SOCKSBIND sb;
struct in_addr in;
TlenProtocol *proto = ft->proto;
useProxy=0;
- if (ft->localName != NULL) mir_free(ft->localName);
- ft->localName = NULL;
+ if (ft->localName != nullptr) mir_free(ft->localName);
+ ft->localName = nullptr;
ft->wPort = 0;
if (db_get_b(NULL, proto->m_szModuleName, "UseFileProxy", FALSE)) {
if (!db_get(NULL, proto->m_szModuleName, "FileProxyHost", &dbv)) {
@@ -506,14 +506,14 @@ HNETLIBCONN TlenP2PListen(TLEN_FILE_TRANSFER *ft)
ft->wPort = nlb.wPort;
ft->wLocalPort = nlb.wExPort;
}
- if (s != NULL) {
+ if (s != nullptr) {
// listenCount++;
}
return s;
}
void TlenP2PStopListening(HANDLE s) {
- if (s != NULL) {
+ if (s != nullptr) {
// listenCount--;
// if (listenCount <= 0) {
// Netlib_CloseHandle(s);
diff --git a/protocols/Tlen/src/tlen_picture.cpp b/protocols/Tlen/src/tlen_picture.cpp
index 79e9b7b545..f75e0a42e6 100644
--- a/protocols/Tlen/src/tlen_picture.cpp
+++ b/protocols/Tlen/src/tlen_picture.cpp
@@ -44,10 +44,10 @@ static void TlenPsPostThread(void *ptr) {
TLEN_LIST_ITEM *item = data->item;
HNETLIBCONN socket = TlenWsConnect(proto, "ps.tlen.pl", 443);
BOOL bSent = FALSE;
- if (socket != NULL) {
+ if (socket != nullptr) {
char header[512];
item->ft->s = socket;
- item->ft->hFileEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+ item->ft->hFileEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
int ret = mir_snprintf(header, "<pic auth='%s' t='p' to='%s' size='%d' idt='%s'/>", proto->threadData->username, item->ft->jid, item->ft->fileTotalSize, item->jid);
TlenWsSend(proto, socket, header, ret);
ret = WaitForSingleObject(item->ft->hFileEvent, 1000 * 60 * 5);
@@ -100,7 +100,7 @@ static void TlenPsGetThread(void *ptr) {
fp = fopen( item->ft->files[0], "wb" );
if (fp) {
HNETLIBCONN socket = TlenWsConnect(proto, "ps.tlen.pl", 443);
- if (socket != NULL) {
+ if (socket != nullptr) {
XmlState xmlState;
char header[512];
char fileBuffer[2048];
@@ -121,7 +121,7 @@ static void TlenPsGetThread(void *ptr) {
if (bHeader) {
char * tagend = (char*)memchr(fileBuffer, '/', totalcount);
tagend = (char*)memchr(tagend + 1, '>', totalcount - (tagend - fileBuffer) - 1);
- if (tagend != NULL) {
+ if (tagend != nullptr) {
int parsed = TlenXmlParse(&xmlState, fileBuffer, tagend - fileBuffer + 1);
if (parsed == 0) {
continue;
@@ -166,7 +166,7 @@ static void TlenPsGet(TlenProtocol *proto, TLEN_LIST_ITEM *item) {
}
void TlenProcessPic(XmlNode *node, TlenProtocol *proto) {
- TLEN_LIST_ITEM *item = NULL;
+ TLEN_LIST_ITEM *item = nullptr;
char *crc, *crc_c, *idt, *size, *from, *fromRaw, *rt;
from = TlenXmlGetAttrValue(node, "from");
fromRaw = TlenLoginFromJID(from);
@@ -175,22 +175,22 @@ void TlenProcessPic(XmlNode *node, TlenProtocol *proto) {
crc_c = TlenXmlGetAttrValue(node, "crc_c");
crc = TlenXmlGetAttrValue(node, "crc");
rt = TlenXmlGetAttrValue(node, "rt");
- if (idt != NULL) {
+ if (idt != nullptr) {
item = TlenListGetItemPtr(proto, LIST_PICTURE, idt);
}
- if (item != NULL) {
+ if (item != nullptr) {
if (!mir_strcmp(from, "ps")) {
char *st = TlenXmlGetAttrValue(node, "st");
- if (st != NULL) {
+ if (st != nullptr) {
item->ft->iqId = mir_strdup(st);
item->ft->id2 = mir_strdup(rt);
- if (item->ft->hFileEvent != NULL) {
+ if (item->ft->hFileEvent != nullptr) {
SetEvent(item->ft->hFileEvent);
- item->ft->hFileEvent = NULL;
+ item->ft->hFileEvent = nullptr;
}
}
} else if (!mir_strcmp(item->ft->jid, fromRaw)) {
- if (crc_c != NULL) {
+ if (crc_c != nullptr) {
if (!mir_strcmp(crc_c, "n")) {
/* crc_c = n, picture transfer accepted */
TlenPsPost(proto, item);
@@ -200,12 +200,12 @@ void TlenProcessPic(XmlNode *node, TlenProtocol *proto) {
TlenP2PFreeFileTransfer(item->ft);
TlenListRemove(proto, LIST_PICTURE, idt);
}
- } else if (rt != NULL) {
+ } else if (rt != nullptr) {
item->ft->id2 = mir_strdup(rt);
TlenPsGet(proto, item);
}
}
- } else if (crc != NULL) {
+ } else if (crc != nullptr) {
BOOL bAccept = proto->tlenOptions.imagePolicy == TLEN_IMAGES_ACCEPT_ALL || (proto->tlenOptions.imagePolicy == TLEN_IMAGES_IGNORE_NIR && IsAuthorized(proto, from));
if (bAccept) {
FILE* fp;
@@ -257,7 +257,7 @@ BOOL SendPicture(TlenProtocol *proto, MCONTACT hContact) {
OPENFILENAME ofn = {0};
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
ofn.lpstrFilter = tszFilter;
- ofn.lpstrCustomFilter = NULL;
+ ofn.lpstrCustomFilter = nullptr;
ofn.lpstrFile = tszFileName;
ofn.nMaxFile = _MAX_PATH;
ofn.Flags = OFN_FILEMUSTEXIST;
diff --git a/protocols/Tlen/src/tlen_presence.cpp b/protocols/Tlen/src/tlen_presence.cpp
index 56e4fc9e10..3e12761582 100644
--- a/protocols/Tlen/src/tlen_presence.cpp
+++ b/protocols/Tlen/src/tlen_presence.cpp
@@ -33,19 +33,19 @@ void TlenProcessPresence(XmlNode *node, TlenProtocol *proto)
int status, laststatus = ID_STATUS_OFFLINE;
char *p;
- if ((from=TlenXmlGetAttrValue(node, "from")) != NULL) {
+ if ((from=TlenXmlGetAttrValue(node, "from")) != nullptr) {
if (TlenListExist(proto, LIST_CHATROOM, from)); //TlenGroupchatProcessPresence(node, userdata);
else {
type = TlenXmlGetAttrValue(node, "type");
item = TlenListGetItemPtr(proto, LIST_ROSTER, from);
- if (item != NULL) {
+ if (item != nullptr) {
if (proto->tlenOptions.enableAvatars) {
TlenProcessPresenceAvatar(proto, node, item);
}
}
- if (type == NULL || (!mir_strcmp(type, "available"))) {
- if ((nick=TlenLocalNickFromJID(from)) != NULL) {
+ if (type == nullptr || (!mir_strcmp(type, "available"))) {
+ if ((nick=TlenLocalNickFromJID(from)) != nullptr) {
if ((hContact=TlenHContactFromJID(proto, from)) == NULL)
hContact = TlenDBCreateContact(proto, from, nick, FALSE);
if (!TlenListExist(proto, LIST_ROSTER, from)) {
@@ -53,8 +53,8 @@ void TlenProcessPresence(XmlNode *node, TlenProtocol *proto)
TlenListAdd(proto, LIST_ROSTER, from);
}
status = ID_STATUS_ONLINE;
- if ((showNode=TlenXmlGetChild(node, "show")) != NULL) {
- if ((show=showNode->text) != NULL) {
+ if ((showNode=TlenXmlGetChild(node, "show")) != nullptr) {
+ if ((show=showNode->text) != nullptr) {
if (!mir_strcmp(show, "away")) status = ID_STATUS_AWAY;
else if (!mir_strcmp(show, "xa")) status = ID_STATUS_NA;
else if (!mir_strcmp(show, "dnd")) status = ID_STATUS_DND;
@@ -70,9 +70,9 @@ void TlenProcessPresence(XmlNode *node, TlenProtocol *proto)
if (statusNode)
p = TlenTextDecode(statusNode->text);
else
- p = NULL;
- TlenListAddResource(proto, LIST_ROSTER, from, status, statusNode?p:NULL);
- if (p != NULL && *p) {
+ p = nullptr;
+ TlenListAddResource(proto, LIST_ROSTER, from, status, statusNode?p:nullptr);
+ if (p != nullptr && *p) {
char* statusMsg_utf8 = mir_utf8encode(p);
db_set_utf(hContact, "CList", "StatusMsg", statusMsg_utf8);
mir_free(statusMsg_utf8);
@@ -81,15 +81,15 @@ void TlenProcessPresence(XmlNode *node, TlenProtocol *proto)
db_unset(hContact, "CList", "StatusMsg");
}
// Determine status to show for the contact and request version information
- if (item != NULL) {
+ if (item != nullptr) {
laststatus = item->status;
item->status = status;
}
- if (strchr(from, '@') != NULL || db_get_b(NULL, proto->m_szModuleName, "ShowTransport", TRUE) == TRUE) {
+ if (strchr(from, '@') != nullptr || db_get_b(NULL, proto->m_szModuleName, "ShowTransport", TRUE) == TRUE) {
if (db_get_w(hContact, proto->m_szModuleName, "Status", ID_STATUS_OFFLINE) != status)
db_set_w(hContact, proto->m_szModuleName, "Status", (WORD) status);
}
- if (item != NULL) {
+ if (item != nullptr) {
if (!item->infoRequested) {
int iqId = TlenSerialNext(proto);
item->infoRequested = TRUE;
@@ -123,10 +123,10 @@ void TlenProcessPresence(XmlNode *node, TlenProtocol *proto)
p = TlenTextDecode(statusNode->text);
}
else
- p = NULL;
+ p = nullptr;
TlenListAddResource(proto, LIST_ROSTER, from, status, p);
if ((hContact=TlenHContactFromJID(proto, from)) != NULL) {
- if (p != NULL && *p) {
+ if (p != nullptr && *p) {
char* statusMsg_utf8 = mir_utf8encode(p);
db_set_utf(hContact, "CList", "StatusMsg", statusMsg_utf8);
mir_free(statusMsg_utf8);
@@ -135,18 +135,18 @@ void TlenProcessPresence(XmlNode *node, TlenProtocol *proto)
db_unset(hContact, "CList", "StatusMsg");
}
}
- if ((item=TlenListGetItemPtr(proto, LIST_ROSTER, from)) != NULL) {
+ if ((item=TlenListGetItemPtr(proto, LIST_ROSTER, from)) != nullptr) {
// Determine status to show for the contact based on the remaining resources
item->status = status;
item->versionRequested = FALSE;
item->infoRequested = FALSE;
}
if ((hContact=TlenHContactFromJID(proto, from)) != NULL) {
- if (strchr(from, '@') != NULL || db_get_b(NULL, proto->m_szModuleName, "ShowTransport", TRUE) == TRUE) {
+ if (strchr(from, '@') != nullptr || db_get_b(NULL, proto->m_szModuleName, "ShowTransport", TRUE) == TRUE) {
if (db_get_w(hContact, proto->m_szModuleName, "Status", ID_STATUS_OFFLINE) != status)
db_set_w(hContact, proto->m_szModuleName, "Status", (WORD) status);
}
- if (item != NULL && item->isTyping) {
+ if (item != nullptr && item->isTyping) {
item->isTyping = FALSE;
CallService(MS_PROTO_CONTACTISTYPING, hContact, PROTOTYPE_CONTACTTYPING_OFF);
}
@@ -154,18 +154,18 @@ void TlenProcessPresence(XmlNode *node, TlenProtocol *proto)
}
}
else if (!mir_strcmp(type, "subscribe")) {
- if (strchr(from, '@') == NULL) {
+ if (strchr(from, '@') == nullptr) {
// automatically send authorization allowed to agent/transport
TlenSend(proto, "<presence to='%s' type='subscribed'/>", from);
}
- else if ((nick=TlenNickFromJID(from)) != NULL) {
+ else if ((nick=TlenNickFromJID(from)) != nullptr) {
proto->debugLogA("%s (%s) requests authorization", nick, from);
TlenDBAddAuthRequest(proto, from, nick);
mir_free(nick);
}
}
else if (!mir_strcmp(type, "subscribed")) {
- if ((item=TlenListGetItemPtr(proto, LIST_ROSTER, from)) != NULL) {
+ if ((item=TlenListGetItemPtr(proto, LIST_ROSTER, from)) != nullptr) {
if (item->subscription == SUB_FROM) item->subscription = SUB_BOTH;
else if (item->subscription == SUB_NONE) {
item->subscription = SUB_TO;
@@ -184,7 +184,7 @@ void setOwnStatusOnCList(TlenProtocol *proto, int status, char *statusMsg)
if(hContact){
if (db_get_w(hContact, proto->m_szModuleName, "Status", ID_STATUS_OFFLINE) != status)
db_set_w(hContact, proto->m_szModuleName, "Status", (WORD)status);
- if (statusMsg != NULL && *statusMsg) {
+ if (statusMsg != nullptr && *statusMsg) {
char* statusMsg_utf8 = mir_utf8encode(statusMsg);
db_set_utf(hContact, "CList", "StatusMsg", statusMsg_utf8);
mir_free(statusMsg_utf8);
@@ -197,7 +197,7 @@ void setOwnStatusOnCList(TlenProtocol *proto, int status, char *statusMsg)
static void TlenSendPresenceTo(TlenProtocol *proto, int status, char*)
{
char *showBody, *statusMsg, *presenceType;
- char *ptr = NULL;
+ char *ptr = nullptr;
if (!proto->isOnline) return;
@@ -205,9 +205,9 @@ static void TlenSendPresenceTo(TlenProtocol *proto, int status, char*)
// Note: tlenModeMsg is already encoded using TlenTextEncode()
mir_cslock lck(proto->modeMsgMutex);
- showBody = NULL;
- statusMsg = NULL;
- presenceType = NULL;
+ showBody = nullptr;
+ statusMsg = nullptr;
+ presenceType = nullptr;
switch (status) {
case ID_STATUS_ONLINE:
showBody = "available";
@@ -277,9 +277,9 @@ static void TlenSendPresenceTo(TlenProtocol *proto, int status, char*)
for (i=0;ptr[i];i++) {
if (ptr[i] != '%') continue;
if (!_strnicmp(ptr+i,"%time%",6))
- GetTimeFormatA(LOCALE_USER_DEFAULT,TIME_NOSECONDS,NULL,NULL,substituteStr,sizeof(substituteStr));
+ GetTimeFormatA(LOCALE_USER_DEFAULT,TIME_NOSECONDS,nullptr,nullptr,substituteStr,sizeof(substituteStr));
else if (!_strnicmp(ptr+i,"%date%",6))
- GetDateFormatA(LOCALE_USER_DEFAULT,DATE_SHORTDATE,NULL,NULL,substituteStr,sizeof(substituteStr));
+ GetDateFormatA(LOCALE_USER_DEFAULT,DATE_SHORTDATE,nullptr,nullptr,substituteStr,sizeof(substituteStr));
else continue;
if (mir_strlen(substituteStr)>6) ptr=(char*)mir_realloc(ptr,mir_strlen(ptr)+1+mir_strlen(substituteStr)-6);
memmove(ptr+i+mir_strlen(substituteStr),ptr+i+6,mir_strlen(ptr)-i-5);
@@ -297,12 +297,12 @@ static void TlenSendPresenceTo(TlenProtocol *proto, int status, char*)
}
proto->m_iStatus = status;
if (presenceType) {
- if (statusMsg != NULL && *statusMsg)
+ if (statusMsg != nullptr && *statusMsg)
TlenSend(proto, "<presence type='%s'><status>%s</status></presence>", presenceType, ptrA(TlenTextEncode(statusMsg)));
else
TlenSend(proto, "<presence type='%s'></presence>", presenceType);
} else {
- if (statusMsg != NULL && *statusMsg)
+ if (statusMsg != nullptr && *statusMsg)
TlenSend(proto, "<presence><show>%s</show><status>%s</status></presence>", showBody, ptrA(TlenTextEncode(statusMsg)));
else
TlenSend(proto, "<presence><show>%s</show></presence>", showBody);
@@ -335,7 +335,7 @@ void TlenSendPresence(TlenProtocol *proto, int statusIn)
statusOut = ID_STATUS_DND;
break;
}
- TlenSendPresenceTo(proto, statusOut, NULL);
+ TlenSendPresenceTo(proto, statusOut, nullptr);
}
diff --git a/protocols/Tlen/src/tlen_svc.cpp b/protocols/Tlen/src/tlen_svc.cpp
index efced9bb74..1366155ccb 100644
--- a/protocols/Tlen/src/tlen_svc.cpp
+++ b/protocols/Tlen/src/tlen_svc.cpp
@@ -62,7 +62,7 @@ INT_PTR TlenProtocol::GetName(WPARAM wParam, LPARAM lParam)
int TlenRunSearch(TlenProtocol *proto) {
int iqId = 0;
if (!proto->isOnline) return 0;
- if (proto->searchQuery != NULL && proto->searchIndex < 10) {
+ if (proto->searchQuery != nullptr && proto->searchIndex < 10) {
iqId = proto->searchID;
TlenIqAdd(proto, iqId, IQ_PROC_GETSEARCH, TlenIqResultSearch);
if (proto->searchIndex == 0) {
@@ -77,9 +77,9 @@ int TlenRunSearch(TlenProtocol *proto) {
}
void TlenResetSearchQuery(TlenProtocol *proto) {
- if (proto->searchQuery != NULL) {
+ if (proto->searchQuery != nullptr) {
mir_free(proto->searchQuery);
- proto->searchQuery = NULL;
+ proto->searchQuery = nullptr;
}
proto->searchQueryLen = 0;
proto->searchIndex = 0;
@@ -89,11 +89,11 @@ void TlenResetSearchQuery(TlenProtocol *proto) {
HANDLE TlenProtocol::SearchBasic(const wchar_t* id)
{
int iqId = 0;
- if (!isOnline) return 0;
- if (id == NULL) return 0;
+ if (!isOnline) return nullptr;
+ if (id == nullptr) return nullptr;
char* id_A = mir_u2a(id);
char *jid = TlenTextEncode(id_A);
- if (jid != NULL) {
+ if (jid != nullptr) {
searchJID = mir_strdup(id_A);
TlenResetSearchQuery(this);
TlenStringAppend(&searchQuery, &searchQueryLen, "<i>%s</i>", jid);
@@ -108,12 +108,12 @@ HANDLE TlenProtocol::SearchByEmail(const wchar_t* email)
{
int iqId = 0;
- if (!isOnline) return 0;
- if (email == NULL) return 0;
+ if (!isOnline) return nullptr;
+ if (email == nullptr) return nullptr;
char* email_A = mir_u2a(email);
char *emailEnc = TlenTextEncode(email_A);
- if (emailEnc != NULL) {
+ if (emailEnc != nullptr) {
TlenResetSearchQuery(this);
TlenStringAppend(&searchQuery, &searchQueryLen, "<email>%s</email>", emailEnc);
iqId = TlenRunSearch(this);
@@ -125,7 +125,7 @@ HANDLE TlenProtocol::SearchByEmail(const wchar_t* email)
HANDLE TlenProtocol::SearchByName(const wchar_t* nickT, const wchar_t* firstNameT, const wchar_t* lastNameT)
{
- if (!isOnline) return 0;
+ if (!isOnline) return nullptr;
char *nick = mir_u2a(nickT);
char *firstName = mir_u2a(firstNameT);
@@ -136,20 +136,20 @@ HANDLE TlenProtocol::SearchByName(const wchar_t* nickT, const wchar_t* firstName
TlenResetSearchQuery(this);
- if (nick != NULL && nick[0] != '\0') {
- if ((p = TlenTextEncode(nick)) != NULL) {
+ if (nick != nullptr && nick[0] != '\0') {
+ if ((p = TlenTextEncode(nick)) != nullptr) {
TlenStringAppend(&searchQuery, &searchQueryLen, "<nick>%s</nick>", p);
mir_free(p);
}
}
- if (firstName != NULL && firstName[0] != '\0') {
- if ((p = TlenTextEncode(firstName)) != NULL) {
+ if (firstName != nullptr && firstName[0] != '\0') {
+ if ((p = TlenTextEncode(firstName)) != nullptr) {
TlenStringAppend(&searchQuery, &searchQueryLen, "<first>%s</first>", p);
mir_free(p);
}
}
- if (lastName != NULL && lastName[0] != '\0') {
- if ((p = TlenTextEncode(lastName)) != NULL) {
+ if (lastName != nullptr && lastName[0] != '\0') {
+ if ((p = TlenTextEncode(lastName)) != nullptr) {
TlenStringAppend(&searchQuery, &searchQueryLen, "<last>%s</last>", p);
mir_free(p);
}
@@ -166,11 +166,11 @@ HWND TlenProtocol::CreateExtendedSearchUI(HWND owner)
HWND TlenProtocol::SearchAdvanced(HWND owner)
{
- if (!isOnline) return 0;
+ if (!isOnline) return nullptr;
TlenResetSearchQuery(this);
int iqId = TlenSerialNext(this);
- if ((searchQuery = TlenAdvSearchCreateQuery(owner, iqId)) != NULL) {
+ if ((searchQuery = TlenAdvSearchCreateQuery(owner, iqId)) != nullptr) {
iqId = TlenRunSearch(this);
}
return (HWND)iqId;
@@ -187,7 +187,7 @@ static MCONTACT AddToListByJID(TlenProtocol *proto, const char *newJid, DWORD fl
Proto_AddToContact(hContact, proto->m_szModuleName);
db_set_s(hContact, proto->m_szModuleName, "jid", jid);
char *nick = TlenNickFromJID(newJid);
- if (nick == NULL)
+ if (nick == nullptr)
nick = mir_strdup(newJid);
db_set_s(hContact, "CList", "MyHandle", nick);
mir_free(nick);
@@ -228,7 +228,7 @@ MCONTACT TlenProtocol::AddToListByEvent(int flags, int, MEVENT hDbEvent)
DBEVENTINFO dbei = {};
if ((dbei.cbBlob = db_event_getBlobSize(hDbEvent)) == (DWORD)(-1))
return NULL;
- if ((dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob)) == NULL)
+ if ((dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob)) == nullptr)
return NULL;
if (db_event_get(hDbEvent, &dbei)) {
mir_free(dbei.pBlob);
@@ -265,7 +265,7 @@ int TlenProtocol::Authorize(MEVENT hDbEvent)
DBEVENTINFO dbei = {};
if ((dbei.cbBlob = db_event_getBlobSize(hDbEvent)) == (DWORD)-1)
return 1;
- if ((dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob)) == NULL)
+ if ((dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob)) == nullptr)
return 1;
if (db_event_get(hDbEvent, &dbei)) {
mir_free(dbei.pBlob);
@@ -288,7 +288,7 @@ int TlenProtocol::Authorize(MEVENT hDbEvent)
MCONTACT hContact;
TLEN_LIST_ITEM *item = TlenListGetItemPtr(this, LIST_ROSTER, blob.get_email());
- if (item == NULL || (item->subscription != SUB_BOTH && item->subscription != SUB_TO)) {
+ if (item == nullptr || (item->subscription != SUB_BOTH && item->subscription != SUB_TO)) {
debugLogA("Try adding contact automatically jid=%s", blob.get_email());
if ((hContact = AddToListByJID(this, blob.get_email(), 0)) != NULL) {
// Trigger actual add by removing the "NotOnList" added by AddToListByJID()
@@ -310,7 +310,7 @@ int TlenProtocol::AuthDeny(MEVENT hDbEvent, const wchar_t*)
DBEVENTINFO dbei = {};
if ((dbei.cbBlob = db_event_getBlobSize(hDbEvent)) == (DWORD)(-1))
return 1;
- if ((dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob)) == NULL)
+ if ((dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob)) == nullptr)
return 1;
if (db_event_get(hDbEvent, &dbei)) {
mir_free(dbei.pBlob);
@@ -363,7 +363,7 @@ int TlenProtocol::SetStatus(int iNewStatus)
// TODO bug? s = proto;
s = threadData->s;
- threadData = NULL;
+ threadData = nullptr;
if (isConnected) {
Sleep(200);
// TlenSend(s, "</s>");
@@ -438,14 +438,14 @@ int TlenProtocol::SetAwayMsg(int iStatus, const wchar_t* msg)
return 1;
}
- if ((*szMsg == NULL && newModeMsg == NULL) ||
- (*szMsg != NULL && newModeMsg != NULL && !mir_strcmp(*szMsg, newModeMsg))) {
+ if ((*szMsg == nullptr && newModeMsg == nullptr) ||
+ (*szMsg != nullptr && newModeMsg != nullptr && !mir_strcmp(*szMsg, newModeMsg))) {
// Message is the same, no update needed
- if (newModeMsg != NULL) mir_free(newModeMsg);
+ if (newModeMsg != nullptr) mir_free(newModeMsg);
}
else {
// Update with the new mode message
- if (*szMsg != NULL) mir_free(*szMsg);
+ if (*szMsg != nullptr) mir_free(*szMsg);
*szMsg = newModeMsg;
// Send a presence update if needed
if (iStatus == m_iStatus) {
@@ -470,8 +470,8 @@ int TlenProtocol::GetInfo(MCONTACT hContact, int)
}
else {
if (db_get(hContact, m_szModuleName, "jid", &dbv)) return 1;
- if ((nick = TlenNickFromJID(dbv.pszVal)) != NULL) {
- if ((pNick = TlenTextEncode(nick)) != NULL) {
+ if ((nick = TlenNickFromJID(dbv.pszVal)) != nullptr) {
+ if ((pNick = TlenTextEncode(nick)) != nullptr) {
iqId = TlenSerialNext(this);
TlenIqAdd(this, iqId, IQ_PROC_NONE, TlenIqResultVcard);
TlenSend(this, "<iq type='get' id='" TLEN_IQID "%d' to='tuba'><query xmlns='jabber:iq:search'><i>%s</i></query></iq>", iqId, pNick);
@@ -557,7 +557,7 @@ static void __cdecl TlenGetAwayMsgThread(void *ptr)
if (!db_get(data->hContact, data->proto->m_szModuleName, "jid", &dbv)) {
TLEN_LIST_ITEM *item = TlenListGetItemPtr(data->proto, LIST_ROSTER, dbv.pszVal);
- if (item != NULL) {
+ if (item != nullptr) {
db_free(&dbv);
ProtoBroadcastAck(data->proto->m_szModuleName, data->hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1,
item->statusMessage == NULL ? NULL : _A2T(item->statusMessage));
@@ -619,8 +619,8 @@ int TlenProtocol::SendMsg(MCONTACT hContact, int, const char* msgRAW)
}
else {
char *msgEnc = TlenTextEncode(msg);
- if (msgEnc != NULL) {
- if (TlenListExist(this, LIST_CHATROOM, dbv.pszVal) && strchr(dbv.pszVal, '/') == NULL)
+ if (msgEnc != nullptr) {
+ if (TlenListExist(this, LIST_CHATROOM, dbv.pszVal) && strchr(dbv.pszVal, '/') == nullptr)
mir_strcpy(msgType, "groupchat");
else if (db_get_b(hContact, m_szModuleName, "bChat", FALSE))
mir_strcpy(msgType, "privchat");
@@ -638,7 +638,7 @@ int TlenProtocol::SendMsg(MCONTACT hContact, int, const char* msgRAW)
mir_forkthread(TlenSendMessageAckThread, new SENDACKTHREADDATA(this, hContact, id));
}
else {
- if ((item = TlenListGetItemPtr(this, LIST_ROSTER, dbv.pszVal)) != NULL)
+ if ((item = TlenListGetItemPtr(this, LIST_ROSTER, dbv.pszVal)) != nullptr)
item->idMsgAckPending = id;
TlenSend(this, "<message to='%s' type='%s' id='" TLEN_IQID "%d'><body>%s</body><x xmlns='jabber:x:event'><offline/><delivered/><composing/></x></message>", dbv.pszVal, msgType, id, msgEnc);
}
@@ -658,8 +658,8 @@ INT_PTR TlenProtocol::GetAvatarInfo(WPARAM wParam, LPARAM lParam)
{
if (!tlenOptions.enableAvatars) return GAIR_NOAVATAR;
BOOL downloadingAvatar = FALSE;
- char *avatarHash = NULL;
- TLEN_LIST_ITEM *item = NULL;
+ char *avatarHash = nullptr;
+ TLEN_LIST_ITEM *item = nullptr;
DBVARIANT dbv;
PROTO_AVATAR_INFORMATION *pai = (PROTO_AVATAR_INFORMATION*)lParam;
@@ -667,19 +667,19 @@ INT_PTR TlenProtocol::GetAvatarInfo(WPARAM wParam, LPARAM lParam)
if (!db_get(pai->hContact, m_szModuleName, "jid", &dbv)) {
item = TlenListGetItemPtr(this, LIST_ROSTER, dbv.pszVal);
db_free(&dbv);
- if (item != NULL) {
+ if (item != nullptr) {
downloadingAvatar = item->newAvatarDownloading;
avatarHash = item->avatarHash;
}
}
}
- else if (threadData != NULL)
+ else if (threadData != nullptr)
avatarHash = threadData->avatarHash;
- if ((avatarHash == NULL || avatarHash[0] == '\0') && !downloadingAvatar)
+ if ((avatarHash == nullptr || avatarHash[0] == '\0') && !downloadingAvatar)
return GAIR_NOAVATAR;
- if (avatarHash != NULL && !downloadingAvatar) {
+ if (avatarHash != nullptr && !downloadingAvatar) {
TlenGetAvatarFileName(this, item, pai->filename, _countof(pai->filename) - 1);
pai->format = (pai->hContact == NULL) ? threadData->avatarFormat : item->avatarFormat;
return GAIR_SUCCESS;
@@ -706,12 +706,12 @@ int TlenProtocol::RecvAwayMsg(MCONTACT, int, PROTORECVEVENT*)
HANDLE TlenProtocol::FileAllow(MCONTACT, HANDLE hTransfer, const wchar_t* szPath)
{
- if (!isOnline) return 0;
+ if (!isOnline) return nullptr;
TLEN_FILE_TRANSFER *ft = (TLEN_FILE_TRANSFER *)hTransfer;
ft->szSavePath = mir_strdup(mir_u2a(szPath)); //TODO convert to wchar_t*
TLEN_LIST_ITEM *item = TlenListAdd(this, LIST_FILE, ft->iqId);
- if (item != NULL) {
+ if (item != nullptr) {
item->ft = ft;
}
char *nick = TlenNickFromJID(ft->jid);
@@ -746,13 +746,13 @@ int TlenProtocol::FileCancel(MCONTACT, HANDLE hTransfer)
{
TLEN_FILE_TRANSFER *ft = (TLEN_FILE_TRANSFER *)hTransfer;
debugLogA("Invoking FileCancel()");
- if (ft->s != NULL) {
+ if (ft->s != nullptr) {
ft->state = FT_ERROR;
Netlib_CloseHandle(ft->s);
- ft->s = NULL;
- if (ft->hFileEvent != NULL) {
+ ft->s = nullptr;
+ if (ft->hFileEvent != nullptr) {
HANDLE hEvent = ft->hFileEvent;
- ft->hFileEvent = NULL;
+ ft->hFileEvent = nullptr;
SetEvent(hEvent);
}
}
@@ -769,9 +769,9 @@ HANDLE TlenProtocol::SendFile(MCONTACT hContact, const wchar_t* szDescription, w
DBVARIANT dbv;
char *nick, *p, idStr[10];
- if (!isOnline) return 0;
+ if (!isOnline) return nullptr;
// if (db_get_w(ccs->hContact, m_szModuleName, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE) return 0;
- if (db_get(hContact, m_szModuleName, "jid", &dbv)) return 0;
+ if (db_get(hContact, m_szModuleName, "jid", &dbv)) return nullptr;
TLEN_FILE_TRANSFER *ft = TlenFileCreateFT(this, dbv.pszVal);
for (ft->fileCount = 0; ppszFiles[ft->fileCount]; ft->fileCount++);
ft->files = (char **)mir_alloc(sizeof(char *) * ft->fileCount);
@@ -797,7 +797,7 @@ HANDLE TlenProtocol::SendFile(MCONTACT hContact, const wchar_t* szDescription, w
int id = TlenSerialNext(this);
mir_snprintf(idStr, "%d", id);
TLEN_LIST_ITEM *item = TlenListAdd(this, LIST_FILE, idStr);
- if (item != NULL) {
+ if (item != nullptr) {
ft->iqId = mir_strdup(idStr);
nick = TlenNickFromJID(ft->jid);
item->ft = ft;
@@ -810,7 +810,7 @@ HANDLE TlenProtocol::SendFile(MCONTACT hContact, const wchar_t* szDescription, w
else {
if (ft->fileCount == 1) {
char* ppszFiles_0_A = mir_u2a(ppszFiles[0]);
- if ((p = strrchr(ppszFiles_0_A, '\\')) != NULL) {
+ if ((p = strrchr(ppszFiles_0_A, '\\')) != nullptr) {
p++;
}
else {
@@ -837,9 +837,9 @@ static char* settingToChar(DBCONTACTWRITESETTING* cws)
case DBVT_ASCIIZ:
return mir_strdup(cws->value.pszVal);
case DBVT_UTF8:
- return mir_utf8decode(mir_strdup(cws->value.pszVal), NULL);
+ return mir_utf8decode(mir_strdup(cws->value.pszVal), nullptr);
}
- return NULL;
+ return nullptr;
}
int TlenProtocol::TlenDbSettingChanged(WPARAM wParam, LPARAM lParam)
@@ -856,11 +856,11 @@ int TlenProtocol::TlenDbSettingChanged(WPARAM wParam, LPARAM lParam)
char *nick, *jid, *group;
char *szProto = GetContactProto(hContact);
- if (szProto == NULL || strcmp(szProto, m_szModuleName)) return 0;
+ if (szProto == nullptr || strcmp(szProto, m_szModuleName)) return 0;
// A contact's group is changed
if (!strcmp(cws->szSetting, "Group")) {
if (!db_get(hContact, m_szModuleName, "jid", &dbv)) {
- if ((item = TlenListGetItemPtr(this, LIST_ROSTER, dbv.pszVal)) != NULL) {
+ if ((item = TlenListGetItemPtr(this, LIST_ROSTER, dbv.pszVal)) != nullptr) {
db_free(&dbv);
if (!db_get(hContact, "CList", "MyHandle", &dbv)) {
nick = TlenTextEncode(dbv.pszVal);
@@ -872,17 +872,17 @@ int TlenProtocol::TlenDbSettingChanged(WPARAM wParam, LPARAM lParam)
}
else nick = TlenNickFromJID(item->jid);
- if (nick != NULL) {
+ if (nick != nullptr) {
// Note: we need to compare with item->group to prevent infinite loop
- if (cws->value.type == DBVT_DELETED && item->group != NULL) {
+ if (cws->value.type == DBVT_DELETED && item->group != nullptr) {
debugLogA("Group set to nothing");
TlenSend(this, "<iq type='set'><query xmlns='jabber:iq:roster'><item name='%s' jid='%s'></item></query></iq>", nick, item->jid);
}
- else if (cws->value.pszVal != NULL) {
+ else if (cws->value.pszVal != nullptr) {
char *newGroup = settingToChar(cws);
- if (item->group == NULL || strcmp(newGroup, item->group)) {
+ if (item->group == nullptr || strcmp(newGroup, item->group)) {
debugLogA("Group set to %s", newGroup);
- if ((group = TlenGroupEncode(newGroup)) != NULL) {
+ if ((group = TlenGroupEncode(newGroup)) != nullptr) {
TlenSend(this, "<iq type='set'><query xmlns='jabber:iq:roster'><item name='%s' jid='%s'><group>%s</group></item></query></iq>", nick, item->jid, group);
mir_free(group);
}
@@ -907,21 +907,21 @@ int TlenProtocol::TlenDbSettingChanged(WPARAM wParam, LPARAM lParam)
if (!db_get(hContact, m_szModuleName, "jid", &dbv)) {
jid = dbv.pszVal;
- if ((item = TlenListGetItemPtr(this, LIST_ROSTER, dbv.pszVal)) != NULL) {
+ if ((item = TlenListGetItemPtr(this, LIST_ROSTER, dbv.pszVal)) != nullptr) {
if (cws->value.type == DBVT_DELETED) {
newNick = mir_u2a(pcli->pfnGetContactDisplayName(hContact, GCDNF_NOMYHANDLE));
}
- else if (cws->value.pszVal != NULL) {
+ else if (cws->value.pszVal != nullptr) {
newNick = settingToChar(cws);
}
else {
- newNick = NULL;
+ newNick = nullptr;
}
// Note: we need to compare with item->nick to prevent infinite loop
- if (newNick != NULL && (item->nick == NULL || (item->nick != NULL && strcmp(item->nick, newNick)))) {
- if ((nick = TlenTextEncode(newNick)) != NULL) {
+ if (newNick != nullptr && (item->nick == nullptr || (item->nick != nullptr && strcmp(item->nick, newNick)))) {
+ if ((nick = TlenTextEncode(newNick)) != nullptr) {
debugLogA("Nick set to %s", newNick);
- if (item->group != NULL && (group = TlenGroupEncode(item->group)) != NULL) {
+ if (item->group != nullptr && (group = TlenGroupEncode(item->group)) != nullptr) {
TlenSend(this, "<iq type='set'><query xmlns='jabber:iq:roster'><item name='%s' jid='%s'><group>%s</group></item></query></iq>", nick, jid, group);
mir_free(group);
}
@@ -931,7 +931,7 @@ int TlenProtocol::TlenDbSettingChanged(WPARAM wParam, LPARAM lParam)
mir_free(nick);
}
}
- if (newNick != NULL) mir_free(newNick);
+ if (newNick != nullptr) mir_free(newNick);
}
db_free(&dbv);
}
@@ -949,10 +949,10 @@ int TlenProtocol::TlenDbSettingChanged(WPARAM wParam, LPARAM lParam)
}
else szNick = TlenNickFromJID(szJid);
- if (szNick != NULL) {
+ if (szNick != nullptr) {
debugLogA("jid=%s szNick=%s", szJid, szNick);
if (!db_get(hContact, "CList", "Group", &dbv)) {
- if ((pGroup = TlenGroupEncode(dbv.pszVal)) != NULL) {
+ if ((pGroup = TlenGroupEncode(dbv.pszVal)) != nullptr) {
TlenSend(this, "<iq type='set'><query xmlns='jabber:iq:roster'><item name='%s' szJid='%s'><group>%s</group></item></query></iq>", szNick, szJid, pGroup);
TlenSend(this, "<presence to='%s' type='subscribe'/>", szJid);
mir_free(pGroup);
@@ -980,7 +980,7 @@ int TlenProtocol::TlenContactDeleted(WPARAM wParam, LPARAM)
return 0;
char *szProto = GetContactProto(wParam);
- if (szProto == NULL || mir_strcmp(szProto, m_szModuleName))
+ if (szProto == nullptr || mir_strcmp(szProto, m_szModuleName))
return 0;
DBVARIANT dbv;
@@ -988,8 +988,8 @@ int TlenProtocol::TlenContactDeleted(WPARAM wParam, LPARAM)
char *p, *q;
char *jid = dbv.pszVal;
- if ((p = strchr(jid, '@')) != NULL) {
- if ((q = strchr(p, '/')) != NULL)
+ if ((p = strchr(jid, '@')) != nullptr) {
+ if ((q = strchr(p, '/')) != nullptr)
*q = '\0';
}
@@ -1009,7 +1009,7 @@ int TlenProtocol::UserIsTyping(MCONTACT hContact, int type)
if (!isOnline) return 0;
if (!db_get(hContact, m_szModuleName, "jid", &dbv)) {
TLEN_LIST_ITEM *item = TlenListGetItemPtr(this, LIST_ROSTER, dbv.pszVal);
- if (item != NULL /*&& item->wantComposingEvent == TRUE*/) {
+ if (item != nullptr /*&& item->wantComposingEvent == TRUE*/) {
switch (type) {
case PROTOTYPE_SELFTYPING_OFF:
TlenSend(this, "<m tp='u' to='%s'/>", dbv.pszVal);
@@ -1028,10 +1028,10 @@ INT_PTR TlenProtocol::GetMyAvatar(WPARAM wParam, LPARAM lParam)
{
wchar_t* buf = (wchar_t*)wParam;
int size = (int)lParam;
- if (buf == NULL || size <= 0)
+ if (buf == nullptr || size <= 0)
return -1;
- TlenGetAvatarFileName(this, NULL, buf, size);
+ TlenGetAvatarFileName(this, nullptr, buf, size);
return 0;
}
@@ -1069,9 +1069,9 @@ INT_PTR TlenProtocol::SetMyAvatar(WPARAM, LPARAM lParam)
}
wchar_t* szFileName = (wchar_t*)lParam;
wchar_t tFileName[MAX_PATH];
- if (szFileName != NULL) {
- int result = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_USER_CHANGEAVATAR), NULL, TlenChangeAvatarDlgProc, (LPARAM)NULL);
- TlenGetAvatarFileName(this, NULL, tFileName, MAX_PATH);
+ if (szFileName != nullptr) {
+ int result = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_USER_CHANGEAVATAR), nullptr, TlenChangeAvatarDlgProc, (LPARAM)NULL);
+ TlenGetAvatarFileName(this, nullptr, tFileName, MAX_PATH);
if (CopyFile(szFileName, tFileName, FALSE) == FALSE)
return 1;
@@ -1080,7 +1080,7 @@ INT_PTR TlenProtocol::SetMyAvatar(WPARAM, LPARAM lParam)
if (fileIn != -1) {
long dwPngSize = filelength(fileIn);
BYTE* pResult = (BYTE *)mir_alloc(dwPngSize);
- if (pResult != NULL) {
+ if (pResult != nullptr) {
read(fileIn, pResult, dwPngSize);
close(fileIn);
TlenUploadAvatar(this, pResult, dwPngSize, (result & 0x10000) != 0);
diff --git a/protocols/Tlen/src/tlen_thread.cpp b/protocols/Tlen/src/tlen_thread.cpp
index 8396a9ab45..0cbe1c4819 100644
--- a/protocols/Tlen/src/tlen_thread.cpp
+++ b/protocols/Tlen/src/tlen_thread.cpp
@@ -96,7 +96,7 @@ static INT_PTR CALLBACK TlenPasswordDlgProc(HWND hwndDlg, UINT msg, WPARAM wPara
static VOID NTAPI TlenPasswordCreateDialogApcProc(ULONG_PTR param)
{
- CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_PASSWORD), NULL, TlenPasswordDlgProc, (LPARAM) param);
+ CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_PASSWORD), nullptr, TlenPasswordDlgProc, (LPARAM) param);
}
void __cdecl TlenServerThread(ThreadData *info)
@@ -115,7 +115,7 @@ void __cdecl TlenServerThread(ThreadData *info)
// Normal server connection, we will fetch all connection parameters
// e.g. username, password, etc. from the database.
- if (info->proto->threadData != NULL) {
+ if (info->proto->threadData != nullptr) {
// Will not start another connection thread if a thread is already running.
// Make APC call to the main thread. This will immediately wake the thread up
// in case it is asleep in the reconnect loop so that it will immediately
@@ -162,7 +162,7 @@ void __cdecl TlenServerThread(ThreadData *info)
// exit code which may not be NULL.
// Should be better with modeless.
onlinePassword[0] = (char) -1;
- hEventPasswdDlg = CreateEvent(NULL, FALSE, FALSE, NULL);
+ hEventPasswdDlg = CreateEvent(nullptr, FALSE, FALSE, nullptr);
QueueUserAPC(TlenPasswordCreateDialogApcProc, hMainThread, (UINT_PTR)jidStr);
WaitForSingleObject(hEventPasswdDlg, INFINITE);
CloseHandle(hEventPasswdDlg);
@@ -191,17 +191,17 @@ void __cdecl TlenServerThread(ThreadData *info)
tlenNetworkBufferSize = 2048;
char *buffer = (char *) mir_alloc(tlenNetworkBufferSize+1); // +1 is for '\0' when debug logging this buffer
- if (buffer == NULL) {
+ if (buffer == nullptr) {
info->proto->debugLogA("Thread ended, network buffer cannot be allocated");
loginErr = LOGINERR_NONETWORK;
}
if (loginErr != 0) {
- info->proto->threadData = NULL;
+ info->proto->threadData = nullptr;
oldStatus = info->proto->m_iStatus;
info->proto->m_iStatus = ID_STATUS_OFFLINE;
ProtoBroadcastAck(info->proto->m_szModuleName, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE) oldStatus, info->proto->m_iStatus);
- ProtoBroadcastAck(info->proto->m_szModuleName, NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, loginErr);
+ ProtoBroadcastAck(info->proto->m_szModuleName, NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, nullptr, loginErr);
mir_free(info);
mir_free(buffer);
return;
@@ -239,12 +239,12 @@ void __cdecl TlenServerThread(ThreadData *info)
for (;;) { // Reconnect loop
info->s = TlenWsConnect(info->proto, connectHost, info->port);
- if (info->s == NULL) {
+ if (info->s == nullptr) {
info->proto->debugLogA("Connection failed (%d)", WSAGetLastError());
if (info->proto->threadData == info) {
oldStatus = info->proto->m_iStatus;
info->proto->m_iStatus = ID_STATUS_OFFLINE;
- ProtoBroadcastAck(info->proto->m_szModuleName, NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_NONETWORK);
+ ProtoBroadcastAck(info->proto->m_szModuleName, NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, nullptr, LOGINERR_NONETWORK);
ProtoBroadcastAck(info->proto->m_szModuleName, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE) oldStatus, info->proto->m_iStatus);
if (info->proto->tlenOptions.reconnect == TRUE) {
reconnectTime = rand() % reconnectMaxTime;
@@ -268,7 +268,7 @@ void __cdecl TlenServerThread(ThreadData *info)
return;
}
}
- info->proto->threadData = NULL;
+ info->proto->threadData = nullptr;
}
info->proto->debugLogA("Thread ended, connection failed");
mir_free(buffer);
@@ -325,7 +325,7 @@ void __cdecl TlenServerThread(ThreadData *info)
else if (datalen == tlenNetworkBufferSize) {
tlenNetworkBufferSize += 2048;
info->proto->debugLogA("Increasing network buffer size to %d", tlenNetworkBufferSize);
- if ((buffer=(char *) mir_realloc(buffer, tlenNetworkBufferSize+1)) == NULL) {
+ if ((buffer=(char *) mir_realloc(buffer, tlenNetworkBufferSize+1)) == nullptr) {
info->proto->debugLogA("Cannot reallocate more network buffer, go offline now");
break;
}
@@ -341,7 +341,7 @@ void __cdecl TlenServerThread(ThreadData *info)
info->proto->isConnected = FALSE;
Menu_EnableItem(info->proto->hMenuMUC, false);
- if (info->proto->hMenuChats != NULL)
+ if (info->proto->hMenuChats != nullptr)
Menu_EnableItem(info->proto->hMenuChats, false);
// Set status to offline
@@ -387,7 +387,7 @@ void __cdecl TlenServerThread(ThreadData *info)
info->proto->debugLogA("Thread ended: server='%s'", info->server);
if (info->proto->threadData == info) {
- info->proto->threadData = NULL;
+ info->proto->threadData = nullptr;
}
mir_free(buffer);
@@ -404,7 +404,7 @@ static void TlenSendAuth(TlenProtocol *proto) {
mir_free(str);
str = TlenSha1(text);
char *p=TlenTextEncode(proto->threadData->username);
- if (p != NULL) {
+ if (p != nullptr) {
iqId = TlenSerialNext(proto->threadData->proto);
TlenIqAdd(proto, iqId, IQ_PROC_NONE, TlenIqResultAuth);
TlenSend(proto, "<iq type='set' id='" TLEN_IQID "%d'><query xmlns='jabber:iq:auth'><username>%s</username><digest>%s</digest><resource>t</resource><host>tlen.pl</host></query></iq>", iqId, p /*info->username*/, str);
@@ -416,16 +416,16 @@ static void TlenSendAuth(TlenProtocol *proto) {
/* processing <s ... > tag sent from server on session opening */
static void TlenProcessStreamOpening(XmlNode *node, ThreadData *info)
{
- if (node->name == NULL || mir_strcmp(node->name, "s"))
+ if (node->name == nullptr || mir_strcmp(node->name, "s"))
return;
char *sid=TlenXmlGetAttrValue(node, "i");
- if (sid != NULL) {
+ if (sid != nullptr) {
if (info->streamId) mir_free(info->streamId);
info->streamId = mir_strdup(sid);
}
char *s=TlenXmlGetAttrValue(node, "s");
- if (s != NULL && !mir_strcmp(s, "1")) {
+ if (s != nullptr && !mir_strcmp(s, "1")) {
int i;
unsigned char aes_key[32];
char aes_key_str[140], aes_iv_str[40];
@@ -459,7 +459,7 @@ static void TlenProcessStreamOpening(XmlNode *node, ThreadData *info)
mpi_read_string( &k2_mpi, 16, k2 );
memset(&aes_mpi, 0, sizeof (mpi));
mpi_read_binary(&aes_mpi, (unsigned char *)aes_key, 16);
- mpi_exp_mod( &aes_mpi, &aes_mpi, &k1_mpi, &k2_mpi, NULL );
+ mpi_exp_mod( &aes_mpi, &aes_mpi, &k1_mpi, &k2_mpi, nullptr );
slen = 140;
mpi_write_string(&aes_mpi, 16, aes_key_str, &slen);
TlenSend(info->proto, "<cipher k1='%s' k2='%s'/>", aes_key_str, aes_iv_str);
@@ -523,16 +523,16 @@ static void TlenProcessIqGetVersion(TlenProtocol *proto, XmlNode *node)
OSVERSIONINFO osvi = { 0 };
char mversion[256];
char *mver;
- char* os = NULL;
+ char* os = nullptr;
if (proto->m_iStatus == ID_STATUS_INVISIBLE) return;
if (!proto->tlenOptions.enableVersion) return;
char *from = TlenXmlGetAttrValue(node, "from");
- if (from == NULL)
+ if (from == nullptr)
return;
TLEN_LIST_ITEM *item = TlenListGetItemPtr(proto, LIST_ROSTER, from);
- if (item == NULL)
+ if (item == nullptr)
return;
char *version = TlenTextEncode(TLEN_VERSION_STRING);
@@ -558,7 +558,7 @@ static void TlenProcessIqGetVersion(TlenProtocol *proto, XmlNode *node)
break;
} }
- if ( os == NULL ) os = TlenTextEncode("Windows");
+ if ( os == nullptr ) os = TlenTextEncode("Windows");
mir_strcpy(mversion, "Miranda NG ");
Miranda_GetVersionText(mversion + 11, sizeof(mversion) - 11);
@@ -582,12 +582,12 @@ static void TlenProcessAvatar(XmlNode* node, ThreadData *info)
{
XmlNode *tokenNode = TlenXmlGetChild(node, "token");
XmlNode *aNode = TlenXmlGetChild(node, "a");
- if (tokenNode != NULL) {
+ if (tokenNode != nullptr) {
char *token = tokenNode->text;
strncpy(info->avatarToken, token, sizeof(info->avatarToken)-1);
}
- if (aNode != NULL) {
- if (TlenProcessAvatarNode(info->proto, node, NULL)) {
+ if (aNode != nullptr) {
+ if (TlenProcessAvatarNode(info->proto, node, nullptr)) {
}
}
}
@@ -604,11 +604,11 @@ static void TlenProcessMessage(XmlNode *node, ThreadData *info)
if (!node->name || mir_strcmp(node->name, "message")) return;
char *type=TlenXmlGetAttrValue(node, "type");
- if (type != NULL && !mir_strcmp(type, "error")) {
+ if (type != nullptr && !mir_strcmp(type, "error")) {
}
else {
char *from=TlenXmlGetAttrValue(node, "from");
- if (from != NULL) {
+ if (from != nullptr) {
if (info->proto->tlenOptions.ignoreAdvertisements && strstr(from, "b73@tlen.pl") == from) {
return;
}
@@ -617,21 +617,21 @@ static void TlenProcessMessage(XmlNode *node, ThreadData *info)
TLEN_LIST_ITEM *item = TlenListGetItemPtr(info->proto, LIST_ROSTER, fromJid);
BOOL isChatRoomJid = TlenListExist(info->proto, LIST_CHATROOM, from);
- if (isChatRoomJid && type != NULL && !mir_strcmp(type, "groupchat")) {
+ if (isChatRoomJid && type != nullptr && !mir_strcmp(type, "groupchat")) {
//TlenGroupchatProcessMessage(node, userdata);
- } else if (type != NULL && !mir_strcmp(type, "pic")) {
+ } else if (type != nullptr && !mir_strcmp(type, "pic")) {
TlenProcessPic(node, info->proto);
- } else if (type != NULL && !mir_strcmp(type, "iq")) {
+ } else if (type != nullptr && !mir_strcmp(type, "iq")) {
XmlNode *iqNode;
// Tlen-compatible iq
- if ((iqNode=TlenXmlGetChild(node, "iq")) != NULL) {
+ if ((iqNode=TlenXmlGetChild(node, "iq")) != nullptr) {
TlenXmlAddAttr(iqNode, "from", from);
TlenProcessIq(iqNode, info);
}
} else {
- if ((bodyNode=TlenXmlGetChild(node, "body")) != NULL) {
- if (bodyNode->text != NULL) {
- if ((subjectNode=TlenXmlGetChild(node, "subject")) != NULL && subjectNode->text != NULL && subjectNode->text[0] != '\0') {
+ if ((bodyNode=TlenXmlGetChild(node, "body")) != nullptr) {
+ if (bodyNode->text != nullptr) {
+ if ((subjectNode=TlenXmlGetChild(node, "subject")) != nullptr && subjectNode->text != nullptr && subjectNode->text[0] != '\0') {
size_t size = mir_strlen(subjectNode->text)+mir_strlen(bodyNode->text)+5;
p = (char *)mir_alloc(size);
mir_snprintf(p, size, "%s\r\n%s", subjectNode->text, bodyNode->text);
@@ -644,33 +644,33 @@ static void TlenProcessMessage(XmlNode *node, ThreadData *info)
msgTime = 0;
delivered = composing = FALSE;
i = 1;
- while ((xNode=TlenXmlGetNthChild(node, "x", i)) != NULL) {
- if ((p=TlenXmlGetAttrValue(xNode, "xmlns")) != NULL) {
+ while ((xNode=TlenXmlGetNthChild(node, "x", i)) != nullptr) {
+ if ((p=TlenXmlGetAttrValue(xNode, "xmlns")) != nullptr) {
if (!mir_strcmp(p, "jabber:x:delay") && msgTime==0) {
- if ((p=TlenXmlGetAttrValue(xNode, "stamp")) != NULL) {
+ if ((p=TlenXmlGetAttrValue(xNode, "stamp")) != nullptr) {
msgTime = TlenIsoToUnixTime(p);
}
}
else if (!mir_strcmp(p, "jabber:x:event")) {
// Check whether any event is requested
- if (!delivered && (n=TlenXmlGetChild(xNode, "delivered")) != NULL) {
+ if (!delivered && (n=TlenXmlGetChild(xNode, "delivered")) != nullptr) {
delivered = TRUE;
idStr = TlenXmlGetAttrValue(node, "id");
- TlenSend(info->proto, "<message to='%s'><x xmlns='jabber:x:event'><delivered/><id>%s</id></x></message>", from, (idStr != NULL)?idStr:"");
+ TlenSend(info->proto, "<message to='%s'><x xmlns='jabber:x:event'><delivered/><id>%s</id></x></message>", from, (idStr != nullptr)?idStr:"");
}
- if (item != NULL && TlenXmlGetChild(xNode, "composing") != NULL) {
+ if (item != nullptr && TlenXmlGetChild(xNode, "composing") != nullptr) {
composing = TRUE;
if (item->messageEventIdStr)
mir_free(item->messageEventIdStr);
idStr = TlenXmlGetAttrValue(node, "id");
- item->messageEventIdStr = (idStr == NULL)?NULL:mir_strdup(idStr);
+ item->messageEventIdStr = (idStr == nullptr)?nullptr:mir_strdup(idStr);
}
}
}
i++;
}
- if (item != NULL) {
+ if (item != nullptr) {
item->wantComposingEvent = composing;
if (item->isTyping) {
item->isTyping = FALSE;
@@ -682,7 +682,7 @@ static void TlenProcessMessage(XmlNode *node, ThreadData *info)
if ((hContact=TlenHContactFromJID(info->proto, fromJid)) == NULL) {
// Create a temporary contact
if (isChatRoomJid) {
- if ((p=strchr(from, '/')) != NULL && p[1]!='\0')
+ if ((p=strchr(from, '/')) != nullptr && p[1]!='\0')
p++;
else
p = from;
@@ -697,7 +697,7 @@ static void TlenProcessMessage(XmlNode *node, ThreadData *info)
}
if (msgTime == 0) {
- msgTime = time(NULL);
+ msgTime = time(nullptr);
} else {
MEVENT hDbEvent = db_event_last(hContact);
if (hDbEvent != NULL) {
@@ -707,8 +707,8 @@ static void TlenProcessMessage(XmlNode *node, ThreadData *info)
msgTime = dbei.timestamp + 1;
}
}
- if (msgTime > (DWORD)time(NULL)) {
- msgTime = time(NULL);
+ if (msgTime > (DWORD)time(nullptr)) {
+ msgTime = time(nullptr);
}
}
char* localMessage_Utf8 = mir_utf8encode(localMessage);
@@ -732,9 +732,9 @@ static void TlenProcessMessage(XmlNode *node, ThreadData *info)
static void TlenProcessIq(XmlNode *node, ThreadData *info)
{
MCONTACT hContact;
- XmlNode *queryNode = NULL;
+ XmlNode *queryNode = nullptr;
char *jid, *nick;
- char *xmlns = NULL;
+ char *xmlns = nullptr;
char *idStr, *str;
int id;
int i;
@@ -744,13 +744,13 @@ static void TlenProcessIq(XmlNode *node, ThreadData *info)
// if ((type=TlenXmlGetAttrValue(node, "type")) == NULL) return;
id = -1;
- if ((idStr=TlenXmlGetAttrValue(node, "id")) != NULL) {
+ if ((idStr=TlenXmlGetAttrValue(node, "id")) != nullptr) {
if (!strncmp(idStr, TLEN_IQID, mir_strlen(TLEN_IQID)))
id = atoi(idStr+mir_strlen(TLEN_IQID));
}
queryNode = TlenXmlGetChild(node, "query");
- if (queryNode != NULL) {
+ if (queryNode != nullptr) {
xmlns = TlenXmlGetAttrValue(queryNode, "xmlns");
}
@@ -759,20 +759,20 @@ static void TlenProcessIq(XmlNode *node, ThreadData *info)
// MATCH BY ID
/////////////////////////////////////////////////////////////////////////
TLEN_IQ_PFUNC pfunc=TlenIqFetchFunc(info->proto, id);
- if (pfunc != NULL) {
+ if (pfunc != nullptr) {
info->proto->debugLogA("Handling iq request for id=%d", id);
pfunc(info->proto, node);
/////////////////////////////////////////////////////////////////////////
// MORE GENERAL ROUTINES, WHEN ID DOES NOT MATCH
/////////////////////////////////////////////////////////////////////////
// new p2p connections
- } else if (xmlns != NULL && !mir_strcmp(xmlns, "p2p")) {
+ } else if (xmlns != nullptr && !mir_strcmp(xmlns, "p2p")) {
if (info->proto->tlenOptions.useNewP2P) {
TlenProcessP2P(node, info);
}
}
// RECVED: <iq type='set'><query ...
- else if (!mir_strcmp(type, "set") && queryNode != NULL && xmlns != NULL) {
+ else if (!mir_strcmp(type, "set") && queryNode != nullptr && xmlns != nullptr) {
// RECVED: roster push
// ACTION: similar to iqIdGetRoster above
@@ -785,17 +785,17 @@ static void TlenProcessIq(XmlNode *node, ThreadData *info)
for (i=0; i<queryNode->numChild; i++) {
itemNode = queryNode->child[i];
if (!mir_strcmp(itemNode->name, "item")) {
- if ((jid=TlenXmlGetAttrValue(itemNode, "jid")) != NULL) {
- if ((str=TlenXmlGetAttrValue(itemNode, "subscription")) != NULL) {
+ if ((jid=TlenXmlGetAttrValue(itemNode, "jid")) != nullptr) {
+ if ((str=TlenXmlGetAttrValue(itemNode, "subscription")) != nullptr) {
// we will not add new account when subscription=remove
if (!mir_strcmp(str, "to") || !mir_strcmp(str, "both") || !mir_strcmp(str, "from") || !mir_strcmp(str, "none")) {
- if ((name=TlenXmlGetAttrValue(itemNode, "name")) != NULL) {
+ if ((name=TlenXmlGetAttrValue(itemNode, "name")) != nullptr) {
nick = TlenTextDecode(name);
} else {
nick = TlenLocalNickFromJID(jid);
}
- if (nick != NULL) {
- if ((item=TlenListAdd(info->proto, LIST_ROSTER, jid)) != NULL) {
+ if (nick != nullptr) {
+ if ((item=TlenListAdd(info->proto, LIST_ROSTER, jid)) != nullptr) {
if (item->nick) mir_free(item->nick);
item->nick = nick;
if ((hContact=TlenHContactFromJID(info->proto, jid)) == NULL) {
@@ -805,16 +805,16 @@ static void TlenProcessIq(XmlNode *node, ThreadData *info)
}
db_set_s(hContact, "CList", "MyHandle", nick);
if (item->group) mir_free(item->group);
- if ((groupNode=TlenXmlGetChild(itemNode, "group")) != NULL && groupNode->text != NULL) {
+ if ((groupNode=TlenXmlGetChild(itemNode, "group")) != nullptr && groupNode->text != nullptr) {
item->group = TlenGroupDecode(groupNode->text);
Clist_GroupCreate(0, _A2T(item->group));
db_set_s(hContact, "CList", "Group", item->group);
}
else {
- item->group = NULL;
+ item->group = nullptr;
db_unset(hContact, "CList", "Group");
}
- if (!mir_strcmp(str, "none") || (!mir_strcmp(str, "from") && strchr(jid, '@') != NULL)) {
+ if (!mir_strcmp(str, "none") || (!mir_strcmp(str, "from") && strchr(jid, '@') != nullptr)) {
if (db_get_w(hContact, info->proto->m_szModuleName, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE)
db_set_w(hContact, info->proto->m_szModuleName, "Status", ID_STATUS_OFFLINE);
}
@@ -824,7 +824,7 @@ static void TlenProcessIq(XmlNode *node, ThreadData *info)
}
}
}
- if ((item=TlenListGetItemPtr(info->proto, LIST_ROSTER, jid)) != NULL) {
+ if ((item=TlenListGetItemPtr(info->proto, LIST_ROSTER, jid)) != nullptr) {
if (!mir_strcmp(str, "both"))
item->subscription = SUB_BOTH;
else if (!mir_strcmp(str, "to"))
@@ -853,14 +853,14 @@ static void TlenProcessIq(XmlNode *node, ThreadData *info)
}
// RECVED: <iq type='get'><query ...
- else if ( !mir_strcmp( type, "get" ) && queryNode != NULL && xmlns != NULL ) {
+ else if ( !mir_strcmp( type, "get" ) && queryNode != nullptr && xmlns != nullptr ) {
// RECVED: software version query
// ACTION: return my software version
if ( !mir_strcmp( xmlns, "jabber:iq:version" )) TlenProcessIqGetVersion(info->proto, node);
}
// RECVED: <iq type='result'><query ...
- else if ( !mir_strcmp( type, "result") && queryNode != NULL) {
- if (xmlns != NULL ) {
+ else if ( !mir_strcmp( type, "result") && queryNode != nullptr) {
+ if (xmlns != nullptr ) {
if ( !mir_strcmp(xmlns, "jabber:iq:roster" )) {
TlenIqResultRoster(info->proto, node);
} else if ( !mir_strcmp( xmlns, "jabber:iq:version" )) {
@@ -870,7 +870,7 @@ static void TlenProcessIq(XmlNode *node, ThreadData *info)
}
} else {
char *from;
- if (( from=TlenXmlGetAttrValue( node, "from" )) != NULL ) {
+ if (( from=TlenXmlGetAttrValue( node, "from" )) != nullptr ) {
if ( !mir_strcmp(from, "tcfg" )) {
TlenIqResultTcfg(info->proto, node);
}
@@ -886,7 +886,7 @@ static void TlenProcessIq(XmlNode *node, ThreadData *info)
item = TlenListGetItemPtrFromIndex(info->proto,i);
if (item->ft->state==FT_CONNECTING && !mir_strcmp(idStr, item->ft->iqId)) {
item->ft->state = FT_DENIED;
- if (item->ft->hFileEvent != NULL)
+ if (item->ft->hFileEvent != nullptr)
SetEvent(item->ft->hFileEvent); // Simulate the termination of file server connection
}
i++;
@@ -907,11 +907,11 @@ static void TlenProcessW(XmlNode *node, ThreadData *info)
return;
char *body=node->text;
- if (body == NULL)
+ if (body == nullptr)
return;
char *f = TlenXmlGetAttrValue(node, "f");
- if (f != NULL) {
+ if (f != nullptr) {
char webContactName[128];
mir_snprintf(webContactName, Translate("%s Web Messages"), info->proto->m_szModuleName);
MCONTACT hContact = TlenHContactFromJID(info->proto, webContactName);
@@ -922,14 +922,14 @@ static void TlenProcessW(XmlNode *node, ThreadData *info)
s = TlenXmlGetAttrValue(node, "s");
e = TlenXmlGetAttrValue(node, "e");
- str = NULL;
+ str = nullptr;
strSize = 0;
TlenStringAppend(&str, &strSize, "%s\r\n%s: ", Translate("Web message"), Translate("From"));
- if (f != NULL)
+ if (f != nullptr)
TlenStringAppend(&str, &strSize, "%s", f);
TlenStringAppend(&str, &strSize, "\r\n%s: ", Translate("E-mail"));
- if (e != NULL)
+ if (e != nullptr)
TlenStringAppend(&str, &strSize, "%s", e);
TlenStringAppend(&str, &strSize, "\r\n\r\n%s", body);
@@ -937,7 +937,7 @@ static void TlenProcessW(XmlNode *node, ThreadData *info)
char* localMessage_Utf8 = mir_utf8encode(localMessage);
PROTORECVEVENT recv = { 0 };
- recv.timestamp = (DWORD) time(NULL);
+ recv.timestamp = (DWORD) time(nullptr);
recv.szMessage = localMessage_Utf8;
ProtoChainRecvMsg(hContact, &recv);
@@ -959,21 +959,21 @@ static void TlenProcessM(XmlNode *node, ThreadData *info)
if (!node->name || mir_strcmp(node->name, "m")) return;
char *f = TlenXmlGetAttrValue(node, "f"); //, *from;//username
- if (f != NULL) {
+ if (f != nullptr) {
char *fLogin = TlenLoginFromJID(f);
MCONTACT hContact=TlenHContactFromJID(info->proto, fLogin);
if (hContact != NULL) {
char *tp=TlenXmlGetAttrValue(node, "tp");//typing start/stop
- if (tp != NULL) {
+ if (tp != nullptr) {
TLEN_LIST_ITEM *item = TlenListGetItemPtr(info->proto, LIST_ROSTER, fLogin);
if (!mir_strcmp(tp, "t")) { //contact is writing
- if (item != NULL ) {
+ if (item != nullptr ) {
item->isTyping = TRUE;
CallService(MS_PROTO_CONTACTISTYPING, hContact, (LPARAM)PROTOTYPE_CONTACTTYPING_INFINITE);
}
}
else if (!mir_strcmp(tp, "u")) {//contact stopped writing
- if (item != NULL) {
+ if (item != nullptr) {
item->isTyping = FALSE;
CallService(MS_PROTO_CONTACTISTYPING, hContact, (LPARAM)PROTOTYPE_CONTACTTYPING_OFF);
}
@@ -998,23 +998,23 @@ static void TlenProcessM(XmlNode *node, ThreadData *info)
}
}
mir_free(fLogin);
- if ((p=strchr(f, '@')) != NULL) {
- if ((p=strchr(p, '/')) != NULL && p[1]!='\0') { // message from user
+ if ((p=strchr(f, '@')) != nullptr) {
+ if ((p=strchr(p, '/')) != nullptr && p[1]!='\0') { // message from user
time_t timestamp;
s = TlenXmlGetAttrValue(node, "s");
- if (s != NULL) {
+ if (s != nullptr) {
timestamp = TlenTimeToUTC(atol(s));
- if (timestamp > time(NULL)) {
- timestamp = time(NULL);
+ if (timestamp > time(nullptr)) {
+ timestamp = time(nullptr);
}
} else {
- timestamp = time(NULL);
+ timestamp = time(nullptr);
}
char *tp=TlenXmlGetAttrValue(node, "tp");//typing start/stop
bNode = TlenXmlGetChild(node, "b");
f = TlenTextDecode(f);
- if (bNode != NULL && bNode->text != NULL) {
- if (tp != NULL && !mir_strcmp(tp, "p")) {
+ if (bNode != nullptr && bNode->text != nullptr) {
+ if (tp != nullptr && !mir_strcmp(tp, "p")) {
/* MUC private message */
str = TlenResourceFromJID(f);
hContact = TlenDBCreateContact(info->proto, f, str, TRUE);
@@ -1036,14 +1036,14 @@ static void TlenProcessM(XmlNode *node, ThreadData *info)
}
}
i=1;
- while ((xNode=TlenXmlGetNthChild(node, "x", i)) != NULL) {
+ while ((xNode=TlenXmlGetNthChild(node, "x", i)) != nullptr) {
invNode=TlenXmlGetChild(xNode, "inv");
- if (invNode != NULL) {
+ if (invNode != nullptr) {
r = TlenTextDecode(f);
f = TlenXmlGetAttrValue(invNode, "f");
f = TlenTextDecode(f);
n = TlenXmlGetAttrValue(invNode, "n");
- if (n != NULL && strstr(r, n) != r) {
+ if (n != nullptr && strstr(r, n) != r) {
n = TlenTextDecode(n);
} else {
n = mir_strdup(Translate("Private conference"));
@@ -1092,15 +1092,15 @@ static void TlenProcessN(XmlNode *node, ThreadData *info)
char *s = TlenXmlGetAttrValue(node, "s");
char *f = TlenXmlGetAttrValue(node, "f");
- if (s != NULL && f != NULL) {
- str = NULL;
+ if (s != nullptr && f != nullptr) {
+ str = nullptr;
strSize = 0;
TlenStringAppend(&str, &strSize, Translate("%s mail"), info->proto->m_szModuleName);
popupTitle = TlenTextDecode(str);
mir_free(str);
- str = NULL;
+ str = nullptr;
strSize = 0;
TlenStringAppend(&str, &strSize, "%s: %s\n", Translate("From"), f);
@@ -1131,10 +1131,10 @@ static void TlenProcessP(XmlNode *node, ThreadData*)
status = ID_STATUS_ONLINE;
f = TlenXmlGetAttrValue(node, "f");
xNode = TlenXmlGetChild(node, "x");
- if (xNode != NULL) { // x subtag present (message from chat room) - change user rights only
+ if (xNode != nullptr) { // x subtag present (message from chat room) - change user rights only
char *temp, *iStr;
iNode = TlenXmlGetChild(xNode, "i");
- if (iNode != NULL) {
+ if (iNode != nullptr) {
iStr = TlenXmlGetAttrValue(iNode, "i");
temp = (char*)mir_alloc(mir_strlen(f)+mir_strlen(iStr)+2);
mir_strcpy(temp, f);
@@ -1151,13 +1151,13 @@ static void TlenProcessP(XmlNode *node, ThreadData*)
f = TlenTextDecode(f);
}
a = TlenXmlGetAttrValue(node, "z");
- if (a != NULL) {
+ if (a != nullptr) {
if (atoi(a) &1 ) {
flags |= USER_FLAGS_REGISTERED;
}
}
a = TlenXmlGetAttrValue(node, "a");
- if (a != NULL) {
+ if (a != nullptr) {
if (atoi(a) == 2) {
flags |= USER_FLAGS_ADMIN;
}
@@ -1172,21 +1172,21 @@ static void TlenProcessP(XmlNode *node, ThreadData*)
}
}
sNode = TlenXmlGetChild(node, "s");
- if (sNode != NULL) {
+ if (sNode != nullptr) {
if (!mir_strcmp(sNode->text, "unavailable")) {
status = ID_STATUS_OFFLINE;
}
}
kNode = TlenXmlGetChild(node, "kick");
- k = NULL;
- if (kNode != NULL) {
+ k = nullptr;
+ if (kNode != nullptr) {
k = TlenXmlGetAttrValue(kNode, "r");
- if (k == NULL) {
+ if (k == nullptr) {
k = "";
}
k = TlenTextDecode(k);
}
- if (k != NULL) {
+ if (k != nullptr) {
mir_free(k);
}
mir_free(f);
@@ -1202,30 +1202,30 @@ static void TlenProcessV(XmlNode *node, ThreadData *info)
// if (!node->name || mir_strcmp(node->name, "v")) return;
char *from=TlenXmlGetAttrValue(node, "f");
- if (from != NULL) {
- if (strchr(from, '@') == NULL) {
+ if (from != nullptr) {
+ if (strchr(from, '@') == nullptr) {
mir_snprintf(jid, "%s@%s", from, info->server);
} else {
strncpy_s(jid, from, _TRUNCATE);
}
- if ((e=TlenXmlGetAttrValue(node, "e")) != NULL) {
+ if ((e=TlenXmlGetAttrValue(node, "e")) != nullptr) {
if (!mir_strcmp(e, "1")) {
- if ((id=TlenXmlGetAttrValue(node, "i")) != NULL) {
+ if ((id=TlenXmlGetAttrValue(node, "i")) != nullptr) {
Skin_PlaySound("TlenVoiceNotify");
TlenVoiceAccept(info->proto, id, from);
}
} else if (!mir_strcmp(e, "3")) {
// FILE_RECV : e='3' : invalid transfer error
- if ((p=TlenXmlGetAttrValue(node, "i")) != NULL) {
- if ((item=TlenListGetItemPtr(info->proto, LIST_VOICE, p)) != NULL) {
- if (item->ft != NULL) {
+ if ((p=TlenXmlGetAttrValue(node, "i")) != nullptr) {
+ if ((item=TlenListGetItemPtr(info->proto, LIST_VOICE, p)) != nullptr) {
+ if (item->ft != nullptr) {
HANDLE hEvent = item->ft->hFileEvent;
- item->ft->hFileEvent = NULL;
+ item->ft->hFileEvent = nullptr;
item->ft->state = FT_ERROR;
- if (item->ft->s != NULL) {
+ if (item->ft->s != nullptr) {
Netlib_CloseHandle(item->ft->s);
- item->ft->s = NULL;
- if (hEvent != NULL) {
+ item->ft->s = nullptr;
+ if (hEvent != nullptr) {
SetEvent(hEvent);
}
} else {
@@ -1238,8 +1238,8 @@ static void TlenProcessV(XmlNode *node, ThreadData *info)
}
} else if (!mir_strcmp(e, "4")) {
// FILE_SEND : e='4' : File sending request was denied by the remote client
- if ((p=TlenXmlGetAttrValue(node, "i")) != NULL) {
- if ((item=TlenListGetItemPtr(info->proto, LIST_VOICE, p)) != NULL) {
+ if ((p=TlenXmlGetAttrValue(node, "i")) != nullptr) {
+ if ((item=TlenListGetItemPtr(info->proto, LIST_VOICE, p)) != nullptr) {
if (!mir_strcmp(item->ft->jid, jid)) {
TlenVoiceCancelAll(info->proto);
//TlenListRemove(info->proto, LIST_VOICE, p);
@@ -1248,8 +1248,8 @@ static void TlenProcessV(XmlNode *node, ThreadData *info)
}
} else if (!mir_strcmp(e, "5")) {
// FILE_SEND : e='5' : Voice request was accepted
- if ((p=TlenXmlGetAttrValue(node, "i")) != NULL) {
- if ((item=TlenListGetItemPtr(info->proto, LIST_VOICE, p)) != NULL) {
+ if ((p=TlenXmlGetAttrValue(node, "i")) != nullptr) {
+ if ((item=TlenListGetItemPtr(info->proto, LIST_VOICE, p)) != nullptr) {
info->proto->debugLogA("should start voice 1 ? %s ?? %s", jid, item->ft->jid);
if (!mir_strcmp(item->ft->jid, jid)) {
info->proto->debugLogA("starting voice 1");
@@ -1259,11 +1259,11 @@ static void TlenProcessV(XmlNode *node, ThreadData *info)
}
} else if (!mir_strcmp(e, "6")) {
// FILE_RECV : e='6' : IP and port information to connect to get file
- if ((p=TlenXmlGetAttrValue(node, "i")) != NULL) {
- if ((item=TlenListGetItemPtr(info->proto, LIST_VOICE, p)) != NULL) {
- if ((p=TlenXmlGetAttrValue(node, "a")) != NULL) {
+ if ((p=TlenXmlGetAttrValue(node, "i")) != nullptr) {
+ if ((item=TlenListGetItemPtr(info->proto, LIST_VOICE, p)) != nullptr) {
+ if ((p=TlenXmlGetAttrValue(node, "a")) != nullptr) {
item->ft->hostName = mir_strdup(p);
- if ((p=TlenXmlGetAttrValue(node, "p")) != NULL) {
+ if ((p=TlenXmlGetAttrValue(node, "p")) != nullptr) {
item->ft->wPort = atoi(p);
TlenVoiceStart(item->ft, 0);
//forkthread((pThreadFunc)TlenVoiceReceiveThread, 0, item->ft);
@@ -1275,12 +1275,12 @@ static void TlenProcessV(XmlNode *node, ThreadData *info)
else if (!mir_strcmp(e, "7")) {
// FILE_RECV : e='7' : IP and port information to connect to send file
// in case the conection to the given server was not successful
- if ((p=TlenXmlGetAttrValue(node, "i")) != NULL) {
- if ((item=TlenListGetItemPtr(info->proto, LIST_VOICE, p)) != NULL) {
- if ((p=TlenXmlGetAttrValue(node, "a")) != NULL) {
- if (item->ft->hostName != NULL) mir_free(item->ft->hostName);
+ if ((p=TlenXmlGetAttrValue(node, "i")) != nullptr) {
+ if ((item=TlenListGetItemPtr(info->proto, LIST_VOICE, p)) != nullptr) {
+ if ((p=TlenXmlGetAttrValue(node, "a")) != nullptr) {
+ if (item->ft->hostName != nullptr) mir_free(item->ft->hostName);
item->ft->hostName = mir_strdup(p);
- if ((p=TlenXmlGetAttrValue(node, "p")) != NULL) {
+ if ((p=TlenXmlGetAttrValue(node, "p")) != nullptr) {
item->ft->wPort = atoi(p);
item->ft->state = FT_SWITCH;
SetEvent(item->ft->hFileEvent);
@@ -1291,8 +1291,8 @@ static void TlenProcessV(XmlNode *node, ThreadData *info)
}
else if (!mir_strcmp(e, "8")) {
// FILE_RECV : e='8' : transfer error
- if ((p=TlenXmlGetAttrValue(node, "i")) != NULL) {
- if ((item=TlenListGetItemPtr(info->proto, LIST_VOICE, p)) != NULL) {
+ if ((p=TlenXmlGetAttrValue(node, "i")) != nullptr) {
+ if ((item=TlenListGetItemPtr(info->proto, LIST_VOICE, p)) != nullptr) {
item->ft->state = FT_ERROR;
SetEvent(item->ft->hFileEvent);
}
diff --git a/protocols/Tlen/src/tlen_userinfo.cpp b/protocols/Tlen/src/tlen_userinfo.cpp
index 6815573b78..8bf7c07045 100644
--- a/protocols/Tlen/src/tlen_userinfo.cpp
+++ b/protocols/Tlen/src/tlen_userinfo.cpp
@@ -34,7 +34,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
TLEN_FIELD_MAP tlenFieldGender[] = {
{ 1, L"Male" },
{ 2, L"Female" },
- { 0, NULL }
+ { 0, nullptr }
};
TLEN_FIELD_MAP tlenFieldLookfor[] = {
{ 1, L"Somebody to talk" },
@@ -42,13 +42,13 @@ TLEN_FIELD_MAP tlenFieldLookfor[] = {
{ 3, L"Flirt/romance" },
{ 4, L"Love" },
{ 5, L"Nothing" },
- { 0, NULL }
+ { 0, nullptr }
};
TLEN_FIELD_MAP tlenFieldStatus[] = {
{ 1, L"All" },
{ 2, L"Available" },
{ 3, L"Free for chat" },
- { 0, NULL }
+ { 0, nullptr }
};
TLEN_FIELD_MAP tlenFieldOccupation[] = {
{ 1, L"Student" },
@@ -63,7 +63,7 @@ TLEN_FIELD_MAP tlenFieldOccupation[] = {
{ 10, L"Teacher" },
{ 11, L"Doctor" },
{ 12, L"Other" },
- { 0, NULL }
+ { 0, nullptr }
};
TLEN_FIELD_MAP tlenFieldPlan[] = {
{ 1, L"I'd like to go downtown" },
@@ -72,7 +72,7 @@ TLEN_FIELD_MAP tlenFieldPlan[] = {
{ 4, L"I'd like to go to the disco" },
{ 5, L"I'd like to go on a blind date" },
{ 6, L"Waiting for suggestion" },
- { 0, NULL }
+ { 0, nullptr }
};
static INT_PTR CALLBACK TlenUserInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
@@ -85,7 +85,7 @@ static void InitComboBox(HWND hwndCombo, TLEN_FIELD_MAP *fieldMap)
SendMessage(hwndCombo, CB_SETITEMDATA, n, 0);
SendMessage(hwndCombo, CB_SETCURSEL, n, 0);
for (i=0;;i++) {
- if (fieldMap[i].name == NULL)
+ if (fieldMap[i].name == nullptr)
break;
n = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM) TranslateW(fieldMap[i].name));
SendMessage(hwndCombo, CB_SETITEMDATA, n, fieldMap[i].id);
@@ -97,12 +97,12 @@ static void FetchField(HWND hwndDlg, UINT idCtrl, char *fieldName, char **str, i
char text[512];
char *localFieldName, *localText;
- if (hwndDlg == NULL || fieldName == NULL || str == NULL || strSize == NULL)
+ if (hwndDlg == nullptr || fieldName == nullptr || str == nullptr || strSize == nullptr)
return;
GetDlgItemTextA(hwndDlg, idCtrl, text, _countof(text));
if (text[0]) {
- if ((localFieldName=TlenTextEncode(fieldName)) != NULL) {
- if ((localText=TlenTextEncode(text)) != NULL) {
+ if ((localFieldName=TlenTextEncode(fieldName)) != nullptr) {
+ if ((localText=TlenTextEncode(text)) != nullptr) {
TlenStringAppend(str, strSize, "<%s>%s</%s>", localFieldName, localText, localFieldName);
mir_free(localText);
}
@@ -113,7 +113,7 @@ static void FetchField(HWND hwndDlg, UINT idCtrl, char *fieldName, char **str, i
static void FetchCombo(HWND hwndDlg, UINT idCtrl, char *fieldName, char **str, int *strSize)
{
- if (hwndDlg == NULL || fieldName == NULL || str == NULL || strSize == NULL)
+ if (hwndDlg == nullptr || fieldName == nullptr || str == nullptr || strSize == nullptr)
return;
int value = (int) SendDlgItemMessage(hwndDlg, idCtrl, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, idCtrl, CB_GETCURSEL, 0, 0), 0);
@@ -132,13 +132,13 @@ int TlenProtocol::UserInfoInit(WPARAM wParam, LPARAM lParam)
MCONTACT hContact = (MCONTACT) lParam;
char *szProto = GetContactProto(hContact);
- if ((szProto != NULL && !mir_strcmp(szProto, m_szModuleName)) || !lParam) {
+ if ((szProto != nullptr && !mir_strcmp(szProto, m_szModuleName)) || !lParam) {
OPTIONSDIALOGPAGE odp = { 0 };
odp.hInstance = hInst;
odp.flags = ODPF_UNICODE;
odp.pfnDlgProc = TlenUserInfoDlgProc;
odp.position = -2000000000;
- odp.pszTemplate = ((HANDLE)lParam != NULL) ? MAKEINTRESOURCEA(IDD_USER_INFO):MAKEINTRESOURCEA(IDD_USER_VCARD);
+ odp.pszTemplate = ((HANDLE)lParam != nullptr) ? MAKEINTRESOURCEA(IDD_USER_INFO):MAKEINTRESOURCEA(IDD_USER_VCARD);
odp.szTitle.w = (hContact != NULL) ? LPGENW("Account") : m_tszUserName;
odp.dwInitParam = (LPARAM)this;
UserInfo_AddPage(wParam, &odp);
@@ -252,7 +252,7 @@ static INT_PTR CALLBACK TlenUserInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wPara
mir_free(jid);
jid = dbv.pszVal;
if (data->proto->isOnline) {
- if ((item=TlenListGetItemPtr(data->proto, LIST_ROSTER, jid)) != NULL) {
+ if ((item=TlenListGetItemPtr(data->proto, LIST_ROSTER, jid)) != nullptr) {
switch (item->subscription) {
case SUB_BOTH:
SetDlgItemText(hwndDlg, IDC_SUBSCRIPTION, TranslateT("both"));
@@ -299,7 +299,7 @@ static INT_PTR CALLBACK TlenUserInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wPara
break;
case WM_COMMAND:
if (LOWORD(wParam) == IDC_SAVE && HIWORD(wParam) == BN_CLICKED) {
- char *str = NULL;
+ char *str = nullptr;
int strSize;
TlenStringAppend(&str, &strSize, "<iq type='set' id='" TLEN_IQID "%d' to='tuba'><query xmlns='jabber:iq:register'>", TlenSerialNext(data->proto));
FetchField(hwndDlg, IDC_FIRSTNAME, "first", &str, &strSize);
diff --git a/protocols/Tlen/src/tlen_util.cpp b/protocols/Tlen/src/tlen_util.cpp
index 0bc0bc5ef8..b0efd769ba 100644
--- a/protocols/Tlen/src/tlen_util.cpp
+++ b/protocols/Tlen/src/tlen_util.cpp
@@ -63,7 +63,7 @@ int TlenSend(TlenProtocol *proto, const char *fmt, ...)
proto->debugLogA("SEND:%s", str);
size = (int)mir_strlen(str);
- if (proto->threadData != NULL) {
+ if (proto->threadData != nullptr) {
if (proto->threadData->useAES) {
result = TlenWsSendAES(proto, str, size, &proto->threadData->aes_out_context, proto->threadData->aes_out_iv);
}
@@ -83,9 +83,9 @@ char *TlenResourceFromJID(const char *jid2)
char* jid = mir_strdup(jid2);
p = strchr(jid, '/');
- if (p != NULL && p[1] != '\0') {
+ if (p != nullptr && p[1] != '\0') {
p++;
- if ((nick = (char *)mir_alloc(1 + mir_strlen(jid) - (p - jid))) != NULL) {
+ if ((nick = (char *)mir_alloc(1 + mir_strlen(jid) - (p - jid))) != nullptr) {
strncpy(nick, p, mir_strlen(jid) - (p - jid));
nick[mir_strlen(jid) - (p - jid)] = '\0';
}
@@ -104,10 +104,10 @@ char *TlenNickFromJID(const char *jid2)
char *nick;
char* jid = mir_strdup(jid2);
- if ((p = strchr(jid, '@')) == NULL)
+ if ((p = strchr(jid, '@')) == nullptr)
p = strchr(jid, '/');
- if (p != NULL) {
- if ((nick = (char *)mir_alloc((p - jid) + 1)) != NULL) {
+ if (p != nullptr) {
+ if ((nick = (char *)mir_alloc((p - jid) + 1)) != nullptr) {
strncpy(nick, jid, p - jid);
nick[p - jid] = '\0';
}
@@ -127,8 +127,8 @@ char *TlenLoginFromJID(const char *jid2)
char* jid = mir_strdup(jid2);
p = strchr(jid, '/');
- if (p != NULL) {
- if ((nick = (char *)mir_alloc((p - jid) + 1)) != NULL) {
+ if (p != nullptr) {
+ if ((nick = (char *)mir_alloc((p - jid) + 1)) != nullptr) {
strncpy(nick, jid, p - jid);
nick[p - jid] = '\0';
}
@@ -158,14 +158,14 @@ char *TlenSha1(char *str)
DWORD digest[5];
char* result;
- if (str == NULL)
- return NULL;
+ if (str == nullptr)
+ return nullptr;
mir_sha1_init(&sha);
mir_sha1_append(&sha, (BYTE*)str, (int)mir_strlen(str));
mir_sha1_finish(&sha, (BYTE*)digest);
- if ((result = (char *)mir_alloc(41)) == NULL)
- return NULL;
+ if ((result = (char *)mir_alloc(41)) == nullptr)
+ return nullptr;
sprintf(result, "%08x%08x%08x%08x%08x", (int)htonl(digest[0]), (int)htonl(digest[1]), (int)htonl(digest[2]), (int)htonl(digest[3]), (int)htonl(digest[4])); //!!!!!!!!!!!
return result;
}
@@ -177,14 +177,14 @@ char *TlenSha1(char *str, int len)
char* result;
int i;
- if (str == NULL)
- return NULL;
+ if (str == nullptr)
+ return nullptr;
mir_sha1_init(&sha);
mir_sha1_append(&sha, (BYTE*)str, len);
mir_sha1_finish(&sha, digest);
- if ((result = (char*)mir_alloc(20)) == NULL)
- return NULL;
+ if ((result = (char*)mir_alloc(20)) == nullptr)
+ return nullptr;
for (i = 0; i < 20; i++)
result[i] = digest[4 * (i >> 2) + (3 - (i & 0x3))];
return result;
@@ -195,7 +195,7 @@ char *TlenPasswordHash(const char *str)
int magic1 = 0x50305735, magic2 = 0x12345671, sum = 7;
char *p, *res;
- if (str == NULL) return NULL;
+ if (str == nullptr) return nullptr;
for (p = (char *)str; *p != '\0'; p++) {
if (*p != ' ' && *p != '\t') {
magic1 ^= (((magic1 & 0x3f) + sum) * ((char)*p)) + (magic1 << 8);
@@ -215,13 +215,13 @@ char *TlenUrlEncode(const char *str)
char *p, *q, *res;
unsigned char c;
- if (str == NULL) return NULL;
+ if (str == nullptr) return nullptr;
res = (char *)mir_alloc(3 * mir_strlen(str) + 1);
for (p = (char *)str, q = res; *p != '\0'; p++, q++) {
if (*p == ' ') {
*q = '+';
}
- else if (*p < 0x20 || *p >= 0x7f || strchr("%&+:'<>\"", *p) != NULL) {
+ else if (*p < 0x20 || *p >= 0x7f || strchr("%&+:'<>\"", *p) != nullptr) {
// Convert first from CP1252 to ISO8859-2
switch ((unsigned char)*p) {
case 0xa5: c = (unsigned char)0xa1; break;
@@ -248,7 +248,7 @@ void TlenUrlDecode(char *str)
char *p, *q;
unsigned int code;
- if (str == NULL) return;
+ if (str == nullptr) return;
for (p = q = str; *p != '\0'; p++, q++) {
if (*p == '+') {
*q = ' ';
@@ -277,7 +277,7 @@ void TlenUrlDecode(char *str)
char * TlenGroupDecode(const char *str)
{
char *p, *q;
- if (str == NULL) return NULL;
+ if (str == nullptr) return nullptr;
p = q = TlenTextDecode(str);
for (; *p != '\0'; p++) {
if (*p == '/') {
@@ -290,7 +290,7 @@ char * TlenGroupDecode(const char *str)
char * TlenGroupEncode(const char *str)
{
char *p, *q;
- if (str == NULL) return NULL;
+ if (str == nullptr) return nullptr;
p = q = mir_strdup(str);
for (; *p != '\0'; p++) {
if (*p == '\\') {
@@ -306,9 +306,9 @@ char *TlenTextEncode(const char *str)
{
char *s1;
- if (str == NULL) return NULL;
- if ((s1 = TlenUrlEncode(str)) == NULL)
- return NULL;
+ if (str == nullptr) return nullptr;
+ if ((s1 = TlenUrlEncode(str)) == nullptr)
+ return nullptr;
return s1;
}
@@ -316,7 +316,7 @@ char *TlenTextDecode(const char *str)
{
char *s1;
- if (str == NULL) return NULL;
+ if (str == nullptr) return nullptr;
s1 = mir_strdup(str);
TlenUrlDecode(s1);
return s1;
@@ -348,7 +348,7 @@ time_t TlenIsoToUnixTime(char *stamp)
int i, y;
time_t t;
- if (stamp == NULL) return (time_t)0;
+ if (stamp == nullptr) return (time_t)0;
p = stamp;
@@ -400,9 +400,9 @@ void TlenStringAppend(char **str, int *sizeAlloced, const char *fmt, ...)
char *p;
int size, len;
- if (str == NULL) return;
+ if (str == nullptr) return;
- if (*str == NULL || *sizeAlloced <= 0) {
+ if (*str == nullptr || *sizeAlloced <= 0) {
*sizeAlloced = size = 2048;
*str = (char *)mir_alloc(size);
len = 0;
@@ -426,7 +426,7 @@ void TlenStringAppend(char **str, int *sizeAlloced, const char *fmt, ...)
BOOL IsAuthorized(TlenProtocol *proto, const char *jid)
{
TLEN_LIST_ITEM *item = TlenListGetItemPtr(proto, LIST_ROSTER, jid);
- if (item != NULL) {
+ if (item != nullptr) {
return item->subscription == SUB_BOTH || item->subscription == SUB_FROM;
}
return FALSE;
diff --git a/protocols/Tlen/src/tlen_voice.cpp b/protocols/Tlen/src/tlen_voice.cpp
index 3255cd53f1..a209ea3edd 100644
--- a/protocols/Tlen/src/tlen_voice.cpp
+++ b/protocols/Tlen/src/tlen_voice.cpp
@@ -71,7 +71,7 @@ static void __cdecl TlenVoiceRecordingThreadProc(void *param)
control->isRunning = 1;
control->stopThread = 0;
while (TRUE) {
- GetMessage(&msg, NULL, 0, 0);
+ GetMessage(&msg, nullptr, 0, 0);
if (msg.message == MM_WIM_DATA) {
// TlenLog("recording thread running...%d", msg.message);
hWaveIn = (HWAVEIN)msg.wParam;
@@ -245,7 +245,7 @@ static void TlenVoiceFreeVc(TLEN_VOICE_CONTROL *vc)
while (vc->isRunning) {
Sleep(50);
}
- if (vc->hThread != NULL) CloseHandle(vc->hThread);
+ if (vc->hThread != nullptr) CloseHandle(vc->hThread);
if (vc->hWaveIn) {
for (int i = 0; i < vc->waveHeadersNum; i++) {
while (waveInUnprepareHeader(vc->hWaveIn, &vc->waveHeaders[i], sizeof(WAVEHDR)) == WAVERR_STILLPLAYING) {
@@ -298,12 +298,12 @@ static void __cdecl TlenVoiceReceiveThread(void *arg)
nloc.szHost = ft->hostName;
nloc.wPort = ft->wPort;
HNETLIBCONN s = Netlib_OpenConnection(ft->proto->m_hNetlibUser, &nloc);
- if (s != NULL) {
+ if (s != nullptr) {
ft->s = s;
ft->proto->debugLogA("Entering file receive loop");
TlenP2PEstablishOutgoingConnection(ft, FALSE);
if (ft->state != FT_ERROR) {
- ft->proto->playbackControl = NULL;
+ ft->proto->playbackControl = nullptr;
ft->proto->recordingControl = TlenVoiceCreateVC(ft->proto, 3);
ft->proto->recordingControl->ft = ft;
TlenVoiceRecordingStart(ft->proto->recordingControl);
@@ -311,22 +311,22 @@ static void __cdecl TlenVoiceReceiveThread(void *arg)
TlenVoiceReceiveParse(ft);
}
TlenVoiceFreeVc(ft->proto->recordingControl);
- ft->proto->playbackControl = NULL;
- ft->proto->recordingControl = NULL;
+ ft->proto->playbackControl = nullptr;
+ ft->proto->recordingControl = nullptr;
}
if (ft->s) {
Netlib_CloseHandle(s);
}
- ft->s = NULL;
+ ft->s = nullptr;
}
else {
ft->proto->debugLogA("Connection failed - receiving as server");
ft->pfnNewConnectionV2 = TlenVoiceReceivingConnection;
s = (HNETLIBCONN)TlenP2PListen(ft);
- if (s != NULL) {
+ if (s != nullptr) {
SetDlgItemText(ft->proto->voiceDlgHWND, IDC_STATUS, TranslateT("...Waiting for connection..."));
ft->s = s;
- HANDLE hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+ HANDLE hEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
ft->hFileEvent = hEvent;
ft->currentFile = 0;
ft->state = FT_CONNECTING;
@@ -335,7 +335,7 @@ static void __cdecl TlenVoiceReceiveThread(void *arg)
mir_free(nick);
ft->proto->debugLogA("Waiting for the file to be received...");
WaitForSingleObject(hEvent, INFINITE);
- ft->hFileEvent = NULL;
+ ft->hFileEvent = nullptr;
CloseHandle(hEvent);
ft->proto->debugLogA("Finish all files");
Netlib_CloseHandle(s);
@@ -368,12 +368,12 @@ static void TlenVoiceReceivingConnection(HNETLIBCONN hConnection, DWORD, void *
TlenProtocol *proto = (TlenProtocol *)pExtra;
TLEN_FILE_TRANSFER *ft = TlenP2PEstablishIncomingConnection(proto, hConnection, LIST_VOICE, FALSE);
- if (ft != NULL) {
+ if (ft != nullptr) {
slisten = ft->s;
ft->s = hConnection;
ft->proto->debugLogA("Set ft->s to %d (saving %d)", hConnection, slisten);
ft->proto->debugLogA("Entering send loop for this file connection... (ft->s is hConnection)");
- proto->playbackControl = NULL;
+ proto->playbackControl = nullptr;
proto->recordingControl = TlenVoiceCreateVC(proto, 3);
proto->recordingControl->ft = ft;
TlenVoiceRecordingStart(proto->recordingControl);
@@ -381,8 +381,8 @@ static void TlenVoiceReceivingConnection(HNETLIBCONN hConnection, DWORD, void *
TlenVoiceReceiveParse(ft);
}
TlenVoiceFreeVc(proto->recordingControl);
- proto->playbackControl = NULL;
- proto->recordingControl = NULL;
+ proto->playbackControl = nullptr;
+ proto->recordingControl = nullptr;
if (ft->state == FT_DONE) {
SetDlgItemText(proto->voiceDlgHWND, IDC_STATUS, TranslateT("...Finished..."));
// ProtoBroadcastAck(proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, ft, 0);
@@ -396,7 +396,7 @@ static void TlenVoiceReceivingConnection(HNETLIBCONN hConnection, DWORD, void *
ft->proto->debugLogA("ft->s is restored to %d", ft->s);
}
Netlib_CloseHandle(hConnection);
- if (ft != NULL && ft->hFileEvent != NULL)
+ if (ft != nullptr && ft->hFileEvent != nullptr)
SetEvent(ft->hFileEvent);
}
@@ -407,7 +407,7 @@ static void TlenVoiceReceiveParse(TLEN_FILE_TRANSFER *ft)
char *p;
float val;
TLEN_FILE_PACKET *packet = TlenP2PPacketReceive(ft->s);
- if (packet != NULL) {
+ if (packet != nullptr) {
statusTxt = " Unknown packet ";
p = packet->packet;
if (packet->type == TLEN_VOICE_PACKET) {
@@ -420,7 +420,7 @@ static void TlenVoiceReceiveParse(TLEN_FILE_TRANSFER *ft)
statusTxt = " Unknown codec ";
}
else {
- if (ft->proto->playbackControl == NULL) {
+ if (ft->proto->playbackControl == nullptr) {
ft->proto->playbackControl = TlenVoiceCreateVC(ft->proto, codec);
TlenVoicePlaybackStart(ft->proto->playbackControl);
ft->proto->framesAvailableForPlayback = 0;
@@ -501,9 +501,9 @@ static void TlenVoiceReceiveParse(TLEN_FILE_TRANSFER *ft)
TlenP2PPacketFree(packet);
}
else {
- if (ft->proto->playbackControl != NULL) {
+ if (ft->proto->playbackControl != nullptr) {
TlenVoiceFreeVc(ft->proto->playbackControl);
- ft->proto->playbackControl = NULL;
+ ft->proto->playbackControl = nullptr;
}
ft->state = FT_ERROR;
}
@@ -518,14 +518,14 @@ static void __cdecl TlenVoiceSendingThread(void *arg)
ft->proto->debugLogA("Thread started: type=voice_send");
ft->pfnNewConnectionV2 = TlenVoiceReceivingConnection;
HNETLIBCONN s = (HNETLIBCONN)TlenP2PListen(ft);
- if (s != NULL) {
+ if (s != nullptr) {
SetDlgItemText(ft->proto->voiceDlgHWND, IDC_STATUS, TranslateT("...Waiting for connection..."));
//ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_CONNECTING, ft, 0);
ft->s = s;
//TlenLog("ft->s = %d", s);
//TlenLog("fileCount = %d", ft->fileCount);
- HANDLE hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+ HANDLE hEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
ft->hFileEvent = hEvent;
ft->currentFile = 0;
ft->state = FT_CONNECTING;
@@ -535,11 +535,11 @@ static void __cdecl TlenVoiceSendingThread(void *arg)
mir_free(nick);
ft->proto->debugLogA("Waiting for the voice data to be sent...");
WaitForSingleObject(hEvent, INFINITE);
- ft->hFileEvent = NULL;
+ ft->hFileEvent = nullptr;
CloseHandle(hEvent);
ft->proto->debugLogA("Finish voice");
Netlib_CloseHandle(s);
- ft->s = NULL;
+ ft->s = nullptr;
ft->proto->debugLogA("ft->s is NULL");
if (ft->state == FT_SWITCH) {
@@ -550,14 +550,14 @@ static void __cdecl TlenVoiceSendingThread(void *arg)
nloc.szHost = ft->hostName;
nloc.wPort = ft->wPort;
HNETLIBCONN sock = Netlib_OpenConnection(ft->proto->m_hNetlibUser, &nloc);
- if (sock != NULL) {
+ if (sock != nullptr) {
SetDlgItemText(ft->proto->voiceDlgHWND, IDC_STATUS, TranslateT("...Connecting..."));
//ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_CONNECTING, ft, 0);
ft->s = sock;
TlenP2PEstablishOutgoingConnection(ft, FALSE);
if (ft->state != FT_ERROR) {
ft->proto->debugLogA("Entering send loop for this file connection...");
- ft->proto->playbackControl = NULL;
+ ft->proto->playbackControl = nullptr;
ft->proto->recordingControl = TlenVoiceCreateVC(ft->proto, 3);
ft->proto->recordingControl->ft = ft;
TlenVoiceRecordingStart(ft->proto->recordingControl);
@@ -605,7 +605,7 @@ static void TlenVoiceSendParse(TLEN_FILE_TRANSFER *ft)
int codec = ft->proto->recordingControl->codec;
TLEN_FILE_PACKET *packet = TlenP2PPacketCreate(sizeof(DWORD) + MODE_FRAME_SIZE[codec] * 33);
- if (packet != NULL) {
+ if (packet != nullptr) {
short *in;
float val;
in = ft->proto->recordingControl->recordingData;
@@ -647,19 +647,19 @@ int TlenVoiceCancelAll(TlenProtocol *proto)
while ((i = TlenListFindNext(proto, LIST_VOICE, 0)) >= 0) {
TLEN_LIST_ITEM *item = TlenListGetItemPtrFromIndex(proto, i);
- if (item != NULL) {
+ if (item != nullptr) {
TLEN_FILE_TRANSFER *ft = item->ft;
TlenListRemoveByIndex(proto, i);
- if (ft != NULL) {
+ if (ft != nullptr) {
if (ft->s) {
//ProtoBroadcastAck(proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0);
proto->debugLogA("Closing ft->s = %d", ft->s);
ft->state = FT_ERROR;
Netlib_CloseHandle(ft->s);
- ft->s = NULL;
- if (ft->hFileEvent != NULL) {
+ ft->s = nullptr;
+ if (ft->hFileEvent != nullptr) {
hEvent = ft->hFileEvent;
- ft->hFileEvent = NULL;
+ ft->hFileEvent = nullptr;
SetEvent(hEvent);
}
}
@@ -670,7 +670,7 @@ int TlenVoiceCancelAll(TlenProtocol *proto)
}
}
}
- if (proto->voiceDlgHWND != NULL) {
+ if (proto->voiceDlgHWND != nullptr) {
EndDialog(proto->voiceDlgHWND, 0);
}
return 0;
@@ -688,7 +688,7 @@ INT_PTR TlenProtocol::VoiceContactMenuHandleVoice(WPARAM wParam, LPARAM)
char serialId[32];
mir_snprintf(serialId, "%d", TlenSerialNext(this));
TLEN_LIST_ITEM *item = TlenListAdd(this, LIST_VOICE, serialId);
- if (item != NULL) {
+ if (item != nullptr) {
TLEN_FILE_TRANSFER *ft = TlenFileCreateFT(this, dbv.pszVal);
ft->iqId = mir_strdup(serialId);
item->ft = ft;
@@ -702,7 +702,7 @@ INT_PTR TlenProtocol::VoiceContactMenuHandleVoice(WPARAM wParam, LPARAM)
}
int TlenVoiceIsInUse(TlenProtocol *proto) {
- if (TlenListFindNext(proto, LIST_VOICE, 0) >= 0 || proto->voiceDlgHWND != NULL) {
+ if (TlenListFindNext(proto, LIST_VOICE, 0) >= 0 || proto->voiceDlgHWND != nullptr) {
proto->debugLogA("voice in use ? %d", proto->voiceDlgHWND);
return 1;
}
@@ -723,9 +723,9 @@ static HBITMAP TlenVoiceMakeBitmap(int w, int h, int bpp, void *ptr)
bmih.bmiHeader.biYPelsPerMeter = 0;
bmih.bmiHeader.biClrUsed = 0;
bmih.bmiHeader.biClrImportant = 0;
- HDC hdc = CreateDC(L"DISPLAY", NULL, NULL, NULL);
+ HDC hdc = CreateDC(L"DISPLAY", nullptr, nullptr, nullptr);
HBITMAP hbm = CreateDIBitmap(hdc, (PBITMAPINFOHEADER)&bmih, CBM_INIT, ptr, &bmih, DIB_RGB_COLORS);
- ReleaseDC(NULL, hdc);
+ ReleaseDC(nullptr, hdc);
return hbm;
}
@@ -802,10 +802,10 @@ static INT_PTR CALLBACK TlenVoiceDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,
TlenVoiceInitVUMeters();
SetDlgItemText(hwndDlg, IDC_STATUS, TranslateT("...???..."));
counter = 0;
- SetTimer(hwndDlg, 1, 100, NULL);
+ SetTimer(hwndDlg, 1, 100, nullptr);
return FALSE;
case WM_TIMER:
- if (proto->recordingControl != NULL && !proto->recordingControl->bDisable) {
+ if (proto->recordingControl != nullptr && !proto->recordingControl->bDisable) {
v = proto->recordingControl->vuMeter % VU_METER_LEVELS;
if (proto->recordingControl->vuMeter > 0) {
proto->recordingControl->vuMeter--;
@@ -815,13 +815,13 @@ static INT_PTR CALLBACK TlenVoiceDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,
v = 0;
}
hDC = GetDC(GetDlgItem(hwndDlg, IDC_VUMETERIN));
- if (NULL != (hMemDC = CreateCompatibleDC(hDC))) {
+ if (nullptr != (hMemDC = CreateCompatibleDC(hDC))) {
SelectObject(hMemDC, vuMeterBitmaps[v]);
BitBlt(hDC, 0, 0, VU_METER_WIDTH, VU_METER_HEIGHT, hMemDC, 0, 0, SRCCOPY);
DeleteDC(hMemDC);
}
ReleaseDC(GetDlgItem(hwndDlg, IDC_PLAN), hDC);
- if (proto->playbackControl != NULL && !proto->playbackControl->bDisable) {
+ if (proto->playbackControl != nullptr && !proto->playbackControl->bDisable) {
v = proto->playbackControl->vuMeter % VU_METER_LEVELS;
if (proto->playbackControl->vuMeter > 0) {
proto->playbackControl->vuMeter--;
@@ -831,7 +831,7 @@ static INT_PTR CALLBACK TlenVoiceDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,
v = 0;
}
hDC = GetDC(GetDlgItem(hwndDlg, IDC_VUMETEROUT));
- if (NULL != (hMemDC = CreateCompatibleDC(hDC))) {
+ if (nullptr != (hMemDC = CreateCompatibleDC(hDC))) {
SelectObject(hMemDC, vuMeterBitmaps[v]);
BitBlt(hDC, 0, 0, VU_METER_WIDTH, VU_METER_HEIGHT, hMemDC, 0, 0, SRCCOPY);
DeleteDC(hMemDC);
@@ -841,7 +841,7 @@ static INT_PTR CALLBACK TlenVoiceDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,
if (counter % 10 == 0) {
char str[50];
float fv;
- if (proto->recordingControl != NULL) {
+ if (proto->recordingControl != nullptr) {
fv = (float)proto->recordingControl->bytesSum;
proto->recordingControl->bytesSum = 0;
}
@@ -850,7 +850,7 @@ static INT_PTR CALLBACK TlenVoiceDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,
}
mir_snprintf(str, "%.1f kB/s", fv / 1024);
SetDlgItemTextA(hwndDlg, IDC_BYTESOUT, str);
- if (proto->playbackControl != NULL) {
+ if (proto->playbackControl != nullptr) {
fv = (float)proto->playbackControl->bytesSum;
proto->playbackControl->bytesSum = 0;
}
@@ -868,7 +868,7 @@ static INT_PTR CALLBACK TlenVoiceDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,
return TRUE;
case IDC_VCQUALITY:
if (HIWORD(wParam) == CBN_SELCHANGE) {
- if (proto->recordingControl != NULL) {
+ if (proto->recordingControl != nullptr) {
int codec = SendDlgItemMessage(hwndDlg, IDC_VCQUALITY, CB_GETCURSEL, 0, 0) + 2;
if (codec != proto->recordingControl->codec && codec > 1 && codec < 6) {
TLEN_FILE_TRANSFER *ft = proto->recordingControl->ft;
@@ -881,12 +881,12 @@ static INT_PTR CALLBACK TlenVoiceDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,
}
break;
case IDC_MICROPHONE:
- if (proto->recordingControl != NULL) {
+ if (proto->recordingControl != nullptr) {
proto->recordingControl->bDisable = BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_MICROPHONE);
}
break;
case IDC_SPEAKER:
- if (proto->playbackControl != NULL) {
+ if (proto->playbackControl != nullptr) {
proto->playbackControl->bDisable = BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_SPEAKER);
}
break;
@@ -896,7 +896,7 @@ static INT_PTR CALLBACK TlenVoiceDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,
EndDialog(hwndDlg, 0);
break;
case WM_DESTROY:
- proto->voiceDlgHWND = NULL;
+ proto->voiceDlgHWND = nullptr;
break;
}
@@ -908,7 +908,7 @@ static void __cdecl TlenVoiceDlgThread(void *ptr)
TLEN_FILE_TRANSFER *ft = (TLEN_FILE_TRANSFER *)ptr;
TlenProtocol *proto = ft->proto;
- DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_VOICE), NULL, TlenVoiceDlgProc, (LPARAM)proto);
+ DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_VOICE), nullptr, TlenVoiceDlgProc, (LPARAM)proto);
TlenVoiceCancelAll(proto);
}
@@ -981,7 +981,7 @@ static void __cdecl TlenVoiceAcceptDlgThread(void *ptr)
{
ACCEPTDIALOGDATA *data = (ACCEPTDIALOGDATA *)ptr;
- int result = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_ACCEPT_VOICE), NULL, TlenVoiceAcceptDlgProc, (LPARAM)data);
+ int result = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_ACCEPT_VOICE), nullptr, TlenVoiceAcceptDlgProc, (LPARAM)data);
if (result && data->proto->isOnline) {
data->item->ft = TlenFileCreateFT(data->proto, data->item->nick);
data->item->ft->iqId = mir_strdup(data->item->jid);
@@ -1001,7 +1001,7 @@ int TlenVoiceAccept(TlenProtocol *proto, const char *id, const char *from)
{
if (!TlenVoiceIsInUse(proto)) {
TLEN_LIST_ITEM *item = TlenListAdd(proto, LIST_VOICE, id);
- if (item != NULL) {
+ if (item != nullptr) {
bool ask = true, ignore = false;
int voiceChatPolicy = db_get_w(NULL, proto->m_szModuleName, "VoiceChatPolicy", 0);
if (voiceChatPolicy == TLEN_MUC_ASK) {
diff --git a/protocols/Tlen/src/tlen_ws.cpp b/protocols/Tlen/src/tlen_ws.cpp
index 3da3a54c88..1cf07644d8 100644
--- a/protocols/Tlen/src/tlen_ws.cpp
+++ b/protocols/Tlen/src/tlen_ws.cpp
@@ -44,15 +44,15 @@ BOOL TlenWsInit(TlenProtocol *proto)
nlus.useProxy = 0;
Netlib_SetUserSettings(proto->hFileNetlibUser, &nlus);
- return (proto->m_hNetlibUser != NULL)?TRUE:FALSE;
+ return (proto->m_hNetlibUser != nullptr)?TRUE:FALSE;
}
void TlenWsUninit(TlenProtocol *proto)
{
- if (proto->m_hNetlibUser != NULL) Netlib_CloseHandle(proto->m_hNetlibUser);
- if (proto->hFileNetlibUser != NULL) Netlib_CloseHandle(proto->hFileNetlibUser);
- proto->m_hNetlibUser = NULL;
- proto->hFileNetlibUser = NULL;
+ if (proto->m_hNetlibUser != nullptr) Netlib_CloseHandle(proto->m_hNetlibUser);
+ if (proto->hFileNetlibUser != nullptr) Netlib_CloseHandle(proto->hFileNetlibUser);
+ proto->m_hNetlibUser = nullptr;
+ proto->hFileNetlibUser = nullptr;
}
HNETLIBCONN TlenWsConnect(TlenProtocol *proto, char *host, WORD port)
@@ -97,7 +97,7 @@ int TlenWsSendAES(TlenProtocol *proto, char *data, int datalen, aes_context *aes
int len, sendlen;
unsigned char aes_input[16];
unsigned char aes_output[256];
- if (proto->threadData == NULL) {
+ if (proto->threadData == nullptr) {
return FALSE;
}
while (datalen > 0) {
@@ -127,7 +127,7 @@ int TlenWsRecvAES(TlenProtocol *proto, char *data, long datalen, aes_context *ae
int ret, len = 0, maxlen = datalen;
unsigned char aes_input[16];
unsigned char *aes_output = (unsigned char *)data;
- if (proto->threadData == NULL) {
+ if (proto->threadData == nullptr) {
return 0;
}
for (maxlen = maxlen & ~0xF; maxlen != 0; maxlen = maxlen & 0xF) {
diff --git a/protocols/Tlen/src/tlen_xml.cpp b/protocols/Tlen/src/tlen_xml.cpp
index 28e3ca07c6..68ddc29145 100644
--- a/protocols/Tlen/src/tlen_xml.cpp
+++ b/protocols/Tlen/src/tlen_xml.cpp
@@ -29,25 +29,25 @@ static void TlenXmlRemoveChild(XmlNode *node, XmlNode *child);
void TlenXmlInitState(XmlState *xmlState)
{
- if (xmlState == NULL) return;
- xmlState->root.name = NULL;
+ if (xmlState == nullptr) return;
+ xmlState->root.name = nullptr;
xmlState->root.depth = 0;
xmlState->root.numAttr = 0;
xmlState->root.maxNumAttr = 0;
- xmlState->root.attr = NULL;
+ xmlState->root.attr = nullptr;
xmlState->root.numChild = 0;
xmlState->root.maxNumChild = 0;
- xmlState->root.child = NULL;
- xmlState->root.text = NULL;
+ xmlState->root.child = nullptr;
+ xmlState->root.text = nullptr;
xmlState->root.state = NODE_OPEN;
- xmlState->callback1_open = NULL;
- xmlState->callback1_close = NULL;
- xmlState->callback2_open = NULL;
- xmlState->callback2_close = NULL;
- xmlState->userdata1_open = NULL;
- xmlState->userdata1_close = NULL;
- xmlState->userdata2_open = NULL;
- xmlState->userdata2_close = NULL;
+ xmlState->callback1_open = nullptr;
+ xmlState->callback1_close = nullptr;
+ xmlState->callback2_open = nullptr;
+ xmlState->callback2_close = nullptr;
+ xmlState->userdata1_open = nullptr;
+ xmlState->userdata1_close = nullptr;
+ xmlState->userdata2_open = nullptr;
+ xmlState->userdata2_close = nullptr;
}
void TlenXmlDestroyState(XmlState *xmlState)
@@ -55,7 +55,7 @@ void TlenXmlDestroyState(XmlState *xmlState)
int i;
XmlNode *node;
- if (xmlState == NULL)
+ if (xmlState == nullptr)
return;
// Note: cannot use TlenXmlFreeNode() to free xmlState->root
// because it will do mir_free(xmlState->root) which is not freeable.
@@ -173,7 +173,7 @@ int TlenXmlParse(XmlState *xmlState, char *buffer, int datalen)
str = (char *) mir_alloc(q-p+1);
strncpy(str, p, q-p);
str[q-p] = '\0';
- TlenXmlProcessElem(xmlState, ELEM_TEXT, str, NULL);
+ TlenXmlProcessElem(xmlState, ELEM_TEXT, str, nullptr);
mir_free(str);
num += (q-p);
p = q;
@@ -193,7 +193,7 @@ static void TlenXmlParseAttr(XmlNode *node, char *text)
char *p;
XmlAttr *a;
- if (node == NULL || text == NULL || mir_strlen(text) <= 0)
+ if (node == nullptr || text == nullptr || mir_strlen(text) <= 0)
return;
for (p=text;;) {
@@ -277,7 +277,7 @@ static BOOL TlenXmlProcessElem(XmlState *xmlState, XmlElemType elemType, char *e
//BOOL activateCallback = FALSE;
char *text, *attr;
- if (elemText == NULL) return FALSE;
+ if (elemText == nullptr) return FALSE;
if (elemType == ELEM_OPEN && !mir_strcmp(elemText, "?xml")) {
// TlenLog("XML: skip <?xml> tag");
@@ -286,7 +286,7 @@ static BOOL TlenXmlProcessElem(XmlState *xmlState, XmlElemType elemType, char *e
// Find active node
node = &(xmlState->root);
- parentNode = NULL;
+ parentNode = nullptr;
while (node->numChild>0 && node->child[node->numChild-1]->state == NODE_OPEN) {
parentNode = node;
node = node->child[node->numChild-1];
@@ -299,7 +299,7 @@ static BOOL TlenXmlProcessElem(XmlState *xmlState, XmlElemType elemType, char *e
if (elemAttr)
attr = mir_strdup(elemAttr);
else
- attr = NULL;
+ attr = nullptr;
switch (elemType) {
case ELEM_OPEN:
@@ -313,14 +313,14 @@ static BOOL TlenXmlProcessElem(XmlState *xmlState, XmlElemType elemType, char *e
n->depth = node->depth + 1;
n->state = NODE_OPEN;
n->numChild = n->maxNumChild = 0;
- n->child = NULL;
+ n->child = nullptr;
n->numAttr = n->maxNumAttr = 0;
- n->attr = NULL;
+ n->attr = nullptr;
TlenXmlParseAttr(n, attr);
- n->text = NULL;
- if (n->depth == 1 && xmlState->callback1_open != NULL)
+ n->text = nullptr;
+ if (n->depth == 1 && xmlState->callback1_open != nullptr)
(*(xmlState->callback1_open))(n, xmlState->userdata1_open);
- if (n->depth == 2 && xmlState->callback2_open != NULL)
+ if (n->depth == 2 && xmlState->callback2_open != nullptr)
(*xmlState->callback2_open)(n, xmlState->userdata2_open);
break;
case ELEM_OPENCLOSE:
@@ -334,29 +334,29 @@ static BOOL TlenXmlProcessElem(XmlState *xmlState, XmlElemType elemType, char *e
n->depth = node->depth + 1;
n->state = NODE_CLOSE;
n->numChild = n->maxNumAttr = 0;
- n->child = NULL;
+ n->child = nullptr;
n->numAttr = n->maxNumAttr = 0;
- n->attr = NULL;
+ n->attr = nullptr;
TlenXmlParseAttr(n, attr);
- n->text = NULL;
- if (n->depth == 1 && xmlState->callback1_close != NULL) {
+ n->text = nullptr;
+ if (n->depth == 1 && xmlState->callback1_close != nullptr) {
(*(xmlState->callback1_close))(n, xmlState->userdata1_close);
TlenXmlRemoveChild(node, n);
}
- if (n->depth == 2 && xmlState->callback2_close != NULL) {
+ if (n->depth == 2 && xmlState->callback2_close != nullptr) {
(*xmlState->callback2_close)(n, xmlState->userdata2_close);
TlenXmlRemoveChild(node, n);
}
break;
case ELEM_CLOSE:
- if (node->name != NULL && !mir_strcmp(node->name, text)) {
+ if (node->name != nullptr && !mir_strcmp(node->name, text)) {
node->state = NODE_CLOSE;
int nodeDepth = node->depth;
- if (nodeDepth == 1 && xmlState->callback1_close != NULL) {
+ if (nodeDepth == 1 && xmlState->callback1_close != nullptr) {
(*(xmlState->callback1_close))(node, xmlState->userdata1_close);
TlenXmlRemoveChild(parentNode, node);
}
- if (nodeDepth == 2 && xmlState->callback2_close != NULL) {
+ if (nodeDepth == 2 && xmlState->callback2_close != nullptr) {
(*xmlState->callback2_close)(node, xmlState->userdata2_close);
TlenXmlRemoveChild(parentNode, node);
}
@@ -387,13 +387,13 @@ char *TlenXmlGetAttrValue(XmlNode *node, char *key)
{
int i;
- if (node == NULL || node->numAttr <= 0 || key == NULL || mir_strlen(key) <= 0)
- return NULL;
+ if (node == nullptr || node->numAttr <= 0 || key == nullptr || mir_strlen(key) <= 0)
+ return nullptr;
for (i=0; i<node->numAttr; i++) {
if (node->attr[i]->name && !mir_strcmp(key, node->attr[i]->name))
return node->attr[i]->value;
}
- return NULL;
+ return nullptr;
}
XmlNode *TlenXmlGetChild(XmlNode *node, char *tag)
@@ -405,8 +405,8 @@ XmlNode *TlenXmlGetNthChild(XmlNode *node, char *tag, int nth)
{
int i, num;
- if (node == NULL || node->numChild <= 0 || tag == NULL || mir_strlen(tag) <= 0 || nth < 1)
- return NULL;
+ if (node == nullptr || node->numChild <= 0 || tag == nullptr || mir_strlen(tag) <= 0 || nth < 1)
+ return nullptr;
num = 1;
for (i=0; i<node->numChild; i++) {
if (node->child[i]->name && !mir_strcmp(tag, node->child[i]->name)) {
@@ -416,7 +416,7 @@ XmlNode *TlenXmlGetNthChild(XmlNode *node, char *tag, int nth)
num++;
}
}
- return NULL;
+ return nullptr;
}
XmlNode *TlenXmlGetChildWithGivenAttrValue(XmlNode *node, char *tag, char *attrKey, char *attrValue)
@@ -424,23 +424,23 @@ XmlNode *TlenXmlGetChildWithGivenAttrValue(XmlNode *node, char *tag, char *attrK
int i;
char *str;
- if (node == NULL || node->numChild <= 0 || tag == NULL || mir_strlen(tag) <= 0 || attrKey == NULL || mir_strlen(attrKey) <= 0 || attrValue == NULL || mir_strlen(attrValue) <= 0)
- return NULL;
+ if (node == nullptr || node->numChild <= 0 || tag == nullptr || mir_strlen(tag) <= 0 || attrKey == nullptr || mir_strlen(attrKey) <= 0 || attrValue == nullptr || mir_strlen(attrValue) <= 0)
+ return nullptr;
for (i=0; i<node->numChild; i++) {
if (node->child[i]->name && !mir_strcmp(tag, node->child[i]->name)) {
- if ((str=TlenXmlGetAttrValue(node->child[i], attrKey)) != NULL)
+ if ((str=TlenXmlGetAttrValue(node->child[i], attrKey)) != nullptr)
if (!mir_strcmp(str, attrValue))
return node->child[i];
}
}
- return NULL;
+ return nullptr;
}
static void TlenXmlRemoveChild(XmlNode *node, XmlNode *child)
{
int i;
- if (node == NULL || child == NULL || node->numChild <= 0) return;
+ if (node == nullptr || child == nullptr || node->numChild <= 0) return;
for (i=0; i<node->numChild; i++) {
if (node->child[i] == child)
break;
@@ -457,7 +457,7 @@ void TlenXmlFreeNode(XmlNode *node)
{
int i;
- if (node == NULL)
+ if (node == nullptr)
return;
// Free all children first
for (i=0; i<node->numChild; i++)
@@ -482,7 +482,7 @@ XmlNode *TlenXmlCopyNode(XmlNode *node)
XmlNode *n;
int i;
- if (node == NULL) return NULL;
+ if (node == nullptr) return nullptr;
n = (XmlNode *) mir_alloc(sizeof(XmlNode));
// Copy attributes
if (node->numAttr > 0) {
@@ -490,13 +490,13 @@ XmlNode *TlenXmlCopyNode(XmlNode *node)
for (i=0; i<node->numAttr; i++) {
n->attr[i] = (XmlAttr *) mir_alloc(sizeof(XmlAttr));
if (node->attr[i]->name) n->attr[i]->name = mir_strdup(node->attr[i]->name);
- else n->attr[i]->name = NULL;
+ else n->attr[i]->name = nullptr;
if (node->attr[i]->value) n->attr[i]->value = mir_strdup(node->attr[i]->value);
- else n->attr[i]->value = NULL;
+ else n->attr[i]->value = nullptr;
}
}
else
- n->attr = NULL;
+ n->attr = nullptr;
// Recursively copy children
if (node->numChild > 0) {
n->child = (XmlNode **) mir_alloc(node->numChild*sizeof(XmlNode *));
@@ -504,7 +504,7 @@ XmlNode *TlenXmlCopyNode(XmlNode *node)
n->child[i] = TlenXmlCopyNode(node->child[i]);
}
else
- n->child = NULL;
+ n->child = nullptr;
// Copy other fields
n->numAttr = node->numAttr;
n->maxNumAttr = node->numAttr;
@@ -512,8 +512,8 @@ XmlNode *TlenXmlCopyNode(XmlNode *node)
n->maxNumChild = node->numChild;
n->depth = node->depth;
n->state = node->state;
- n->name = (node->name)?mir_strdup(node->name):NULL;
- n->text = (node->text)?mir_strdup(node->text):NULL;
+ n->name = (node->name)?mir_strdup(node->name):nullptr;
+ n->text = (node->text)?mir_strdup(node->text):nullptr;
return n;
}
@@ -522,8 +522,8 @@ XmlNode *TlenXmlCreateNode(char *name)
{
XmlNode *n;
- if (name == NULL)
- return NULL;
+ if (name == nullptr)
+ return nullptr;
n = (XmlNode *) mir_alloc(sizeof(XmlNode));
memset(n, 0, sizeof(XmlNode));
@@ -535,7 +535,7 @@ void TlenXmlAddAttr(XmlNode *n, char *name, char *value)
{
int i;
- if (n == NULL || name == NULL || value == NULL)
+ if (n == nullptr || name == nullptr || value == nullptr)
return;
i = n->numAttr;
@@ -550,8 +550,8 @@ XmlNode *TlenXmlAddChild(XmlNode *n, char *name)
{
int i;
- if (n == NULL || name == NULL)
- return NULL;
+ if (n == nullptr || name == nullptr)
+ return nullptr;
i = n->numChild;
n->numChild++;
@@ -564,7 +564,7 @@ XmlNode *TlenXmlAddChild(XmlNode *n, char *name)
void TlenXmlAddText(XmlNode *n, char *text)
{
- if (n != NULL && text != NULL) {
+ if (n != nullptr && text != nullptr) {
if (n->text) mir_free(n->text);
n->text = mir_strdup(text);
}