diff options
author | George Hazan <george.hazan@gmail.com> | 2014-07-14 14:45:08 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-07-14 14:45:08 +0000 |
commit | 26950a6982ca08e78c9e28dba8bbcc7d60768d65 (patch) | |
tree | b65473631a571e864867d5a334c8e0b5f4b6eccc /protocols/IcqOscarJ | |
parent | ffb105f462a9c207ea1c05abda71f9fe72c70dca (diff) |
git-svn-id: http://svn.miranda-ng.org/main/trunk@9795 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/IcqOscarJ')
-rw-r--r-- | protocols/IcqOscarJ/src/oscar_filetransfer.cpp | 30 | ||||
-rw-r--r-- | protocols/IcqOscarJ/src/utilities.cpp | 39 |
2 files changed, 35 insertions, 34 deletions
diff --git a/protocols/IcqOscarJ/src/oscar_filetransfer.cpp b/protocols/IcqOscarJ/src/oscar_filetransfer.cpp index 97ba1155ea..7c7e093769 100644 --- a/protocols/IcqOscarJ/src/oscar_filetransfer.cpp +++ b/protocols/IcqOscarJ/src/oscar_filetransfer.cpp @@ -2020,11 +2020,8 @@ void CIcqProto::oft_sendPeerInit(oscar_connection *oc) {
icq_lock l(oftMutex);
- oscar_filetransfer *ft = oc->ft;
- struct _stati64 statbuf;
- char *pszThisFileName;
-
// prepare init frame
+ oscar_filetransfer *ft = oc->ft;
if (ft->iCurrentFile >= (int)ft->wFilesCount) { // All files done, great!
ProtoBroadcastAck(ft->hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, ft, 0);
// Release transfer
@@ -2034,6 +2031,8 @@ void CIcqProto::oft_sendPeerInit(oscar_connection *oc) SAFE_FREE(&ft->szThisFile);
ft->szThisFile = null_strdup(ft->files[ft->iCurrentFile].szFile);
+
+ struct _stati64 statbuf;
if (FileStatUtf(ft->szThisFile, &statbuf)) {
icq_LogMessage(LOG_ERROR, LPGEN("Your file transfer has been aborted because one of the files that you selected to send is no longer readable from the disk. You may have deleted or moved it."));
@@ -2043,14 +2042,13 @@ void CIcqProto::oft_sendPeerInit(oscar_connection *oc) return;
}
- { // create full relative filename
- char* szThisContainer = ft->files[ft->iCurrentFile].szContainer;
+ // create full relative filename
+ char* szThisContainer = ft->files[ft->iCurrentFile].szContainer;
- pszThisFileName = (char*)SAFE_MALLOC(strlennull(ft->szThisFile) + strlennull(szThisContainer) + 4);
- strcpy(pszThisFileName, szThisContainer);
- NormalizeBackslash(pszThisFileName);
- strcat(pszThisFileName, ExtractFileName(ft->szThisFile));
- }
+ char *pszThisFileName = (char*)SAFE_MALLOC(strlennull(ft->szThisFile) + strlennull(szThisContainer) + 4);
+ strcpy(pszThisFileName, szThisContainer);
+ NormalizeBackslash(pszThisFileName);
+ strcat(pszThisFileName, ExtractFileName(ft->szThisFile));
// convert backslashes to dir markings
for (int i = 0; i < strlennull(pszThisFileName); i++)
@@ -2082,7 +2080,8 @@ void CIcqProto::oft_sendPeerInit(oscar_connection *oc) if (IsUSASCII(pszThisFileName, strlennull(pszThisFileName))) {
ft->wEncoding = 0; // ascii
ft->cbRawFileName = strlennull(pszThisFileName) + 1;
- if (ft->cbRawFileName < 64) ft->cbRawFileName = 64;
+ if (ft->cbRawFileName < 64)
+ ft->cbRawFileName = 64;
ft->rawFileName = (char*)SAFE_MALLOC(ft->cbRawFileName);
strcpy(ft->rawFileName, (char*)pszThisFileName);
SAFE_FREE((void**)&pszThisFileName);
@@ -2092,7 +2091,8 @@ void CIcqProto::oft_sendPeerInit(oscar_connection *oc) WCHAR *pwsThisFile = make_unicode_string(pszThisFileName);
SAFE_FREE((void**)&pszThisFileName);
ft->cbRawFileName = strlennull(pwsThisFile) * (int)sizeof(WCHAR) + 2;
- if (ft->cbRawFileName < 64) ft->cbRawFileName = 64;
+ if (ft->cbRawFileName < 64)
+ ft->cbRawFileName = 64;
ft->rawFileName = (char*)SAFE_MALLOC(ft->cbRawFileName);
// convert to LE ordered string
BYTE *pwsThisFileBuf = (BYTE*)pwsThisFile; // need this - unpackWideString moves the address!
@@ -2107,14 +2107,16 @@ void CIcqProto::oft_sendPeerInit(oscar_connection *oc) void CIcqProto::sendOFT2FramePacket(oscar_connection *oc, WORD datatype)
{
oscar_filetransfer *ft = oc->ft;
- icq_packet packet;
+ icq_packet packet;
packet.wLen = 192 + ft->cbRawFileName;
init_generic_packet(&packet, 0);
+
// Basic Oscar Frame
packDWord(&packet, 0x4F465432); // Magic
packWord(&packet, packet.wLen);
packWord(&packet, datatype);
+
// Cookie
packLEDWord(&packet, ft->pMessage.dwMsgID1);
packLEDWord(&packet, ft->pMessage.dwMsgID2);
diff --git a/protocols/IcqOscarJ/src/utilities.cpp b/protocols/IcqOscarJ/src/utilities.cpp index fed294427a..9a53b20726 100644 --- a/protocols/IcqOscarJ/src/utilities.cpp +++ b/protocols/IcqOscarJ/src/utilities.cpp @@ -514,12 +514,11 @@ MCONTACT CIcqProto::HContactFromUID(DWORD dwUin, const char *szUid, int *Added) while (hContact) {
DWORD dwContactUin;
uid_str szContactUid;
-
if (!getContactUid(hContact, &dwContactUin, &szContactUid)) {
if (!dwContactUin && !stricmpnull(szContactUid, szUid)) {
- if (strcmpnull(szContactUid, szUid)) { // fix case in SN
+ if (strcmpnull(szContactUid, szUid)) // fix case in SN
setString(hContact, UNIQUEIDSETTING, szUid);
- }
+
return hContact;
}
}
@@ -528,6 +527,8 @@ MCONTACT CIcqProto::HContactFromUID(DWORD dwUin, const char *szUid, int *Added) //not present: add
if (Added) {
+ debugLogA("Attempt to create ICQ contact by string <%s>", szUid);
+
hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
CallService(MS_PROTO_ADDTOCONTACT, hContact, (LPARAM)m_szModuleName);
@@ -551,13 +552,12 @@ MCONTACT CIcqProto::HContactFromUID(DWORD dwUin, const char *szUid, int *Added) return INVALID_CONTACT_ID;
}
-
MCONTACT CIcqProto::HContactFromAuthEvent(HANDLE hEvent)
{
- DBEVENTINFO dbei = { sizeof(dbei) };
DWORD body[3];
- dbei.cbBlob = sizeof(DWORD)* 2;
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ dbei.cbBlob = sizeof(DWORD) * 2;
dbei.pBlob = (PBYTE)&body;
if (db_event_get(hEvent, &dbei))
@@ -572,7 +572,7 @@ MCONTACT CIcqProto::HContactFromAuthEvent(HANDLE hEvent) return DbGetAuthEventContact(&dbei);
}
-char *NickFromHandle(MCONTACT hContact)
+char* NickFromHandle(MCONTACT hContact)
{
if (hContact == INVALID_CONTACT_ID)
return null_strdup(Translate("<invalid>"));
@@ -580,7 +580,7 @@ char *NickFromHandle(MCONTACT hContact) return null_strdup((char *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, 0));
}
-char *NickFromHandleUtf(MCONTACT hContact)
+char* NickFromHandleUtf(MCONTACT hContact)
{
if (hContact == INVALID_CONTACT_ID)
return ICQTranslateUtf(LPGEN("<invalid>"));
@@ -588,7 +588,7 @@ char *NickFromHandleUtf(MCONTACT hContact) return tchar_to_utf8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GCDNF_TCHAR));
}
-char *strUID(DWORD dwUIN, char *pszUID)
+char* strUID(DWORD dwUIN, char *pszUID)
{
if (dwUIN && pszUID)
_ltoa(dwUIN, pszUID, 10);
@@ -731,7 +731,7 @@ void parseServerAddress(char* szServer, WORD* wPort) szServer[i] = '\0';
}
-char *DemangleXml(const char *string, int len)
+char* DemangleXml(const char *string, int len)
{
char *szWork = (char*)SAFE_MALLOC(len + 1), *szChar = szWork;
int i;
@@ -767,7 +767,7 @@ char *DemangleXml(const char *string, int len) return szWork;
}
-char *MangleXml(const char *string, int len)
+char* MangleXml(const char *string, int len)
{
int i, l = 1;
char *szWork, *szChar;
@@ -807,7 +807,7 @@ char *MangleXml(const char *string, int len) return szWork;
}
-char *EliminateHtml(const char *string, int len)
+char* EliminateHtml(const char *string, int len)
{
char *tmp = (char*)SAFE_MALLOC(len + 1);
int i, j;
@@ -840,12 +840,13 @@ char *EliminateHtml(const char *string, int len) return res;
}
-char *ApplyEncoding(const char *string, const char *pszEncoding)
-{ // decode encoding to Utf-8
+char* ApplyEncoding(const char *string, const char *pszEncoding)
+{
+ // decode encoding to Utf-8
if (string && pszEncoding) { // we do only encodings known to icq5.1 // TODO: check if this is enough
- if (!_strnicmp(pszEncoding, "utf-8", 5)) { // it is utf-8 encoded
+ if (!_strnicmp(pszEncoding, "utf-8", 5)) // it is utf-8 encoded
return null_strdup(string);
- }
+
if (!_strnicmp(pszEncoding, "unicode-2-0", 11)) { // it is UCS-2 encoded
int wLen = strlennull((WCHAR*)string) + 1;
WCHAR *szStr = (WCHAR*)_alloca(wLen * 2);
@@ -855,13 +856,11 @@ char *ApplyEncoding(const char *string, const char *pszEncoding) return make_utf8_string(szStr);
}
- if (!_strnicmp(pszEncoding, "iso-8859-1", 10)) { // we use "Latin I" instead - it does the job
+ if (!_strnicmp(pszEncoding, "iso-8859-1", 10)) // we use "Latin I" instead - it does the job
return ansi_to_utf8_codepage(string, 1252);
- }
}
- if (string) { // consider it CP_ACP
+ if (string) // consider it CP_ACP
return ansi_to_utf8(string);
- }
return NULL;
}
|