diff options
-rw-r--r-- | bin10/lib/mir_core64.lib | bin | 25756 -> 25952 bytes | |||
-rw-r--r-- | include/m_idle.h | 1 | ||||
-rw-r--r-- | plugins/BasicHistory/HistoryWindow.cpp | 4 | ||||
-rw-r--r-- | plugins/SeenPlugin/utils.cpp | 26 | ||||
-rw-r--r-- | plugins/Svc_dbepp/moduletree.cpp | 3 | ||||
-rw-r--r-- | plugins/Updater/options.cpp | 9 | ||||
-rw-r--r-- | src/core/miranda.cpp | 2 | ||||
-rw-r--r-- | src/modules/autoaway/autoaway.cpp | 8 | ||||
-rw-r--r-- | src/modules/findadd/searchresults.cpp | 8 | ||||
-rw-r--r-- | src/modules/history/history.cpp | 2 | ||||
-rw-r--r-- | src/modules/idle/idle.cpp | 9 | ||||
-rw-r--r-- | src/modules/json/JSONMemory.cpp | 4 | ||||
-rw-r--r-- | src/modules/netlib/netlibopenconn.cpp | 438 | ||||
-rw-r--r-- | src/modules/srfile/fileexistsdlg.cpp | 14 | ||||
-rw-r--r-- | src/modules/srfile/filexferdlg.cpp | 9 | ||||
-rw-r--r-- | src/resource.h | 1 | ||||
-rw-r--r-- | src/resource.rc | 5 |
17 files changed, 234 insertions, 309 deletions
diff --git a/bin10/lib/mir_core64.lib b/bin10/lib/mir_core64.lib Binary files differindex bd6041429f..dd57837e1c 100644 --- a/bin10/lib/mir_core64.lib +++ b/bin10/lib/mir_core64.lib diff --git a/include/m_idle.h b/include/m_idle.h index 57394c9cc9..5fed10c55a 100644 --- a/include/m_idle.h +++ b/include/m_idle.h @@ -57,6 +57,7 @@ typedef struct { int aaStatus; // status to go to when user is auto away
int aaLock; // the status shouldn't be unset if its set
int idleType;
+ int idlesoundsoff;
}
MIRANDA_IDLE_INFO;
diff --git a/plugins/BasicHistory/HistoryWindow.cpp b/plugins/BasicHistory/HistoryWindow.cpp index 55cef0da86..d5c3948cb7 100644 --- a/plugins/BasicHistory/HistoryWindow.cpp +++ b/plugins/BasicHistory/HistoryWindow.cpp @@ -39,8 +39,8 @@ extern char* metaContactProto; void ResetCList(HWND hWnd);
-HistoryWindow::HistoryWindow(HANDLE _hContact)
- : isDestroyed(true),
+HistoryWindow::HistoryWindow(HANDLE _hContact) :
+ isDestroyed(true),
OldSplitterProc(0),
splitterY(0),
splitterOrgY(0),
diff --git a/plugins/SeenPlugin/utils.cpp b/plugins/SeenPlugin/utils.cpp index e33d6edfa0..533882977e 100644 --- a/plugins/SeenPlugin/utils.cpp +++ b/plugins/SeenPlugin/utils.cpp @@ -596,36 +596,22 @@ int addContactToQueue(HANDLE hContact){ static DWORD __stdcall waitThread(logthread_info* infoParam)
{
-// char str[MAXMODULELABELLENGTH];
-// sprintf(str,"In Thread: %s; %s; %s\n",
-// infoParam->sProtoName,
-// (char *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)infoParam->hContact,0),
-// (const char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,(WPARAM)infoParam->courStatus,0)
-// );
-// OutputDebugStringA(str);
WORD prevStatus = DBGetContactSettingWord(infoParam->hContact,S_MOD,"StatusTriger",ID_STATUS_OFFLINE);
Sleep(1500); // I hope in 1.5 second all the needed info will be set
- if (includeIdle){
- if (DBGetContactSettingDword(infoParam->hContact,infoParam->sProtoName,"IdleTS",0)) {
+ if (includeIdle)
+ if (DBGetContactSettingDword(infoParam->hContact,infoParam->sProtoName,"IdleTS",0))
infoParam->courStatus &=0x7FFF;
- }
- }
+
if (infoParam->courStatus != prevStatus){
DBWriteContactSettingWord(infoParam->hContact,S_MOD,"OldStatus",(WORD)(prevStatus|0x8000));
- if (includeIdle){
+ if (includeIdle)
DBWriteContactSettingByte(infoParam->hContact,S_MOD,"OldIdle",(BYTE)((prevStatus&0x8000)==0));
- }
+
DBWriteContactSettingWord(infoParam->hContact,S_MOD,"StatusTriger",infoParam->courStatus);
}
-// sprintf(str,"OutThread: %s; %s; %s\n",
-// infoParam->sProtoName,
-// (char *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)infoParam->hContact,0),
-// (const char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,(WPARAM)infoParam->courStatus,0)
-// );
-// infoParam->hContact = 0; //declare the slot as empty
+
contactQueue[infoParam->queueIndex] = 0;
free(infoParam);
-// OutputDebugStringA(str);
return 0;
}
diff --git a/plugins/Svc_dbepp/moduletree.cpp b/plugins/Svc_dbepp/moduletree.cpp index c927851ecc..b5554cabc5 100644 --- a/plugins/Svc_dbepp/moduletree.cpp +++ b/plugins/Svc_dbepp/moduletree.cpp @@ -462,10 +462,8 @@ void replaceTreeItem(HWND hwnd, HANDLE hContact, const char *module, const char TreeView_InsertItem(hwnd, &tvi);
}
-
}
-
void refreshTree(int restore)
{
UseKnownModList = DBGetContactSettingByte(NULL,modname,"UseKnownModList",0);
@@ -474,7 +472,6 @@ void refreshTree(int restore) forkthread(PopulateModuleTreeThreadFunc,0,(HWND)restore);
}
-
void __cdecl PopulateModuleTreeThreadFunc(LPVOID di)
{
TVINSERTSTRUCT tvi;
diff --git a/plugins/Updater/options.cpp b/plugins/Updater/options.cpp index 15e1d69754..e440cd684e 100644 --- a/plugins/Updater/options.cpp +++ b/plugins/Updater/options.cpp @@ -388,14 +388,11 @@ int OptInit(WPARAM wParam,LPARAM lParam) return 0;
}
-
-#define DBGetString DBGetContactSettingTString
-#define DBWriteString DBWriteContactSettingTString
-
-
-void InitOptionsMenuItems() {
+void InitOptionsMenuItems()
+{
if(options.restart_menu_item)
add_restart_menu_item();
+
if(options.update_and_exit_menu_item)
add_update_and_exit_menu_item();
}
diff --git a/src/core/miranda.cpp b/src/core/miranda.cpp index 2e0759c04d..a04846b217 100644 --- a/src/core/miranda.cpp +++ b/src/core/miranda.cpp @@ -112,6 +112,8 @@ INT_PTR MirandaIsTerminated(WPARAM, LPARAM) static void __cdecl compactHeapsThread(void*)
{
+ Thread_SetName("compactHeapsThread");
+
while ( !Miranda_Terminated()) {
HANDLE hHeaps[256];
DWORD hc;
diff --git a/src/modules/autoaway/autoaway.cpp b/src/modules/autoaway/autoaway.cpp index 764cd3e965..46aadca316 100644 --- a/src/modules/autoaway/autoaway.cpp +++ b/src/modules/autoaway/autoaway.cpp @@ -64,6 +64,14 @@ static int AutoAwayEvent(WPARAM, LPARAM lParam) Proto_SetStatus(pa->szModuleName, ID_STATUS_ONLINE);
} } }
+ if ((lParam&IDF_ISIDLE) && mii.idlesoundsoff && DBGetContactSettingByte(0, "Skin", "UseSound", 1)) {
+ BYTE oldsound = DBGetContactSettingByte(0, "Skin", "UseSound", 1);
+ DBWriteContactSettingByte(NULL, "Skin", "UseSound", 0);
+ DBWriteContactSettingByte(NULL, AA_MODULE, "OldSound", oldsound);
+ }
+ else if (!(lParam & IDF_ISIDLE) && mii.idlesoundsoff)
+ DBWriteContactSettingByte(NULL, "Skin", "UseSound", DBGetContactSettingByte(NULL, AA_MODULE, "OldSound", 1));
+
return 0;
}
diff --git a/src/modules/findadd/searchresults.cpp b/src/modules/findadd/searchresults.cpp index 5352bfd6a7..e579c9888b 100644 --- a/src/modules/findadd/searchresults.cpp +++ b/src/modules/findadd/searchresults.cpp @@ -207,12 +207,11 @@ static void BeginSearchFailed(void * arg) int BeginSearch(HWND, struct FindAddDlgData *dat, const char *szProto, const char *szSearchService, DWORD requiredCapability, void *pvSearchParams)
{
- int i;
if (szProto == NULL) {
int failures = 0;
dat->searchCount = 0;
dat->search = (struct ProtoSearchInfo*)mir_calloc(sizeof(struct ProtoSearchInfo) * accounts.getCount());
- for (i=0; i < accounts.getCount();i++) {
+ for (int i=0; i < accounts.getCount();i++) {
PROTOACCOUNT* pa = accounts[i];
if ( !Proto_IsAccountEnabled(pa)) continue;
DWORD caps=(DWORD)CallProtoServiceInt(NULL,pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0);
@@ -229,7 +228,8 @@ int BeginSearch(HWND, struct FindAddDlgData *dat, const char *szProto, const cha mir_free(dat->search);
dat->search=NULL;
return 1;
- } }
+ }
+ }
}
else {
dat->search=(struct ProtoSearchInfo*)mir_alloc(sizeof(struct ProtoSearchInfo));
@@ -238,7 +238,7 @@ int BeginSearch(HWND, struct FindAddDlgData *dat, const char *szProto, const cha dat->search[0].szProto=szProto;
if (dat->search[0].hProcess == NULL) {
//infuriatingly vague error message. fixme.
- PROTOACCOUNT* pa = Proto_GetAccount(szProto);
+ PROTOACCOUNT* pa = Proto_GetAccount(szProto);
forkthread(BeginSearchFailed, 0, mir_tstrdup(pa->tszAccountName));
mir_free(dat->search);
dat->search=NULL;
diff --git a/src/modules/history/history.cpp b/src/modules/history/history.cpp index 218b040d01..403ffecd79 100644 --- a/src/modules/history/history.cpp +++ b/src/modules/history/history.cpp @@ -184,6 +184,8 @@ typedef struct { static void FillHistoryThread(void* param)
{
+ Thread_SetName("HistoryWindow::FillHistoryThread");
+
TCHAR str[200], eventText[256], strdatetime[64];
HANDLE hDbEvent;
DBEVENTINFO dbei;
diff --git a/src/modules/idle/idle.cpp b/src/modules/idle/idle.cpp index 2577812207..dfd2fdf628 100644 --- a/src/modules/idle/idle.cpp +++ b/src/modules/idle/idle.cpp @@ -35,6 +35,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define IDL_IDLESTATUSLOCK "IdleStatusLock" // IDC_IDLESTATUSLOCK
#define IDL_AAENABLE "AAEnable"
#define IDL_AASTATUS "AAStatus"
+#define IDL_IDLESOUNDSOFF "IdleSoundsOff"
#define IdleObject_IsIdle(obj) (obj->state&0x1)
#define IdleObject_SetIdle(obj) (obj->state|=0x1)
@@ -152,6 +153,7 @@ typedef struct { unsigned int mouseidle;
int aastatus;
int idleType;
+ int aasoundsoff;
}
IdleObject;
@@ -168,6 +170,10 @@ static void IdleObject_ReadSettings(IdleObject * obj) obj->useridlecheck = DBGetContactSettingByte(NULL, IDLEMOD, IDL_USERIDLECHECK, 0);
obj->minutes = DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLETIME1ST, 10);
obj->aastatus = !DBGetContactSettingByte(NULL, IDLEMOD, IDL_AAENABLE, 0) ? 0 : DBGetContactSettingWord(NULL, IDLEMOD, IDL_AASTATUS, 0);
+ if (DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLESOUNDSOFF, 1))
+ obj->aasoundsoff = 1;
+ else
+ obj->aasoundsoff = 0;
if (DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLEMETHOD, 0)) IdleObject_UseMethod1(obj);
else IdleObject_UseMethod0(obj);
if (DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLEONSAVER, 0)) IdleObject_SetSaverCheck(obj);
@@ -358,6 +364,7 @@ static INT_PTR CALLBACK IdleOptsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L EnableWindow(GetDlgItem(hwndDlg, IDC_IDLETERMINAL), FALSE);
else
CheckDlgButton(hwndDlg, IDC_IDLETERMINAL, DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLEONTSDC, 0) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_IDLESOUNDSOFF, DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLESOUNDSOFF, 1) ? BST_CHECKED : BST_UNCHECKED);
SendDlgItemMessage(hwndDlg, IDC_IDLESPIN, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, IDC_IDLE1STTIME), 0);
SendDlgItemMessage(hwndDlg, IDC_IDLESPIN, UDM_SETRANGE32, 1, 60);
SendDlgItemMessage(hwndDlg, IDC_IDLESPIN, UDM_SETPOS, 0, MAKELONG((short) DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLETIME1ST, 10), 0));
@@ -404,6 +411,7 @@ static INT_PTR CALLBACK IdleOptsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L DBWriteContactSettingWord(NULL, IDLEMOD, IDL_AASTATUS, (WORD)(aa_Status[curSel]));
}
}
+ DBWriteContactSettingByte(NULL, IDLEMOD, IDL_IDLESOUNDSOFF, (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_IDLESOUNDSOFF) == BST_CHECKED));
// destroy any current idle and reset settings.
IdleObject_Destroy(&gIdleObject);
IdleObject_Create(&gIdleObject);
@@ -461,6 +469,7 @@ static INT_PTR IdleGetInfo(WPARAM, LPARAM lParam) mii->privacy = gIdleObject.state&0x10;
mii->aaStatus = gIdleObject.aastatus;
mii->aaLock = gIdleObject.state&0x20;
+ mii->idlesoundsoff = gIdleObject.aasoundsoff;
if (mii->cbSize == sizeof(MIRANDA_IDLE_INFO))
mii->idleType = gIdleObject.idleType;
diff --git a/src/modules/json/JSONMemory.cpp b/src/modules/json/JSONMemory.cpp index bd9cd045a2..08b6d7fd70 100644 --- a/src/modules/json/JSONMemory.cpp +++ b/src/modules/json/JSONMemory.cpp @@ -58,7 +58,7 @@ void * JSONMemory::json_malloc(size_t siz){ JSON_ASSERT(result, JSON_TEXT("out of memory")); return result; #else - return mymalloc(siz); + return mymalloc((unsigned long)siz); #endif } #ifdef JSON_DEBUG //in debug mode, see if the malloc was successful @@ -77,7 +77,7 @@ void * JSONMemory::json_realloc(void * ptr, size_t siz){ JSON_ASSERT(result, JSON_TEXT("out of memory")); return result; #else - return myrealloc(ptr, siz); + return myrealloc(ptr, (unsigned long)siz); #endif } #ifdef JSON_DEBUG //in debug mode, see if the malloc was successful diff --git a/src/modules/netlib/netlibopenconn.cpp b/src/modules/netlib/netlibopenconn.cpp index 3bc19e684f..b96c27aa4d 100644 --- a/src/modules/netlib/netlibopenconn.cpp +++ b/src/modules/netlib/netlibopenconn.cpp @@ -81,8 +81,7 @@ int WaitUntilWritable(SOCKET s, DWORD dwTimeout) FD_ZERO(&writefd);
FD_SET(s, &writefd);
- switch(select(0, 0, &writefd, 0, &tv))
- {
+ switch(select(0, 0, &writefd, 0, &tv)) {
case 0:
SetLastError(ERROR_TIMEOUT);
case SOCKET_ERROR:
@@ -96,8 +95,7 @@ bool RecvUntilTimeout(struct NetlibConnection *nlc, char *buf, int len, int flag int nReceived = 0;
DWORD dwTimeNow, dwCompleteTime = GetTickCount() + dwTimeout;
- while ((dwTimeNow = GetTickCount()) < dwCompleteTime)
- {
+ while ((dwTimeNow = GetTickCount()) < dwCompleteTime) {
if (WaitUntilReadable(nlc->s, dwCompleteTime - dwTimeNow) <= 0) return false;
nReceived = NLRecv(nlc, buf, len, flags);
if (nReceived <= 0) return false;
@@ -130,39 +128,36 @@ static int NetlibInitSocks4Connection(NetlibConnection *nlc, NetlibUser *nlu, NE //if cannot resolve host, try resolving through proxy (requires SOCKS4a)
DWORD ip = DnsLookup(nlu, nloc->szHost);
*(PDWORD)&pInit[4] = ip ? ip : 0x01000000;
- if ( !ip)
- {
+ if ( !ip) {
memcpy(&pInit[len], nloc->szHost, nHostLen);
len += nHostLen;
}
- if (NLSend(nlc, pInit, (int)len, MSG_DUMPPROXY) == SOCKET_ERROR)
- {
+ if (NLSend(nlc, pInit, (int)len, MSG_DUMPPROXY) == SOCKET_ERROR) {
NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "NLSend", GetLastError());
return 0;
}
char reply[8];
- if ( !RecvUntilTimeout(nlc, reply, sizeof(reply), MSG_DUMPPROXY, RECV_DEFAULT_TIMEOUT))
- {
+ if ( !RecvUntilTimeout(nlc, reply, sizeof(reply), MSG_DUMPPROXY, RECV_DEFAULT_TIMEOUT)) {
NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "RecvUntilTimeout", GetLastError());
return 0;
}
- switch ((BYTE)reply[1])
- {
- case 90: return 1;
- case 91: SetLastError(ERROR_ACCESS_DENIED); break;
- case 92: SetLastError(ERROR_CONNECTION_UNAVAIL); break;
- case 93: SetLastError(ERROR_INVALID_ACCESS); break;
- default: SetLastError(ERROR_INVALID_DATA); break;
+ switch ((BYTE)reply[1]) {
+ case 90: return 1;
+ case 91: SetLastError(ERROR_ACCESS_DENIED); break;
+ case 92: SetLastError(ERROR_CONNECTION_UNAVAIL); break;
+ case 93: SetLastError(ERROR_INVALID_ACCESS); break;
+ default: SetLastError(ERROR_INVALID_DATA); break;
}
NetlibLogf(nlu, "%s %d: Proxy connection failed (%x %u)", __FILE__, __LINE__, (BYTE)reply[1], GetLastError());
return 0;
}
static int NetlibInitSocks5Connection(struct NetlibConnection *nlc, struct NetlibUser *nlu, NETLIBOPENCONNECTION *nloc)
-{ //rfc1928
+{
+ //rfc1928
BYTE buf[258];
buf[0]=5; //yep, socks5
@@ -214,46 +209,42 @@ static int NetlibInitSocks5Connection(struct NetlibConnection *nlc, struct Netli }
}
- {
- PBYTE pInit;
- int nHostLen;
- DWORD hostIP;
+ PBYTE pInit;
+ int nHostLen;
+ DWORD hostIP;
- if (nlc->dnsThroughProxy)
- {
- hostIP = inet_addr(nloc->szHost);
- if (hostIP == INADDR_NONE)
- nHostLen = lstrlenA(nloc->szHost)+1;
- else nHostLen = 4;
- }
- else
- {
- hostIP = DnsLookup(nlu, nloc->szHost);
- if (hostIP == 0)
- return 0;
- nHostLen = 4;
- }
- pInit=(PBYTE)mir_alloc(6+nHostLen);
- pInit[0]=5; //SOCKS5
- pInit[1]= nloc->flags & NLOCF_UDP ? 3 : 1; //connect or UDP
- pInit[2]=0; //reserved
- if (hostIP == INADDR_NONE) { //DNS lookup through proxy
- pInit[3]=3;
- pInit[4]=nHostLen-1;
- memcpy(pInit+5, nloc->szHost, nHostLen-1);
- }
- else {
- pInit[3]=1;
- *(PDWORD)(pInit+4)=hostIP;
- }
- *(PWORD)(pInit+4+nHostLen)=htons(nloc->wPort);
- if (NLSend(nlc, (char*)pInit, 6+nHostLen, MSG_DUMPPROXY) == SOCKET_ERROR) {
- NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "NLSend", GetLastError());
- mir_free(pInit);
+ if (nlc->dnsThroughProxy) {
+ hostIP = inet_addr(nloc->szHost);
+ if (hostIP == INADDR_NONE)
+ nHostLen = lstrlenA(nloc->szHost)+1;
+ else nHostLen = 4;
+ }
+ else {
+ hostIP = DnsLookup(nlu, nloc->szHost);
+ if (hostIP == 0)
return 0;
- }
+ nHostLen = 4;
+ }
+ pInit=(PBYTE)mir_alloc(6+nHostLen);
+ pInit[0]=5; //SOCKS5
+ pInit[1]= nloc->flags & NLOCF_UDP ? 3 : 1; //connect or UDP
+ pInit[2]=0; //reserved
+ if (hostIP == INADDR_NONE) { //DNS lookup through proxy
+ pInit[3]=3;
+ pInit[4]=nHostLen-1;
+ memcpy(pInit+5, nloc->szHost, nHostLen-1);
+ }
+ else {
+ pInit[3]=1;
+ *(PDWORD)(pInit+4)=hostIP;
+ }
+ *(PWORD)(pInit+4+nHostLen)=htons(nloc->wPort);
+ if (NLSend(nlc, (char*)pInit, 6+nHostLen, MSG_DUMPPROXY) == SOCKET_ERROR) {
+ NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "NLSend", GetLastError());
mir_free(pInit);
+ return 0;
}
+ mir_free(pInit);
if ( !RecvUntilTimeout(nlc, (char*)buf, 5, MSG_DUMPPROXY, RECV_DEFAULT_TIMEOUT)) {
NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "RecvUntilTimeout", GetLastError());
@@ -264,52 +255,50 @@ static int NetlibInitSocks5Connection(struct NetlibConnection *nlc, struct Netli const char* err = "Unknown response";
if (buf[0] != 5)
SetLastError(ERROR_BAD_FORMAT);
- else
- {
- switch(buf[1])
- {
- case 1: SetLastError(ERROR_GEN_FAILURE); err = "General failure"; break;
- case 2: SetLastError(ERROR_ACCESS_DENIED); err = "Connection not allowed by ruleset"; break;
- case 3: SetLastError(WSAENETUNREACH); err = "Network unreachable"; break;
- case 4: SetLastError(WSAEHOSTUNREACH); err = "Host unreachable"; break;
- case 5: SetLastError(WSAECONNREFUSED); err = "Connection refused by destination host"; break;
- case 6: SetLastError(WSAETIMEDOUT); err = "TTL expired"; break;
- case 7: SetLastError(ERROR_CALL_NOT_IMPLEMENTED); err = "Command not supported / protocol error"; break;
- case 8: SetLastError(ERROR_INVALID_ADDRESS); err = "Address type not supported"; break;
- default: SetLastError(ERROR_INVALID_DATA); break;
+ else {
+ switch(buf[1]) {
+ case 1: SetLastError(ERROR_GEN_FAILURE); err = "General failure"; break;
+ case 2: SetLastError(ERROR_ACCESS_DENIED); err = "Connection not allowed by ruleset"; break;
+ case 3: SetLastError(WSAENETUNREACH); err = "Network unreachable"; break;
+ case 4: SetLastError(WSAEHOSTUNREACH); err = "Host unreachable"; break;
+ case 5: SetLastError(WSAECONNREFUSED); err = "Connection refused by destination host"; break;
+ case 6: SetLastError(WSAETIMEDOUT); err = "TTL expired"; break;
+ case 7: SetLastError(ERROR_CALL_NOT_IMPLEMENTED); err = "Command not supported / protocol error"; break;
+ case 8: SetLastError(ERROR_INVALID_ADDRESS); err = "Address type not supported"; break;
+ default: SetLastError(ERROR_INVALID_DATA); break;
}
}
NetlibLogf(nlu, "%s %d: Proxy conection failed. %s.", __FILE__, __LINE__, err);
return 0;
}
- {
- int nRecvSize = 0;
- switch(buf[3]) {
- case 1:// ipv4 addr
- nRecvSize = 5;
- break;
- case 3:// dns name addr
- nRecvSize = buf[4] + 2;
- break;
- case 4:// ipv6 addr
- nRecvSize = 17;
- break;
- default:
- NetlibLogf(nlu, "%s %d: %s() unknown address type (%u)", __FILE__, __LINE__, "NetlibInitSocks5Connection", (int)buf[3]);
- return 0;
- }
- if ( !RecvUntilTimeout(nlc, (char*)buf, nRecvSize, MSG_DUMPPROXY, RECV_DEFAULT_TIMEOUT)) {
- NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "RecvUntilTimeout", GetLastError());
- return 0;
- }
+
+ int nRecvSize = 0;
+ switch(buf[3]) {
+ case 1:// ipv4 addr
+ nRecvSize = 5;
+ break;
+ case 3:// dns name addr
+ nRecvSize = buf[4] + 2;
+ break;
+ case 4:// ipv6 addr
+ nRecvSize = 17;
+ break;
+ default:
+ NetlibLogf(nlu, "%s %d: %s() unknown address type (%u)", __FILE__, __LINE__, "NetlibInitSocks5Connection", (int)buf[3]);
+ return 0;
}
+ if ( !RecvUntilTimeout(nlc, (char*)buf, nRecvSize, MSG_DUMPPROXY, RECV_DEFAULT_TIMEOUT)) {
+ NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "RecvUntilTimeout", GetLastError());
+ return 0;
+ }
//connected
return 1;
}
static bool NetlibInitHttpsConnection(struct NetlibConnection *nlc, struct NetlibUser *nlu, NETLIBOPENCONNECTION *nloc)
-{ //rfc2817
+{
+ //rfc2817
NETLIBHTTPREQUEST nlhrSend = {0}, *nlhrReply;
char szUrl[512];
@@ -317,11 +306,8 @@ static bool NetlibInitHttpsConnection(struct NetlibConnection *nlc, struct Netli nlhrSend.requestType = REQUEST_CONNECT;
nlhrSend.flags = NLHRF_GENERATEHOST | NLHRF_DUMPPROXY | NLHRF_SMARTAUTHHEADER | NLHRF_HTTP11 | NLHRF_NOPROXY | NLHRF_REDIRECT;
if (nlc->dnsThroughProxy)
- {
mir_snprintf(szUrl, SIZEOF(szUrl), "%s:%u", nloc->szHost, nloc->wPort);
- }
- else
- {
+ else {
DWORD ip = DnsLookup(nlu, nloc->szHost);
if (ip == 0) return false;
mir_snprintf(szUrl, SIZEOF(szUrl), "%s:%u", inet_ntoa(*(PIN_ADDR)&ip), nloc->wPort);
@@ -330,18 +316,18 @@ static bool NetlibInitHttpsConnection(struct NetlibConnection *nlc, struct Netli nlc->usingHttpGateway = true;
- if (NetlibHttpSendRequest((WPARAM)nlc, (LPARAM)&nlhrSend) == SOCKET_ERROR)
- {
+ if (NetlibHttpSendRequest((WPARAM)nlc, (LPARAM)&nlhrSend) == SOCKET_ERROR) {
nlc->usingHttpGateway = false;
return 0;
}
+
nlhrReply = NetlibHttpRecv(nlc, MSG_DUMPPROXY | MSG_RAW, MSG_DUMPPROXY | MSG_RAW, true);
nlc->usingHttpGateway = false;
- if (nlhrReply == NULL) return false;
- if (nlhrReply->resultCode < 200 || nlhrReply->resultCode >= 300)
- {
- if (nlhrReply->resultCode == 403 && nlc->dnsThroughProxy)
- {
+ if (nlhrReply == NULL)
+ return false;
+
+ if (nlhrReply->resultCode < 200 || nlhrReply->resultCode >= 300) {
+ if (nlhrReply->resultCode == 403 && nlc->dnsThroughProxy) {
NetlibHttpFreeRequestStruct(0, (LPARAM)nlhrReply);
nlc->dnsThroughProxy = 0;
return NetlibInitHttpsConnection(nlc, nlu, nloc);
@@ -386,8 +372,7 @@ static bool my_connectIPv4(NetlibConnection *nlc, NETLIBOPENCONNECTION * nloc) if (dwTimeout == 0) dwTimeout = 30;
// this is for XP SP2 where there is a default connection attempt limit of 10/second
- if (connectionTimeout)
- {
+ if (connectionTimeout) {
WaitForSingleObject(hConnectionOpenMutex, 10000);
int waitdiff = GetTickCount() - g_LastConnectionTick;
if (waitdiff < connectionTimeout) SleepEx(connectionTimeout, TRUE);
@@ -402,8 +387,7 @@ static bool my_connectIPv4(NetlibConnection *nlc, NETLIBOPENCONNECTION * nloc) SOCKADDR_IN sin = {0};
sin.sin_family = AF_INET;
- if (nlc->proxyType)
- {
+ if (nlc->proxyType) {
if ( !nlc->szProxyServer) return false;
if (nloc)
@@ -414,8 +398,7 @@ static bool my_connectIPv4(NetlibConnection *nlc, NETLIBOPENCONNECTION * nloc) sin.sin_port = htons(nlc->wProxyPort);
he = gethostbyname(nlc->szProxyServer);
}
- else
- {
+ else {
if ( !nloc || !nloc->szHost || nloc->szHost[0] == '[' || strchr(nloc->szHost, ':')) return false;
NetlibLogf(nlc->nlu, "(%p) Connecting to server %s:%d....", nlc, nloc->szHost, nloc->wPort);
@@ -423,8 +406,7 @@ static bool my_connectIPv4(NetlibConnection *nlc, NETLIBOPENCONNECTION * nloc) he = gethostbyname(nloc->szHost);
}
- for (char** har = he->h_addr_list; *har && !Miranda_Terminated(); ++har)
- {
+ for (char** har = he->h_addr_list; *har && !Miranda_Terminated(); ++har) {
sin.sin_addr.s_addr = *(u_long*)*har;
char* szIp = NetlibAddressToString((SOCKADDR_INET_M*)&sin);
@@ -433,36 +415,33 @@ static bool my_connectIPv4(NetlibConnection *nlc, NETLIBOPENCONNECTION * nloc) retry:
nlc->s = socket(AF_INET, nloc->flags & NLOCF_UDP ? SOCK_DGRAM : SOCK_STREAM, 0);
- if (nlc->s == INVALID_SOCKET) return false;
+ if (nlc->s == INVALID_SOCKET)
+ return false;
// return the socket to non blocking
- if (ioctlsocket(nlc->s, FIONBIO, ¬blocking) != 0) return false;
+ if (ioctlsocket(nlc->s, FIONBIO, ¬blocking) != 0)
+ return false;
- if (nlc->nlu->settings.specifyOutgoingPorts && nlc->nlu->settings.szOutgoingPorts && nlc->nlu->settings.szOutgoingPorts[0])
- {
+ if (nlc->nlu->settings.specifyOutgoingPorts && nlc->nlu->settings.szOutgoingPorts && nlc->nlu->settings.szOutgoingPorts[0]) {
if ( !BindSocketToPort(nlc->nlu->settings.szOutgoingPorts, nlc->s, INVALID_SOCKET, &nlc->nlu->inportnum))
NetlibLogf(nlc->nlu, "Netlib connect: Not enough ports for outgoing connections specified");
}
// try a connect
- if (connect(nlc->s, (LPSOCKADDR)&sin, sizeof(sin)) == 0)
- {
+ if (connect(nlc->s, (LPSOCKADDR)&sin, sizeof(sin)) == 0) {
rc = 0;
break;
}
// didn't work, was it cos of nonblocking?
- if (WSAGetLastError() != WSAEWOULDBLOCK)
- {
+ if (WSAGetLastError() != WSAEWOULDBLOCK) {
rc = SOCKET_ERROR;
-
closesocket(nlc->s);
nlc->s = INVALID_SOCKET;
continue;
}
- for (;;)
- {
+ while (true) {
fd_set r, w, e;
FD_ZERO(&r); FD_ZERO(&w); FD_ZERO(&e);
FD_SET(nlc->s, &r);
@@ -471,48 +450,39 @@ retry: if ((rc = select(0, &r, &w, &e, &tv)) == SOCKET_ERROR)
break;
- if (rc > 0)
- {
- if (FD_ISSET(nlc->s, &w))
- {
+ if (rc > 0) {
+ if (FD_ISSET(nlc->s, &w)){
// connection was successful
rc = 0;
}
- if (FD_ISSET(nlc->s, &r))
- {
+ if (FD_ISSET(nlc->s, &r)) {
// connection was closed
rc = SOCKET_ERROR;
lasterr = WSAECONNRESET;
}
- if (FD_ISSET(nlc->s, &e))
- {
+ if (FD_ISSET(nlc->s, &e)) {
// connection failed.
int len = sizeof(lasterr);
rc = SOCKET_ERROR;
getsockopt(nlc->s, SOL_SOCKET, SO_ERROR, (char*)&lasterr, &len);
- if (lasterr == WSAEADDRINUSE && ++retrycnt <= 2)
- {
+ if (lasterr == WSAEADDRINUSE && ++retrycnt <= 2) {
closesocket(nlc->s);
goto retry;
}
}
break;
}
- else if (Miranda_Terminated())
- {
+ else if (Miranda_Terminated()) {
rc = SOCKET_ERROR;
lasterr = ERROR_TIMEOUT;
break;
}
- else if (nloc->cbSize == sizeof(NETLIBOPENCONNECTION) && nloc->flags & NLOCF_V2 &&
- nloc->waitcallback != NULL && nloc->waitcallback(&dwTimeout) == 0)
- {
+ else if (nloc->cbSize == sizeof(NETLIBOPENCONNECTION) && nloc->flags & NLOCF_V2 && nloc->waitcallback != NULL && nloc->waitcallback(&dwTimeout) == 0) {
rc = SOCKET_ERROR;
lasterr = ERROR_TIMEOUT;
break;
}
- if (--dwTimeout == 0)
- {
+ if (--dwTimeout == 0) {
rc = SOCKET_ERROR;
lasterr = ERROR_TIMEOUT;
break;
@@ -543,8 +513,7 @@ static bool my_connectIPv6(NetlibConnection *nlc, NETLIBOPENCONNECTION * nloc) if (dwTimeout == 0) dwTimeout = 30;
// this is for XP SP2 where there is a default connection attempt limit of 10/second
- if (connectionTimeout)
- {
+ if (connectionTimeout) {
WaitForSingleObject(hConnectionOpenMutex, 10000);
int waitdiff = GetTickCount() - g_LastConnectionTick;
if (waitdiff < connectionTimeout) SleepEx(connectionTimeout, TRUE);
@@ -560,20 +529,18 @@ static bool my_connectIPv6(NetlibConnection *nlc, NETLIBOPENCONNECTION * nloc) hints.ai_family = AF_UNSPEC;
- if (nloc->flags & NLOCF_UDP)
- {
+ if (nloc->flags & NLOCF_UDP) {
hints.ai_socktype = SOCK_DGRAM;
hints.ai_protocol = IPPROTO_UDP;
}
- else
- {
+ else {
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
}
- if (nlc->proxyType)
- {
- if ( !nlc->szProxyServer) return false;
+ if (nlc->proxyType) {
+ if ( !nlc->szProxyServer)
+ return false;
if (nloc)
NetlibLogf(nlc->nlu, "(%p) Connecting to proxy %s:%d for %s:%d ....", nlc, nlc->szProxyServer, nlc->wProxyPort, nloc->szHost, nloc->wPort);
@@ -581,40 +548,39 @@ static bool my_connectIPv6(NetlibConnection *nlc, NETLIBOPENCONNECTION * nloc) NetlibLogf(nlc->nlu, "(%p) Connecting to proxy %s:%d ....", nlc, nlc->szProxyServer, nlc->wProxyPort);
_itoa(nlc->wProxyPort, szPort, 10);
- if (MyGetaddrinfo(nlc->szProxyServer, szPort, &hints, &air))
- {
+ if (MyGetaddrinfo(nlc->szProxyServer, szPort, &hints, &air)) {
NetlibLogf(nlc->nlu, "%s %d: %s() for host %s failed (%u)", __FILE__, __LINE__, "getaddrinfo", nlc->szProxyServer, WSAGetLastError());
return false;
}
}
- else
- {
- if ( !nloc || !nloc->szHost) return false;
+ else {
+ if ( !nloc || !nloc->szHost)
+ return false;
+
NetlibLogf(nlc->nlu, "(%p) Connecting to server %s:%d....", nlc, nloc->szHost, nloc->wPort);
_itoa(nlc->nloc.wPort, szPort, 10);
- if (MyGetaddrinfo(nlc->nloc.szHost, szPort, &hints, &air))
- {
+ if (MyGetaddrinfo(nlc->nloc.szHost, szPort, &hints, &air)) {
NetlibLogf(nlc->nlu, "%s %d: %s() for host %s failed (%u)", __FILE__, __LINE__, "getaddrinfo", nlc->nloc.szHost, WSAGetLastError());
return false;
}
}
- for (ai = air; ai && !Miranda_Terminated(); ai = ai->ai_next)
- {
+ for (ai = air; ai && !Miranda_Terminated(); ai = ai->ai_next) {
char* szIp = NetlibAddressToString((SOCKADDR_INET_M*)ai->ai_addr);
NetlibLogf(nlc->nlu, "(%p) Connecting to ip %s ....", nlc, szIp);
mir_free(szIp);
retry:
nlc->s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
- if (nlc->s == INVALID_SOCKET) return false;
+ if (nlc->s == INVALID_SOCKET)
+ return false;
// return the socket to non blocking
- if (ioctlsocket(nlc->s, FIONBIO, ¬blocking) != 0) return false;
+ if (ioctlsocket(nlc->s, FIONBIO, ¬blocking) != 0)
+ return false;
- if (nlc->nlu->settings.specifyOutgoingPorts && nlc->nlu->settings.szOutgoingPorts && nlc->nlu->settings.szOutgoingPorts[0])
- {
+ if (nlc->nlu->settings.specifyOutgoingPorts && nlc->nlu->settings.szOutgoingPorts && nlc->nlu->settings.szOutgoingPorts[0]) {
SOCKET s = ai->ai_family == AF_INET ? nlc->s : INVALID_SOCKET;
SOCKET s6 = ai->ai_family == AF_INET6 ? nlc->s : INVALID_SOCKET;
if ( !BindSocketToPort(nlc->nlu->settings.szOutgoingPorts, s, s6, &nlc->nlu->inportnum))
@@ -622,24 +588,20 @@ retry: }
// try a connect
- if (connect(nlc->s, ai->ai_addr, (int)ai->ai_addrlen) == 0)
- {
+ if (connect(nlc->s, ai->ai_addr, (int)ai->ai_addrlen) == 0) {
rc = 0;
break;
}
// didn't work, was it cos of nonblocking?
- if (WSAGetLastError() != WSAEWOULDBLOCK)
- {
+ if (WSAGetLastError() != WSAEWOULDBLOCK) {
rc = SOCKET_ERROR;
-
closesocket(nlc->s);
nlc->s = INVALID_SOCKET;
continue;
}
- for (;;) // timeout loop
- {
+ while (true) { // timeout loop
fd_set r, w, e;
FD_ZERO(&r); FD_ZERO(&w); FD_ZERO(&e);
FD_SET(nlc->s, &r);
@@ -648,22 +610,18 @@ retry: if ((rc = select(0, &r, &w, &e, &tv)) == SOCKET_ERROR)
break;
- if (rc > 0)
- {
- if (FD_ISSET(nlc->s, &w))
- {
+ if (rc > 0) {
+ if (FD_ISSET(nlc->s, &w)){
// connection was successful
rc = 0;
lasterr = 0;
}
- if (FD_ISSET(nlc->s, &r))
- {
+ if (FD_ISSET(nlc->s, &r)) {
// connection was closed
rc = SOCKET_ERROR;
lasterr = WSAECONNRESET;
}
- if (FD_ISSET(nlc->s, &e))
- {
+ if (FD_ISSET(nlc->s, &e)) {
// connection failed.
int len = sizeof(lasterr);
rc = SOCKET_ERROR;
@@ -677,21 +635,17 @@ retry: }
break;
}
- else if (Miranda_Terminated())
- {
+ else if (Miranda_Terminated()) {
rc = SOCKET_ERROR;
lasterr = ERROR_TIMEOUT;
break;
}
- else if (nloc->cbSize == sizeof(NETLIBOPENCONNECTION) && nloc->flags & NLOCF_V2 &&
- nloc->waitcallback != NULL && nloc->waitcallback(&dwTimeout) == 0)
- {
+ else if (nloc->cbSize == sizeof(NETLIBOPENCONNECTION) && nloc->flags & NLOCF_V2 && nloc->waitcallback != NULL && nloc->waitcallback(&dwTimeout) == 0) {
rc = SOCKET_ERROR;
lasterr = ERROR_TIMEOUT;
break;
}
- if (--dwTimeout == 0)
- {
+ if (--dwTimeout == 0) {
rc = SOCKET_ERROR;
lasterr = ERROR_TIMEOUT;
break;
@@ -726,8 +680,7 @@ static int NetlibHttpFallbackToDirect(struct NetlibConnection *nlc, struct Netli nlc->proxyAuthNeeded = false;
nlc->proxyType = 0;
mir_free(nlc->szProxyServer); nlc->szProxyServer = NULL;
- if ( !my_connect(nlc, nloc))
- {
+ if ( !my_connect(nlc, nloc)) {
NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "connect", WSAGetLastError());
return false;
}
@@ -742,16 +695,11 @@ bool NetlibDoConnect(NetlibConnection *nlc) mir_free(nlc->szProxyServer); nlc->szProxyServer = NULL;
bool usingProxy = false, forceHttps = false;
- if (nlu->settings.useProxy)
- {
+ if (nlu->settings.useProxy) {
if (nlu->settings.proxyType == PROXYTYPE_IE)
- {
usingProxy = NetlibGetIeProxyConn(nlc, false);
- }
- else
- {
- if (nlu->settings.szProxyServer && nlu->settings.szProxyServer[0])
- {
+ else {
+ if (nlu->settings.szProxyServer && nlu->settings.szProxyServer[0]) {
nlc->szProxyServer = mir_strdup(nlu->settings.szProxyServer);
nlc->wProxyPort = nlu->settings.wProxyPort;
nlc->proxyType = nlu->settings.proxyType;
@@ -761,34 +709,26 @@ bool NetlibDoConnect(NetlibConnection *nlc) }
retry:
- if (usingProxy)
- {
- if ( !my_connect(nlc, nloc))
- {
+ if (usingProxy) {
+ if ( !my_connect(nlc, nloc)) {
usingProxy = false;
nlc->proxyType = 0;
}
}
+
if ( !usingProxy)
- {
my_connect(nlc, nloc);
- }
- if (nlc->s == INVALID_SOCKET)
- {
- if (usingProxy && (nlc->proxyType == PROXYTYPE_HTTPS || nlc->proxyType == PROXYTYPE_HTTP))
- {
+ if (nlc->s == INVALID_SOCKET) {
+ if (usingProxy && (nlc->proxyType == PROXYTYPE_HTTPS || nlc->proxyType == PROXYTYPE_HTTP)) {
usingProxy = false;
- if ( !NetlibHttpFallbackToDirect(nlc, nlu, nloc))
- {
+ if ( !NetlibHttpFallbackToDirect(nlc, nlu, nloc)) {
NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "connect", WSAGetLastError());
return false;
}
}
- else
- {
- if (nlu->settings.useProxy && !usingProxy && nlu->settings.proxyType == PROXYTYPE_IE && !forceHttps)
- {
+ else {
+ if (nlu->settings.useProxy && !usingProxy && nlu->settings.proxyType == PROXYTYPE_IE && !forceHttps) {
forceHttps = true;
usingProxy = NetlibGetIeProxyConn(nlc, true);
if (usingProxy) goto retry;
@@ -798,25 +738,24 @@ retry: }
}
- if (usingProxy && !((nloc->flags & (NLOCF_HTTP | NLOCF_SSL)) == NLOCF_HTTP &&
- (nlc->proxyType == PROXYTYPE_HTTP || nlc->proxyType == PROXYTYPE_HTTPS)))
- {
- if ( !WaitUntilWritable(nlc->s, 30000)) return false;
+ if (usingProxy && !((nloc->flags & (NLOCF_HTTP | NLOCF_SSL)) == NLOCF_HTTP && (nlc->proxyType == PROXYTYPE_HTTP || nlc->proxyType == PROXYTYPE_HTTPS))) {
+ if ( !WaitUntilWritable(nlc->s, 30000))
+ return false;
- switch (nlc->proxyType)
- {
+ switch (nlc->proxyType) {
case PROXYTYPE_SOCKS4:
- if ( !NetlibInitSocks4Connection(nlc, nlu, nloc)) return false;
+ if ( !NetlibInitSocks4Connection(nlc, nlu, nloc))
+ return false;
break;
case PROXYTYPE_SOCKS5:
- if ( !NetlibInitSocks5Connection(nlc, nlu, nloc)) return false;
+ if ( !NetlibInitSocks5Connection(nlc, nlu, nloc))
+ return false;
break;
case PROXYTYPE_HTTPS:
nlc->proxyAuthNeeded = true;
- if ( !NetlibInitHttpsConnection(nlc, nlu, nloc))
- {
+ if ( !NetlibInitHttpsConnection(nlc, nlu, nloc)) {
usingProxy = false;
if ( !NetlibHttpFallbackToDirect(nlc, nlu, nloc))
return false;
@@ -825,21 +764,18 @@ retry: case PROXYTYPE_HTTP:
nlc->proxyAuthNeeded = true;
- if ( !(nlu->user.flags & NUF_HTTPGATEWAY || nloc->flags & NLOCF_HTTPGATEWAY) || nloc->flags & NLOCF_SSL)
- {
+ if ( !(nlu->user.flags & NUF_HTTPGATEWAY || nloc->flags & NLOCF_HTTPGATEWAY) || nloc->flags & NLOCF_SSL) {
//NLOCF_HTTP not specified and no HTTP gateway available: try HTTPS
- if ( !NetlibInitHttpsConnection(nlc, nlu, nloc))
- {
+ if ( !NetlibInitHttpsConnection(nlc, nlu, nloc)) {
//can't do HTTPS: try direct
usingProxy = false;
if ( !NetlibHttpFallbackToDirect(nlc, nlu, nloc))
return false;
}
}
- else
- {
- if ( !NetlibInitHttpConnection(nlc, nlu, nloc)) return false;
- }
+ else if ( !NetlibInitHttpConnection(nlc, nlu, nloc))
+ return false;
+
break;
default:
@@ -848,8 +784,7 @@ retry: return false;
}
}
- else if (nloc->flags & NLOCF_HTTPGATEWAY)
- {
+ else if (nloc->flags & NLOCF_HTTPGATEWAY) {
if ( !NetlibInitHttpConnection(nlc, nlu, nloc)) return false;
nlc->usingDirectHttpGateway = true;
}
@@ -857,9 +792,7 @@ retry: NetlibLogf(nlu, "(%d) Connected to %s:%d", nlc->s, nloc->szHost, nloc->wPort);
if (NLOCF_SSL & nloc->flags)
- {
return NetlibStartSsl((WPARAM)nlc, 0) != 0;
- }
return true;
}
@@ -868,11 +801,8 @@ bool NetlibReconnect(NetlibConnection *nlc) {
char buf[4];
bool opened = nlc->s != INVALID_SOCKET;
-
- if (opened)
- {
- switch (WaitUntilReadable(nlc->s, 0, true))
- {
+ if (opened) {
+ switch (WaitUntilReadable(nlc->s, 0, true)) {
case SOCKET_ERROR:
opened = false;
break;
@@ -890,16 +820,15 @@ bool NetlibReconnect(NetlibConnection *nlc) NetlibDoClose(nlc, true);
}
- if ( !opened)
- {
- if (Miranda_Terminated()) return false;
- if (nlc->usingHttpGateway)
- {
+ if ( !opened) {
+ if (Miranda_Terminated())
+ return false;
+
+ if (nlc->usingHttpGateway) {
nlc->proxyAuthNeeded = true;
return my_connect(nlc, &nlc->nloc);
}
- else
- return NetlibDoConnect(nlc);
+ return NetlibDoConnect(nlc);
}
return true;
}
@@ -907,19 +836,18 @@ bool NetlibReconnect(NetlibConnection *nlc) INT_PTR NetlibOpenConnection(WPARAM wParam, LPARAM lParam)
{
NETLIBOPENCONNECTION *nloc = (NETLIBOPENCONNECTION*)lParam;
- struct NetlibUser *nlu = (struct NetlibUser*)wParam;
- struct NetlibConnection *nlc;
-
- NetlibLogf(nlu, "Connection request to %s:%d (Flags %x)....", nloc->szHost, nloc->wPort, nloc->flags);
-
- if (GetNetlibHandleType(nlu) != NLH_USER || !(nlu->user.flags & NUF_OUTGOING) || nloc == NULL ||
- (nloc->cbSize != NETLIBOPENCONNECTION_V1_SIZE && nloc->cbSize != sizeof(NETLIBOPENCONNECTION)) ||
- nloc->szHost == NULL || nloc->wPort == 0)
- {
+ if (nloc == NULL || nloc->cbSize != sizeof(NETLIBOPENCONNECTION) || nloc->szHost == NULL || nloc->wPort == 0) {
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
- nlc = (struct NetlibConnection*)mir_calloc(sizeof(struct NetlibConnection));
+
+ NetlibUser *nlu = (NetlibUser*)wParam;
+ if (GetNetlibHandleType(nlu) != NLH_USER || !(nlu->user.flags & NUF_OUTGOING))
+ return 0;
+
+ NetlibLogf(nlu, "Connection request to %s:%d (Flags %x)....", nloc->szHost, nloc->wPort, nloc->flags);
+
+ NetlibConnection *nlc = (NetlibConnection*)mir_calloc(sizeof(struct NetlibConnection));
nlc->handleType = NLH_CONNECTION;
nlc->nlu = nlu;
nlc->nloc = *nloc;
@@ -934,17 +862,14 @@ INT_PTR NetlibOpenConnection(WPARAM wParam, LPARAM lParam) NetlibInitializeNestedCS(&nlc->ncsSend);
NetlibInitializeNestedCS(&nlc->ncsRecv);
- if ( !NetlibDoConnect(nlc))
- {
+ if ( !NetlibDoConnect(nlc)) {
FreePartiallyInitedConnection(nlc);
return 0;
}
- if (iUPnPCleanup == 0)
- {
+ if (iUPnPCleanup == 0) {
EnterCriticalSection(&csNetlibUser);
- if (iUPnPCleanup == 0)
- {
+ if (iUPnPCleanup == 0) {
iUPnPCleanup = 1;
forkthread(NetlibUPnPCleanup, 0, NULL);
}
@@ -957,7 +882,8 @@ INT_PTR NetlibOpenConnection(WPARAM wParam, LPARAM lParam) INT_PTR NetlibStartSsl(WPARAM wParam, LPARAM lParam)
{
NetlibConnection *nlc = (NetlibConnection*)wParam;
- if (nlc == NULL) return 0;
+ if (nlc == NULL)
+ return 0;
NETLIBSSL *sp = (NETLIBSSL*)lParam;
const char *szHost = sp ? sp->host : nlc->nloc.szHost;
diff --git a/src/modules/srfile/fileexistsdlg.cpp b/src/modules/srfile/fileexistsdlg.cpp index 1975226b90..70ad5613b0 100644 --- a/src/modules/srfile/fileexistsdlg.cpp +++ b/src/modules/srfile/fileexistsdlg.cpp @@ -139,6 +139,7 @@ struct loadiconsstartinfo { HWND hwndDlg;
TCHAR *szFilename;
};
+
void __cdecl LoadIconsAndTypesThread(void* param)
{
loadiconsstartinfo *info = (loadiconsstartinfo*)param;
@@ -167,9 +168,8 @@ void __cdecl LoadIconsAndTypesThread(void* param) SetDlgItemText(info->hwndDlg, IDC_NEWTYPE, fileInfo.szTypeName);
SendDlgItemMessage(info->hwndDlg, IDC_EXISTINGICON, STM_SETICON, (WPARAM)fileInfo.hIcon, 0);
szIconFile[0]='\0';
- if ( !lstrcmp(szExtension, _T("EXE"))) {
+ if ( !lstrcmp(szExtension, _T("EXE")))
SRFile_GetRegValue(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Icons"), _T("2"), szIconFile, SIZEOF(szIconFile));
- }
else {
TCHAR szTypeName[MAX_PATH];
if (SRFile_GetRegValue(HKEY_CLASSES_ROOT, pszExtension, NULL, szTypeName, SIZEOF(szTypeName))) {
@@ -181,15 +181,9 @@ void __cdecl LoadIconsAndTypesThread(void* param) } } }
if (szIconFile[0]) {
- int iconIndex;
- HICON hIcon;
TCHAR *pszComma = _tcsrchr(szIconFile, ',');
- if (pszComma == NULL)
- iconIndex=0;
- else {
- iconIndex = _ttoi(pszComma+1); *pszComma='\0';
- }
- hIcon = ExtractIcon(hInst, szIconFile, iconIndex);
+ int iconIndex = (pszComma == NULL) ? 0 :_ttoi(pszComma+1); *pszComma='\0';
+ HICON hIcon = ExtractIcon(hInst, szIconFile, iconIndex);
if (hIcon)
fileInfo.hIcon = hIcon;
}
diff --git a/src/modules/srfile/filexferdlg.cpp b/src/modules/srfile/filexferdlg.cpp index 3dc4e27bd5..99eed2c3d9 100644 --- a/src/modules/srfile/filexferdlg.cpp +++ b/src/modules/srfile/filexferdlg.cpp @@ -684,10 +684,11 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR vstsi->returnCode = -1;
}
SetFtStatus(hwndDlg, LPGENT("Scanning for viruses..."), FTS_TEXT);
- if (vstsi) forkthread((void (*)(void*))RunVirusScannerThread, 0, vstsi);
- } else {
- dat->fs=NULL; /* protocol will free structure */
- }
+ if (vstsi)
+ forkthread((void (*)(void*))RunVirusScannerThread, 0, vstsi);
+ }
+ else dat->fs=NULL; /* protocol will free structure */
+
dat->transferStatus.currentFileNumber=dat->transferStatus.totalFiles;
} // else dat->send
diff --git a/src/resource.h b/src/resource.h index b431120306..791f7570b6 100644 --- a/src/resource.h +++ b/src/resource.h @@ -423,6 +423,7 @@ #define IDC_UPGRADE 1645
#define IDC_FULLSCREEN 1645
#define IDC_IDLE1STTIME 1646
+#define IDC_IDLESOUNDSOFF 1647
#define IDC_IDLEPRIVATE 1649
#define IDC_AASTATUS 1650
#define IDC_AASHORTIDLE 1651
diff --git a/src/resource.rc b/src/resource.rc index c7b75c7e25..2ab24c7b40 100644 --- a/src/resource.rc +++ b/src/resource.rc @@ -840,7 +840,7 @@ BEGIN LTEXT "You will always be asked about files from people not on your contact list", IDC_STATIC, 212, 198, 90, 24
END
-IDD_OPT_IDLE DIALOGEX 0, 0, 312, 190
+IDD_OPT_IDLE DIALOGEX 0, 0, 312, 193
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_BORDER
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
@@ -865,9 +865,10 @@ BEGIN CONTROL "Change my status mode to:", IDC_AASHORTIDLE, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 25, 147, 132, 11
CONTROL "Do not set status back to online when returning from idle", IDC_IDLESTATUSLOCK,
"Button", BS_AUTOCHECKBOX | WS_TABSTOP, 35, 164, 254, 10
- GROUPBOX "Idle Options", IDC_STATIC, 3, 3, 304, 182
+ GROUPBOX "Idle Options", IDC_STATIC, 3, 1, 304, 192
CONTROL "Become idle if application full screen", IDC_FULLSCREEN,
"Button", BS_AUTOCHECKBOX | WS_TABSTOP, 25, 94, 265, 9
+ CONTROL "Disable sounds on idle", IDC_IDLESOUNDSOFF, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 25, 177, 265, 9
END
IDD_PROFILE_SELECTION DIALOGEX 0, 0, 386, 142
|