summaryrefslogtreecommitdiff
path: root/protocols/EmLanProto/src
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/EmLanProto/src')
-rw-r--r--protocols/EmLanProto/src/amdproto.cpp23
-rw-r--r--protocols/EmLanProto/src/get_time.cpp19
-rw-r--r--protocols/EmLanProto/src/lan.cpp2
-rw-r--r--protocols/EmLanProto/src/lan.h6
-rw-r--r--protocols/EmLanProto/src/mlan.cpp164
-rw-r--r--protocols/EmLanProto/src/mlan.h14
-rw-r--r--protocols/EmLanProto/src/stdafx.cxx (renamed from protocols/EmLanProto/src/stdafx.cpp)16
-rw-r--r--protocols/EmLanProto/src/stdafx.h1
-rw-r--r--protocols/EmLanProto/src/version.h2
9 files changed, 117 insertions, 130 deletions
diff --git a/protocols/EmLanProto/src/amdproto.cpp b/protocols/EmLanProto/src/amdproto.cpp
index d594a8f277..1bcc43a24d 100644
--- a/protocols/EmLanProto/src/amdproto.cpp
+++ b/protocols/EmLanProto/src/amdproto.cpp
@@ -28,7 +28,7 @@ bool g_InitOptions = false;
std::fstream emlanLog("EmLanLog.txt", std::ios::out|std::ios::app);
#endif
-extern "C" __declspec(dllexport) PLUGININFOEX* __cdecl MirandaPluginInfoEx(DWORD mirandaVersion)
+extern "C" __declspec(dllexport) PLUGININFOEX* __cdecl MirandaPluginInfoEx(DWORD)
{
return &pluginInfo;
}
@@ -95,7 +95,7 @@ static INT_PTR __cdecl EMPGetStatus(WPARAM, LPARAM)
return g_lan->GetMirandaStatus();
}
-INT_PTR __cdecl EMPSetStatus(WPARAM new_status, LPARAM lParam)
+INT_PTR __cdecl EMPSetStatus(WPARAM new_status, LPARAM)
{
g_lan->SetMirandaStatus(new_status);
return 0;
@@ -124,7 +124,8 @@ static INT_PTR __cdecl EMPAddToList(WPARAM flags, LPARAM lParam)
static INT_PTR __cdecl EMPBasicSearch(WPARAM, LPARAM lParam)
{
- return g_lan->Search((const char*)lParam);
+ const wchar_t *wszName = (const wchar_t*)lParam;
+ return g_lan->Search(_T2A(wszName));
}
static INT_PTR __cdecl EMPGetAwayMsg(WPARAM, LPARAM lParam)
@@ -147,27 +148,27 @@ static INT_PTR __cdecl EMPFileResume(WPARAM wParam, LPARAM lParam)
return g_lan->FileResume((int)wParam, (PROTOFILERESUME*)lParam);
}
-static INT_PTR __cdecl EMPSendFileAllow(WPARAM wParam, LPARAM lParam)
+static INT_PTR __cdecl EMPSendFileAllow(WPARAM, LPARAM lParam)
{
return g_lan->FileAllow((CCSDATA*)lParam);
}
-static INT_PTR __cdecl EMPSendFileDeny(WPARAM wParam, LPARAM lParam)
+static INT_PTR __cdecl EMPSendFileDeny(WPARAM, LPARAM lParam)
{
return g_lan->FileDeny((CCSDATA*)lParam);
}
-static INT_PTR __cdecl EMPSendFileCancel(WPARAM wParam, LPARAM lParam)
+static INT_PTR __cdecl EMPSendFileCancel(WPARAM, LPARAM lParam)
{
return g_lan->FileCancel((CCSDATA*)lParam);
}
-static INT_PTR __cdecl EMPSendFile(WPARAM wParam, LPARAM lParam)
+static INT_PTR __cdecl EMPSendFile(WPARAM, LPARAM lParam)
{
return g_lan->SendFile((CCSDATA*)lParam);
}
-static INT_PTR __cdecl EMPRecvFile(WPARAM wParam, LPARAM lParam)
+static INT_PTR __cdecl EMPRecvFile(WPARAM, LPARAM lParam)
{
g_lan->RecvFile((CCSDATA*)lParam);
return 0;
@@ -187,7 +188,7 @@ INT_PTR CALLBACK EMPDlgProcMainOpts(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPAR
int cind = 0;
for (int i = 0; i < count; i++) {
in_addr addr = g_lan->GetHostAddress(i);
- char* ipStr = inet_ntoa(addr);
+ wchar_t* ipStr = mir_a2u(inet_ntoa(addr));
if (addr.S_un.S_addr == caddr.S_un.S_addr)
cind = i;
SendDlgItemMessage(hwndDlg, IDC_LIST_IP, LB_ADDSTRING, 0, (LPARAM)ipStr);
@@ -275,7 +276,7 @@ int __cdecl EMPCreateOptionsDlg(WPARAM wParam, LPARAM)
OPTIONSDIALOGPAGE odp = { 0 };
odp.position = 100000000;
odp.hInstance = g_hInstance;
- odp.pszTemplate = MAKEINTRESOURCE(IDD_EMP_FORM_OPT);
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_EMP_FORM_OPT);
odp.szTitle.a = LPGEN("E-mage LAN protocol");
odp.szGroup.a = LPGEN("Network");
odp.flags = ODPF_BOLDGROUPS;
@@ -286,7 +287,7 @@ int __cdecl EMPCreateOptionsDlg(WPARAM wParam, LPARAM)
//////////////////////////////////////////////////////////////////////////
-INT_PTR CALLBACK EMPDlgProcMessage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+INT_PTR CALLBACK EMPDlgProcMessage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM)
{
HWND hwndOwner;
RECT rc, rcDlg, rcOwner;
diff --git a/protocols/EmLanProto/src/get_time.cpp b/protocols/EmLanProto/src/get_time.cpp
index 76ad065fdf..6ffccc5047 100644
--- a/protocols/EmLanProto/src/get_time.cpp
+++ b/protocols/EmLanProto/src/get_time.cpp
@@ -19,7 +19,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "stdafx.h"
-
static int daysInMonth[]={31,28,31,30,31,30,31,31,30,31,30,31};
static int IsLeapYear(int year)
{
@@ -42,24 +41,6 @@ static DWORD YMDHMSToTime(int year,int month,int day,int hour,int minute,int sec
return ret+3600*hour+60*minute+second;
}
-
-static DWORD TimestampLocalToGMT(DWORD from)
-{
- FILETIME ft1,ft2;
- LARGE_INTEGER liFiletime;
-
- //this huge number is the difference between 1970 and 1601 in seconds
- //liFiletime.QuadPart=(11644473600i64+(__int64)from)*10000000;
- __int64 t = 11644473600;
- liFiletime.QuadPart=(t+(__int64)from)*10000000;
- ft1.dwHighDateTime=liFiletime.HighPart;
- ft1.dwLowDateTime=liFiletime.LowPart;
- LocalFileTimeToFileTime(&ft1,&ft2);
- liFiletime.HighPart=ft2.dwHighDateTime;
- liFiletime.LowPart=ft2.dwLowDateTime;
- return (DWORD)(liFiletime.QuadPart/10000000-t);
-}
-
DWORD get_time()
{
SYSTEMTIME stime;
diff --git a/protocols/EmLanProto/src/lan.cpp b/protocols/EmLanProto/src/lan.cpp
index 336e64bb75..301e2a8284 100644
--- a/protocols/EmLanProto/src/lan.cpp
+++ b/protocols/EmLanProto/src/lan.cpp
@@ -191,7 +191,7 @@ void CLan::SendPacket(in_addr addr, const u_char* mes, int len)
addrTo.sin_addr = addr;
addrTo.sin_family = AF_INET;
addrTo.sin_port = PORT_NUMBER;
- int res = sendto(m_income, (const char*)mes, len, 0, (sockaddr*)&addrTo, sizeof(addrTo));
+ sendto(m_income, (const char*)mes, len, 0, (sockaddr*)&addrTo, sizeof(addrTo));
}
}
diff --git a/protocols/EmLanProto/src/lan.h b/protocols/EmLanProto/src/lan.h
index 1fd2bbe80a..c6dc217c64 100644
--- a/protocols/EmLanProto/src/lan.h
+++ b/protocols/EmLanProto/src/lan.h
@@ -69,11 +69,11 @@ protected:
void SendPacketBroadcast(const u_char* mes, int len);
//! Event - called when packet is received
- virtual void OnRecvPacket(u_char* mes, int len, in_addr from) { };
+ virtual void OnRecvPacket(u_char*, int, in_addr) { };
//! Event - called when new incoming tcp connection is created (new thread is created)
- virtual void OnInTCPConnection(u_long addr, SOCKET m_socket) { };
+ virtual void OnInTCPConnection(u_long, SOCKET) { };
//! Event - called when new outgoing tcp connection is created )new thread is created)
- virtual void OnOutTCPConnection(u_long addr, SOCKET m_socket, LPVOID lpParameter) {};
+ virtual void OnOutTCPConnection(u_long, SOCKET, LPVOID) {};
//! Creates new outgoing TCP connection
SOCKET CreateTCPConnection(u_long addr, LPVOID lpParameter);
diff --git a/protocols/EmLanProto/src/mlan.cpp b/protocols/EmLanProto/src/mlan.cpp
index 107effffdb..6cd8255697 100644
--- a/protocols/EmLanProto/src/mlan.cpp
+++ b/protocols/EmLanProto/src/mlan.cpp
@@ -35,8 +35,6 @@ CMLan::CMLan()
m_mirStatus = ID_STATUS_OFFLINE;
m_pRootContact = nullptr;
-
- m_pRootContact = nullptr;
m_hCheckThread = nullptr;
m_handleId = 1;
@@ -73,7 +71,7 @@ CMLan::~CMLan()
void CMLan::DeleteCache()
{
- TContact* pCont = m_pRootContact;
+ TContact *pCont = m_pRootContact;
m_pRootContact = nullptr;
while (pCont) {
delete[] pCont->m_nick;
@@ -190,8 +188,9 @@ void CMLan::RequestStatus(bool answer, u_long addr)
TPacket pak;
memset(&pak, 0, sizeof(pak));
pak.flReqStatus = answer;
- pak.strName = m_name;
+ pak.strName = mir_u2a(m_name);
SendPacketExt(pak, addr);
+ mir_free(pak.strName);
}
void CMLan::SendPacketExt(TPacket& pak, u_long addr)
@@ -283,9 +282,6 @@ void CMLan::OnRecvPacket(u_char* mes, int len, in_addr from)
u_int rip = cont->m_addr.S_un.S_addr;
int tip = (rip << 24) | ((rip & 0xff00) << 8) | ((rip & 0xff0000) >> 8) | (rip >> 24);
db_set_dw(hContact, PROTONAME, "IP", tip);
- // HOSTENT* host = gethostbyaddr((const char*)&rip, sizeof(rip), AF_INET);
- // if (host)
- // db_set_s(hContact, PROTONAME, "UID", host->h_name);
}
}
}
@@ -325,24 +321,22 @@ void CMLan::OnRecvPacket(u_char* mes, int len, in_addr from)
}
if (pak.idReqAwayMessage && cont) {
- MCONTACT hContact = FindContact(cont->m_addr, cont->m_nick, true, false, false);
// Removed - it causes that whoisreadingawaymessage plugin was not working
- // if (hContact)
- // {
- // int IcqStatus = 0;
- // switch (m_mirStatus)
- // {
- // case ID_STATUS_AWAY: IcqStatus = ICQ_MSGTYPE_GETAWAYMSG; break;
- // case ID_STATUS_NA: IcqStatus = ICQ_MSGTYPE_GETNAMSG; break;
- // case ID_STATUS_OCCUPIED: IcqStatus = ICQ_MSGTYPE_GETOCCUMSG; break;
- // case ID_STATUS_DND: IcqStatus = ICQ_MSGTYPE_GETDNDMSG; break;
- // case ID_STATUS_FREECHAT: IcqStatus = ICQ_MSGTYPE_GETFFCMSG; break;
- // }
- // // HACK: this is a real hack
- // db_set_dw(hContact, "ICQ", "UIN", 1/*0xffffffff*/);
- // NotifyEventHooks(m_hookIcqMsgReq, IcqStatus, 1/*0xffffffff*/);
- // db_unset(hContact, "ICQ", "UIN");
- // }
+ // MCONTACT hContact = FindContact(cont->m_addr, cont->m_nick, true, false, false);
+ // if (hContact) {
+ // int IcqStatus = 0;
+ // switch (m_mirStatus) {
+ // case ID_STATUS_AWAY: IcqStatus = ICQ_MSGTYPE_GETAWAYMSG; break;
+ // case ID_STATUS_NA: IcqStatus = ICQ_MSGTYPE_GETNAMSG; break;
+ // case ID_STATUS_OCCUPIED: IcqStatus = ICQ_MSGTYPE_GETOCCUMSG; break;
+ // case ID_STATUS_DND: IcqStatus = ICQ_MSGTYPE_GETDNDMSG; break;
+ // case ID_STATUS_FREECHAT: IcqStatus = ICQ_MSGTYPE_GETFFCMSG; break;
+ // }
+ // // HACK: this is a real hack
+ // db_set_dw(hContact, "ICQ", "UIN", 1/*0xffffffff*/);
+ // NotifyEventHooks(m_hookIcqMsgReq, IcqStatus, 1/*0xffffffff*/);
+ // db_unset(hContact, "ICQ", "UIN");
+ // }
mir_cslock lck(m_csAccessAwayMes);
@@ -370,7 +364,12 @@ void CMLan::OnRecvPacket(u_char* mes, int len, in_addr from)
void CMLan::RecvMessageUrl(CCSDATA* ccs)
{
PROTORECVEVENT *pre = (PROTORECVEVENT*)ccs->lParam;
- ptrA szMessage(Utf8Encode(pre->szMessage));
+ ptrA szMessage;
+ // input string might be already utf8-encoded
+ if (Utf8CheckString(pre->szMessage))
+ szMessage = mir_strdup(pre->szMessage);
+ else
+ szMessage = Utf8Encode(pre->szMessage);
DBEVENTINFO dbei = {};
if (!mir_strcmp(ccs->szProtoService, PSR_MESSAGE))
@@ -410,31 +409,31 @@ INT_PTR CMLan::AddToContactList(u_int flags, EMPSEARCHRESULT *psr)
int CMLan::SendMessageUrl(CCSDATA* ccs, bool isUrl)
{
int cid = GetRandomProcId();
- size_t len;
+ size_t len = 0;
if (isUrl) {
len = mir_strlen((char*)ccs->lParam);
((char*)ccs->lParam)[len] = 1;
}
- TDataHolder* hold = new TDataHolder(ccs, cid, isUrl ? LEXT_SENDURL : LEXT_SENDMESSAGE, this);
+ TDataHolder *hold = new TDataHolder(ccs, cid, isUrl ? LEXT_SENDURL : LEXT_SENDMESSAGE, this);
if (isUrl) {
((char*)ccs->lParam)[len] = 0;
hold->msg[len] = 0;
}
- mir_forkthread(LaunchExt, (void*)hold);
+ mir_forkthread(LaunchExt, hold);
return cid;
}
int CMLan::Search(const char* name)
{
int cid = GetRandomProcId();
- mir_forkthread(LaunchExt, (void*)new TDataHolder(name, cid, LEXT_SEARCH, this));
+ mir_forkthread(LaunchExt, new TDataHolder(name, cid, LEXT_SEARCH, this));
return cid;
}
int CMLan::GetAwayMsg(CCSDATA* ccs)
{
int cid = GetRandomProcId();
- mir_forkthread(LaunchExt, (void*)new TDataHolder(ccs, cid, LEXT_GETAWAYMSG, this));
+ mir_forkthread(LaunchExt, new TDataHolder(ccs, cid, LEXT_GETAWAYMSG, this));
return cid;
}
@@ -484,10 +483,23 @@ void CMLan::SearchExt(TDataHolder* hold)
psr.ipaddr = cont->m_addr.S_un.S_addr;
psr.stat = cont->m_status;
psr.ver = cont->m_ver;
-
ProtoBroadcastAck(PROTONAME, NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)hold->id, (LPARAM)&psr);
}
}
+
+ // search string might contain some ip address
+ ULONG addr = inet_addr(hold->msg);
+ if (addr != INADDR_NONE) {
+ psr.nick.a = hold->msg;
+ psr.firstName.a = "";
+ psr.lastName.a = "";
+ psr.email.a = hold->msg;
+ psr.ipaddr = addr;
+ psr.stat = ID_STATUS_OFFLINE;
+ psr.ver = 0;
+ ProtoBroadcastAck(PROTONAME, NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)hold->id, (LPARAM)&psr);
+ }
+
ProtoBroadcastAck(PROTONAME, NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)hold->id, 0);
delete hold;
}
@@ -582,7 +594,7 @@ u_char* CMLan::CreatePacket(TPacket& pak, int* pBufLen)
if (pak.idStatus)
len += 1 + 1 + 2;
- size_t nameLen;
+ size_t nameLen = 0;
if (pak.strName) {
nameLen = mir_strlen(pak.strName);
len += 1 + 1 + nameLen + 1;
@@ -760,23 +772,17 @@ void CMLan::LoadSettings()
m_RequiredIp = db_get_dw(NULL, PROTONAME, "ipaddr", 0);
m_UseHostName = db_get_b(NULL, PROTONAME, "UseHostName", 1) != 0;
if (m_UseHostName) {
- gethostname(m_name, MAX_HOSTNAME_LEN);
+ m_nameLen = MAX_HOSTNAME_LEN;
+ GetComputerName(m_name, &m_nameLen);
CharLower(m_name);
}
else {
- DBVARIANT dbv;
- // Deleting old 'Name' value - using 'Nick' instead of it now
- if (db_get_s(NULL, PROTONAME, "Nick", &dbv)) {
- if (db_get_s(NULL, PROTONAME, "Name", &dbv))
- dbv.pszVal = "EmLan_User";
- else
- db_unset(NULL, PROTONAME, "Name");
- }
- if (!dbv.pszVal[0])
- dbv.pszVal = "EmLan_User";
- mir_strcpy(m_name, dbv.pszVal);
+ ptrW nick(db_get_wsa(NULL, PROTONAME, "Nick"));
+ if (!nick)
+ nick = mir_wstrdup(L"EmLan_User");
+ mir_wstrcpy(m_name, nick);
}
- m_nameLen = (int)mir_strlen(m_name);
+ m_nameLen = (int)mir_wstrlen(m_name);
if (GetStatus() != LM_LISTEN) {
int ipcount = GetHostAddrCount();
@@ -794,7 +800,7 @@ void CMLan::SaveSettings()
{
db_set_dw(NULL, PROTONAME, "ipaddr", m_RequiredIp);
db_set_b(NULL, PROTONAME, "UseHostName", m_UseHostName);
- db_set_s(NULL, PROTONAME, "Nick", m_name);
+ db_set_ws(NULL, PROTONAME, "Nick", m_name);
}
//////////////////////////////////////////////////////////////////////////
@@ -812,7 +818,7 @@ CMLan::TFileConnection::~TFileConnection()
}
delete[] m_szDescription;
if (m_szFiles) {
- char** cp = m_szFiles;
+ wchar_t** cp = m_szFiles;
while (*cp) {
delete[] * cp;
cp++;
@@ -1029,11 +1035,11 @@ void CMLan::OnInTCPConnection(u_long addr, SOCKET in_sock)
char* pf_to = pre.szMessage + 4;
char* pf_fr = (char*)conn->m_buf + 1 + 4 + 4;
- conn->m_szFiles = new char*[rcTotalFiles + 1];
+ conn->m_szFiles = new wchar_t*[rcTotalFiles + 1];
conn->m_szFiles[rcTotalFiles] = nullptr;
for (int i = 0; i < rcTotalFiles; i++) {
- conn->m_szFiles[i] = _strdup(pf_fr);
+ conn->m_szFiles[i] = mir_a2u(pf_fr);
if (i)
*pf_to++ = ' ';
while (*pf_fr)
@@ -1074,12 +1080,12 @@ void CMLan::OnInTCPConnection(u_long addr, SOCKET in_sock)
}
// Getting current directory
- char path[MAX_PATH];
- char* pathpart;
+ wchar_t path[MAX_PATH];
+ wchar_t* pathpart;
GetFullPathName(conn->m_szDir, MAX_PATH, path, &pathpart);
if (!SetCurrentDirectory(path)) {
if (rcTotalFiles == 1)
- conn->m_szRenamedFile = _strdup(pathpart);
+ conn->m_szRenamedFile = mir_wstrdup(pathpart);
*pathpart = 0;
if (!SetCurrentDirectory(path)) {
conn->Send(nullptr, 0);
@@ -1094,13 +1100,13 @@ void CMLan::OnInTCPConnection(u_long addr, SOCKET in_sock)
PROTOFILETRANSFERSTATUS fts;
fts.cbSize = sizeof(fts);
+ fts.flags = PFTS_UNICODE;
+ fts.hContact = conn->m_hContact;
fts.totalBytes = rcTotalSize;
fts.totalFiles = rcTotalFiles;
fts.totalProgress = 0;
- fts.szWorkingDir = conn->m_szDir;
- fts.flags = false;
- fts.hContact = conn->m_hContact;
- fts.pszFiles = conn->m_szFiles;
+ fts.wszWorkingDir = conn->m_szDir;
+ fts.pwszFiles = conn->m_szFiles;
bool err = false;
@@ -1150,7 +1156,7 @@ void CMLan::OnInTCPConnection(u_long addr, SOCKET in_sock)
}
EMLOG("Still processing");
- char* filename = conn->m_szRenamedFile;
+ wchar_t* filename = conn->m_szRenamedFile;
if (!filename)
filename = conn->m_szFiles[fileNo];
@@ -1238,7 +1244,7 @@ void CMLan::OnInTCPConnection(u_long addr, SOCKET in_sock)
delete conn;
}
-void CMLan::OnOutTCPConnection(u_long addr, SOCKET out_socket, LPVOID lpParameter)
+void CMLan::OnOutTCPConnection(u_long, SOCKET out_socket, LPVOID lpParameter)
{
EMLOG("Sending OUT TCP connection");
TFileConnection* conn = (TFileConnection*)lpParameter;
@@ -1258,13 +1264,13 @@ void CMLan::OnOutTCPConnection(u_long addr, SOCKET out_socket, LPVOID lpParamete
FileAddToList(conn);
u_char buf[FILE_SEND_BLOCK + 1];
- char name[MAX_PATH + 8];
+ wchar_t name[MAX_PATH + 8];
buf[0] = FCODE_SND_FILEREQ;
int len = 1 + 4 + 4;
int size = 0;
int filecount = 0;
- char** pf = conn->m_szFiles;
+ wchar_t** pf = conn->m_szFiles;
while (*pf) {
// TODO: FIX IT !
EMLOG("Opening file");
@@ -1279,33 +1285,33 @@ void CMLan::OnOutTCPConnection(u_long addr, SOCKET out_socket, LPVOID lpParamete
filecount++;
CloseHandle(hFile);
- char* filepart;
- GetFullPathName(*pf, MAX_PATH, (char*)name, &filepart);
+ wchar_t* filepart;
+ GetFullPathName(*pf, MAX_PATH, name, &filepart);
free(*pf);
- *pf = _strdup(name);
- mir_strcpy((char*)buf + len, filepart);
- len += (int)mir_strlen(filepart) + 1;
+ *pf = mir_wstrdup(name);
+ mir_strcpy((char*)buf + len, _T2A(filepart));
+ len += (int)mir_wstrlen(filepart) + 1;
pf++;
}
- mir_strcpy((char*)buf + len, conn->m_szDescription);
- len += (int)mir_strlen(conn->m_szDescription) + 1;
+ mir_strcpy((char*)buf + len, _T2A(conn->m_szDescription));
+ len += (int)mir_wstrlen(conn->m_szDescription) + 1;
*((int*)(buf + 1)) = size;
*((int*)(buf + 1 + 4)) = filecount;
GetCurrentDirectory(MAX_PATH, name);
- conn->m_szDir = _strdup(name);
+ conn->m_szDir = mir_wstrdup(name);
PROTOFILETRANSFERSTATUS fts;
fts.cbSize = sizeof(fts);
+ fts.flags = PFTS_SENDING | PFTS_UNICODE;
+ fts.hContact = conn->m_hContact;
fts.totalBytes = size;
fts.totalFiles = filecount;
fts.totalProgress = 0;
- fts.szWorkingDir = conn->m_szDir;
- fts.flags = PFTS_SENDING;
- fts.hContact = conn->m_hContact;
- fts.pszFiles = conn->m_szFiles;
+ fts.wszWorkingDir = conn->m_szDir;
+ fts.pwszFiles = conn->m_szFiles;
EMLOG("Sending file size");
if (conn->Send(buf, len)) {
@@ -1388,7 +1394,7 @@ void CMLan::OnOutTCPConnection(u_long addr, SOCKET out_socket, LPVOID lpParamete
EMLOG("Ok");
buf[0] = FCODE_SND_FILEDATA;
- if (readbytes != tosend) {
+ if ((int)readbytes != tosend) {
EMLOG("Error during reading file. File was changed");
CloseHandle(hFile);
conn->Send(nullptr, 0);
@@ -1455,14 +1461,14 @@ int CMLan::SendFile(CCSDATA* ccs)
conn->m_cid = cid;
conn->m_hContact = ccs->hContact;
- conn->m_szDescription = _strdup((char*)ccs->wParam);
+ conn->m_szDescription = mir_wstrdup((wchar_t*)ccs->wParam);
int files = 0;
- char** ppszFiles = (char**)ccs->lParam;
+ wchar_t** ppszFiles = (wchar_t**)ccs->lParam;
while (ppszFiles[files])
files++;
- conn->m_szFiles = new char*[files + 1];
+ conn->m_szFiles = new wchar_t*[files + 1];
for (int i = 0; i < files; i++)
- conn->m_szFiles[i] = _strdup(ppszFiles[i]);
+ conn->m_szFiles[i] = mir_wstrdup(ppszFiles[i]);
conn->m_szFiles[files] = nullptr;
u_long addr = db_get_dw(ccs->hContact, PROTONAME, "ipaddr", 0);
@@ -1485,7 +1491,7 @@ int CMLan::FileAllow(CCSDATA* ccs)
mir_cslock connLck(conn->m_csAccess);
conn->m_state = TFileConnection::FCS_ALLOW;
- conn->m_szDir = _strdup((char*)ccs->lParam);
+ conn->m_szDir = mir_wstrdup((wchar_t*)ccs->lParam);
return cid;
}
@@ -1546,7 +1552,7 @@ int CMLan::FileResume(int cid, PROTOFILERESUME* pfr)
case FILERESUME_RENAME:
conn->m_state = TFileConnection::FCS_RENAME;
delete[] conn->m_szRenamedFile;
- conn->m_szRenamedFile = _strdup((char*)pfr->szFilename);
+ conn->m_szRenamedFile = mir_wstrdup(pfr->szFilename);
break;
case FILERESUME_SKIP:
conn->m_state = TFileConnection::FCS_SKIP;
diff --git a/protocols/EmLanProto/src/mlan.h b/protocols/EmLanProto/src/mlan.h
index ed151e1212..a314c054cd 100644
--- a/protocols/EmLanProto/src/mlan.h
+++ b/protocols/EmLanProto/src/mlan.h
@@ -62,7 +62,7 @@ public:
void LoadSettings();
void SaveSettings();
- char* GetName() { return m_name; }
+ wchar_t* GetName() { return m_name; }
bool GetUseHostName() { return m_UseHostName; }
void SetUseHostName(bool val) { m_UseHostName = val; }
void SetRequiredIp(u_long ip) { m_RequiredIp = ip; }
@@ -92,8 +92,8 @@ private:
TContact* m_pRootContact;
HANDLE m_hCheckThread;
- char m_name[MAX_HOSTNAME_LEN];
- int m_nameLen;
+ wchar_t m_name[MAX_HOSTNAME_LEN];
+ DWORD m_nameLen;
mir_cs m_csAccessClass;
mir_cs m_csAccessAwayMes;
@@ -174,10 +174,10 @@ private:
u_long m_addr;
MCONTACT m_hContact;
- char* m_szDescription;
- char** m_szFiles;
- char* m_szDir;
- char* m_szRenamedFile;
+ wchar_t* m_szDescription;
+ wchar_t** m_szFiles;
+ wchar_t* m_szDir;
+ wchar_t* m_szRenamedFile;
u_char* m_buf;
int m_recSize;
diff --git a/protocols/EmLanProto/src/stdafx.cpp b/protocols/EmLanProto/src/stdafx.cxx
index fc3e963191..e8691edb87 100644
--- a/protocols/EmLanProto/src/stdafx.cpp
+++ b/protocols/EmLanProto/src/stdafx.cxx
@@ -1,8 +1,8 @@
-// stdafx.cpp : source file that includes just the standard includes
-// amdproto.pch will be the pre-compiled header
-// stdafx.obj will contain the pre-compiled type information
-
-#include "stdafx.h"
-
-// TODO: reference any additional headers you need in STDAFX.H
-// and not in this file
+// stdafx.cpp : source file that includes just the standard includes
+// amdproto.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+// TODO: reference any additional headers you need in STDAFX.H
+// and not in this file
diff --git a/protocols/EmLanProto/src/stdafx.h b/protocols/EmLanProto/src/stdafx.h
index d826592439..8fefd8f2f8 100644
--- a/protocols/EmLanProto/src/stdafx.h
+++ b/protocols/EmLanProto/src/stdafx.h
@@ -5,7 +5,6 @@
#pragma once
-#define _CRT_SECURE_NO_WARNINGS
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
diff --git a/protocols/EmLanProto/src/version.h b/protocols/EmLanProto/src/version.h
index 95d22389ca..4a9cf125ce 100644
--- a/protocols/EmLanProto/src/version.h
+++ b/protocols/EmLanProto/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 1
#define __RELEASE_NUM 0
-#define __BUILD_NUM 1
+#define __BUILD_NUM 2
#include <stdver.h>
#define __FILEVERSION_DWORD PLUGIN_MAKE_VERSION(__MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM)