diff options
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/IcqOscarJ/src/icq_clients.cpp | 8 | ||||
-rw-r--r-- | protocols/IcqOscarJ/src/icq_uploadui.cpp | 526 | ||||
-rw-r--r-- | protocols/IcqOscarJ/src/oscar_filetransfer.cpp | 10 | ||||
-rw-r--r-- | protocols/IcqOscarJ/src/tlv.cpp | 94 | ||||
-rw-r--r-- | protocols/Tlen/src/tlen_iqid.cpp | 201 | ||||
-rw-r--r-- | protocols/Tlen/src/tlen_picture.cpp | 27 | ||||
-rw-r--r-- | protocols/Tlen/src/tlen_svc.cpp | 271 | ||||
-rw-r--r-- | protocols/Tlen/src/tlen_util.cpp | 138 | ||||
-rw-r--r-- | protocols/Xfire/xfire.vcxproj | 1 | ||||
-rw-r--r-- | protocols/Yahoo/src/libyahoo2/yahoo_util.cpp | 6 |
10 files changed, 630 insertions, 652 deletions
diff --git a/protocols/IcqOscarJ/src/icq_clients.cpp b/protocols/IcqOscarJ/src/icq_clients.cpp index 1eaa7898ae..add5fa3ad4 100644 --- a/protocols/IcqOscarJ/src/icq_clients.cpp +++ b/protocols/IcqOscarJ/src/icq_clients.cpp @@ -296,8 +296,8 @@ const char* CIcqProto::detectUserClient( szClient = "Virus";
// capabilities based detection
- capstr* capId;
- char ver[10];
+ capstr *capId;
+ char ver[16];
if (nIsICQ && caps) {
// check capabilities for client identification
@@ -526,8 +526,6 @@ const char* CIcqProto::detectUserClient( else if (capId = MatchCapability(caps, wLen, &capCorePager, 0xA)) {
mir_strcpy(szClientBuf, "CORE Pager");
if (dwFT2 == 0x0FFFF0011 && dwFT3 == 0x1100FFFF && (dwFT1 >> 0x18)) {
- char ver[16];
-
mir_snprintf(ver, " %d.%d", dwFT1 >> 0x18, (dwFT1 >> 0x10) & 0xFF);
if ((dwFT1 & 0xFF) == 0x0B)
mir_strcat(ver, " Beta");
@@ -940,7 +938,7 @@ const char* CIcqProto::detectUserClient( // custom miranda packs
if (caps && bMirandaIM) {
- capstr *capId = MatchCapability(caps, wLen, &capMimPack, 4);
+ capId = MatchCapability(caps, wLen, &capMimPack, 4);
if (capId) {
char szPack[16];
mir_snprintf(szPack, " [%.12s]", (*capId) + 4);
diff --git a/protocols/IcqOscarJ/src/icq_uploadui.cpp b/protocols/IcqOscarJ/src/icq_uploadui.cpp index a39ec5864f..1dba00dda6 100644 --- a/protocols/IcqOscarJ/src/icq_uploadui.cpp +++ b/protocols/IcqOscarJ/src/icq_uploadui.cpp @@ -33,18 +33,18 @@ static int bListInit = 0; static HANDLE hItemAll;
static int dwUploadDelay = 1000; // initial setting, it is too low for icq server but good for short updates
-static HWND hwndUploadContacts=NULL;
-static const UINT settingsControls[]={IDOK};
+static HWND hwndUploadContacts = NULL;
+static const UINT settingsControls[] = { IDOK };
-static WORD* pwGroupIds = NULL;
+static WORD *pwGroupIds = NULL;
static int cbGroupIds = 0;
// Init default clist options
static void ResetCListOptions(HWND hwndList)
{
- SetWindowLongPtr(hwndList, GWL_STYLE, GetWindowLongPtr(hwndList, GWL_STYLE)|CLS_SHOWHIDDEN);
+ SetWindowLongPtr(hwndList, GWL_STYLE, GetWindowLongPtr(hwndList, GWL_STYLE) | CLS_SHOWHIDDEN);
if (CallService(MS_CLUI_GETCAPS, 0, 0) & CLUIF_HIDEEMPTYGROUPS) // hide empty groups
- SendMessage(hwndList, CLM_SETHIDEEMPTYGROUPS, (WPARAM) TRUE, 0);
+ SendMessage(hwndList, CLM_SETHIDEEMPTYGROUPS, (WPARAM)TRUE, 0);
}
// Selects the "All contacts" checkbox if all other list entries
@@ -54,13 +54,10 @@ static void UpdateAllContactsCheckmark(HWND hwndList, CIcqProto* ppro, HANDLE ph int check = 1;
MCONTACT hContact = db_find_first(ppro->m_szModuleName);
- while (hContact)
- {
+ while (hContact) {
HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, hContact, 0);
- if (hItem)
- {
- if (!SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)hItem, 0))
- { // if any of our contacts is unchecked, uncheck all contacts as well
+ if (hItem) {
+ if (!SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)hItem, 0)) { // if any of our contacts is unchecked, uncheck all contacts as well
check = 0;
break;
}
@@ -79,11 +76,9 @@ static int UpdateCheckmarks(HWND hwndList, CIcqProto* ppro, HANDLE phItemAll) bListInit = 1; // lock CLC events
MCONTACT hContact = db_find_first(ppro->m_szModuleName);
- while (hContact)
- {
+ while (hContact) {
HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, hContact, 0);
- if (hItem)
- {
+ if (hItem) {
if (ppro->getWord(hContact, DBSETTING_SERVLIST_ID, 0))
SendMessage(hwndList, CLM_SETCHECKMARK, (WPARAM)hItem, 1);
else
@@ -127,25 +122,25 @@ static void AppendToUploadLog(HWND hwndDlg, const char *fmt, ...) static void DeleteLastUploadLogLine(HWND hwndDlg)
{
- SendDlgItemMessage(hwndDlg, IDC_LOG, LB_DELETESTRING, SendDlgItemMessage(hwndDlg, IDC_LOG, LB_GETCOUNT, 0, 0)-1, 0);
+ SendDlgItemMessage(hwndDlg, IDC_LOG, LB_DELETESTRING, SendDlgItemMessage(hwndDlg, IDC_LOG, LB_GETCOUNT, 0, 0) - 1, 0);
}
static void GetLastUploadLogLine(HWND hwndDlg, char *szBuf, size_t cbBuf)
{
WCHAR str[MAX_PATH];
- SendDlgItemMessageW(hwndDlg, IDC_LOG, LB_GETTEXT, SendDlgItemMessage(hwndDlg, IDC_LOG, LB_GETCOUNT, 0, 0)-1, (LPARAM)str);
+ SendDlgItemMessageW(hwndDlg, IDC_LOG, LB_GETTEXT, SendDlgItemMessage(hwndDlg, IDC_LOG, LB_GETCOUNT, 0, 0) - 1, (LPARAM)str);
make_utf8_string_static(str, szBuf, cbBuf);
}
-static int GroupEnumIdsEnumProc(const char *szSetting,LPARAM lParam)
-{
+static int GroupEnumIdsEnumProc(const char *szSetting, LPARAM lParam)
+{
// it is probably server group
if (szSetting && mir_strlen(szSetting) < 5) {
- char val[MAX_PATH+2]; // dummy
+ char val[MAX_PATH + 2]; // dummy
if (db_get_static(NULL, (char*)lParam, szSetting, val, MAX_PATH))
return 0; // this converts all string types to DBVT_ASCIIZ
- pwGroupIds = (WORD*)SAFE_REALLOC(pwGroupIds, (cbGroupIds+1)*sizeof(WORD));
+ pwGroupIds = (WORD*)SAFE_REALLOC(pwGroupIds, (cbGroupIds + 1)*sizeof(WORD));
pwGroupIds[cbGroupIds] = (WORD)strtoul(szSetting, NULL, 0x10);
cbGroupIds++;
}
@@ -154,7 +149,7 @@ static int GroupEnumIdsEnumProc(const char *szSetting,LPARAM lParam) static void enumServerGroups(CIcqProto* ppro)
{
- char szModule[MAX_PATH+9];
+ char szModule[MAX_PATH + 9];
mir_snprintf(szModule, "%s%s", ppro->m_szModuleName, "SrvGroups");
DBCONTACTENUMSETTINGS dbces = { 0 };
@@ -169,8 +164,7 @@ static DWORD sendUploadGroup(CIcqProto* ppro, WORD wAction, WORD wGroupId, char* DWORD dwCookie;
cookie_servlist_action* ack;
- if (ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action)))
- { // we have cookie good, go on
+ if (ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action))) { // we have cookie good, go on
ack->wGroupId = wGroupId;
ack->dwAction = SSA_SERVLIST_ACK;
dwCookie = ppro->AllocateCookie(CKT_SERVERLIST, wAction, 0, ack);
@@ -184,38 +178,35 @@ static DWORD sendUploadGroup(CIcqProto* ppro, WORD wAction, WORD wGroupId, char* static DWORD sendUploadBuddy(CIcqProto* ppro, MCONTACT hContact, WORD wAction, DWORD dwUin, char *szUID, WORD wContactId, WORD wGroupId, WORD wItemType)
{
- DWORD dwCookie;
- cookie_servlist_action* ack;
-
- if (ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action)))
- { // we have cookie good, go on
- ack->hContact = hContact;
- ack->wContactId = wContactId;
- ack->wGroupId = wGroupId;
- ack->dwAction = SSA_SERVLIST_ACK;
- dwCookie = ppro->AllocateCookie(CKT_SERVERLIST, wAction, hContact, ack);
- ack->lParam = dwCookie;
-
- if (wItemType == SSI_ITEM_BUDDY)
- ppro->icq_sendServerContact(hContact, dwCookie, wAction, ack->wGroupId, ack->wContactId, SSOP_ITEM_ACTION | SSOF_CONTACT, 500, NULL);
- else
- ppro->icq_sendSimpleItem(dwCookie, wAction, dwUin, szUID, ack->wGroupId, ack->wContactId, wItemType, SSOP_ITEM_ACTION, 500);
-
- return dwCookie;
- }
- return 0;
+ cookie_servlist_action *ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action));
+ if (ack == NULL)
+ return 0;
+
+ // we have cookie good, go on
+ ack->hContact = hContact;
+ ack->wContactId = wContactId;
+ ack->wGroupId = wGroupId;
+ ack->dwAction = SSA_SERVLIST_ACK;
+ DWORD dwCookie = ppro->AllocateCookie(CKT_SERVERLIST, wAction, hContact, ack);
+ ack->lParam = dwCookie;
+
+ if (wItemType == SSI_ITEM_BUDDY)
+ ppro->icq_sendServerContact(hContact, dwCookie, wAction, ack->wGroupId, ack->wContactId, SSOP_ITEM_ACTION | SSOF_CONTACT, 500, NULL);
+ else
+ ppro->icq_sendSimpleItem(dwCookie, wAction, dwUin, szUID, ack->wGroupId, ack->wContactId, wItemType, SSOP_ITEM_ACTION, 500);
+
+ return dwCookie;
}
static char* getServerResultDesc(int wCode)
{
- switch (wCode)
- {
- case 0: return LPGEN("OK");
- case 2: return LPGEN("NOT FOUND");
- case 3: return LPGEN("ALREADY EXISTS");
- case 0xA: return LPGEN("INVALID DATA");
- case 0xC: return LPGEN("LIST FULL");
- default: return LPGEN("FAILED");
+ switch (wCode) {
+ case 0: return LPGEN("OK");
+ case 2: return LPGEN("NOT FOUND");
+ case 3: return LPGEN("ALREADY EXISTS");
+ case 0xA: return LPGEN("INVALID DATA");
+ case 0xC: return LPGEN("LIST FULL");
+ default: return LPGEN("FAILED");
}
}
@@ -245,6 +236,7 @@ static char* getServerResultDesc(int wCode) static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
CIcqProto* ppro = (CIcqProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ MCONTACT hContact;
static int working;
static HANDLE hProtoAckHook;
@@ -280,195 +272,184 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa // The M_PROTOACK message is received when the
// server has responded to our last update packet
case M_PROTOACK:
- {
- int bMulti = 0;
- ACKDATA *ack = (ACKDATA*)lParam;
- char szLastLogLine[MAX_PATH];
- char str[MAX_PATH];
-
- // Is this an ack we are waiting for?
- if (mir_strcmp(ack->szModule, ppro->m_szModuleName))
- break;
-
- if (ack->type == ICQACKTYPE_RATEWARNING) { // we are sending tooo fast, slow down the process
- if (ack->hProcess != (HANDLE)1) break; // check class
- if (ack->lParam == 2 || ack->lParam == 3) // check status
- {
- GetLastUploadLogLine(hwndDlg, szLastLogLine, MAX_PATH);
- DeleteLastUploadLogLine(hwndDlg);
- AppendToUploadLog(hwndDlg, ICQTranslateUtfStatic(LPGEN("Server rate warning -> slowing down the process."), str, MAX_PATH));
- AppendToUploadLog(hwndDlg, szLastLogLine);
-
- dwUploadDelay *= 2;
+ {
+ int bMulti = 0;
+ ACKDATA *ack = (ACKDATA*)lParam;
+ char szLastLogLine[MAX_PATH];
+ char str[MAX_PATH];
+ // Is this an ack we are waiting for?
+ if (mir_strcmp(ack->szModule, ppro->m_szModuleName))
break;
- }
- if (ack->lParam == 4) dwUploadDelay /= 2; // the rate is ok, turn up
- }
- if (ack->type != ICQACKTYPE_SERVERCLIST)
- break;
+ if (ack->type == ICQACKTYPE_RATEWARNING) { // we are sending tooo fast, slow down the process
+ if (ack->hProcess != (HANDLE)1) break; // check class
+ if (ack->lParam == 2 || ack->lParam == 3) { // check status
+ GetLastUploadLogLine(hwndDlg, szLastLogLine, MAX_PATH);
+ DeleteLastUploadLogLine(hwndDlg);
+ AppendToUploadLog(hwndDlg, ICQTranslateUtfStatic(LPGEN("Server rate warning -> slowing down the process."), str, MAX_PATH));
+ AppendToUploadLog(hwndDlg, szLastLogLine);
- if ((INT_PTR)ack->hProcess != currentSequence)
- break;
+ dwUploadDelay *= 2;
- lastAckResult = ack->result == ACKRESULT_SUCCESS ? 0 : 1;
+ break;
+ }
+ if (ack->lParam == 4) dwUploadDelay /= 2; // the rate is ok, turn up
+ }
- switch (currentAction) {
- case ACTION_ADDBUDDY:
- if (ack->result == ACKRESULT_SUCCESS) {
- ppro->setByte(hCurrentContact, "Auth", 0);
- ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_ID, wNewContactId);
- ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_GROUP, wNewGroupId);
+ if (ack->type != ICQACKTYPE_SERVERCLIST)
break;
- }
- else { // If the server refused to add the contact without authorization,
- // we try again _with_ authorization TLV
- ppro->setByte(hCurrentContact, "Auth", 1);
-
- DWORD dwUIN;
- uid_str szUID;
- if (!ppro->getContactUid(hCurrentContact, &dwUIN, &szUID)) {
- currentAction = ACTION_ADDBUDDYAUTH;
- currentSequence = sendUploadBuddy(ppro, hCurrentContact, ICQ_LISTS_ADDTOLIST, dwUIN, szUID, wNewContactId, wNewGroupId, SSI_ITEM_BUDDY);
- }
- return FALSE;
- }
+ if ((INT_PTR)ack->hProcess != currentSequence)
+ break;
- case ACTION_ADDBUDDYAUTH:
- if (ack->result == ACKRESULT_SUCCESS) {
- ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_ID, wNewContactId);
- ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_GROUP, wNewGroupId);
- }
- else {
- db_unset(hCurrentContact, ppro->m_szModuleName, "Auth");
- ppro->FreeServerID(wNewContactId, SSIT_ITEM);
- }
+ lastAckResult = ack->result == ACKRESULT_SUCCESS ? 0 : 1;
- break;
+ switch (currentAction) {
+ case ACTION_ADDBUDDY:
+ if (ack->result == ACKRESULT_SUCCESS) {
+ ppro->setByte(hCurrentContact, "Auth", 0);
+ ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_ID, wNewContactId);
+ ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_GROUP, wNewGroupId);
+ break;
+ }
+ else { // If the server refused to add the contact without authorization,
+ // we try again _with_ authorization TLV
+ ppro->setByte(hCurrentContact, "Auth", 1);
+
+ DWORD dwUIN;
+ uid_str szUID;
+ if (!ppro->getContactUid(hCurrentContact, &dwUIN, &szUID)) {
+ currentAction = ACTION_ADDBUDDYAUTH;
+ currentSequence = sendUploadBuddy(ppro, hCurrentContact, ICQ_LISTS_ADDTOLIST, dwUIN, szUID, wNewContactId, wNewGroupId, SSI_ITEM_BUDDY);
+ }
- case ACTION_REMOVEBUDDY:
- if (ack->result == ACKRESULT_SUCCESS) { // clear obsolete settings
- ppro->FreeServerID(wNewContactId, SSIT_ITEM);
- db_unset(hCurrentContact, ppro->m_szModuleName, DBSETTING_SERVLIST_ID);
- db_unset(hCurrentContact, ppro->m_szModuleName, DBSETTING_SERVLIST_GROUP);
- db_unset(hCurrentContact, ppro->m_szModuleName, "Auth");
- }
- break;
+ return FALSE;
+ }
- case ACTION_ADDGROUP:
- if (ack->result == ACKRESULT_SUCCESS) {
- void* groupData;
- int groupSize;
- cookie_servlist_action* ack;
+ case ACTION_ADDBUDDYAUTH:
+ if (ack->result == ACKRESULT_SUCCESS) {
+ ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_ID, wNewContactId);
+ ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_GROUP, wNewGroupId);
+ }
+ else {
+ db_unset(hCurrentContact, ppro->m_szModuleName, "Auth");
+ ppro->FreeServerID(wNewContactId, SSIT_ITEM);
+ }
+ break;
- ppro->setServListGroupName(wNewGroupId, szNewGroupName); // add group to list
- ppro->setServListGroupLinkID(szNewGroupName, wNewGroupId); // grouppath is known
+ case ACTION_REMOVEBUDDY:
+ if (ack->result == ACKRESULT_SUCCESS) { // clear obsolete settings
+ ppro->FreeServerID(wNewContactId, SSIT_ITEM);
+ db_unset(hCurrentContact, ppro->m_szModuleName, DBSETTING_SERVLIST_ID);
+ db_unset(hCurrentContact, ppro->m_szModuleName, DBSETTING_SERVLIST_GROUP);
+ db_unset(hCurrentContact, ppro->m_szModuleName, "Auth");
+ }
+ break;
- groupData = ppro->collectGroups(&groupSize);
- groupData = SAFE_REALLOC(groupData, groupSize + 2);
- *(((WORD*)groupData) + (groupSize >> 1)) = wNewGroupId; // add this new group id
- groupSize += 2;
+ case ACTION_ADDGROUP:
+ if (ack->result == ACKRESULT_SUCCESS) {
+ ppro->setServListGroupName(wNewGroupId, szNewGroupName); // add group to list
+ ppro->setServListGroupLinkID(szNewGroupName, wNewGroupId); // grouppath is known
- ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action));
- if (ack) {
- DWORD dwCookie; // we do not use this
+ int groupSize;
+ void *groupData = ppro->collectGroups(&groupSize);
+ groupData = SAFE_REALLOC(groupData, groupSize + 2);
+ *(((WORD*)groupData) + (groupSize >> 1)) = wNewGroupId; // add this new group id
+ groupSize += 2;
- ack->dwAction = SSA_SERVLIST_ACK;
- dwCookie = ppro->AllocateCookie(CKT_SERVERLIST, ICQ_LISTS_UPDATEGROUP, 0, ack);
+ cookie_servlist_action *action = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action));
+ if (action) {
+ DWORD dwCookie; // we do not use this
- ppro->icq_sendServerGroup(dwCookie, ICQ_LISTS_UPDATEGROUP, 0, ack->szGroupName, groupData, groupSize, 0);
- }
- SAFE_FREE((void**)&groupData);
- }
- else
- ppro->FreeServerID(wNewGroupId, SSIT_GROUP);
+ action->dwAction = SSA_SERVLIST_ACK;
+ dwCookie = ppro->AllocateCookie(CKT_SERVERLIST, ICQ_LISTS_UPDATEGROUP, 0, action);
- SAFE_FREE((void**)&szNewGroupName);
- break;
+ ppro->icq_sendServerGroup(dwCookie, ICQ_LISTS_UPDATEGROUP, 0, action->szGroupName, groupData, groupSize, 0);
+ }
+ SAFE_FREE((void**)&groupData);
+ }
+ else ppro->FreeServerID(wNewGroupId, SSIT_GROUP);
- case ACTION_REMOVEGROUP:
- if (ack->result == ACKRESULT_SUCCESS) {
- void* groupData;
- int groupSize;
- cookie_servlist_action* ack;
+ SAFE_FREE((void**)&szNewGroupName);
+ break;
- ppro->FreeServerID(wNewGroupId, SSIT_GROUP);
- ppro->setServListGroupName(wNewGroupId, NULL); // remove group from list
- ppro->removeGroupPathLinks(wNewGroupId); // grouppath is known
+ case ACTION_REMOVEGROUP:
+ if (ack->result == ACKRESULT_SUCCESS) {
+ ppro->FreeServerID(wNewGroupId, SSIT_GROUP);
+ ppro->setServListGroupName(wNewGroupId, NULL); // remove group from list
+ ppro->removeGroupPathLinks(wNewGroupId); // grouppath is known
- groupData = ppro->collectGroups(&groupSize);
+ int groupSize;
+ void *groupData = ppro->collectGroups(&groupSize);
- ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action));
- if (ack) {
- DWORD dwCookie; // we do not use this
+ cookie_servlist_action *action = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action));
+ if (action) {
+ DWORD dwCookie; // we do not use this
- ack->dwAction = SSA_SERVLIST_ACK;
- dwCookie = ppro->AllocateCookie(CKT_SERVERLIST, ICQ_LISTS_UPDATEGROUP, 0, ack);
+ action->dwAction = SSA_SERVLIST_ACK;
+ dwCookie = ppro->AllocateCookie(CKT_SERVERLIST, ICQ_LISTS_UPDATEGROUP, 0, action);
- ppro->icq_sendServerGroup(dwCookie, ICQ_LISTS_UPDATEGROUP, 0, ack->szGroupName, groupData, groupSize, 0);
+ ppro->icq_sendServerGroup(dwCookie, ICQ_LISTS_UPDATEGROUP, 0, action->szGroupName, groupData, groupSize, 0);
+ }
+ SAFE_FREE((void**)&groupData);
}
- SAFE_FREE((void**)&groupData);
- }
- break;
+ break;
- case ACTION_UPDATESTATE:
- // do nothing
- break;
+ case ACTION_UPDATESTATE:
+ // do nothing
+ break;
- case ACTION_MOVECONTACT:
- if (ack->result == ACKRESULT_SUCCESS) {
- ppro->FreeServerID(ppro->getWord(hCurrentContact, DBSETTING_SERVLIST_ID, 0), SSIT_ITEM);
- ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_ID, wNewContactId);
- ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_GROUP, wNewGroupId);
- dwUploadDelay *= 2; // we double the delay here (2 packets)
- }
- break;
+ case ACTION_MOVECONTACT:
+ if (ack->result == ACKRESULT_SUCCESS) {
+ ppro->FreeServerID(ppro->getWord(hCurrentContact, DBSETTING_SERVLIST_ID, 0), SSIT_ITEM);
+ ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_ID, wNewContactId);
+ ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_GROUP, wNewGroupId);
+ dwUploadDelay *= 2; // we double the delay here (2 packets)
+ }
+ break;
- case ACTION_ADDVISIBLE:
- if (ack->result == ACKRESULT_SUCCESS)
- ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_PERMIT, wNewContactId);
- else
- ppro->FreeServerID(wNewContactId, SSIT_ITEM);
- break;
+ case ACTION_ADDVISIBLE:
+ if (ack->result == ACKRESULT_SUCCESS)
+ ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_PERMIT, wNewContactId);
+ else
+ ppro->FreeServerID(wNewContactId, SSIT_ITEM);
+ break;
- case ACTION_ADDINVISIBLE:
- if (ack->result == ACKRESULT_SUCCESS)
- ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_DENY, wNewContactId);
- else
- ppro->FreeServerID(wNewContactId, SSIT_ITEM);
- break;
+ case ACTION_ADDINVISIBLE:
+ if (ack->result == ACKRESULT_SUCCESS)
+ ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_DENY, wNewContactId);
+ else
+ ppro->FreeServerID(wNewContactId, SSIT_ITEM);
+ break;
- case ACTION_REMOVEVISIBLE:
- if (ack->result == ACKRESULT_SUCCESS) {
- ppro->FreeServerID(wNewContactId, SSIT_ITEM);
- ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_PERMIT, 0);
- }
- break;
+ case ACTION_REMOVEVISIBLE:
+ if (ack->result == ACKRESULT_SUCCESS) {
+ ppro->FreeServerID(wNewContactId, SSIT_ITEM);
+ ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_PERMIT, 0);
+ }
+ break;
- case ACTION_REMOVEINVISIBLE:
- if (ack->result == ACKRESULT_SUCCESS) {
- ppro->FreeServerID(wNewContactId, SSIT_ITEM);
- ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_DENY, 0);
+ case ACTION_REMOVEINVISIBLE:
+ if (ack->result == ACKRESULT_SUCCESS) {
+ ppro->FreeServerID(wNewContactId, SSIT_ITEM);
+ ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_DENY, 0);
+ }
+ break;
}
- break;
- }
- // Update the log window
- GetLastUploadLogLine(hwndDlg, szLastLogLine, MAX_PATH);
- DeleteLastUploadLogLine(hwndDlg);
- AppendToUploadLog(hwndDlg, "%s%s", szLastLogLine,
- ICQTranslateUtfStatic(getServerResultDesc(ack->lParam), str, MAX_PATH));
+ // Update the log window
+ GetLastUploadLogLine(hwndDlg, szLastLogLine, MAX_PATH);
+ DeleteLastUploadLogLine(hwndDlg);
+ AppendToUploadLog(hwndDlg, "%s%s", szLastLogLine,
+ ICQTranslateUtfStatic(getServerResultDesc(ack->lParam), str, MAX_PATH));
- if (!bMulti) {
- SetTimer(hwndDlg, M_UPLOADMORE, dwUploadDelay, 0); // delay
+ if (!bMulti)
+ SetTimer(hwndDlg, M_UPLOADMORE, dwUploadDelay, 0); // delay
}
- }
break;
case WM_TIMER:
- {
switch (wParam) {
case M_UPLOADMORE:
KillTimer(hwndDlg, M_UPLOADMORE);
@@ -476,31 +457,19 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa dwUploadDelay /= 2; // turn it back
PostMessage(hwndDlg, M_UPLOADMORE, 0, 0);
-
return 0;
}
- }
// The M_UPLOADMORE window message is received when the user presses 'Update'
// and every time an ack from the server has been taken care of.
case M_UPLOADMORE:
{
- MCONTACT hContact;
- HANDLE hItem;
- char *pszNick;
- char *pszGroup;
- int isChecked;
- int isOnServer;
- BOOL bUidOk;
char str[MAX_PATH];
- HWND hwndList = GetDlgItem(hwndDlg, IDC_CLIST);
switch (currentState) {
case STATE_REGROUP:
-
// TODO: iterate over all checked groups and create if needed
// if creation requires reallocation of groups do it here
-
currentState = STATE_ITEMS;
hCurrentContact = NULL;
PostMessage(hwndDlg, M_UPLOADMORE, 0, 0);
@@ -520,22 +489,23 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa while (hContact) {
hCurrentContact = hContact;
- hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, hContact, 0);
+ HWND hwndList = GetDlgItem(hwndDlg, IDC_CLIST);
+ HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, hContact, 0);
if (hItem) {
- isChecked = SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)hItem, 0) != 0;
- isOnServer = ppro->getWord(hContact, DBSETTING_SERVLIST_ID, 0) != 0;
+ int isChecked = SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)hItem, 0) != 0;
+ int isOnServer = ppro->getWord(hContact, DBSETTING_SERVLIST_ID, 0) != 0;
DWORD dwUin;
uid_str szUid;
- bUidOk = !ppro->getContactUid(hContact, &dwUin, &szUid);
+ BOOL bUidOk = !ppro->getContactUid(hContact, &dwUin, &szUid);
// Is this one out of sync?
if (bUidOk && (isChecked != isOnServer)) {
// Only upload custom nicks
- pszNick = ppro->getSettingStringUtf(hContact, "CList", "MyHandle", NULL);
+ char *pszNick = ppro->getSettingStringUtf(hContact, "CList", "MyHandle", NULL);
if (isChecked) { // Queue for uploading
- pszGroup = ppro->getContactCListGroup(hContact);
+ char *pszGroup = ppro->getContactCListGroup(hContact);
if (!mir_strlen(pszGroup))
pszGroup = null_strdup(DEFAULT_SS_GROUP);
@@ -566,11 +536,11 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa wNewContactId = ppro->GenerateServerID(SSIT_ITEM, 0);
currentSequence = sendUploadBuddy(ppro, hCurrentContact, ICQ_LISTS_ADDTOLIST, dwUin, szUid,
- wNewContactId, wNewGroupId, SSI_ITEM_BUDDY);
+ wNewContactId, wNewGroupId, SSI_ITEM_BUDDY);
SAFE_FREE(&pszNick);
return FALSE;
}
-
+
char szLastLogLine[MAX_PATH];
// Update the log window with the failure and continue with next contact
GetLastUploadLogLine(hwndDlg, szLastLogLine, MAX_PATH);
@@ -590,7 +560,7 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa wNewContactId = ppro->getWord(hContact, DBSETTING_SERVLIST_ID, 0);
currentAction = ACTION_REMOVEBUDDY;
currentSequence = sendUploadBuddy(ppro, hContact, ICQ_LISTS_REMOVEFROMLIST, dwUin, szUid,
- wNewContactId, wNewGroupId, SSI_ITEM_BUDDY);
+ wNewContactId, wNewGroupId, SSI_ITEM_BUDDY);
}
SAFE_FREE((void**)&pszNick);
break;
@@ -600,9 +570,10 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa if (bUidOk && isChecked) {
WORD wCurrentGroupId = ppro->getWord(hContact, DBSETTING_SERVLIST_GROUP, 0);
- pszGroup = ppro->getContactCListGroup(hContact);
+ char *pszGroup = ppro->getContactCListGroup(hContact);
if (!mir_strlen(pszGroup))
pszGroup = null_strdup(DEFAULT_SS_GROUP);
+
wNewGroupId = ppro->getServListGroupLinkID(pszGroup);
if (!wNewGroupId && strstrnull(pszGroup, "\\") != NULL) { // if it is sub-group, take master parent
strstrnull(pszGroup, "\\")[0] = '\0';
@@ -624,7 +595,7 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa if (wNewGroupId && (wNewGroupId != wCurrentGroupId)) {
WORD wCurrentContactId = ppro->getWord(hContact, DBSETTING_SERVLIST_ID, 0);
- pszNick = ppro->getSettingStringUtf(hContact, "CList", "MyHandle", NULL);
+ char *pszNick = ppro->getSettingStringUtf(hContact, "CList", "MyHandle", NULL);
if (pszNick)
AppendToUploadLog(hwndDlg, ICQTranslateUtfStatic(LPGEN("Moving %s to group \"%s\"..."), str, MAX_PATH), pszNick, pszGroup);
else
@@ -733,7 +704,7 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa wNewGroupId = pwGroupIds[cbGroupIds];
if (groupData = ppro->collectBuddyGroup(wNewGroupId, &groupSize)) { // the group is still not empty, just update it
- char* pszGroup = ppro->getServListGroupName(wNewGroupId);
+ char *pszGroup = ppro->getServListGroupName(wNewGroupId);
cookie_servlist_action* ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action));
ack->dwAction = SSA_SERVLIST_ACK;
@@ -789,7 +760,7 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa // end server modifications here
ppro->servlistPostPacket(NULL, 0, SSO_END_OPERATION, 100);
working = 0;
- UpdateCheckmarks(hwndList, ppro, hItemAll);
+ UpdateCheckmarks(GetDlgItem(hwndDlg, IDC_CLIST), ppro, hItemAll);
if (hProtoAckHook)
UnhookEvent(hProtoAckHook);
}
@@ -810,10 +781,9 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa currentState = STATE_REGROUP;
currentAction = ACTION_NONE;
icq_ShowMultipleControls(hwndDlg, settingsControls, _countof(settingsControls), SW_HIDE);
- // SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETGREYOUTFLAGS, 0xFFFFFFFF, 0);
- // InvalidateRect(GetDlgItem(hwndDlg, IDC_CLIST), NULL, FALSE);
EnableDlgItem(hwndDlg, IDC_CLIST, FALSE);
hProtoAckHook = HookEventMessage(ME_PROTO_ACK, hwndDlg, M_PROTOACK);
+
// start server modifications here
ppro->servlistPostPacket(NULL, 0, SSO_BEGIN_OPERATION | SSOF_IMPORT_OPERATION, 100);
PostMessage(hwndDlg, M_UPLOADMORE, 0, 0);
@@ -826,67 +796,63 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa break;
case WM_NOTIFY:
- switch (((NMHDR*)lParam)->idFrom) {
- case IDC_CLIST:
- {
- HWND hClist = GetDlgItem(hwndDlg, IDC_CLIST);
-
- switch (((NMHDR*)lParam)->code) {
- case CLN_OPTIONSCHANGED:
- ResetCListOptions(hClist);
- break;
+ if (((NMHDR*)lParam)->idFrom == IDC_CLIST) {
+ HWND hClist = GetDlgItem(hwndDlg, IDC_CLIST);
- case CLN_NEWCONTACT:
- case CLN_CONTACTMOVED:
- // Delete non-icq contacts
- DeleteOtherContactsFromControl(hClist, ppro);
- if (hItemAll)
- UpdateAllContactsCheckmark(hClist, ppro, hItemAll);
- break;
+ switch (((NMHDR*)lParam)->code) {
+ case CLN_OPTIONSCHANGED:
+ ResetCListOptions(hClist);
+ break;
- case CLN_LISTREBUILT:
- {
- int bCheck = false;
+ case CLN_NEWCONTACT:
+ case CLN_CONTACTMOVED:
+ // Delete non-icq contacts
+ DeleteOtherContactsFromControl(hClist, ppro);
+ if (hItemAll)
+ UpdateAllContactsCheckmark(hClist, ppro, hItemAll);
+ break;
- // Delete non-icq contacts
- if (ppro) {
- DeleteOtherContactsFromControl(hClist, ppro);
- if (!bListInit) // do not enter twice
- bCheck = UpdateCheckmarks(hClist, ppro, NULL);
- }
+ case CLN_LISTREBUILT:
+ {
+ int bCheck = false;
- if (!hItemAll) { // Add the "All contacts" item
- CLCINFOITEM cii = { 0 };
- cii.cbSize = sizeof(cii);
- cii.flags = CLCIIF_GROUPFONT | CLCIIF_CHECKBOX;
- cii.pszText = TranslateT(LPGEN("** All contacts **"));
- hItemAll = (HANDLE)SendMessage(hClist, CLM_ADDINFOITEM, 0, (LPARAM)&cii);
- }
+ // Delete non-icq contacts
+ if (ppro) {
+ DeleteOtherContactsFromControl(hClist, ppro);
+ if (!bListInit) // do not enter twice
+ bCheck = UpdateCheckmarks(hClist, ppro, NULL);
+ }
- SendMessage(hClist, CLM_SETCHECKMARK, (WPARAM)hItemAll, bCheck);
+ if (!hItemAll) { // Add the "All contacts" item
+ CLCINFOITEM cii = { 0 };
+ cii.cbSize = sizeof(cii);
+ cii.flags = CLCIIF_GROUPFONT | CLCIIF_CHECKBOX;
+ cii.pszText = TranslateT(LPGEN("** All contacts **"));
+ hItemAll = (HANDLE)SendMessage(hClist, CLM_ADDINFOITEM, 0, (LPARAM)&cii);
}
- break;
- case CLN_CHECKCHANGED:
- if (!bListInit) {
- NMCLISTCONTROL *nm = (NMCLISTCONTROL*)lParam;
- if (nm->flags&CLNF_ISINFO) {
- int check = SendMessage(hClist, CLM_GETCHECKMARK, (WPARAM)hItemAll, 0);
-
- MCONTACT hContact = db_find_first(ppro->m_szModuleName);
- while (hContact) {
- HANDLE hItem = (HANDLE)SendMessage(hClist, CLM_FINDCONTACT, hContact, 0);
- if (hItem)
- SendMessage(hClist, CLM_SETCHECKMARK, (WPARAM)hItem, check);
- hContact = db_find_next(hContact, ppro->m_szModuleName);
- }
+ SendMessage(hClist, CLM_SETCHECKMARK, (WPARAM)hItemAll, bCheck);
+ }
+ break;
+
+ case CLN_CHECKCHANGED:
+ if (!bListInit) {
+ NMCLISTCONTROL *nm = (NMCLISTCONTROL*)lParam;
+ if (nm->flags&CLNF_ISINFO) {
+ int check = SendMessage(hClist, CLM_GETCHECKMARK, (WPARAM)hItemAll, 0);
+
+ hContact = db_find_first(ppro->m_szModuleName);
+ while (hContact) {
+ HANDLE hItem = (HANDLE)SendMessage(hClist, CLM_FINDCONTACT, hContact, 0);
+ if (hItem)
+ SendMessage(hClist, CLM_SETCHECKMARK, (WPARAM)hItem, check);
+ hContact = db_find_next(hContact, ppro->m_szModuleName);
}
- else UpdateAllContactsCheckmark(hClist, ppro, hItemAll);
}
- break;
+ else UpdateAllContactsCheckmark(hClist, ppro, hItemAll);
}
+ break;
}
- break;
}
break;
diff --git a/protocols/IcqOscarJ/src/oscar_filetransfer.cpp b/protocols/IcqOscarJ/src/oscar_filetransfer.cpp index 4367dadc88..6305536dcb 100644 --- a/protocols/IcqOscarJ/src/oscar_filetransfer.cpp +++ b/protocols/IcqOscarJ/src/oscar_filetransfer.cpp @@ -432,9 +432,9 @@ void CIcqProto::handleRecvServMsgOFT(BYTE *buf, size_t wLen, DWORD dwUin, char * return;
}
- BYTE* tBuf = tlv->pData;
+ BYTE *tBuf = tlv->pData;
size_t tLen = tlv->wLen;
- WORD wFlag;
+ WORD wFlag;
unpackWord(&tBuf, &wFlag); // FT flag
unpackWord(&tBuf, &ft->wFilesCount);
@@ -488,9 +488,7 @@ void CIcqProto::handleRecvServMsgOFT(BYTE *buf, size_t wLen, DWORD dwUin, char * }
}
int bAdded;
- MCONTACT hContact = HContactFromUID(dwUin, szUID, &bAdded);
-
- ft->hContact = hContact;
+ ft->hContact = HContactFromUID(dwUin, szUID, &bAdded);
ft->fileId = -1;
// Send chain event
@@ -508,7 +506,7 @@ void CIcqProto::handleRecvServMsgOFT(BYTE *buf, size_t wLen, DWORD dwUin, char * pre.descr.t = mir_utf8decodeT(pszDescription);
pre.files.t = &ptszFileName;
pre.lParam = (LPARAM)ft;
- ProtoChainRecvFile(hContact, &pre);
+ ProtoChainRecvFile(ft->hContact, &pre);
mir_free(pre.descr.t);
mir_free(ptszFileName);
diff --git a/protocols/IcqOscarJ/src/tlv.cpp b/protocols/IcqOscarJ/src/tlv.cpp index 81488e8c78..30625b6708 100644 --- a/protocols/IcqOscarJ/src/tlv.cpp +++ b/protocols/IcqOscarJ/src/tlv.cpp @@ -115,10 +115,10 @@ WORD oscar_tlv_chain::getChainLength() oscar_tlv* oscar_tlv_chain::putTLV(WORD wType, size_t wLen, BYTE *pData, BOOL bReplace)
{
- oscar_tlv *tlv = getTLV(wType, 1);
+ oscar_tlv *pTLV = getTLV(wType, 1);
- if (tlv && bReplace)
- SAFE_FREE((void**)&tlv->pData);
+ if (pTLV && bReplace)
+ SAFE_FREE((void**)&pTLV->pData);
else {
oscar_tlv_chain *last = this;
@@ -127,26 +127,26 @@ oscar_tlv* oscar_tlv_chain::putTLV(WORD wType, size_t wLen, BYTE *pData, BOOL bR if (last) {
last->next = (oscar_tlv_chain*)SAFE_MALLOC(sizeof(oscar_tlv_chain));
- tlv = &last->next->tlv;
- tlv->wType = wType;
+ pTLV = &last->next->tlv;
+ pTLV->wType = wType;
}
}
- if (tlv) {
- tlv->wLen = WORD(wLen);
- tlv->pData = (PBYTE)SAFE_MALLOC(wLen);
- memcpy(tlv->pData, pData, wLen);
+ if (pTLV) {
+ pTLV->wLen = WORD(wLen);
+ pTLV->pData = (PBYTE)SAFE_MALLOC(wLen);
+ memcpy(pTLV->pData, pData, wLen);
}
- return tlv;
+ return pTLV;
}
-oscar_tlv_chain* oscar_tlv_chain::removeTLV(oscar_tlv *tlv)
+oscar_tlv_chain* oscar_tlv_chain::removeTLV(oscar_tlv *pTLV)
{
oscar_tlv_chain *list = this, *prev = NULL, *chain = this;
while (list) {
- if (&list->tlv == tlv) {
+ if (&list->tlv == pTLV) {
if (prev) // relink
prev->next = list->next;
- else if (list->next) { // move second item's tlv to the first item
+ else if (list->next) { // move second item's pTLV to the first item
list->tlv = list->next->tlv;
list = list->next;
}
@@ -165,9 +165,9 @@ oscar_tlv_chain* oscar_tlv_chain::removeTLV(oscar_tlv *tlv) WORD oscar_tlv_chain::getLength(WORD wType, WORD wIndex)
{
- oscar_tlv *tlv = getTLV(wType, wIndex);
- if (tlv)
- return tlv->wLen;
+ oscar_tlv *pTLV = getTLV(wType, wIndex);
+ if (pTLV)
+ return pTLV->wLen;
return 0;
}
@@ -180,12 +180,12 @@ DWORD oscar_tlv_chain::getDWord(WORD wType, WORD wIndex) {
DWORD dw = 0;
- oscar_tlv *tlv = getTLV(wType, wIndex);
- if (tlv && tlv->wLen >= 4) {
- dw |= (*((tlv->pData) + 0) << 24);
- dw |= (*((tlv->pData) + 1) << 16);
- dw |= (*((tlv->pData) + 2) << 8);
- dw |= (*((tlv->pData) + 3));
+ oscar_tlv *pTLV = getTLV(wType, wIndex);
+ if (pTLV && pTLV->wLen >= 4) {
+ dw |= (*((pTLV->pData) + 0) << 24);
+ dw |= (*((pTLV->pData) + 1) << 16);
+ dw |= (*((pTLV->pData) + 2) << 8);
+ dw |= (*((pTLV->pData) + 3));
}
return dw;
@@ -195,10 +195,10 @@ WORD oscar_tlv_chain::getWord(WORD wType, WORD wIndex) {
WORD w = 0;
- oscar_tlv *tlv = getTLV(wType, wIndex);
- if (tlv && tlv->wLen >= 2) {
- w |= (*((tlv->pData) + 0) << 8);
- w |= (*((tlv->pData) + 1));
+ oscar_tlv *pTLV = getTLV(wType, wIndex);
+ if (pTLV && pTLV->wLen >= 2) {
+ w |= (*((pTLV->pData) + 0) << 8);
+ w |= (*((pTLV->pData) + 1));
}
return w;
@@ -208,22 +208,22 @@ BYTE oscar_tlv_chain::getByte(WORD wType, WORD wIndex) {
BYTE b = 0;
- oscar_tlv *tlv = getTLV(wType, wIndex);
- if (tlv && tlv->wLen)
- b = *(tlv->pData);
+ oscar_tlv *pTLV = getTLV(wType, wIndex);
+ if (pTLV && pTLV->wLen)
+ b = *(pTLV->pData);
return b;
}
int oscar_tlv_chain::getNumber(WORD wType, WORD wIndex)
{
- oscar_tlv *tlv = getTLV(wType, wIndex);
- if (tlv) {
- if (tlv->wLen == 1)
+ oscar_tlv *pTLV = getTLV(wType, wIndex);
+ if (pTLV) {
+ if (pTLV->wLen == 1)
return getByte(wType, wIndex);
- if (tlv->wLen == 2)
+ if (pTLV->wLen == 2)
return getWord(wType, wIndex);
- if (tlv->wLen == 4)
+ if (pTLV->wLen == 4)
return getDWord(wType, wIndex);
}
return 0;
@@ -231,9 +231,9 @@ int oscar_tlv_chain::getNumber(WORD wType, WORD wIndex) double oscar_tlv_chain::getDouble(WORD wType, WORD wIndex)
{
- oscar_tlv *tlv = getTLV(wType, wIndex);
- if (tlv && tlv->wLen == 8) {
- BYTE *buf = tlv->pData;
+ oscar_tlv *pTLV = getTLV(wType, wIndex);
+ if (pTLV && pTLV->wLen == 8) {
+ BYTE *buf = pTLV->pData;
double d = 0;
unpackQWord(&buf, (DWORD64*)&d);
@@ -245,19 +245,18 @@ double oscar_tlv_chain::getDouble(WORD wType, WORD wIndex) char* oscar_tlv_chain::getString(WORD wType, WORD wIndex)
{
- char *str = NULL;
-
- oscar_tlv *tlv = getTLV(wType, wIndex);
- if (tlv) {
- str = (char*)SAFE_MALLOC(tlv->wLen + 1); /* For \0 */
-
- if (!str) return NULL;
+ oscar_tlv *pTLV = getTLV(wType, wIndex);
+ if (pTLV) {
+ char *str = (char*)SAFE_MALLOC(pTLV->wLen + 1); /* For \0 */
+ if (!str)
+ return NULL;
- memcpy(str, tlv->pData, tlv->wLen);
- str[tlv->wLen] = '\0';
+ memcpy(str, pTLV->pData, pTLV->wLen);
+ str[pTLV->wLen] = '\0';
+ return str;
}
- return str;
+ return NULL;
}
void disposeChain(oscar_tlv_chain **chain)
@@ -266,7 +265,6 @@ void disposeChain(oscar_tlv_chain **chain) return;
oscar_tlv_chain *now = *chain;
-
while (now) {
oscar_tlv_chain *next = now->next;
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, "<iq type='get' id='"TLEN_IQID"%d'><query xmlns='jabber:iq:roster'/></iq>", iqId);
+ // iqId = TlenSerialNext();
+ // TlenIqAdd(iqId, IQ_PROC_NONE, TlenIqResultGetRoster);
+ // TlenSend(info, "<iq type='get' id='"TLEN_IQID"%d'><query xmlns='jabber:iq:roster'/></iq>", iqId);
TlenSend(proto, "<iq type='get' id='GetRoster'><query xmlns='jabber:iq:roster'/></iq>");
TlenSend(proto, "<iq to='tcfg' type='get' id='TcfgGetAfterLoggedIn'></iq>");
@@ -55,7 +55,7 @@ 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);
+ 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; i<queryNode->numChild; 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; i<queryNode->numChild; 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("<iq/> iqIdGetVcard (tlen)");
- char *type=TlenXmlGetAttrValue(iqNode, "type");
+ // TlenLog("<iq/> 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; i<itemNode->numChild; 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("<iq/> iqIdGetSearch");
+ // TlenLog("<iq/> 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; i<queryNode->numChild; 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, "<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, (int)ret);
+ 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);
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, "<pic st='%s' idt='%s'/>", item->ft->iqId, item->jid);
- TlenWsSend(proto, socket, header, i);
+ ret = mir_snprintf(header, "<pic st='%s' idt='%s'/>", 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, "<iq type='get' id='" TLEN_IQID "%d' to='tuba'><query xmlns='jabber:iq:search'>%s</query></iq>", iqId, proto->searchQuery);
- } else {
+ }
+ else {
TlenSend(proto, "<iq type='get' id='" TLEN_IQID "%d' to='tuba'><query xmlns='jabber:iq:search'>%s<f>%d</f></query></iq>", 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, "<email>%s</email>", 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, "<nick>%s</nick>", p);
mir_free(p);
}
}
if (firstName != NULL && firstName[0] != '\0') {
- if ((p=TlenTextEncode(firstName)) != NULL) {
+ if ((p = TlenTextEncode(firstName)) != NULL) {
TlenStringAppend(&searchQuery, &searchQueryLen, "<first>%s</first>", p);
mir_free(p);
}
}
if (lastName != NULL && lastName[0] != '\0') {
- if ((p=TlenTextEncode(lastName)) != NULL) {
+ if ((p = TlenTextEncode(lastName)) != NULL) {
TlenStringAppend(&searchQuery, &searchQueryLen, "<last>%s</last>", 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, "</s>");
- // Force closing connection
+ // TlenSend(s, "</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, "<iq type='get' id='" TLEN_IQID "%d' to='tuba'><query xmlns='jabber:iq:register'></query></iq>", 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, "<iq type='get' id='" TLEN_IQID "%d' to='tuba'><query xmlns='jabber:iq:search'><i>%s</i></query></iq>", 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, "<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);
}
@@ -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, "<iq to='%s'><query xmlns='p2p'><fs t='%s' e='5' i='%s' v='1'/></query></iq>", ft->jid, ft->jid, ft->iqId);
- } else {
+ }
+ else {
TlenSend(this, "<f t='%s' i='%s' e='5' v='1'/>", 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, "<f i='%s' e='4' t='%s'/>", ft->iqId, nick);\
- } else {
- TlenSend(this, "<f i='%s' e='4' t='%s'/>", ft->iqId, nick);\
+ TlenSend(this, "<f i='%s' e='4' t='%s'/>", ft->iqId, nick); \
+ }
+ else {
+ TlenSend(this, "<f i='%s' e='4' t='%s'/>", 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; i<ft->fileCount; 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, "<f t='%s' n='%s' e='1' i='%s' c='1' s='%d' v='1'/>", nick, p, idStr, ft->allFileTotalSize);
mir_free(ppszFiles[0]);
mir_free(p);
- } else {
+ }
+ else {
TlenSend(this, "<f t='%s' e='1' i='%s' c='%d' s='%d' v='1'/>", 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, "<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);
}
@@ -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, "<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);
- } else {
+ }
+ else {
TlenSend(this, "<iq type='set'><query xmlns='jabber:iq:roster'><item name='%s' jid='%s'></item></query></iq>", 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, "<iq type='set'><query xmlns='jabber:iq:roster'><item name='%s' jid='%s'><group>%s</group></item></query></iq>", nick, jid, pGroup);
- TlenSend(this, "<presence to='%s' type='subscribe'/>", jid);
+ if ((pGroup = TlenGroupEncode(dbv.pszVal)) != NULL) {
+ 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);
}
db_free(&dbv);
}
else {
- TlenSend(this, "<iq type='set'><query xmlns='jabber:iq:roster'><item name='%s' jid='%s'/></query></iq>", nick, jid);
- TlenSend(this, "<presence to='%s' type='subscribe'/>", jid);
+ TlenSend(this, "<iq type='set'><query xmlns='jabber:iq:roster'><item name='%s' szJid='%s'/></query></iq>", szNick, szJid);
+ TlenSend(this, "<presence to='%s' type='subscribe'/>", 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<TlenProtocol>(aProtoName, aUserName)
+ PROTO<TlenProtocol>(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);
diff --git a/protocols/Xfire/xfire.vcxproj b/protocols/Xfire/xfire.vcxproj index 4c08d50ff1..4a24bbbf01 100644 --- a/protocols/Xfire/xfire.vcxproj +++ b/protocols/Xfire/xfire.vcxproj @@ -27,6 +27,7 @@ </ImportGroup>
<ItemDefinitionGroup>
<ClCompile>
+ <DisableSpecificWarnings>4458;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<ExceptionHandling>Sync</ExceptionHandling>
</ClCompile>
</ItemDefinitionGroup>
diff --git a/protocols/Yahoo/src/libyahoo2/yahoo_util.cpp b/protocols/Yahoo/src/libyahoo2/yahoo_util.cpp index 63149f3821..8192436834 100644 --- a/protocols/Yahoo/src/libyahoo2/yahoo_util.cpp +++ b/protocols/Yahoo/src/libyahoo2/yahoo_util.cpp @@ -119,14 +119,12 @@ void y_strfreev(char ** vector) char ** y_strsplit(char * str, char * sep, int nelem)
{
char ** vector;
- char *s, *p;
int i=0;
int l = (int)strlen(sep);
if (nelem <= 0) {
- char * s;
nelem=0;
if (*str) {
- for(s=strstr(str, sep); s; s=strstr(s+l, sep),nelem++)
+ for(char *s=strstr(str, sep); s; s=strstr(s+l, sep),nelem++)
;
if (strcmp(str+strlen(str)-l, sep))
nelem++;
@@ -135,7 +133,7 @@ char ** y_strsplit(char * str, char * sep, int nelem) vector = y_new(char *, nelem + 1);
- for(p=str, s=strstr(p,sep); i<nelem && s; p=s+l, s=strstr(p,sep), i++) {
+ for(char *p=str, *s=strstr(p,sep); i<nelem && s; p=s+l, s=strstr(p,sep), i++) {
int len = s-p;
vector[i] = y_new(char, len+1);
strncpy(vector[i], p, len);
|