From 995d9bcf3ef85618ac6bc44e3b0543f9e357e661 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 29 Aug 2015 17:51:10 +0000 Subject: oops... some more 'hides' warnings git-svn-id: http://svn.miranda-ng.org/main/trunk@15100 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Tlen/src/tlen_iqid.cpp | 201 +++++++++++++------------- protocols/Tlen/src/tlen_picture.cpp | 27 ++-- protocols/Tlen/src/tlen_svc.cpp | 271 +++++++++++++++++++----------------- protocols/Tlen/src/tlen_util.cpp | 138 +++++++++--------- 4 files changed, 328 insertions(+), 309 deletions(-) (limited to 'protocols/Tlen/src') diff --git a/protocols/Tlen/src/tlen_iqid.cpp b/protocols/Tlen/src/tlen_iqid.cpp index 786c642758..aa27bb4e04 100644 --- a/protocols/Tlen/src/tlen_iqid.cpp +++ b/protocols/Tlen/src/tlen_iqid.cpp @@ -31,7 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // ACTION: if successfully logged in, continue by requesting roster list and set my initial status void TlenIqResultAuth(TlenProtocol *proto, XmlNode *iqNode) { - char *type=TlenXmlGetAttrValue(iqNode, "type"); + char *type = TlenXmlGetAttrValue(iqNode, "type"); if (type == NULL) return; @@ -42,9 +42,9 @@ void TlenIqResultAuth(TlenProtocol *proto, XmlNode *iqNode) db_set_s(NULL, proto->m_szModuleName, "Nick", proto->threadData->username); else db_free(&dbv); -// iqId = TlenSerialNext(); -// TlenIqAdd(iqId, IQ_PROC_NONE, TlenIqResultGetRoster); -// TlenSend(info, "", iqId); + // iqId = TlenSerialNext(); + // TlenIqAdd(iqId, IQ_PROC_NONE, TlenIqResultGetRoster); + // TlenSend(info, "", iqId); TlenSend(proto, ""); TlenSend(proto, ""); @@ -55,7 +55,7 @@ void TlenIqResultAuth(TlenProtocol *proto, XmlNode *iqNode) TlenSend(proto, ""); 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); + 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 } @@ -67,10 +67,10 @@ void TlenResultSetRoster(TlenProtocol *proto, XmlNode *queryNode) { MCONTACT hContact; char *name, *nick; - for (int i=0; inumChild; i++) { + for (int i = 0; i < queryNode->numChild; i++) { XmlNode *itemNode = queryNode->child[i]; if (!mir_strcmp(itemNode->name, "item")) { - char *jid=TlenXmlGetAttrValue(itemNode, "jid"); + char *jid = TlenXmlGetAttrValue(itemNode, "jid"); if (jid != NULL) { char *str = TlenXmlGetAttrValue(itemNode, "subscription"); if (str == NULL) @@ -81,7 +81,8 @@ void TlenResultSetRoster(TlenProtocol *proto, XmlNode *queryNode) { db_set_w(hContact, proto->m_szModuleName, "Status", ID_STATUS_OFFLINE); } TlenListRemove(proto, LIST_ROSTER, jid); - } else { + } + else { TLEN_LIST_ITEM *item = TlenListAdd(proto, LIST_ROSTER, jid); if (item != NULL) { if (!mir_strcmp(str, "both")) @@ -92,23 +93,24 @@ 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")) != NULL) { nick = TlenTextDecode(name); - } else { + } + else { nick = TlenLocalNickFromJID(jid); } if (nick != NULL) { if (item->nick) mir_free(item->nick); item->nick = nick; - if ((hContact=TlenHContactFromJID(proto, jid)) == NULL) { + if ((hContact = TlenHContactFromJID(proto, jid)) == NULL) { // Received roster has a new JID. // Add the jid (with empty resource) to Miranda contact list. hContact = TlenDBCreateContact(proto, jid, nick, FALSE); } 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")) != NULL && groupNode->text != NULL) { item->group = TlenGroupDecode(groupNode->text); Clist_CreateGroup(0, _A2T(item->group)); // Don't set group again if already correct, or Miranda may show wrong group count in some case @@ -116,9 +118,11 @@ void TlenResultSetRoster(TlenProtocol *proto, XmlNode *queryNode) { if (mir_strcmp(dbv.pszVal, item->group)) db_set_s(hContact, "CList", "Group", item->group); db_free(&dbv); - } else + } + else db_set_s(hContact, "CList", "Group", item->group); - } else { + } + else { item->group = NULL; db_unset(hContact, "CList", "Group"); } @@ -134,9 +138,9 @@ void TlenResultSetRoster(TlenProtocol *proto, XmlNode *queryNode) { // ACTION: populate LIST_ROSTER and create contact for any new rosters void TlenIqResultRoster(TlenProtocol *proto, XmlNode *iqNode) { - char *type=TlenXmlGetAttrValue(iqNode, "type"); + char *type = TlenXmlGetAttrValue(iqNode, "type"); if (type == NULL) return; - XmlNode *queryNode=TlenXmlGetChild(iqNode, "query"); + XmlNode *queryNode = TlenXmlGetChild(iqNode, "query"); if (queryNode == NULL) return; if (!mir_strcmp(type, "result")) { @@ -149,7 +153,7 @@ void TlenIqResultRoster(TlenProtocol *proto, XmlNode *iqNode) char *jid, *name, *nick; int i, oldStatus; - for (i=0; inumChild; i++) { + for (i = 0; i < queryNode->numChild; i++) { itemNode = queryNode->child[i]; if (!mir_strcmp(itemNode->name, "item")) { str = TlenXmlGetAttrValue(itemNode, "subscription"); @@ -159,26 +163,26 @@ void TlenIqResultRoster(TlenProtocol *proto, XmlNode *iqNode) 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")) != NULL) { + if ((name = TlenXmlGetAttrValue(itemNode, "name")) != NULL) nick = TlenTextDecode(name); else nick = TlenLocalNickFromJID(jid); - + if (nick != NULL) { MCONTACT hContact; item = TlenListAdd(proto, LIST_ROSTER, jid); if (item->nick) mir_free(item->nick); item->nick = nick; item->subscription = sub; - if ((hContact=TlenHContactFromJID(proto, jid)) == NULL) { + if ((hContact = TlenHContactFromJID(proto, jid)) == NULL) { // Received roster has a new JID. // Add the jid (with empty resource) to Miranda contact list. hContact = TlenDBCreateContact(proto, jid, nick, FALSE); } 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")) != NULL && groupNode->text != NULL) { item->group = TlenGroupDecode(groupNode->text); Clist_CreateGroup(0, _A2T(item->group)); // Don't set group again if already correct, or Miranda may show wrong group count in some case @@ -193,25 +197,25 @@ void TlenIqResultRoster(TlenProtocol *proto, XmlNode *iqNode) item->group = NULL; db_unset(hContact, "CList", "Group"); } - if (!db_get(hContact, proto->m_szModuleName, "AvatarHash", &dbv)) { - if (item->avatarHash) mir_free(item->avatarHash); - item->avatarHash = mir_strdup(dbv.pszVal); + + ptrA szAvatarHash(proto->getStringA(hContact, "AvatarHash")); + if (szAvatarHash != NULL) { + replaceStr(item->avatarHash, szAvatarHash); proto->debugLogA("Setting hash [%s] = %s", nick, item->avatarHash); - db_free(&dbv); } item->avatarFormat = db_get_dw(hContact, proto->m_szModuleName, "AvatarFormat", PA_FORMAT_UNKNOWN); } } } } - + // Delete orphaned contacts (if roster sync is enabled) if (db_get_b(NULL, proto->m_szModuleName, "RosterSync", FALSE) == TRUE) { for (MCONTACT hContact = db_find_first(proto->m_szModuleName); hContact; ) { MCONTACT hNext = hContact = db_find_next(hContact, proto->m_szModuleName); - ptrA jid( db_get_sa(hContact, proto->m_szModuleName, "jid")); - if (jid != NULL) { - if (!TlenListExist(proto, LIST_ROSTER, jid)) { + ptrA szJid(proto->getStringA(hContact, "szJid")); + if (szJid != NULL) { + if (!TlenListExist(proto, LIST_ROSTER, szJid)) { proto->debugLogA("Syncing roster: deleting 0x%x", hContact); CallService(MS_DB_CONTACT_DELETE, hContact, 0); } @@ -228,7 +232,7 @@ void TlenIqResultRoster(TlenProtocol *proto, XmlNode *iqNode) proto->debugLogA("Status changed via THREADSTART"); oldStatus = proto->m_iStatus; TlenSendPresence(proto, proto->m_iDesiredStatus); - ProtoBroadcastAck(proto->m_szModuleName, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE) oldStatus, proto->m_iStatus); + ProtoBroadcastAck(proto->m_szModuleName, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, proto->m_iStatus); } } } @@ -241,27 +245,28 @@ void TlenIqResultVcard(TlenProtocol *proto, XmlNode *iqNode) MCONTACT hContact; char *nText; -// TlenLog(" iqIdGetVcard (tlen)"); - char *type=TlenXmlGetAttrValue(iqNode, "type"); + // TlenLog(" iqIdGetVcard (tlen)"); + char *type = TlenXmlGetAttrValue(iqNode, "type"); if (type == NULL) return; if (!mir_strcmp(type, "result")) { DBVARIANT dbv; - XmlNode *queryNode=TlenXmlGetChild(iqNode, "query"); + XmlNode *queryNode = TlenXmlGetChild(iqNode, "query"); if (queryNode == NULL) return; - XmlNode *itemNode=TlenXmlGetChild(queryNode, "item"); + XmlNode *itemNode = TlenXmlGetChild(queryNode, "item"); if (itemNode == NULL) return; - char *jid=TlenXmlGetAttrValue(itemNode, "jid"); + 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); - } else { - mir_snprintf(text, "%s@%s", jid, dbv.pszVal); // Add @tlen.pl + } + else { + mir_snprintf(text, "%s@%s", jid, dbv.pszVal); // Add @tlen.pl } db_free(&dbv); - if ((hContact=TlenHContactFromJID(proto, text)) == NULL) { + if ((hContact = TlenHContactFromJID(proto, text)) == NULL) { if (db_get(NULL, proto->m_szModuleName, "LoginName", &dbv)) return; if (mir_strcmp(dbv.pszVal, jid)) { db_free(&dbv); @@ -269,12 +274,13 @@ void TlenIqResultVcard(TlenProtocol *proto, XmlNode *iqNode) } db_free(&dbv); } - } else { + } + else { hContact = NULL; } 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; inumChild; i++) { + for (int i = 0; i < itemNode->numChild; i++) { XmlNode *n = itemNode->child[i]; if (n == NULL || n->name == NULL) continue; if (!mir_strcmp(n->name, "first")) { @@ -327,7 +333,7 @@ void TlenIqResultVcard(TlenProtocol *proto, XmlNode *iqNode) else if (!mir_strcmp(n->name, "s")) { if (n->text != NULL && 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')); + db_set_b(hContact, proto->m_szModuleName, "Gender", (BYTE)(n->text[0] == '1' ? 'M' : 'F')); } } else if (!mir_strcmp(n->name, "e")) { @@ -386,7 +392,7 @@ void TlenIqResultVcard(TlenProtocol *proto, XmlNode *iqNode) db_unset(hContact, proto->m_szModuleName, "Occupation"); if (!hasLookFor) db_unset(hContact, proto->m_szModuleName, "LookingFor"); - ProtoBroadcastAck(proto->m_szModuleName, hContact, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, (HANDLE) 1, 0); + ProtoBroadcastAck(proto->m_szModuleName, hContact, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, (HANDLE)1, 0); } } @@ -395,64 +401,69 @@ void TlenIqResultSearch(TlenProtocol *proto, XmlNode *iqNode) XmlNode *queryNode, *itemNode, *n; char *jid; int i, found = 0; - TLEN_SEARCH_RESULT jsr = {0}; - DBVARIANT dbv = {0}; + TLEN_SEARCH_RESULT jsr = { 0 }; + DBVARIANT dbv = { 0 }; -// TlenLog(" iqIdGetSearch"); + // TlenLog(" iqIdGetSearch"); char *type = TlenXmlGetAttrValue(iqNode, "type"); if (type == NULL) return; char *str = TlenXmlGetAttrValue(iqNode, "id"); if (str == NULL) return; - int id = atoi(str+mir_strlen(TLEN_IQID)); + 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")) == NULL) return; if (!db_get(NULL, proto->m_szModuleName, "LoginServer", &dbv)) { jsr.hdr.cbSize = sizeof(TLEN_SEARCH_RESULT); jsr.hdr.flags = PSR_TCHAR; - for (i=0; inumChild; i++) { + for (i = 0; i < queryNode->numChild; i++) { itemNode = queryNode->child[i]; if (!mir_strcmp(itemNode->name, "item")) { - if ((jid=TlenXmlGetAttrValue(itemNode, "jid")) != NULL) { + if ((jid = TlenXmlGetAttrValue(itemNode, "jid")) != NULL) { if (strchr(jid, '@') != NULL) { strncpy_s(jsr.jid, jid, _TRUNCATE); - } else { + } + else { mir_snprintf(jsr.jid, "%s@%s", jid, dbv.pszVal); } - jsr.jid[sizeof(jsr.jid)-1] = '\0'; + jsr.jid[sizeof(jsr.jid) - 1] = '\0'; jsr.hdr.id.t = mir_a2t(jid); - if ((n=TlenXmlGetChild(itemNode, "nick")) != NULL && n->text != NULL){ + if ((n = TlenXmlGetChild(itemNode, "nick")) != NULL && n->text != NULL) { char* buf = TlenTextDecode(n->text); jsr.hdr.nick.t = mir_a2t(buf); mir_free(buf); - } else { + } + else { jsr.hdr.nick.t = mir_tstrdup(TEXT("")); } - if ((n=TlenXmlGetChild(itemNode, "first")) != NULL && n->text != NULL){ + if ((n = TlenXmlGetChild(itemNode, "first")) != NULL && n->text != NULL) { char* buf = TlenTextDecode(n->text); jsr.hdr.firstName.t = mir_a2t(buf); mir_free(buf); - } else { + } + else { jsr.hdr.firstName.t = mir_tstrdup(TEXT("")); } - if ((n=TlenXmlGetChild(itemNode, "last")) != NULL && n->text != NULL){ + if ((n = TlenXmlGetChild(itemNode, "last")) != NULL && n->text != NULL) { char* buf = TlenTextDecode(n->text); jsr.hdr.lastName.t = mir_a2t(buf); mir_free(buf); - } else { + } + else { jsr.hdr.lastName.t = mir_tstrdup(TEXT("")); } - if ((n=TlenXmlGetChild(itemNode, "email"))!=NULL && n->text!=NULL){ + if ((n = TlenXmlGetChild(itemNode, "email")) != NULL && n->text != NULL) { char* buf = TlenTextDecode(n->text); jsr.hdr.email.t = mir_a2t(buf); mir_free(buf); - } else { + } + else { jsr.hdr.email.t = mir_tstrdup(TEXT("")); } - ProtoBroadcastAck(proto->m_szModuleName, NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE) id, (LPARAM) &jsr); + ProtoBroadcastAck(proto->m_szModuleName, NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)id, (LPARAM)&jsr); found = 1; mir_free(jsr.hdr.id.t); mir_free(jsr.hdr.nick.t); @@ -470,7 +481,7 @@ void TlenIqResultSearch(TlenProtocol *proto, XmlNode *iqNode) mir_snprintf(jsr.jid, "%s@%s", proto->searchJID, dbv.pszVal); jsr.hdr.nick.t = jsr.hdr.firstName.t = jsr.hdr.lastName.t = jsr.hdr.email.t = jsr.hdr.id.t = TEXT(""); - ProtoBroadcastAck(proto->m_szModuleName, NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE) id, (LPARAM) &jsr); + ProtoBroadcastAck(proto->m_szModuleName, NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)id, (LPARAM)&jsr); } mir_free(proto->searchJID); proto->searchJID = NULL; @@ -482,13 +493,14 @@ void TlenIqResultSearch(TlenProtocol *proto, XmlNode *iqNode) found = TlenRunSearch(proto); } if (!found) { - ProtoBroadcastAck(proto->m_szModuleName, NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE) id, 0); + ProtoBroadcastAck(proto->m_szModuleName, NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0); } - } else if (!mir_strcmp(type, "error")) { + } + else if (!mir_strcmp(type, "error")) { // ProtoBroadcastAck(proto->m_szModuleName, NULL, ACKTYPE_SEARCH, ACKRESULT_FAILED, (HANDLE) id, 0); // There is no ACKRESULT_FAILED for ACKTYPE_SEARCH :) look at findadd.c // So we will just send a SUCCESS - ProtoBroadcastAck(proto->m_szModuleName, NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE) id, 0); + ProtoBroadcastAck(proto->m_szModuleName, NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0); } } @@ -500,7 +512,8 @@ void GetConfigItem(XmlNode *node, char *dest, BOOL bMethod, int *methodDest) { char *method = TlenXmlGetAttrValue(node, "method"); if (method != NULL && !strcmpi(method, "POST")) { *methodDest = REQUEST_POST; - } else { + } + else { *methodDest = REQUEST_GET; } } @@ -510,33 +523,33 @@ void TlenIqResultTcfg(TlenProtocol *proto, XmlNode *iqNode) { XmlNode *queryNode, *miniMailNode, *node; - char *type=TlenXmlGetAttrValue(iqNode, "type"); + char *type = TlenXmlGetAttrValue(iqNode, "type"); if (type == NULL) 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) { + 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 ((node=TlenXmlGetChild(miniMailNode, "msg")) != NULL) { + if ((node = TlenXmlGetChild(miniMailNode, "msg")) != NULL) { GetConfigItem(node, proto->threadData->tlenConfig.mailMsg, TRUE, &proto->threadData->tlenConfig.mailMsgMthd); } - if ((node=TlenXmlGetChild(miniMailNode, "index")) != NULL) { + if ((node = TlenXmlGetChild(miniMailNode, "index")) != NULL) { GetConfigItem(node, proto->threadData->tlenConfig.mailIndex, TRUE, &proto->threadData->tlenConfig.mailIndexMthd); } - if ((node=TlenXmlGetChild(miniMailNode, "login")) != NULL) { + if ((node = TlenXmlGetChild(miniMailNode, "login")) != NULL) { GetConfigItem(node, proto->threadData->tlenConfig.mailLogin, TRUE, &proto->threadData->tlenConfig.mailLoginMthd); } - if ((node=TlenXmlGetChild(miniMailNode, "compose")) != NULL) { + if ((node = TlenXmlGetChild(miniMailNode, "compose")) != NULL) { GetConfigItem(node, proto->threadData->tlenConfig.mailCompose, TRUE, &proto->threadData->tlenConfig.mailComposeMthd); } - if ((node=TlenXmlGetChild(miniMailNode, "avatar-get")) != NULL) { + if ((node = TlenXmlGetChild(miniMailNode, "avatar-get")) != NULL) { GetConfigItem(node, proto->threadData->tlenConfig.avatarGet, TRUE, &proto->threadData->tlenConfig.avatarGetMthd); } - if ((node=TlenXmlGetChild(miniMailNode, "avatar-upload")) != NULL) { + if ((node = TlenXmlGetChild(miniMailNode, "avatar-upload")) != NULL) { GetConfigItem(node, proto->threadData->tlenConfig.avatarUpload, TRUE, &proto->threadData->tlenConfig.avatarUploadMthd); } - if ((node=TlenXmlGetChild(miniMailNode, "avatar-remove")) != NULL) { + if ((node = TlenXmlGetChild(miniMailNode, "avatar-remove")) != NULL) { GetConfigItem(node, proto->threadData->tlenConfig.avatarRemove, TRUE, &proto->threadData->tlenConfig.avatarRemoveMthd); } } @@ -547,30 +560,32 @@ void TlenIqResultVersion(TlenProtocol *proto, XmlNode *iqNode) XmlNode *queryNode = TlenXmlGetChild(iqNode, "query"); if (queryNode != NULL) { char *from = TlenXmlGetAttrValue(iqNode, "from"); - if (from != NULL ) { + if (from != NULL) { TLEN_LIST_ITEM *item = TlenListGetItemPtr(proto, LIST_ROSTER, from); if (item != NULL) { 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 ) { - item->software = TlenTextDecode( n->text ); - } else + 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) { + item->software = TlenTextDecode(n->text); + } + else item->software = NULL; - if (( n=TlenXmlGetChild( queryNode, "version" )) != NULL && n->text ) - item->version = TlenTextDecode( n->text ); + if ((n = TlenXmlGetChild(queryNode, "version")) != NULL && n->text) + item->version = TlenTextDecode(n->text); else item->version = NULL; - if (( n=TlenXmlGetChild( queryNode, "os" )) != NULL && n->text ) - item->system = TlenTextDecode( n->text ); + if ((n = TlenXmlGetChild(queryNode, "os")) != NULL && n->text) + item->system = TlenTextDecode(n->text); else item->system = NULL; MCONTACT hContact = TlenHContactFromJID(proto, item->jid); if (hContact != NULL) { if (item->software != NULL) { db_set_s(hContact, proto->m_szModuleName, "MirVer", item->software); - } else { + } + else { db_unset(hContact, proto->m_szModuleName, "MirVer"); } } @@ -583,14 +598,14 @@ void TlenIqResultInfo(TlenProtocol *proto, XmlNode *iqNode) { XmlNode *queryNode = TlenXmlGetChild(iqNode, "query"); if (queryNode != NULL) { - char *from=TlenXmlGetAttrValue(queryNode, "from"); - if (from != NULL ) { - TLEN_LIST_ITEM *item=TlenListGetItemPtr(proto, LIST_ROSTER, from); + char *from = TlenXmlGetAttrValue(queryNode, "from"); + if (from != NULL) { + TLEN_LIST_ITEM *item = TlenListGetItemPtr(proto, LIST_ROSTER, from); if (item != NULL) { XmlNode *version = TlenXmlGetChild(queryNode, "version"); if (version != NULL) { item->protocolVersion = TlenTextDecode(version->text); - MCONTACT hContact=TlenHContactFromJID(proto, item->jid); + MCONTACT hContact = TlenHContactFromJID(proto, item->jid); if (hContact != NULL) { if (item->software == NULL) { char str[128]; diff --git a/protocols/Tlen/src/tlen_picture.cpp b/protocols/Tlen/src/tlen_picture.cpp index 840bc0134c..7279e831d2 100644 --- a/protocols/Tlen/src/tlen_picture.cpp +++ b/protocols/Tlen/src/tlen_picture.cpp @@ -46,40 +46,32 @@ static void TlenPsPostThread(void *ptr) { BOOL bSent = FALSE; if (socket != NULL) { char header[512]; - DWORD ret; item->ft->s = socket; item->ft->hFileEvent = CreateEvent(NULL, FALSE, FALSE, NULL); - ret = mir_snprintf(header, "", proto->threadData->username, item->ft->jid, item->ft->fileTotalSize, item->jid); - TlenWsSend(proto, socket, header, (int)ret); + int ret = mir_snprintf(header, "", proto->threadData->username, item->ft->jid, item->ft->fileTotalSize, item->jid); + TlenWsSend(proto, socket, header, ret); ret = WaitForSingleObject(item->ft->hFileEvent, 1000 * 60 * 5); if (ret == WAIT_OBJECT_0) { FILE *fp = fopen( item->ft->files[0], "rb" ); if (fp) { - int i; - char header[512]; char fileBuffer[2048]; - i = mir_snprintf(header, "", item->ft->iqId, item->jid); - TlenWsSend(proto, socket, header, i); + ret = mir_snprintf(header, "", item->ft->iqId, item->jid); + TlenWsSend(proto, socket, header, ret); proto->debugLogA("Sending picture data..."); - for (i = item->ft->filesSize[0]; i > 0; ) { + for (int i = item->ft->filesSize[0]; i > 0; ) { int toread = min(2048, i); int readcount = (int)fread(fileBuffer, (size_t)1, (size_t)toread, fp); i -= readcount; - if (readcount > 0) { + if (readcount > 0) TlenWsSend(proto, socket, fileBuffer, readcount); - } - if (toread != readcount) { + + if (toread != readcount) break; - } } fclose(fp); SleepEx(3000, TRUE); bSent = TRUE; - } else { - /* picture not found */ } - } else { - /* 5 minutes passed */ } Netlib_CloseHandle(socket); if (bSent) { @@ -88,9 +80,8 @@ static void TlenPsPostThread(void *ptr) { } TlenP2PFreeFileTransfer(item->ft); TlenListRemove(proto, LIST_PICTURE, item->jid); - } else { - /* cannot connect to ps server */ } + mir_free(data); } diff --git a/protocols/Tlen/src/tlen_svc.cpp b/protocols/Tlen/src/tlen_svc.cpp index c8aaed11fe..4e4f992347 100644 --- a/protocols/Tlen/src/tlen_svc.cpp +++ b/protocols/Tlen/src/tlen_svc.cpp @@ -35,17 +35,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. DWORD_PTR TlenProtocol::GetCaps(int type, MCONTACT) { - switch(type) { + switch (type) { case PFLAGNUM_1: - return PF1_IM|PF1_AUTHREQ|PF1_SERVERCLIST|PF1_MODEMSG|PF1_BASICSEARCH|PF1_SEARCHBYEMAIL|PF1_EXTSEARCH|PF1_EXTSEARCHUI|PF1_SEARCHBYNAME|PF1_FILE;//|PF1_VISLIST|PF1_INVISLIST; + return PF1_IM | PF1_AUTHREQ | PF1_SERVERCLIST | PF1_MODEMSG | PF1_BASICSEARCH | PF1_SEARCHBYEMAIL | PF1_EXTSEARCH | PF1_EXTSEARCHUI | PF1_SEARCHBYNAME | PF1_FILE;//|PF1_VISLIST|PF1_INVISLIST; case PFLAGNUM_2: - return PF2_ONLINE|PF2_INVISIBLE|PF2_SHORTAWAY|PF2_LONGAWAY|PF2_HEAVYDND|PF2_FREECHAT; + return PF2_ONLINE | PF2_INVISIBLE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_HEAVYDND | PF2_FREECHAT; case PFLAGNUM_3: - return PF2_ONLINE|PF2_INVISIBLE|PF2_SHORTAWAY|PF2_LONGAWAY|PF2_HEAVYDND|PF2_FREECHAT; + return PF2_ONLINE | PF2_INVISIBLE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_HEAVYDND | PF2_FREECHAT; case PFLAGNUM_4: - return PF4_FORCEAUTH|PF4_NOCUSTOMAUTH|PF4_SUPPORTTYPING|PF4_AVATARS|PF4_IMSENDOFFLINE|PF4_OFFLINEFILES; + return PF4_FORCEAUTH | PF4_NOCUSTOMAUTH | PF4_SUPPORTTYPING | PF4_AVATARS | PF4_IMSENDOFFLINE | PF4_OFFLINEFILES; case PFLAG_UNIQUEIDTEXT: - return (INT_PTR) Translate("Tlen login"); + return (INT_PTR)Translate("Tlen login"); case PFLAG_UNIQUEIDSETTING: return (INT_PTR) "jid"; default: @@ -67,10 +67,11 @@ int TlenRunSearch(TlenProtocol *proto) { TlenIqAdd(proto, iqId, IQ_PROC_GETSEARCH, TlenIqResultSearch); if (proto->searchIndex == 0) { TlenSend(proto, "%s", iqId, proto->searchQuery); - } else { + } + else { TlenSend(proto, "%s%d", iqId, proto->searchQuery, proto->searchIndex * TLEN_MAX_SEARCH_RESULTS_PER_PAGE); } - proto->searchIndex ++; + proto->searchIndex++; } return iqId; } @@ -91,7 +92,7 @@ HANDLE TlenProtocol::SearchBasic(const TCHAR* id) if (!isOnline) return 0; if (id == NULL) return 0; char* id_A = mir_t2a(id); - char *jid=TlenTextEncode(id_A); + char *jid = TlenTextEncode(id_A); if (jid != NULL) { searchJID = mir_strdup(id_A); TlenResetSearchQuery(this); @@ -111,7 +112,7 @@ HANDLE TlenProtocol::SearchByEmail(const TCHAR* email) if (email == NULL) return 0; char* email_A = mir_t2a(email); - char *emailEnc=TlenTextEncode(email_A); + char *emailEnc = TlenTextEncode(email_A); if (emailEnc != NULL) { TlenResetSearchQuery(this); TlenStringAppend(&searchQuery, &searchQueryLen, "%s", emailEnc); @@ -136,19 +137,19 @@ HANDLE TlenProtocol::SearchByName(const TCHAR* nickT, const TCHAR* firstNameT, c TlenResetSearchQuery(this); if (nick != NULL && nick[0] != '\0') { - if ((p=TlenTextEncode(nick)) != NULL) { + if ((p = TlenTextEncode(nick)) != NULL) { TlenStringAppend(&searchQuery, &searchQueryLen, "%s", p); mir_free(p); } } if (firstName != NULL && firstName[0] != '\0') { - if ((p=TlenTextEncode(firstName)) != NULL) { + if ((p = TlenTextEncode(firstName)) != NULL) { TlenStringAppend(&searchQuery, &searchQueryLen, "%s", p); mir_free(p); } } if (lastName != NULL && lastName[0] != '\0') { - if ((p=TlenTextEncode(lastName)) != NULL) { + if ((p = TlenTextEncode(lastName)) != NULL) { TlenStringAppend(&searchQuery, &searchQueryLen, "%s", p); mir_free(p); } @@ -160,7 +161,7 @@ HANDLE TlenProtocol::SearchByName(const TCHAR* nickT, const TCHAR* firstNameT, c HWND TlenProtocol::CreateExtendedSearchUI(HWND owner) { - return (HWND) CreateDialog(hInst, MAKEINTRESOURCE(IDD_ADVSEARCH), owner, TlenAdvSearchDlgProc); + return (HWND)CreateDialog(hInst, MAKEINTRESOURCE(IDD_ADVSEARCH), owner, TlenAdvSearchDlgProc); } HWND TlenProtocol::SearchAdvanced(HWND owner) @@ -182,10 +183,10 @@ static MCONTACT AddToListByJID(TlenProtocol *proto, const char *newJid, DWORD fl if (hContact == NULL) { // not already there: add char *jid = mir_strdup(newJid); _strlwr(jid); - hContact = (MCONTACT) CallService(MS_DB_CONTACT_ADD, 0, 0); + hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0); Proto_AddToContact(hContact, proto->m_szModuleName); db_set_s(hContact, proto->m_szModuleName, "jid", jid); - char *nick=TlenNickFromJID(newJid); + char *nick = TlenNickFromJID(newJid); if (nick == NULL) nick = mir_strdup(newJid); db_set_s(hContact, "CList", "MyHandle", nick); @@ -227,7 +228,7 @@ MCONTACT TlenProtocol::AddToListByEvent(int flags, int, MEVENT hDbEvent) DBEVENTINFO dbei = { sizeof(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)) == NULL) return NULL; if (db_event_get(hDbEvent, &dbei)) { mir_free(dbei.pBlob); @@ -238,24 +239,24 @@ MCONTACT TlenProtocol::AddToListByEvent(int flags, int, MEVENT hDbEvent) return NULL; } -/* - // EVENTTYPE_CONTACTS is when adding from when we receive contact list (not used in Tlen) - // EVENTTYPE_ADDED is when adding from when we receive "You are added" (also not used in Tlen) - // Tlen will only handle the case of EVENTTYPE_AUTHREQUEST - // EVENTTYPE_AUTHREQUEST is when adding from the authorization request dialog -*/ + /* + // EVENTTYPE_CONTACTS is when adding from when we receive contact list (not used in Tlen) + // EVENTTYPE_ADDED is when adding from when we receive "You are added" (also not used in Tlen) + // Tlen will only handle the case of EVENTTYPE_AUTHREQUEST + // EVENTTYPE_AUTHREQUEST is when adding from the authorization request dialog + */ if (dbei.eventType != EVENTTYPE_AUTHREQUEST) { mir_free(dbei.pBlob); return NULL; } - char *nick = (char *)dbei.pBlob + sizeof(DWORD)*2; + char *nick = (char *)dbei.pBlob + sizeof(DWORD) * 2; char *firstName = nick + mir_strlen(nick) + 1; char *lastName = firstName + mir_strlen(firstName) + 1; char *jid = lastName + mir_strlen(lastName) + 1; - MCONTACT hContact = (MCONTACT) AddToListByJID(this, jid, flags); + MCONTACT hContact = (MCONTACT)AddToListByJID(this, jid, flags); mir_free(dbei.pBlob); return hContact; } @@ -268,9 +269,9 @@ int TlenProtocol::Authorize(MEVENT hDbEvent) DBEVENTINFO dbei = { sizeof(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)) == NULL) return 1; - if (db_event_get(hDbEvent, &dbei)){ + if (db_event_get(hDbEvent, &dbei)) { mir_free(dbei.pBlob); return 1; } @@ -283,7 +284,7 @@ int TlenProtocol::Authorize(MEVENT hDbEvent) return 1; } - char *nick = (char *)dbei.pBlob + sizeof(DWORD)*2; + char *nick = (char *)dbei.pBlob + sizeof(DWORD) * 2; char *firstName = nick + mir_strlen(nick) + 1; char *lastName = firstName + mir_strlen(firstName) + 1; char *jid = lastName + mir_strlen(lastName) + 1; @@ -297,7 +298,7 @@ int TlenProtocol::Authorize(MEVENT hDbEvent) if (item == NULL || (item->subscription != SUB_BOTH && item->subscription != SUB_TO)) { debugLogA("Try adding contact automatically jid=%s", jid); - if ((hContact=AddToListByJID(this, jid, 0)) != NULL) { + if ((hContact = AddToListByJID(this, jid, 0)) != NULL) { // Trigger actual add by removing the "NotOnList" added by AddToListByJID() // See AddToListByJID() and TlenDbSettingChanged(). db_unset(hContact, "CList", "NotOnList"); @@ -317,7 +318,7 @@ int TlenProtocol::AuthDeny(MEVENT hDbEvent, const TCHAR*) DBEVENTINFO dbei = { sizeof(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)) == NULL) return 1; if (db_event_get(hDbEvent, &dbei)) { mir_free(dbei.pBlob); @@ -332,7 +333,7 @@ int TlenProtocol::AuthDeny(MEVENT hDbEvent, const TCHAR*) return 1; } - char *nick = (char *)dbei.pBlob + sizeof(DWORD)*2; + char *nick = (char *)dbei.pBlob + sizeof(DWORD) * 2; char *firstName = nick + mir_strlen(nick) + 1; char *lastName = firstName + mir_strlen(firstName) + 1; char *jid = lastName + mir_strlen(lastName) + 1; @@ -346,15 +347,15 @@ int TlenProtocol::AuthDeny(MEVENT hDbEvent, const TCHAR*) static void TlenConnect(TlenProtocol *proto, int initialStatus) { if (!proto->isConnected) { - ThreadData *thread = (ThreadData *) mir_alloc(sizeof(ThreadData)); + ThreadData *thread = (ThreadData *)mir_alloc(sizeof(ThreadData)); memset(thread, 0, sizeof(ThreadData)); thread->proto = proto; proto->m_iDesiredStatus = initialStatus; int oldStatus = proto->m_iStatus; proto->m_iStatus = ID_STATUS_CONNECTING; - ProtoBroadcastAck(proto->m_szModuleName, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE) oldStatus, proto->m_iStatus); - thread->hThread = (HANDLE) forkthread((void (__cdecl *)(void*))TlenServerThread, 0, thread); + ProtoBroadcastAck(proto->m_szModuleName, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, proto->m_iStatus); + thread->hThread = (HANDLE)forkthread((void(__cdecl *)(void*))TlenServerThread, 0, thread); } } @@ -377,8 +378,8 @@ int TlenProtocol::SetStatus(int iNewStatus) threadData = NULL; if (isConnected) { Sleep(200); -// TlenSend(s, ""); - // Force closing connection + // TlenSend(s, ""); + // Force closing connection isConnected = FALSE; isOnline = FALSE; Netlib_CloseHandle(s); @@ -393,9 +394,10 @@ int TlenProtocol::SetStatus(int iNewStatus) } } else if (iNewStatus != m_iStatus) { - if (!isConnected){ + if (!isConnected) { TlenConnect(this, iNewStatus); - } else { + } + else { // change status oldStatus = m_iStatus; // send presence update @@ -477,10 +479,11 @@ int TlenProtocol::GetInfo(MCONTACT hContact, int) iqId = TlenSerialNext(this); TlenIqAdd(this, iqId, IQ_PROC_NONE, TlenIqResultVcard); TlenSend(this, "", iqId); - } else { + } + 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)) != NULL) { + if ((pNick = TlenTextEncode(nick)) != NULL) { iqId = TlenSerialNext(this); TlenIqAdd(this, iqId, IQ_PROC_NONE, TlenIqResultVcard); TlenSend(this, "%s", iqId, pNick); @@ -503,8 +506,8 @@ int TlenProtocol::SetApparentMode(MCONTACT hContact, int mode) if (!db_get_b(NULL, m_szModuleName, "VisibilitySupport", FALSE)) return 0; if (mode != 0 && mode != ID_STATUS_ONLINE && mode != ID_STATUS_OFFLINE) return 1; oldMode = db_get_w(hContact, m_szModuleName, "ApparentMode", 0); - if ((int) mode == oldMode) return 1; - db_set_w(hContact, m_szModuleName, "ApparentMode", (WORD) mode); + if ((int)mode == oldMode) return 1; + db_set_w(hContact, m_szModuleName, "ApparentMode", (WORD)mode); if (!db_get(hContact, m_szModuleName, "jid", &dbv)) { jid = dbv.pszVal; switch (mode) { @@ -532,9 +535,9 @@ int TlenProtocol::SetApparentMode(MCONTACT hContact, int mode) struct SENDACKTHREADDATA { - __inline SENDACKTHREADDATA(TlenProtocol *_ppro, MCONTACT _hContact, int _msgid=0) : + __inline SENDACKTHREADDATA(TlenProtocol *_ppro, MCONTACT _hContact, int _msgid = 0) : proto(_ppro), hContact(_hContact), msgid(_msgid) - {} + {} TlenProtocol *proto; MCONTACT hContact; @@ -565,25 +568,28 @@ static void __cdecl TlenGetAwayMsgThread(void *ptr) Sleep(50); if (!db_get(data->hContact, data->proto->m_szModuleName, "jid", &dbv)) { - TLEN_LIST_ITEM *item=TlenListGetItemPtr(data->proto, LIST_ROSTER, dbv.pszVal); + TLEN_LIST_ITEM *item = TlenListGetItemPtr(data->proto, LIST_ROSTER, dbv.pszVal); if (item != NULL) { db_free(&dbv); ProtoBroadcastAck(data->proto->m_szModuleName, data->hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, item->statusMessage == NULL ? NULL : _A2T(item->statusMessage)); - } else { + } + else { ptrA ownJid(db_get_sa(NULL, data->proto->m_szModuleName, "jid")); - if (!mir_strcmp(ownJid, dbv.pszVal)){ + if (!mir_strcmp(ownJid, dbv.pszVal)) { DBVARIANT dbv2; - if (!db_get_s(data->hContact, "CList", "StatusMsg", &dbv2, DBVT_TCHAR)){ + if (!db_get_s(data->hContact, "CList", "StatusMsg", &dbv2, DBVT_TCHAR)) { data->proto->ProtoBroadcastAck(data->hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)dbv2.ptszVal); db_free(&dbv2); - } else { + } + else { data->proto->ProtoBroadcastAck(data->hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, NULL); } } db_free(&dbv); } - } else { + } + else { data->proto->ProtoBroadcastAck(data->hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, NULL); } @@ -644,7 +650,7 @@ int TlenProtocol::SendMsg(MCONTACT hContact, int, const char* msgRAW) forkthread(TlenSendMessageAckThread, 0, new SENDACKTHREADDATA(this, hContact, id)); } else { - if ((item=TlenListGetItemPtr(this, LIST_ROSTER, dbv.pszVal)) != NULL) + if ((item = TlenListGetItemPtr(this, LIST_ROSTER, dbv.pszVal)) != NULL) item->idMsgAckPending = id; TlenSend(this, "%s", dbv.pszVal, msgType, id, msgEnc); } @@ -686,13 +692,13 @@ INT_PTR TlenProtocol::GetAvatarInfo(WPARAM wParam, LPARAM lParam) return GAIR_NOAVATAR; if (avatarHash != NULL && !downloadingAvatar) { - TlenGetAvatarFileName(this, item, pai->filename, _countof(pai->filename)-1); - pai->format = ( pai->hContact == NULL ) ? threadData->avatarFormat : item->avatarFormat; + TlenGetAvatarFileName(this, item, pai->filename, _countof(pai->filename) - 1); + pai->format = (pai->hContact == NULL) ? threadData->avatarFormat : item->avatarFormat; return GAIR_SUCCESS; } /* get avatar */ - if (( wParam & GAIF_FORCE ) != 0 && pai->hContact != NULL && isOnline) + if ((wParam & GAIF_FORCE) != 0 && pai->hContact != NULL && isOnline) return GAIR_WAITFOR; return GAIR_NOAVATAR; @@ -701,7 +707,7 @@ INT_PTR TlenProtocol::GetAvatarInfo(WPARAM wParam, LPARAM lParam) HANDLE TlenProtocol::GetAwayMsg(MCONTACT hContact) { SENDACKTHREADDATA *tdata = new SENDACKTHREADDATA(this, hContact, 0); - forkthread((void (__cdecl *)(void*))TlenGetAwayMsgThread, 0, (void*)tdata); + forkthread((void(__cdecl *)(void*))TlenGetAwayMsgThread, 0, (void*)tdata); return (HANDLE)1; } @@ -714,7 +720,7 @@ HANDLE TlenProtocol::FileAllow(MCONTACT, HANDLE hTransfer, const TCHAR* szPath) { if (!isOnline) return 0; - TLEN_FILE_TRANSFER *ft = (TLEN_FILE_TRANSFER *) hTransfer; + TLEN_FILE_TRANSFER *ft = (TLEN_FILE_TRANSFER *)hTransfer; ft->szSavePath = mir_strdup(mir_t2a(szPath)); //TODO convert to TCHAR* TLEN_LIST_ITEM *item = TlenListAdd(this, LIST_FILE, ft->iqId); if (item != NULL) { @@ -723,7 +729,8 @@ HANDLE TlenProtocol::FileAllow(MCONTACT, HANDLE hTransfer, const TCHAR* szPath) char *nick = TlenNickFromJID(ft->jid); if (ft->newP2P) { TlenSend(this, "", ft->jid, ft->jid, ft->iqId); - } else { + } + else { TlenSend(this, "", nick, ft->iqId); } mir_free(nick); @@ -734,12 +741,13 @@ int TlenProtocol::FileDeny(MCONTACT, HANDLE hTransfer, const TCHAR*) { if (!isOnline) return 1; - TLEN_FILE_TRANSFER *ft = (TLEN_FILE_TRANSFER *) hTransfer; + TLEN_FILE_TRANSFER *ft = (TLEN_FILE_TRANSFER *)hTransfer; char *nick = TlenNickFromJID(ft->jid); if (ft->newP2P) { - TlenSend(this, "", ft->iqId, nick);\ - } else { - TlenSend(this, "", ft->iqId, nick);\ + TlenSend(this, "", ft->iqId, nick); \ + } + else { + TlenSend(this, "", ft->iqId, nick); \ } mir_free(nick); TlenP2PFreeFileTransfer(ft); @@ -753,7 +761,7 @@ int TlenProtocol::FileResume(HANDLE, int*, const TCHAR**) int TlenProtocol::FileCancel(MCONTACT, HANDLE hTransfer) { - TLEN_FILE_TRANSFER *ft = (TLEN_FILE_TRANSFER *) hTransfer; + TLEN_FILE_TRANSFER *ft = (TLEN_FILE_TRANSFER *)hTransfer; debugLogA("Invoking FileCancel()"); if (ft->s != NULL) { ft->state = FT_ERROR; @@ -764,7 +772,8 @@ int TlenProtocol::FileCancel(MCONTACT, HANDLE hTransfer) ft->hFileEvent = NULL; SetEvent(hEvent); } - } else { + } + else { TlenP2PFreeFileTransfer(ft); } return 0; @@ -778,14 +787,14 @@ HANDLE TlenProtocol::SendFile(MCONTACT hContact, const TCHAR* szDescription, TCH char *nick, *p, idStr[10]; if (!isOnline) return 0; -// if (db_get_w(ccs->hContact, m_szModuleName, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE) return 0; + // 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; 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); - ft->filesSize = (long *) mir_alloc(sizeof(long) * ft->fileCount); + for (ft->fileCount = 0; ppszFiles[ft->fileCount]; ft->fileCount++); + ft->files = (char **)mir_alloc(sizeof(char *) * ft->fileCount); + ft->filesSize = (long *)mir_alloc(sizeof(long) * ft->fileCount); ft->allFileTotalSize = 0; - for (i=j=0; ifileCount; i++) { + for (i = j = 0; i < ft->fileCount; i++) { char* ppszFiles_i_A = mir_t2a(ppszFiles[i]); if (_stat(ppszFiles_i_A, &statbuf)) debugLogA("'%s' is an invalid filename", ppszFiles[i]); @@ -814,43 +823,46 @@ HANDLE TlenProtocol::SendFile(MCONTACT hContact, const TCHAR* szDescription, TCH ft->jid, ft->jid, idStr, ft->fileCount, ft->allFileTotalSize, ft->fileCount); ft->newP2P = TRUE; - } else { + } + else { if (ft->fileCount == 1) { char* ppszFiles_0_A = mir_t2a(ppszFiles[0]); - if ((p=strrchr(ppszFiles_0_A, '\\')) != NULL) { + if ((p = strrchr(ppszFiles_0_A, '\\')) != NULL) { p++; - } else { + } + else { p = ppszFiles_0_A; } p = TlenTextEncode(p); TlenSend(this, "", nick, p, idStr, ft->allFileTotalSize); mir_free(ppszFiles[0]); mir_free(p); - } else { + } + else { TlenSend(this, "", nick, idStr, ft->fileCount, ft->allFileTotalSize); } } mir_free(nick); } - return (HANDLE) ft; + return (HANDLE)ft; } -static char* settingToChar( DBCONTACTWRITESETTING* cws ) +static char* settingToChar(DBCONTACTWRITESETTING* cws) { - switch( cws->value.type ) { + switch (cws->value.type) { case DBVT_ASCIIZ: - return mir_strdup( cws->value.pszVal ); + 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), NULL); } return NULL; } int TlenProtocol::TlenDbSettingChanged(WPARAM wParam, LPARAM lParam) { - MCONTACT hContact = (MCONTACT) wParam; - DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *) lParam; + MCONTACT hContact = (MCONTACT)wParam; + DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *)lParam; // no action for hContact == NULL or when offline if (hContact == NULL) return 0; if (!isConnected) return 0; @@ -865,7 +877,7 @@ int TlenProtocol::TlenDbSettingChanged(WPARAM wParam, LPARAM lParam) // A contact's group is changed if (!mir_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)) != NULL) { db_free(&dbv); if (!db_get(hContact, "CList", "MyHandle", &dbv)) { nick = TlenTextEncode(dbv.pszVal); @@ -887,7 +899,7 @@ int TlenProtocol::TlenDbSettingChanged(WPARAM wParam, LPARAM lParam) char *newGroup = settingToChar(cws); if (item->group == NULL || mir_strcmp(newGroup, item->group)) { debugLogA("Group set to %s", newGroup); - if ((group=TlenGroupEncode(newGroup)) != NULL) { + if ((group = TlenGroupEncode(newGroup)) != NULL) { TlenSend(this, "%s", nick, item->jid, group); mir_free(group); } @@ -906,28 +918,31 @@ int TlenProtocol::TlenDbSettingChanged(WPARAM wParam, LPARAM lParam) else if (!mir_strcmp(cws->szSetting, "MyHandle")) { char *newNick; -// hContact = (MCONTACT) wParam; -// szProto = GetContactProto(hContact); -// if (szProto == NULL || mir_strcmp(szProto, proto->m_szModuleName)) return 0; + // hContact = (MCONTACT) wParam; + // szProto = GetContactProto(hContact); + // if (szProto == NULL || mir_strcmp(szProto, proto->m_szModuleName)) return 0; 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)) != NULL) { if (cws->value.type == DBVT_DELETED) { - newNick = mir_strdup((char *) pcli->pfnGetContactDisplayName(hContact, GCDNF_NOMYHANDLE)); - } else if (cws->value.pszVal != NULL) { + newNick = mir_strdup((char *)pcli->pfnGetContactDisplayName(hContact, GCDNF_NOMYHANDLE)); + } + else if (cws->value.pszVal != NULL) { newNick = settingToChar(cws); - } else { + } + else { newNick = NULL; } // Note: we need to compare with item->nick to prevent infinite loop if (newNick != NULL && (item->nick == NULL || (item->nick != NULL && mir_strcmp(item->nick, newNick)))) { - if ((nick=TlenTextEncode(newNick)) != NULL) { + if ((nick = TlenTextEncode(newNick)) != NULL) { debugLogA("Nick set to %s", newNick); - if (item->group != NULL && (group=TlenGroupEncode(item->group)) != NULL) { + if (item->group != NULL && (group = TlenGroupEncode(item->group)) != NULL) { TlenSend(this, "%s", nick, jid, group); mir_free(group); - } else { + } + else { TlenSend(this, "", nick, jid); } mir_free(nick); @@ -940,38 +955,34 @@ int TlenProtocol::TlenDbSettingChanged(WPARAM wParam, LPARAM lParam) } // A temporary contact has been added permanently else if (!mir_strcmp(cws->szSetting, "NotOnList")) { - char *jid, *nick, *pGroup; - - if (cws->value.type==DBVT_DELETED || (cws->value.type==DBVT_BYTE && cws->value.bVal==0)) { - if (!db_get(hContact, m_szModuleName, "jid", &dbv)) { - jid = mir_strdup(dbv.pszVal); - db_free(&dbv); - debugLogA("Add %s permanently to list", jid); + if (cws->value.type == DBVT_DELETED || (cws->value.type == DBVT_BYTE && cws->value.bVal == 0)) { + ptrA szJid(db_get_sa(hContact, m_szModuleName, "jid")); + if (szJid != NULL) { + char *szNick, *pGroup; + debugLogA("Add %s permanently to list", szJid); if (!db_get(hContact, "CList", "MyHandle", &dbv)) { - nick = TlenTextEncode(dbv.pszVal); //Utf8Encode + szNick = TlenTextEncode(dbv.pszVal); //Utf8Encode db_free(&dbv); } - else { - nick = TlenNickFromJID(jid); - } - if (nick != NULL) { - debugLogA("jid=%s nick=%s", jid, nick); + else szNick = TlenNickFromJID(szJid); + + if (szNick != NULL) { + debugLogA("jid=%s szNick=%s", szJid, szNick); if (!db_get(hContact, "CList", "Group", &dbv)) { - if ((pGroup=TlenGroupEncode(dbv.pszVal)) != NULL) { - TlenSend(this, "%s", nick, jid, pGroup); - TlenSend(this, "", jid); + if ((pGroup = TlenGroupEncode(dbv.pszVal)) != NULL) { + TlenSend(this, "%s", szNick, szJid, pGroup); + TlenSend(this, "", szJid); mir_free(pGroup); } db_free(&dbv); } else { - TlenSend(this, "", nick, jid); - TlenSend(this, "", jid); + TlenSend(this, "", szNick, szJid); + TlenSend(this, "", szJid); } - mir_free(nick); + mir_free(szNick); db_unset(hContact, "CList", "Hidden"); } - mir_free(jid); } } } @@ -994,8 +1005,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, '@')) != NULL) { + if ((q = strchr(p, '/')) != NULL) *q = '\0'; } @@ -1033,8 +1044,8 @@ int TlenProtocol::UserIsTyping(MCONTACT hContact, int type) INT_PTR TlenProtocol::GetMyAvatar(WPARAM wParam, LPARAM lParam) { TCHAR* buf = (TCHAR*)wParam; - int size = ( int )lParam; - if ( buf == NULL || size <= 0 ) + int size = (int)lParam; + if (buf == NULL || size <= 0) return -1; TlenGetAvatarFileName(this, NULL, buf, size); @@ -1056,14 +1067,14 @@ static INT_PTR CALLBACK TlenChangeAvatarDlgProc(HWND hwndDlg, UINT msg, WPARAM w case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: - { - int result = LOWORD(wParam); - if (IsDlgButtonChecked(hwndDlg, IDC_PUBLICAVATAR)) { - result |= 0x10000; - } - EndDialog(hwndDlg, result); + { + int result = LOWORD(wParam); + if (IsDlgButtonChecked(hwndDlg, IDC_PUBLICAVATAR)) { + result |= 0x10000; } - return TRUE; + EndDialog(hwndDlg, result); + } + return TRUE; } break; } @@ -1109,12 +1120,12 @@ INT_PTR TlenProtocol::GetAvatarCaps(WPARAM wParam, LPARAM lParam) { switch (wParam) { case AF_MAXSIZE: - { - POINT* size = (POINT*)lParam; - if (size) - size->x = size->y = 64; - } - return 0; + { + POINT* size = (POINT*)lParam; + if (size) + size->x = size->y = 64; + } + return 0; case AF_PROPORTION: return PIP_SQUARE; case AF_FORMATSUPPORTED: @@ -1166,7 +1177,7 @@ void TlenInitServicesVTbl(TlenProtocol *proto) } TlenProtocol::TlenProtocol(const char *aProtoName, const TCHAR *aUserName) : -PROTO(aProtoName, aUserName) + PROTO(aProtoName, aUserName) { TlenInitServicesVTbl(this); diff --git a/protocols/Tlen/src/tlen_util.cpp b/protocols/Tlen/src/tlen_util.cpp index a3314e5a20..0bc0bc5ef8 100644 --- a/protocols/Tlen/src/tlen_util.cpp +++ b/protocols/Tlen/src/tlen_util.cpp @@ -52,12 +52,12 @@ int TlenSend(TlenProtocol *proto, const char *fmt, ...) mir_cslock lck(proto->csSend); - va_start(vararg,fmt); + va_start(vararg, fmt); size = 512; - str = (char *) mir_alloc(size); + str = (char *)mir_alloc(size); while (mir_vsnprintf(str, size, fmt, vararg) == -1) { size += 512; - str = (char *) mir_realloc(str, size); + str = (char *)mir_realloc(str, size); } va_end(vararg); @@ -66,7 +66,8 @@ int TlenSend(TlenProtocol *proto, const char *fmt, ...) if (proto->threadData != NULL) { if (proto->threadData->useAES) { result = TlenWsSendAES(proto, str, size, &proto->threadData->aes_out_context, proto->threadData->aes_out_iv); - } else { + } + else { result = TlenWsSend(proto, proto->threadData->s, str, size); } } @@ -81,12 +82,12 @@ char *TlenResourceFromJID(const char *jid2) char *nick; char* jid = mir_strdup(jid2); - p=strchr(jid, '/'); + p = strchr(jid, '/'); if (p != NULL && p[1] != '\0') { p++; - if ((nick=(char *) mir_alloc(1+mir_strlen(jid)-(p-jid))) != NULL) { - strncpy(nick, p, mir_strlen(jid)-(p-jid)); - nick[mir_strlen(jid)-(p-jid)] = '\0'; + if ((nick = (char *)mir_alloc(1 + mir_strlen(jid) - (p - jid))) != NULL) { + strncpy(nick, p, mir_strlen(jid) - (p - jid)); + nick[mir_strlen(jid) - (p - jid)] = '\0'; } } else { @@ -103,12 +104,12 @@ char *TlenNickFromJID(const char *jid2) char *nick; char* jid = mir_strdup(jid2); - if ((p=strchr(jid, '@')) == NULL) + if ((p = strchr(jid, '@')) == NULL) p = strchr(jid, '/'); if (p != NULL) { - if ((nick=(char *) mir_alloc((p-jid)+1)) != NULL) { - strncpy(nick, jid, p-jid); - nick[p-jid] = '\0'; + if ((nick = (char *)mir_alloc((p - jid) + 1)) != NULL) { + strncpy(nick, jid, p - jid); + nick[p - jid] = '\0'; } } else { @@ -127,9 +128,9 @@ char *TlenLoginFromJID(const char *jid2) p = strchr(jid, '/'); if (p != NULL) { - if ((nick=(char *) mir_alloc((p-jid)+1)) != NULL) { - strncpy(nick, jid, p-jid); - nick[p-jid] = '\0'; + if ((nick = (char *)mir_alloc((p - jid) + 1)) != NULL) { + strncpy(nick, jid, p - jid); + nick[p - jid] = '\0'; } } else { @@ -157,13 +158,13 @@ char *TlenSha1(char *str) DWORD digest[5]; char* result; - if ( str == NULL ) + if (str == NULL) return NULL; - 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) + 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; 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; @@ -176,16 +177,16 @@ char *TlenSha1(char *str, int len) char* result; int i; - if ( str == NULL ) + if (str == NULL) return NULL; - mir_sha1_init( &sha ); - mir_sha1_append( &sha, (BYTE* )str, len); - mir_sha1_finish( &sha, digest ); - if (( result=( char* )mir_alloc( 20 )) == NULL ) + 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; - for (i=0; i<20; i++) - result[i]=digest[4*(i>>2)+(3-(i&0x3))]; + for (i = 0; i < 20; i++) + result[i] = digest[4 * (i >> 2) + (3 - (i & 0x3))]; return result; } @@ -195,16 +196,16 @@ char *TlenPasswordHash(const char *str) char *p, *res; if (str == NULL) return NULL; - for (p=(char *)str; *p != '\0'; p++) { + for (p = (char *)str; *p != '\0'; p++) { if (*p != ' ' && *p != '\t') { - magic1 ^= (((magic1 & 0x3f) + sum) * ((char) *p)) + (magic1 << 8); + magic1 ^= (((magic1 & 0x3f) + sum) * ((char)*p)) + (magic1 << 8); magic2 += (magic2 << 8) ^ magic1; - sum += ((char) *p); + sum += ((char)*p); } } magic1 &= 0x7fffffff; magic2 &= 0x7fffffff; - res = (char *) mir_alloc(17); + res = (char *)mir_alloc(17); sprintf(res, "%08x%08x", magic1, magic2); //!!!!!!!!!!! return res; } @@ -215,21 +216,21 @@ char *TlenUrlEncode(const char *str) unsigned char c; if (str == NULL) return NULL; - res = (char *) mir_alloc(3*mir_strlen(str) + 1); - for (p=(char *)str,q=res; *p != '\0'; p++,q++) { + 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) { // Convert first from CP1252 to ISO8859-2 - switch ((unsigned char) *p) { - case 0xa5: c = (unsigned char) 0xa1; break; - case 0x8c: c = (unsigned char) 0xa6; break; - case 0x8f: c = (unsigned char) 0xac; break; - case 0xb9: c = (unsigned char) 0xb1; break; - case 0x9c: c = (unsigned char) 0xb6; break; - case 0x9f: c = (unsigned char) 0xbc; break; - default: c = (unsigned char) *p; break; + switch ((unsigned char)*p) { + case 0xa5: c = (unsigned char)0xa1; break; + case 0x8c: c = (unsigned char)0xa6; break; + case 0x8f: c = (unsigned char)0xac; break; + case 0xb9: c = (unsigned char)0xb1; break; + case 0x9c: c = (unsigned char)0xb6; break; + case 0x9f: c = (unsigned char)0xbc; break; + default: c = (unsigned char)*p; break; } sprintf(q, "%%%02X", c); //!!!!!!!!!!! q += 2; @@ -248,21 +249,21 @@ void TlenUrlDecode(char *str) unsigned int code; if (str == NULL) return; - for (p=q=str; *p != '\0'; p++,q++) { + for (p = q = str; *p != '\0'; p++, q++) { if (*p == '+') { *q = ' '; } - else if (*p == '%' && *(p+1) != '\0' && isxdigit(*(p+1)) && *(p+2) != '\0' && isxdigit(*(p+2))) { - sscanf(p+1, "%2x", &code); - *q = (char) code; + else if (*p == '%' && *(p + 1) != '\0' && isxdigit(*(p + 1)) && *(p + 2) != '\0' && isxdigit(*(p + 2))) { + sscanf(p + 1, "%2x", &code); + *q = (char)code; // Convert from ISO8859-2 to CP1252 - switch ((unsigned char) *q) { - case 0xa1: *q = (char) 0xa5; break; - case 0xa6: *q = (char) 0x8c; break; - case 0xac: *q = (char) 0x8f; break; - case 0xb1: *q = (char) 0xb9; break; - case 0xb6: *q = (char) 0x9c; break; - case 0xbc: *q = (char) 0x9f; break; + switch ((unsigned char)*q) { + case 0xa1: *q = (char)0xa5; break; + case 0xa6: *q = (char)0x8c; break; + case 0xac: *q = (char)0x8f; break; + case 0xb1: *q = (char)0xb9; break; + case 0xb6: *q = (char)0x9c; break; + case 0xbc: *q = (char)0x9f; break; } p += 2; } @@ -306,7 +307,7 @@ char *TlenTextEncode(const char *str) char *s1; if (str == NULL) return NULL; - if ((s1=TlenUrlEncode(str)) == NULL) + if ((s1 = TlenUrlEncode(str)) == NULL) return NULL; return s1; } @@ -328,11 +329,12 @@ char *TlenTextDecode(const char *str) time_t TlenTimeToUTC(time_t time) { struct tm *timestamp; timestamp = gmtime(&time); - if ( (timestamp->tm_mon > 2 && timestamp->tm_mon < 9) || - (timestamp->tm_mon == 2 && timestamp->tm_mday - timestamp->tm_wday >= 25) || - (timestamp->tm_mon == 9 && timestamp->tm_mday - timestamp->tm_wday < 25)) { + if ((timestamp->tm_mon > 2 && timestamp->tm_mon < 9) || + (timestamp->tm_mon == 2 && timestamp->tm_mday - timestamp->tm_wday >= 25) || + (timestamp->tm_mon == 9 && timestamp->tm_mday - timestamp->tm_wday < 25)) { //time -= 3600; - } else { + } + else { //time += 3600; } return time; @@ -346,39 +348,39 @@ time_t TlenIsoToUnixTime(char *stamp) int i, y; time_t t; - if (stamp == NULL) return (time_t) 0; + if (stamp == NULL) return (time_t)0; p = stamp; // Get the date part - for (i=0; *p != '\0' && i<8 && isdigit(*p); p++,i++) + for (i = 0; *p != '\0' && i < 8 && isdigit(*p); p++, i++) date[i] = *p; // Parse year if (i == 6) { // 2-digit year (1970-2069) - y = (date[0]-'0')*10 + (date[1]-'0'); + y = (date[0] - '0') * 10 + (date[1] - '0'); if (y < 70) y += 100; } else if (i == 8) { // 4-digit year - y = (date[0]-'0')*1000 + (date[1]-'0')*100 + (date[2]-'0')*10 + date[3]-'0'; + y = (date[0] - '0') * 1000 + (date[1] - '0') * 100 + (date[2] - '0') * 10 + date[3] - '0'; y -= 1900; } else - return (time_t) 0; + return (time_t)0; timestamp.tm_year = y; // Parse month - timestamp.tm_mon = (date[i-4]-'0')*10 + date[i-3]-'0' - 1; + timestamp.tm_mon = (date[i - 4] - '0') * 10 + date[i - 3] - '0' - 1; // Parse date - timestamp.tm_mday = (date[i-2]-'0')*10 + date[i-1]-'0'; + timestamp.tm_mday = (date[i - 2] - '0') * 10 + date[i - 1] - '0'; // Skip any date/time delimiter for (; *p != '\0' && !isdigit(*p); p++); // Parse time if (sscanf(p, "%d:%d:%d", &(timestamp.tm_hour), &(timestamp.tm_min), &(timestamp.tm_sec)) != 3) - return (time_t) 0; + return (time_t)0; timestamp.tm_isdst = 0; // DST is already present in _timezone below _tzset(); @@ -389,7 +391,7 @@ time_t TlenIsoToUnixTime(char *stamp) if (t >= 0) return t; else - return (time_t) 0; + return (time_t)0; } void TlenStringAppend(char **str, int *sizeAlloced, const char *fmt, ...) @@ -402,7 +404,7 @@ void TlenStringAppend(char **str, int *sizeAlloced, const char *fmt, ...) if (*str == NULL || *sizeAlloced <= 0) { *sizeAlloced = size = 2048; - *str = (char *) mir_alloc(size); + *str = (char *)mir_alloc(size); len = 0; } else { @@ -415,7 +417,7 @@ void TlenStringAppend(char **str, int *sizeAlloced, const char *fmt, ...) while (mir_vsnprintf(p, size, fmt, vararg) == -1) { size += 2048; (*sizeAlloced) += 2048; - *str = (char *) mir_realloc(*str, *sizeAlloced); + *str = (char *)mir_realloc(*str, *sizeAlloced); p = *str + len; } va_end(vararg); -- cgit v1.2.3