summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
Diffstat (limited to 'protocols')
-rw-r--r--protocols/Gadu-Gadu/src/avatar.cpp14
-rw-r--r--protocols/Gadu-Gadu/src/core.cpp4
-rw-r--r--protocols/Gadu-Gadu/src/gg.cpp20
-rw-r--r--protocols/Gadu-Gadu/src/gg.h1
-rw-r--r--protocols/Gadu-Gadu/src/import.cpp16
-rw-r--r--protocols/Gadu-Gadu/src/libgadu/win32.h7
-rw-r--r--protocols/Gadu-Gadu/src/ownerinfo.cpp4
-rw-r--r--protocols/Gadu-Gadu/src/services.cpp6
-rw-r--r--protocols/Gadu-Gadu/src/userutils.cpp16
9 files changed, 55 insertions, 33 deletions
diff --git a/protocols/Gadu-Gadu/src/avatar.cpp b/protocols/Gadu-Gadu/src/avatar.cpp
index 58a8208a27..e5e2d162f3 100644
--- a/protocols/Gadu-Gadu/src/avatar.cpp
+++ b/protocols/Gadu-Gadu/src/avatar.cpp
@@ -35,9 +35,9 @@ void GGPROTO::getAvatarFilename(MCONTACT hContact, TCHAR *pszDest, int cbLen)
if (ret == 0)
debugLog(_T("getAvatarFilename(): Created new directory for avatar cache: %s."), pszDest);
else {
- debugLog(_T("getAvatarFilename(): Can not create directory for avatar cache: %s. errno=%d: %s"), pszDest, errno, strerror(errno));
+ debugLog(_T("getAvatarFilename(): Can not create directory for avatar cache: %s. errno=%d: %s"), pszDest, errno, ws_strerror(errno));
TCHAR error[512];
- mir_sntprintf(error, TranslateT("Cannot create avatars cache directory. ERROR: %d: %s\n%s"), errno, _tcserror(errno), pszDest);
+ mir_sntprintf(error, TranslateT("Cannot create avatars cache directory. ERROR: %d: %s\n%s"), errno, ws_strerror(errno), pszDest);
showpopup(m_tszUserName, error, GG_POPUP_ERROR | GG_POPUP_ALLOW_MSGBOX | GG_POPUP_ONCE);
}
}
@@ -267,11 +267,11 @@ void __cdecl GGPROTO::avatarrequestthread(void*)
_write(file_fd, resp->pData, resp->dataLength);
_close(file_fd);
result = 1;
- debugLog(_T("avatarrequestthread() new avatar_transfers item. Saved data from url=%s to file=%s."), data->szAvatarURL, ai.filename);
+ debugLog(_T("avatarrequestthread() new avatar_transfers item. Saved data to file=%s."), ai.filename);
} else {
- debugLog(_T("avatarrequestthread(): _topen file %s error. errno=%d: %s"), ai.filename, errno, strerror(errno));
+ debugLog(_T("avatarrequestthread(): _topen file %s error. errno=%d: %s"), ai.filename, errno, ws_strerror(errno));
TCHAR error[512];
- mir_sntprintf(error, TranslateT("Cannot create avatar file. ERROR: %d: %s\n%s"), errno, _tcserror(errno), ai.filename);
+ mir_sntprintf(error, TranslateT("Cannot create avatar file. ERROR: %d: %s\n%s"), errno, ws_strerror(errno), ai.filename);
showpopup(m_tszUserName, error, GG_POPUP_ERROR);
}
}
@@ -361,9 +361,9 @@ void __cdecl GGPROTO::setavatarthread(void *param)
TCHAR *szFilename = (TCHAR*)param;
int file_fd = _topen(szFilename, _O_RDONLY | _O_BINARY, _S_IREAD);
if (file_fd == -1) {
- debugLogA("setavatarthread(): Failed to open avatar file errno=%d: %s.", errno, strerror(errno));
+ debugLog(_T("setavatarthread(): Failed to open avatar file errno=%d: %s)", errno, ws_strerror(errno));
TCHAR error[512];
- mir_sntprintf(error, TranslateT("Cannot open avatar file. ERROR: %d: %s\n%s"), errno, _tcserror(errno), szFilename);
+ mir_sntprintf(error, TranslateT("Cannot open avatar file. ERROR: %d: %s\n%s"), errno, ws_strerror(errno), szFilename);
showpopup(m_tszUserName, error, GG_POPUP_ERROR);
mir_free(szFilename);
int prevType = getByte(GG_KEY_AVATARTYPEPREV, -1);
diff --git a/protocols/Gadu-Gadu/src/core.cpp b/protocols/Gadu-Gadu/src/core.cpp
index 4f8816fd7e..d7ad598eef 100644
--- a/protocols/Gadu-Gadu/src/core.cpp
+++ b/protocols/Gadu-Gadu/src/core.cpp
@@ -423,10 +423,10 @@ retry:
}
}
if (!perror) {
- mir_sntprintf(error, TranslateT("Connection cannot be established. errno=%d: %s"),errno, strerror(errno));
+ mir_sntprintf(error, TranslateT("Connection cannot be established. errno=%d: %s"), errno, ws_strerror(errno));
perror = error;
}
- debugLogA("mainthread() (%x): %s", this, perror);
+ debugLog(_T("mainthread() (%x): %s"), this, perror);
if (getByte(GG_KEY_SHOWCERRORS, GG_KEYDEF_SHOWCERRORS))
showpopup(m_tszUserName, perror, GG_POPUP_ERROR | GG_POPUP_ALLOW_MSGBOX | GG_POPUP_ONCE);
diff --git a/protocols/Gadu-Gadu/src/gg.cpp b/protocols/Gadu-Gadu/src/gg.cpp
index e218ad8cde..feb65aa5d9 100644
--- a/protocols/Gadu-Gadu/src/gg.cpp
+++ b/protocols/Gadu-Gadu/src/gg.cpp
@@ -75,6 +75,26 @@ TCHAR* ws_strerror(int code)
return _tcserror(code);
}
+char* as_strerror(int code)
+{
+ static char err_desc[160];
+
+ // Not a windows error display WinSock
+ if (code == 0)
+ {
+ char buff[128];
+ int len = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, WSAGetLastError(), 0, buff, _countof(buff), NULL);
+ if (len == 0)
+ mir_snprintf(err_desc, "WinSock %u: Unknown error.", WSAGetLastError());
+ else
+ mir_snprintf(err_desc, "WinSock %d: %s", WSAGetLastError(), buff);
+ return err_desc;
+ }
+
+ // Return normal error
+ return strerror(code);
+}
+
//////////////////////////////////////////////////////////
// Build the crc table
void crc_gentable(void)
diff --git a/protocols/Gadu-Gadu/src/gg.h b/protocols/Gadu-Gadu/src/gg.h
index a06ed4dfb2..4dc5f9bf3b 100644
--- a/protocols/Gadu-Gadu/src/gg.h
+++ b/protocols/Gadu-Gadu/src/gg.h
@@ -311,6 +311,7 @@ unsigned long crc_get(char *mem);
int gg_normalizestatus(int status);
char *gg_status2db(int status, const char *suffix);
TCHAR *ws_strerror(int code);
+char *as_strerror(int code);
uint32_t swap32(uint32_t x);
const char *gg_version2string(int v);
diff --git a/protocols/Gadu-Gadu/src/import.cpp b/protocols/Gadu-Gadu/src/import.cpp
index 9db2f2e3a9..190270ceac 100644
--- a/protocols/Gadu-Gadu/src/import.cpp
+++ b/protocols/Gadu-Gadu/src/import.cpp
@@ -278,9 +278,9 @@ INT_PTR GGPROTO::import_server(WPARAM, LPARAM)
{
TCHAR error[128];
gg_LeaveCriticalSection(&sess_mutex, "import_server", 65, 1, "sess_mutex", 1);
- mir_sntprintf(error, TranslateT("List cannot be imported because of error:\n\t%s (Error: %d)"), _tcserror(errno), errno);
+ mir_sntprintf(error, TranslateT("List cannot be imported because of error:\n\t%s (Error: %d)"), ws_strerror(errno), errno);
MessageBox(NULL, error, m_tszUserName, MB_OK | MB_ICONSTOP);
- debugLogA("import_server(): Cannot import list. errno:%d: %s", errno, strerror(errno));
+ debugLog(_T("import_server(): Cannot import list. errno:%d: %s"), errno, ws_strerror(errno));
}
gg_LeaveCriticalSection(&sess_mutex, "import_server", 65, 2, "sess_mutex", 1);
@@ -316,9 +316,9 @@ INT_PTR GGPROTO::remove_server(WPARAM, LPARAM)
{
TCHAR error[128];
gg_LeaveCriticalSection(&sess_mutex, "remove_server", 66, 1, "sess_mutex", 1);
- mir_sntprintf(error, TranslateT("List cannot be removed because of error: %s (Error: %d)"), _tcserror(errno), errno);
+ mir_sntprintf(error, TranslateT("List cannot be removed because of error: %s (Error: %d)"), ws_strerror(errno), errno);
MessageBox(NULL, error, m_tszUserName, MB_OK | MB_ICONSTOP);
- debugLogA("remove_server(): Cannot remove list. errno=%d: %s", errno, strerror(errno));
+ debugLog(_T("remove_server(): Cannot remove list. errno=%d: %s"), errno, ws_strerror(errno));
}
gg_LeaveCriticalSection(&sess_mutex, "remove_server", 66, 2, "sess_mutex", 1);
@@ -392,7 +392,7 @@ INT_PTR GGPROTO::import_text(WPARAM, LPARAM)
TCHAR error[256];
mir_sntprintf(error, TranslateT("List cannot be imported from file \"%s\" because of error:\n\t%s (Error: %d)"), str, _tcserror(errno), errno);
MessageBox(NULL, error, m_tszUserName, MB_OK | MB_ICONSTOP);
- debugLog(_T("import_text(): Cannot import list from file \"%s\". errno=%d: %s"), str, errno, strerror(errno));
+ debugLog(_T("import_text(): Cannot import list from file \"%s\". errno=%d: %s"), str, errno, _tcserror(errno));
if (f)
fclose(f);
return 0;
@@ -454,7 +454,7 @@ INT_PTR GGPROTO::export_text(WPARAM, LPARAM)
TCHAR error[128];
mir_sntprintf(error, TranslateT("List cannot be exported to file \"%s\" because of error:\n\t%s (Error: %d)"), str, _tcserror(errno), errno);
MessageBox(NULL, error, m_tszUserName, MB_OK | MB_ICONSTOP);
- debugLogA("export_text(): Cannot export list to file \"%s\". errno=%d: %s", str, errno, strerror(errno));
+ debugLog(_T("export_text(): Cannot export list to file \"%s\". errno=%d: %s"), str, errno, _tcserror(errno));
}
return 0;
@@ -496,9 +496,9 @@ INT_PTR GGPROTO::export_server(WPARAM, LPARAM)
{
TCHAR error[128];
gg_LeaveCriticalSection(&sess_mutex, "export_server", 67, 1, "sess_mutex", 1);
- mir_sntprintf(error, TranslateT("List cannot be exported because of error:\n\t%s (Error: %d)"), _tcserror(errno), errno);
+ mir_sntprintf(error, TranslateT("List cannot be exported because of error:\n\t%s (Error: %d)"), ws_strerror(errno), errno);
MessageBox(NULL, error, m_tszUserName, MB_OK | MB_ICONSTOP);
- debugLogA("export_server(): Cannot export list. errno=%d: %s", errno, strerror(errno));
+ debugLog(_T("export_server(): Cannot export list. errno=%d: %s"), errno, ws_strerror(errno));
}
gg_LeaveCriticalSection(&sess_mutex, "export_server", 67, 2, "sess_mutex", 1);
diff --git a/protocols/Gadu-Gadu/src/libgadu/win32.h b/protocols/Gadu-Gadu/src/libgadu/win32.h
index d432a359ac..fdc5017279 100644
--- a/protocols/Gadu-Gadu/src/libgadu/win32.h
+++ b/protocols/Gadu-Gadu/src/libgadu/win32.h
@@ -59,10 +59,11 @@
#define WNOHANG WHOHANG
#define SHUT_RDWR 2
-/* Defined in gg.c custom error reporting function */
+/* Defined in gg.c custom error reporting function, override only at \libgadu\ dir */
+#define GG_CONFIG_MIRANDA
#ifdef GG_CONFIG_MIRANDA
-char *ws_strerror(int code);
-#define strerror(x) ws_strerror(x)
+char *as_strerror(int code);
+#define strerror(x) as_strerror(x)
#endif
#define fork() (-1)
diff --git a/protocols/Gadu-Gadu/src/ownerinfo.cpp b/protocols/Gadu-Gadu/src/ownerinfo.cpp
index 013256f92e..b51fd7caba 100644
--- a/protocols/Gadu-Gadu/src/ownerinfo.cpp
+++ b/protocols/Gadu-Gadu/src/ownerinfo.cpp
@@ -57,9 +57,9 @@ void __cdecl GGPROTO::remindpasswordthread(void *param)
if (!(h = gg_remind_passwd3(rp->uin, rp->email, token.id, token.val, 0)))
{
TCHAR error[128];
- mir_sntprintf(error, TranslateT("Password could not be reminded because of error:\n\t%s (Error: %d)"), _tcserror(errno), errno);
+ mir_sntprintf(error, TranslateT("Password could not be reminded because of error:\n\t%s (Error: %d)"), ws_strerror(errno), errno);
MessageBox(NULL, error, m_tszUserName, MB_OK | MB_ICONSTOP);
- debugLogA("remindpasswordthread(): Password could not be reminded. errno=%d: %s", errno, strerror(errno));
+ debugLog(_T("remindpasswordthread(): Password could not be reminded. errno=%d: %s"), errno, ws_strerror(errno));
}
else
{
diff --git a/protocols/Gadu-Gadu/src/services.cpp b/protocols/Gadu-Gadu/src/services.cpp
index f10e42c2e8..2dae64d0ff 100644
--- a/protocols/Gadu-Gadu/src/services.cpp
+++ b/protocols/Gadu-Gadu/src/services.cpp
@@ -235,12 +235,12 @@ INT_PTR GGPROTO::getavatarinfo(WPARAM wParam, LPARAM lParam)
}
requestAvatarTransfer(pai->hContact, AvatarURL);
- debugLog(_T("getavatarinfo(): Incoming request for avatar information. uin=%d. Avatar hash unchanged but file %s does not exist. errno=%d: %s. requestAvatarTransfer() fired. return GAIR_WAITFOR"), uin, pai->filename, errno, strerror(errno));
+ debugLog(_T("getavatarinfo(): Incoming request for avatar information. uin=%d. Avatar hash unchanged but file %s does not exist. errno=%d: %s. requestAvatarTransfer() fired. return GAIR_WAITFOR"), uin, pai->filename, errno, ws_strerror(errno));
return GAIR_WAITFOR;
}
if ((wParam & GAIF_FORCE) != 0) {
if (_tremove(pai->filename) != 0){
- debugLog(_T("getavatarinfo(): refresh. _tremove 1 file %s error. errno=%d: %s"), pai->filename, errno, strerror(errno));
+ debugLog(_T("getavatarinfo(): refresh. _tremove 1 file %s error. errno=%d: %s"), pai->filename, errno, _tcserror(errno));
TCHAR error[512];
mir_sntprintf(error, TranslateT("Cannot remove old avatar file before refresh. ERROR: %d: %s\n%s"), errno, _tcserror(errno), pai->filename);
showpopup(m_tszUserName, error, GG_POPUP_ERROR);
@@ -255,7 +255,7 @@ INT_PTR GGPROTO::getavatarinfo(WPARAM wParam, LPARAM lParam)
if (AvatarHash == NULL && AvatarSavedHash != NULL) {
getAvatarFilename(pai->hContact, pai->filename, _countof(pai->filename));
if (_tremove(pai->filename) != 0){
- debugLog(_T("getavatarinfo(): delete. _tremove file %s error. errno=%d: %s"), pai->filename, errno, strerror(errno));
+ debugLog(_T("getavatarinfo(): delete. _tremove file %s error. errno=%d: %s"), pai->filename, errno, _tcserror(errno));
TCHAR error[512];
mir_sntprintf(error, TranslateT("Cannot remove old avatar file. ERROR: %d: %s\n%s"), errno, _tcserror(errno), pai->filename);
showpopup(m_tszUserName, error, GG_POPUP_ERROR);
diff --git a/protocols/Gadu-Gadu/src/userutils.cpp b/protocols/Gadu-Gadu/src/userutils.cpp
index 90cc89579a..03bb478ac5 100644
--- a/protocols/Gadu-Gadu/src/userutils.cpp
+++ b/protocols/Gadu-Gadu/src/userutils.cpp
@@ -42,9 +42,9 @@ void *gg_doregister(GGPROTO *gg, char *newPass, char *newEmail)
TCHAR error[128];
mir_sntprintf(error, TranslateT("Cannot register new account because of error:\n\t%s"),
(h && !s) ? http_error_string(h->error) :
- (s ? TranslateT("Registration rejected") : _tcserror(errno)));
+ (s ? TranslateT("Registration rejected") : ws_strerror(errno)));
MessageBox(NULL, error, gg->m_tszUserName, MB_OK | MB_ICONSTOP);
- gg->debugLogA("gg_doregister(): Cannot register. errno=%d: %s", errno, strerror(errno));
+ gg->debugLog(_T("gg_doregister(): Cannot register. errno=%d: %s"), errno, ws_strerror(errno));
}
else {
gg->setDword(GG_KEY_UIN, s->uin);
@@ -88,9 +88,9 @@ void *gg_dounregister(GGPROTO *gg, uin_t uin, char *password)
TCHAR error[128];
mir_sntprintf(error, TranslateT("Your account cannot be removed because of error:\n\t%s"),
(h && !s) ? http_error_string(h->error) :
- (s ? TranslateT("Bad number or password") : _tcserror(errno)));
+ (s ? TranslateT("Bad number or password") : ws_strerror(errno)));
MessageBox(NULL, error, gg->m_tszUserName, MB_OK | MB_ICONSTOP);
- gg->debugLogA("gg_dounregister(): Cannot remove account. errno=%d: %s", errno, strerror(errno));
+ gg->debugLog(_T("gg_dounregister(): Cannot remove account. errno=%d: %s"), errno, ws_strerror(errno));
}
else
{
@@ -140,9 +140,9 @@ void *gg_dochpass(GGPROTO *gg, uin_t uin, char *password, char *newPass)
TCHAR error[128];
mir_sntprintf(error, TranslateT("Your password cannot be changed because of error:\n\t%s"),
(h && !s) ? http_error_string(h->error) :
- (s ? TranslateT("Invalid data entered") : _tcserror(errno)));
+ (s ? TranslateT("Invalid data entered") : ws_strerror(errno)));
MessageBox(NULL, error, gg->m_tszUserName, MB_OK | MB_ICONSTOP);
- gg->debugLogA("gg_dochpass(): Cannot change password. errno=%d: %s", errno, strerror(errno));
+ gg->debugLog(_T("gg_dochpass(): Cannot change password. errno=%d: %s"), errno, ws_strerror(errno));
}
else
{
@@ -181,9 +181,9 @@ void *gg_dochemail(GGPROTO *gg, uin_t uin, char *password, char *email, char *ne
{
TCHAR error[128];
mir_sntprintf(error, TranslateT("Your e-mail cannot be changed because of error:\n\t%s"),
- (h && !s) ? http_error_string(h->error) : (s ? TranslateT("Bad old e-mail or password") : _tcserror(errno)));
+ (h && !s) ? http_error_string(h->error) : (s ? TranslateT("Bad old e-mail or password") : ws_strerror(errno)));
MessageBox(NULL, error, gg->m_tszUserName, MB_OK | MB_ICONSTOP);
- gg->debugLogA("gg_dochemail(): Cannot change e-mail. errno=%d: %s", errno, strerror(errno));
+ gg->debugLog(_T("gg_dochemail(): Cannot change e-mail. errno=%d: %s"), errno, ws_strerror(errno));
}
else
{