diff options
author | Tobias Weimer <wishmaster51@googlemail.com> | 2015-03-14 16:36:48 +0000 |
---|---|---|
committer | Tobias Weimer <wishmaster51@googlemail.com> | 2015-03-14 16:36:48 +0000 |
commit | 23c27ccc254699611882657dbe6936c3b3ad510f (patch) | |
tree | 37ea8eb53e234c8013963df412e0ad50f99d102e /protocols | |
parent | a519adcb90671bb4e3958fba5997d4fad1d50a2f (diff) |
Tlen:
- Minor cleanup
git-svn-id: http://svn.miranda-ng.org/main/trunk@12400 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/Tlen/src/tlen_iqid.cpp | 119 | ||||
-rw-r--r-- | protocols/Tlen/src/tlen_opt.cpp | 9 | ||||
-rw-r--r-- | protocols/Tlen/src/tlen_p2p_old.cpp | 47 | ||||
-rw-r--r-- | protocols/Tlen/src/tlen_thread.cpp | 44 | ||||
-rw-r--r-- | protocols/Tlen/src/tlen_voice.cpp | 32 |
5 files changed, 120 insertions, 131 deletions
diff --git a/protocols/Tlen/src/tlen_iqid.cpp b/protocols/Tlen/src/tlen_iqid.cpp index acc67c7cd3..7c5368822f 100644 --- a/protocols/Tlen/src/tlen_iqid.cpp +++ b/protocols/Tlen/src/tlen_iqid.cpp @@ -27,13 +27,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "tlen_iq.h"
#include "tlen_muc.h"
+// RECVED: authentication result
+// ACTION: if successfully logged in, continue by requesting roster list and set my initial status
void TlenIqResultAuth(TlenProtocol *proto, XmlNode *iqNode)
{
- char *type;
-
- // RECVED: authentication result
- // ACTION: if successfully logged in, continue by requesting roster list and set my initial status
- if ((type=TlenXmlGetAttrValue(iqNode, "type")) == NULL) return;
+ char *type=TlenXmlGetAttrValue(iqNode, "type");
+ if (type == NULL)
+ return;
if (!strcmp(type, "result")) {
DBVARIANT dbv;
@@ -63,32 +63,35 @@ void TlenIqResultAuth(TlenProtocol *proto, XmlNode *iqNode) void TlenResultSetRoster(TlenProtocol *proto, XmlNode *queryNode) {
DBVARIANT dbv;
- XmlNode *itemNode, *groupNode;
- TLEN_LIST_ITEM *item;
+ XmlNode *groupNode;
MCONTACT hContact;
- char *jid, *name, *nick;
- int i;
- char *str;
+ char *name, *nick;
- for (i=0; i<queryNode->numChild; i++) {
- itemNode = queryNode->child[i];
+ for (int i=0; i<queryNode->numChild; i++) {
+ XmlNode *itemNode = queryNode->child[i];
if (!strcmp(itemNode->name, "item")) {
- if ((jid=TlenXmlGetAttrValue(itemNode, "jid")) != NULL) {
- str = TlenXmlGetAttrValue(itemNode, "subscription");
- if (!strcmp(str, "remove")) {
+ char *jid=TlenXmlGetAttrValue(itemNode, "jid");
+ if (jid != NULL) {
+ char *str = TlenXmlGetAttrValue(itemNode, "subscription");
+ if (str == NULL)
+ continue;
+ else if (!strcmp(str, "remove")) {
if ((hContact = TlenHContactFromJID(proto, jid)) != NULL) {
if (db_get_w(hContact, proto->m_szModuleName, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE)
db_set_w(hContact, proto->m_szModuleName, "Status", ID_STATUS_OFFLINE);
}
TlenListRemove(proto, LIST_ROSTER, jid);
} else {
- item = TlenListAdd(proto, LIST_ROSTER, jid);
+ TLEN_LIST_ITEM *item = TlenListAdd(proto, LIST_ROSTER, jid);
if (item != NULL) {
- if (str == NULL) item->subscription = SUB_NONE;
- else if (!strcmp(str, "both")) item->subscription = SUB_BOTH;
- else if (!strcmp(str, "to")) item->subscription = SUB_TO;
- else if (!strcmp(str, "from")) item->subscription = SUB_FROM;
- else item->subscription = SUB_NONE;
+ if (!strcmp(str, "both"))
+ item->subscription = SUB_BOTH;
+ else if (!strcmp(str, "to"))
+ item->subscription = SUB_TO;
+ else if (!strcmp(str, "from"))
+ item->subscription = SUB_FROM;
+ else
+ item->subscription = SUB_NONE;
if ((name=TlenXmlGetAttrValue(itemNode, "name")) != NULL) {
nick = TlenTextDecode(name);
} else {
@@ -127,19 +130,17 @@ void TlenResultSetRoster(TlenProtocol *proto, XmlNode *queryNode) { }
}
+// RECVED: roster information
+// ACTION: populate LIST_ROSTER and create contact for any new rosters
void TlenIqResultRoster(TlenProtocol *proto, XmlNode *iqNode)
{
- char *str;
-
- // RECVED: roster information
- // ACTION: populate LIST_ROSTER and create contact for any new rosters
char *type=TlenXmlGetAttrValue(iqNode, "type");
if (type == NULL) return;
XmlNode *queryNode=TlenXmlGetChild(iqNode, "query");
if (queryNode == NULL) return;
if (!strcmp(type, "result")) {
- str = TlenXmlGetAttrValue(queryNode, "xmlns");
+ char *str = TlenXmlGetAttrValue(queryNode, "xmlns");
if (str != NULL && !strcmp(str, "jabber:iq:roster")) {
DBVARIANT dbv;
XmlNode *itemNode, *groupNode;
@@ -238,7 +239,6 @@ void TlenIqResultRoster(TlenProtocol *proto, XmlNode *iqNode) // Tlen actually use jabber:iq:search for other users vCard or jabber:iq:register for own vCard
void TlenIqResultVcard(TlenProtocol *proto, XmlNode *iqNode)
{
- char *jid;
char text[128];
MCONTACT hContact;
char *nText;
@@ -248,15 +248,14 @@ void TlenIqResultVcard(TlenProtocol *proto, XmlNode *iqNode) if (type == NULL) return;
if (!strcmp(type, "result")) {
- BOOL hasFirst, hasLast, hasNick, hasEmail, hasCity, hasAge, hasGender, hasSchool, hasLookFor, hasOccupation;
DBVARIANT dbv;
- int i;
XmlNode *queryNode=TlenXmlGetChild(iqNode, "query");
if (queryNode == NULL) return;
XmlNode *itemNode=TlenXmlGetChild(queryNode, "item");
if (itemNode == NULL) return;
- if ((jid=TlenXmlGetAttrValue(itemNode, "jid")) != NULL) {
+ char *jid=TlenXmlGetAttrValue(itemNode, "jid");
+ if (jid != NULL) {
if (db_get(NULL, proto->m_szModuleName, "LoginServer", &dbv)) return;
if (strchr(jid, '@') != NULL) {
strncpy_s(text, jid, _TRUNCATE);
@@ -275,13 +274,14 @@ void TlenIqResultVcard(TlenProtocol *proto, XmlNode *iqNode) } else {
hContact = NULL;
}
- hasFirst = hasLast = hasNick = hasEmail = hasCity = hasAge = hasGender = hasOccupation = hasLookFor = hasSchool = FALSE;
- for (i=0; i<itemNode->numChild; i++) {
+ bool hasFirst = false, hasLast = false, hasNick = false, hasEmail = false, hasCity = false, hasAge = false,
+ 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 (!strcmp(n->name, "first")) {
if (n->text != NULL) {
- hasFirst = TRUE;
+ hasFirst = true;
nText = TlenTextDecode(n->text);
db_set_s(hContact, proto->m_szModuleName, "FirstName", nText);
mir_free(nText);
@@ -289,7 +289,7 @@ void TlenIqResultVcard(TlenProtocol *proto, XmlNode *iqNode) }
else if (!strcmp(n->name, "last")) {
if (n->text != NULL) {
- hasLast = TRUE;
+ hasLast = true;
nText = TlenTextDecode(n->text);
db_set_s(hContact, proto->m_szModuleName, "LastName", nText);
mir_free(nText);
@@ -297,7 +297,7 @@ void TlenIqResultVcard(TlenProtocol *proto, XmlNode *iqNode) }
else if (!strcmp(n->name, "nick")) {
if (n->text != NULL) {
- hasNick = TRUE;
+ hasNick = true;
nText = TlenTextDecode(n->text);
db_set_s(hContact, proto->m_szModuleName, "Nick", nText);
mir_free(nText);
@@ -305,7 +305,7 @@ void TlenIqResultVcard(TlenProtocol *proto, XmlNode *iqNode) }
else if (!strcmp(n->name, "email")) {
if (n->text != NULL) {
- hasEmail = TRUE;
+ hasEmail = true;
nText = TlenTextDecode(n->text);
db_set_s(hContact, proto->m_szModuleName, "e-mail", nText);
mir_free(nText);
@@ -313,7 +313,7 @@ void TlenIqResultVcard(TlenProtocol *proto, XmlNode *iqNode) }
else if (!strcmp(n->name, "c")) {
if (n->text != NULL) {
- hasCity = TRUE;
+ hasCity = true;
nText = TlenTextDecode(n->text);
db_set_s(hContact, proto->m_szModuleName, "City", nText);
mir_free(nText);
@@ -321,21 +321,20 @@ void TlenIqResultVcard(TlenProtocol *proto, XmlNode *iqNode) }
else if (!strcmp(n->name, "b")) {
if (n->text != NULL) {
- WORD nAge;
- hasAge = TRUE;
- nAge = atoi(n->text);
+ WORD nAge = atoi(n->text);
+ hasAge = true;
db_set_w(hContact, proto->m_szModuleName, "Age", nAge);
}
}
else if (!strcmp(n->name, "s")) {
if (n->text != NULL && n->text[1] == '\0' && (n->text[0] == '1' || n->text[0] == '2')) {
- hasGender = TRUE;
+ hasGender = true;
db_set_b(hContact, proto->m_szModuleName, "Gender", (BYTE) (n->text[0] == '1'?'M':'F'));
}
}
else if (!strcmp(n->name, "e")) {
if (n->text != NULL) {
- hasSchool = TRUE;
+ hasSchool = true;
nText = TlenTextDecode(n->text);
db_set_s(hContact, proto->m_szModuleName, "School", nText);
mir_free(nText);
@@ -343,31 +342,27 @@ void TlenIqResultVcard(TlenProtocol *proto, XmlNode *iqNode) }
else if (!strcmp(n->name, "j")) {
if (n->text != NULL) {
- WORD nOccupation;
- hasOccupation = TRUE;
- nOccupation = atoi(n->text);
+ hasOccupation = true;
+ WORD nOccupation = atoi(n->text);
db_set_w(hContact, proto->m_szModuleName, "Occupation", nOccupation);
}
}
else if (!strcmp(n->name, "r")) {
if (n->text != NULL) {
- WORD nLookFor;
- hasLookFor = TRUE;
- nLookFor = atoi(n->text);
+ WORD nLookFor = atoi(n->text);
+ hasLookFor = true;
db_set_w(hContact, proto->m_szModuleName, "LookingFor", nLookFor);
}
}
else if (!strcmp(n->name, "g")) { // voice chat enabled
if (n->text != NULL) {
- BYTE bVoice;
- bVoice = atoi(n->text);
+ BYTE bVoice = atoi(n->text);
db_set_w(hContact, proto->m_szModuleName, "VoiceChat", bVoice);
}
}
else if (!strcmp(n->name, "v")) { // status visibility
if (n->text != NULL) {
- BYTE bPublic;
- bPublic = atoi(n->text);
+ BYTE bPublic = atoi(n->text);
db_set_w(hContact, proto->m_szModuleName, "PublicStatus", bPublic);
}
}
@@ -601,16 +596,18 @@ void TlenIqResultInfo(TlenProtocol *proto, XmlNode *iqNode) if (queryNode != NULL) {
char *from=TlenXmlGetAttrValue(queryNode, "from");
if (from != NULL ) {
- TLEN_LIST_ITEM *item;
- if (( item=TlenListGetItemPtr( proto, LIST_ROSTER, from )) != NULL) {
+ TLEN_LIST_ITEM *item=TlenListGetItemPtr(proto, LIST_ROSTER, from);
+ if (item != NULL) {
XmlNode *version = TlenXmlGetChild(queryNode, "version");
- item->protocolVersion = TlenTextDecode(version->text);
- MCONTACT hContact=TlenHContactFromJID(proto, item->jid);
- if (hContact != NULL) {
- if (item->software == NULL) {
- char str[128];
- mir_snprintf(str, SIZEOF(str), "Tlen Protocol %s", item->protocolVersion);
- db_set_s(hContact, proto->m_szModuleName, "MirVer", str);
+ if (version != NULL) {
+ item->protocolVersion = TlenTextDecode(version->text);
+ MCONTACT hContact=TlenHContactFromJID(proto, item->jid);
+ if (hContact != NULL) {
+ if (item->software == NULL) {
+ char str[128];
+ mir_snprintf(str, SIZEOF(str), "Tlen Protocol %s", item->protocolVersion);
+ db_set_s(hContact, proto->m_szModuleName, "MirVer", str);
+ }
}
}
}
diff --git a/protocols/Tlen/src/tlen_opt.cpp b/protocols/Tlen/src/tlen_opt.cpp index df5588a6a7..ead41cad56 100644 --- a/protocols/Tlen/src/tlen_opt.cpp +++ b/protocols/Tlen/src/tlen_opt.cpp @@ -596,17 +596,18 @@ static INT_PTR CALLBACK TlenAdvOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, static void MailPopupPreview(DWORD colorBack, DWORD colorText, TCHAR *title, TCHAR *emailInfo, int delay) { + if (!ServiceExists(MS_POPUP_ADDPOPUPT)) + return; POPUPDATAT ppd = { 0 }; HICON hIcon = GetIcolibIcon(IDI_MAIL); ppd.lchIcon = CopyIcon(hIcon); ReleaseIcolibIcon(hIcon); - _tcscpy(ppd.lptzContactName, title); - _tcscpy(ppd.lptzText, emailInfo); + _tcsncpy(ppd.lptzContactName, title, MAX_CONTACTNAME-1); + _tcsncpy(ppd.lptzText, emailInfo,MAX_SECONDLINE-1); ppd.colorBack = colorBack; ppd.colorText = colorText; ppd.iSeconds = delay; - if ( ServiceExists(MS_POPUP_ADDPOPUPT)) - PUAddPopupT(&ppd); + PUAddPopupT(&ppd); } static INT_PTR CALLBACK TlenPopupsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) diff --git a/protocols/Tlen/src/tlen_p2p_old.cpp b/protocols/Tlen/src/tlen_p2p_old.cpp index e8bea6e2cb..3d3668b42d 100644 --- a/protocols/Tlen/src/tlen_p2p_old.cpp +++ b/protocols/Tlen/src/tlen_p2p_old.cpp @@ -28,7 +28,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. void TlenP2PFreeFileTransfer(TLEN_FILE_TRANSFER *ft)
{
- int i;
if (ft->jid) mir_free(ft->jid);
if (ft->iqId) mir_free(ft->iqId);
if (ft->id2) mir_free(ft->id2);
@@ -38,7 +37,7 @@ void TlenP2PFreeFileTransfer(TLEN_FILE_TRANSFER *ft) if (ft->szDescription) mir_free(ft->szDescription);
if (ft->filesSize) mir_free(ft->filesSize);
if (ft->files) {
- for (i=0; i<ft->fileCount; i++) {
+ for (int i=0; i<ft->fileCount; i++) {
if (ft->files[i]) mir_free(ft->files[i]);
}
mir_free(ft->files);
@@ -48,9 +47,8 @@ void TlenP2PFreeFileTransfer(TLEN_FILE_TRANSFER *ft) TLEN_FILE_PACKET *TlenP2PPacketCreate(int datalen)
{
- TLEN_FILE_PACKET *packet;
-
- if ((packet=(TLEN_FILE_PACKET *) mir_alloc(sizeof(TLEN_FILE_PACKET))) == NULL)
+ TLEN_FILE_PACKET *packet=(TLEN_FILE_PACKET *) mir_alloc(sizeof(TLEN_FILE_PACKET));
+ if (packet == NULL)
return NULL;
packet->packet = NULL;
if (datalen > 0) {
@@ -128,14 +126,12 @@ int TlenP2PPacketSend(HANDLE s, TLEN_FILE_PACKET *packet) TLEN_FILE_PACKET* TlenP2PPacketReceive(HANDLE s)
{
- TLEN_FILE_PACKET *packet;
- DWORD recvResult;
DWORD type, len, pos;
- recvResult = Netlib_Recv(s, (char *)&type, 4, MSG_NODUMP);
+ DWORD recvResult = Netlib_Recv(s, (char *)&type, 4, MSG_NODUMP);
if (recvResult == 0 || recvResult == SOCKET_ERROR) return NULL;
recvResult = Netlib_Recv(s, (char *)&len, 4, MSG_NODUMP);
if (recvResult == 0 || recvResult == SOCKET_ERROR) return NULL;
- packet = TlenP2PPacketCreate(len);
+ TLEN_FILE_PACKET *packet = TlenP2PPacketCreate(len);
TlenP2PPacketSetType(packet, type);
TlenP2PPacketSetLen(packet, len);
pos = 0;
@@ -153,20 +149,18 @@ TLEN_FILE_PACKET* TlenP2PPacketReceive(HANDLE s) void TlenP2PEstablishOutgoingConnection(TLEN_FILE_TRANSFER *ft, BOOL sendAck)
{
- char *hash;
char str[300];
- size_t srt_len;
- TLEN_FILE_PACKET *packet;
TlenProtocol *proto = ft->proto;
proto->debugLogA("Establishing outgoing connection.");
ft->state = FT_ERROR;
- if ((packet = TlenP2PPacketCreate(2*sizeof(DWORD) + 20)) != NULL) {
+ TLEN_FILE_PACKET *packet = TlenP2PPacketCreate(2*sizeof(DWORD) + 20);
+ if (packet != NULL) {
TlenP2PPacketSetType(packet, TLEN_FILE_PACKET_CONNECTION_REQUEST);
TlenP2PPacketPackDword(packet, 1);
TlenP2PPacketPackDword(packet, (DWORD) atoi(ft->iqId));
- srt_len = mir_snprintf(str, SIZEOF(str), "%08X%s%d", atoi(ft->iqId), proto->threadData->username, atoi(ft->iqId));
- hash = TlenSha1(str, (int)srt_len);
+ size_t srt_len = mir_snprintf(str, SIZEOF(str), "%08X%s%d", atoi(ft->iqId), proto->threadData->username, atoi(ft->iqId));
+ char *hash = TlenSha1(str, (int)srt_len);
TlenP2PPacketPackBuffer(packet, hash, 20);
mir_free(hash);
TlenP2PPacketSend(ft->s, packet);
@@ -188,9 +182,6 @@ void TlenP2PEstablishOutgoingConnection(TLEN_FILE_TRANSFER *ft, BOOL sendAck) TLEN_FILE_TRANSFER* TlenP2PEstablishIncomingConnection(TlenProtocol *proto, HANDLE s, TLEN_LIST list, BOOL sendAck)
{
- TLEN_LIST_ITEM *item = NULL;
- TLEN_FILE_PACKET *packet;
- int i;
char str[300];
DWORD iqId;
// TYPE: 0x1
@@ -198,7 +189,7 @@ TLEN_FILE_TRANSFER* TlenP2PEstablishIncomingConnection(TlenProtocol *proto, HAND // (DWORD) 0x1
// (DWORD) id
// (BYTE) hash[20]
- packet = TlenP2PPacketReceive(s);
+ TLEN_FILE_PACKET *packet = TlenP2PPacketReceive(s);
if (packet == NULL || packet->type != TLEN_FILE_PACKET_CONNECTION_REQUEST || packet->len<28) {
if (packet != NULL) {
TlenP2PPacketFree(packet);
@@ -206,9 +197,11 @@ TLEN_FILE_TRANSFER* TlenP2PEstablishIncomingConnection(TlenProtocol *proto, HAND return NULL;
}
iqId = *((DWORD *)(packet->packet+sizeof(DWORD)));
- i = 0;
+ int i = 0;
+ TLEN_LIST_ITEM *item;
while ((i=TlenListFindNext(proto, list, i)) >= 0) {
- if ((item=TlenListGetItemPtrFromIndex(proto, i)) != NULL) {
+ item = TlenListGetItemPtrFromIndex(proto, i);
+ if (item != NULL) {
mir_snprintf(str, SIZEOF(str), "%d", iqId);
if (!strcmp(item->ft->iqId, str)) {
char *hash, *nick;
@@ -247,10 +240,9 @@ TLEN_FILE_TRANSFER* TlenP2PEstablishIncomingConnection(TlenProtocol *proto, HAND static void __cdecl TlenFileBindSocks4Thread(TLEN_FILE_TRANSFER* ft)
{
BYTE buf[8];
- int status;
// TlenLog("Waiting for the file to be sent via SOCKS...");
- status = Netlib_Recv(ft->s, (char*)buf, 8, MSG_NODUMP);
+ int status = Netlib_Recv(ft->s, (char*)buf, 8, MSG_NODUMP);
// TlenLog("accepted connection !!!");
if ( status == SOCKET_ERROR || status < 8 || buf[1] != 90) {
status = 1;
@@ -273,10 +265,9 @@ static void __cdecl TlenFileBindSocks4Thread(TLEN_FILE_TRANSFER* ft) static void __cdecl TlenFileBindSocks5Thread(TLEN_FILE_TRANSFER* ft)
{
BYTE buf[256];
- int status;
// TlenLog("Waiting for the file to be sent via SOCKS...");
- status = Netlib_Recv(ft->s, (char*)buf, sizeof(buf), MSG_NODUMP);
+ int status = Netlib_Recv(ft->s, (char*)buf, sizeof(buf), MSG_NODUMP);
// TlenLog("accepted connection !!!");
if ( status == SOCKET_ERROR || status < 7 || buf[1] != 0) {
status = 1;
@@ -343,7 +334,7 @@ static HANDLE TlenP2PBindSocks4(SOCKSBIND * sb, TLEN_FILE_TRANSFER *ft) return NULL;
}
in.S_un.S_addr = *(PDWORD)(buf+4);
- strcpy(sb->szHost, inet_ntoa(in));
+ strncpy(sb->szHost, inet_ntoa(in), sizeof(sb->szHost)-1);
sb->wPort = htons(*(PWORD)(buf+2));
ft->s = s;
forkthread((void (__cdecl *)(void*))TlenFileBindSocks4Thread, 0, ft);
@@ -472,11 +463,11 @@ HANDLE TlenP2PListen(TLEN_FILE_TRANSFER *ft) if (db_get_b(NULL, proto->m_szModuleName, "FileProxyAuth", FALSE)) {
sb.useAuth = TRUE;
if (!db_get_s(NULL, proto->m_szModuleName, "FileProxyUsername", &dbv)) {
- strcpy(sb.szUser, dbv.pszVal);
+ strncpy(sb.szUser, dbv.pszVal, sizeof(sb.szUser)-1);
db_free(&dbv);
}
if (!db_get_s(NULL, proto->m_szModuleName, "FileProxyPassword", &dbv)) {
- strcpy(sb.szPassword, dbv.pszVal);
+ strncpy(sb.szPassword, dbv.pszVal, sizeof(sb.szPassword)-1);
db_free(&dbv);
}
}
diff --git a/protocols/Tlen/src/tlen_thread.cpp b/protocols/Tlen/src/tlen_thread.cpp index 8d786d2da5..6d93071a28 100644 --- a/protocols/Tlen/src/tlen_thread.cpp +++ b/protocols/Tlen/src/tlen_thread.cpp @@ -227,7 +227,7 @@ void __cdecl TlenServerThread(ThreadData *info) if (!db_get(NULL, info->proto->m_szModuleName, "AvatarHash", &dbv)) {
- strcpy(info->proto->threadData->avatarHash, dbv.pszVal);
+ strncpy(info->proto->threadData->avatarHash, dbv.pszVal, sizeof(info->proto->threadData->avatarHash)-1);
db_free(&dbv);
}
info->avatarFormat = db_get_dw(NULL, info->proto->m_szModuleName, "AvatarFormat", PA_FORMAT_UNKNOWN);
@@ -587,7 +587,7 @@ static void TlenProcessAvatar(XmlNode* node, ThreadData *info) XmlNode *aNode = TlenXmlGetChild(node, "a");
if (tokenNode != NULL) {
char *token = tokenNode->text;
- strcpy(info->avatarToken, token);
+ strncpy(info->avatarToken, token, sizeof(info->avatarToken)-1);
}
if (aNode != NULL) {
if (TlenProcessAvatarNode(info->proto, node, NULL)) {
@@ -603,8 +603,6 @@ static void TlenProcessMessage(XmlNode *node, ThreadData *info) DWORD msgTime;
BOOL delivered, composing;
int i;
- TLEN_LIST_ITEM *item;
- BOOL isChatRoomJid;
if (!node->name || strcmp(node->name, "message")) return;
@@ -619,8 +617,8 @@ static void TlenProcessMessage(XmlNode *node, ThreadData *info) }
char *fromJid = TlenLoginFromJID(from);
// If message is from a stranger (not in roster), item is NULL
- item = TlenListGetItemPtr(info->proto, LIST_ROSTER, fromJid);
- isChatRoomJid = TlenListExist(info->proto, LIST_CHATROOM, from);
+ TLEN_LIST_ITEM *item = TlenListGetItemPtr(info->proto, LIST_ROSTER, fromJid);
+ BOOL isChatRoomJid = TlenListExist(info->proto, LIST_CHATROOM, from);
if (isChatRoomJid && type != NULL && !strcmp(type, "groupchat")) {
//TlenGroupchatProcessMessage(node, userdata);
@@ -739,7 +737,6 @@ static void TlenProcessIq(XmlNode *node, ThreadData *info) char *idStr, *str;
int id;
int i;
- TLEN_IQ_PFUNC pfunc;
if (!node->name || strcmp(node->name, "iq")) return;
char *type=TlenXmlGetAttrValue(node, "type");
@@ -760,7 +757,8 @@ static void TlenProcessIq(XmlNode *node, ThreadData *info) /////////////////////////////////////////////////////////////////////////
// MATCH BY ID
/////////////////////////////////////////////////////////////////////////
- if ((pfunc=TlenIqFetchFunc(info->proto, id)) != NULL) {
+ TLEN_IQ_PFUNC pfunc=TlenIqFetchFunc(info->proto, id);
+ if (pfunc != NULL) {
info->proto->debugLogA("Handling iq request for id=%d", id);
pfunc(info->proto, node);
/////////////////////////////////////////////////////////////////////////
@@ -826,10 +824,14 @@ static void TlenProcessIq(XmlNode *node, ThreadData *info) }
}
if ((item=TlenListGetItemPtr(info->proto, LIST_ROSTER, jid)) != NULL) {
- if (!strcmp(str, "both")) item->subscription = SUB_BOTH;
- else if (!strcmp(str, "to")) item->subscription = SUB_TO;
- else if (!strcmp(str, "from")) item->subscription = SUB_FROM;
- else item->subscription = SUB_NONE;
+ if (!strcmp(str, "both"))
+ item->subscription = SUB_BOTH;
+ else if (!strcmp(str, "to"))
+ item->subscription = SUB_TO;
+ else if (!strcmp(str, "from"))
+ item->subscription = SUB_FROM;
+ else
+ item->subscription = SUB_NONE;
info->proto->debugLogA("Roster push for jid=%s, set subscription to %s", jid, str);
// subscription = remove is to remove from roster list
// but we will just set the contact to offline and not actually
@@ -947,19 +949,19 @@ static void TlenProcessW(XmlNode *node, ThreadData *info) */
static void TlenProcessM(XmlNode *node, ThreadData *info)
{
- MCONTACT hContact;
- char *f;//, *from;//username
- char *tp;//typing start/stop
char *p, *n, *r, *s, *str, *localMessage;
int i;
XmlNode *xNode, *invNode, *bNode;
if (!node->name || strcmp(node->name, "m")) return;
- if ((f=TlenXmlGetAttrValue(node, "f")) != NULL) {
+ char *f = TlenXmlGetAttrValue(node, "f"); //, *from;//username
+ if (f != NULL) {
char *fLogin = TlenLoginFromJID(f);
- if ((hContact=TlenHContactFromJID(info->proto, fLogin)) != NULL) {
- if ((tp=TlenXmlGetAttrValue(node, "tp")) != NULL) {
+ MCONTACT hContact=TlenHContactFromJID(info->proto, fLogin);
+ if (hContact != NULL) {
+ char *tp=TlenXmlGetAttrValue(node, "tp");//typing start/stop
+ if (tp != NULL) {
TLEN_LIST_ITEM *item = TlenListGetItemPtr(info->proto, LIST_ROSTER, fLogin);
if (!strcmp(tp, "t")) { //contact is writing
if (item != NULL ) {
@@ -1005,7 +1007,7 @@ static void TlenProcessM(XmlNode *node, ThreadData *info) } else {
timestamp = time(NULL);
}
- tp=TlenXmlGetAttrValue(node, "tp");
+ char *tp=TlenXmlGetAttrValue(node, "tp");//typing start/stop
bNode = TlenXmlGetChild(node, "b");
f = TlenTextDecode(f);
if (bNode != NULL && bNode->text != NULL) {
@@ -1061,8 +1063,8 @@ static void TlenMailPopup(TlenProtocol *proto, char *title, char *emailInfo) POPUPDATAT ppd = { 0 };
ppd.lchIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_MAIL));
- _tcscpy(ppd.lptzContactName, _A2T(title));
- _tcscpy(ppd.lptzText, _A2T(emailInfo));
+ _tcsncpy(ppd.lptzContactName, _A2T(title), MAX_CONTACTNAME -1);
+ _tcsncpy(ppd.lptzText, _A2T(emailInfo), MAX_SECONDLINE - 1);
ppd.colorBack = db_get_dw(NULL, proto->m_szModuleName, "MailPopupBack", 0);
ppd.colorText = db_get_dw(NULL, proto->m_szModuleName, "MailPopupText", 0);
BYTE delayMode = db_get_b(NULL, proto->m_szModuleName, "MailPopupDelayMode", 0);
diff --git a/protocols/Tlen/src/tlen_voice.cpp b/protocols/Tlen/src/tlen_voice.cpp index 9ad27ed9b5..26ad4ae4d7 100644 --- a/protocols/Tlen/src/tlen_voice.cpp +++ b/protocols/Tlen/src/tlen_voice.cpp @@ -869,8 +869,7 @@ static INT_PTR CALLBACK TlenVoiceDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, case IDC_VCQUALITY:
if (HIWORD(wParam) == CBN_SELCHANGE) {
if (proto->recordingControl != NULL) {
- int codec;
- codec = SendDlgItemMessage(hwndDlg, IDC_VCQUALITY, CB_GETCURSEL, 0, 0) + 2;
+ 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;
TlenVoiceFreeVc(proto->recordingControl);
@@ -880,6 +879,7 @@ static INT_PTR CALLBACK TlenVoiceDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, }
}
}
+ break;
case IDC_MICROPHONE:
if (proto->recordingControl != NULL) {
proto->recordingControl->bDisable = BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_MICROPHONE);
@@ -996,18 +996,16 @@ static void __cdecl TlenVoiceAcceptDlgThread(void *ptr) int TlenVoiceAccept(TlenProtocol *proto, const char *id, const char *from)
{
- TLEN_LIST_ITEM * item;
if (!TlenVoiceIsInUse(proto)) {
- if ((item = TlenListAdd(proto, LIST_VOICE, id)) != NULL) {
- int ask, ignore, voiceChatPolicy;
- ask = TRUE;
- ignore = FALSE;
- voiceChatPolicy = db_get_w(NULL, proto->m_szModuleName, "VoiceChatPolicy", 0);
+ TLEN_LIST_ITEM *item = TlenListAdd(proto, LIST_VOICE, id);
+ if (item != NULL) {
+ bool ask = true, ignore = false;
+ int voiceChatPolicy = db_get_w(NULL, proto->m_szModuleName, "VoiceChatPolicy", 0);
if (voiceChatPolicy == TLEN_MUC_ASK) {
- ignore = FALSE;
- ask = TRUE;
+ ignore = false;
+ ask = true;
} else if (voiceChatPolicy == TLEN_MUC_IGNORE_ALL) {
- ignore = TRUE;
+ ignore = true;
} else if (voiceChatPolicy == TLEN_MUC_IGNORE_NIR) {
char jid[256];
DBVARIANT dbv;
@@ -1015,10 +1013,10 @@ int TlenVoiceAccept(TlenProtocol *proto, const char *id, const char *from) mir_snprintf(jid, SIZEOF(jid), "%s@%s", from, dbv.pszVal);
db_free(&dbv);
} else {
- strcpy(jid, from);
+ strncpy(jid, from, SIZEOF(jid)-1);
}
ignore = !IsAuthorized(proto, jid);
- ask = TRUE;
+ ask = true;
} else if (voiceChatPolicy == TLEN_MUC_ACCEPT_IR) {
char jid[256];
DBVARIANT dbv;
@@ -1026,13 +1024,13 @@ int TlenVoiceAccept(TlenProtocol *proto, const char *id, const char *from) mir_snprintf(jid, SIZEOF(jid), "%s@%s", from, dbv.pszVal);
db_free(&dbv);
} else {
- strcpy(jid, from);
+ strncpy(jid, from, SIZEOF(jid)-1);
}
ask = !IsAuthorized(proto, jid);
- ignore = FALSE;
+ ignore = false;
} else if (voiceChatPolicy == TLEN_MUC_ACCEPT_ALL) {
- ask = FALSE;
- ignore = FALSE;
+ ask = false;
+ ignore = false;
}
if (ignore) {
if (proto->isOnline) {
|