diff options
author | Szymon Tokarz <wsx22@o2.pl> | 2012-12-31 13:22:28 +0000 |
---|---|---|
committer | Szymon Tokarz <wsx22@o2.pl> | 2012-12-31 13:22:28 +0000 |
commit | fd19769f410fe114451ea1329f676ed28c555b2f (patch) | |
tree | 5b521f080dcb3b7e785c9c14edce80249dfc51d0 /protocols | |
parent | 6410348ada83ca5fea19f706506ae4afaf8f4a89 (diff) |
Gadu-Gadu protocol:
- show error popup when file io function returns an error code
hope to explain avatar problems
git-svn-id: http://svn.miranda-ng.org/main/trunk@2895 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/Gadu-Gadu/src/avatar.cpp | 23 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/core.cpp | 2 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/filetransfer.cpp | 10 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/image.cpp | 28 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/import.cpp | 22 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/ownerinfo.cpp | 4 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/userutils.cpp | 8 |
7 files changed, 69 insertions, 28 deletions
diff --git a/protocols/Gadu-Gadu/src/avatar.cpp b/protocols/Gadu-Gadu/src/avatar.cpp index a8c2b6efa7..b66c8c9407 100644 --- a/protocols/Gadu-Gadu/src/avatar.cpp +++ b/protocols/Gadu-Gadu/src/avatar.cpp @@ -39,8 +39,17 @@ void GGPROTO::getAvatarFilename(HANDLE hContact, TCHAR *pszDest, int cbLen) tPathLen = (int)_tcslen(pszDest);
}
- if (_taccess(pszDest, 0))
- CallService(MS_UTILS_CREATEDIRTREET, 0, (LPARAM)pszDest);
+ if (_taccess(pszDest, 0)) {
+ int ret = CallService(MS_UTILS_CREATEDIRTREET, 0, (LPARAM)pszDest);
+ if (ret == 0){
+ netlog("getAvatarFilename(): Created new directory for avatar cache: %S.", pszDest);
+ } else {
+ netlog("getAvatarFilename(): Can not create directory for avatar cache: %S. errno=%d: %s", pszDest, errno, strerror(errno));
+ TCHAR error[512];
+ mir_sntprintf(error, SIZEOF(error), TranslateT("Can not create avatars cache directory. ERROR: %d: %s\n%s"), errno, _tcserror(errno), pszDest);
+ showpopup(m_tszUserName, error, GG_POPUP_ERROR | GG_POPUP_ALLOW_MSGBOX | GG_POPUP_ONCE);
+ }
+ }
switch (db_get_b(hContact, m_szModuleName, GG_KEY_AVATARTYPE, GG_KEYDEF_AVATARTYPE)) {
case PA_FORMAT_JPEG: avatartype = _T("jpg"); break;
@@ -264,6 +273,11 @@ void __cdecl GGPROTO::avatarrequestthread(void*) _write(file_fd, resp->pData, resp->dataLength);
_close(file_fd);
result = 1;
+ } else {
+ netlog("avatarrequestthread(): _topen file %S error. errno=%d: %s", pai.filename, errno, strerror(errno));
+ TCHAR error[512];
+ mir_sntprintf(error, SIZEOF(error), TranslateT("Can not create avatar file. ERROR: %d: %s\n%s"), errno, _tcserror(errno), pai.filename);
+ showpopup(m_tszUserName, error, GG_POPUP_ERROR);
}
}
else netlog("avatarrequestthread(): Invalid response code from HTTP request");
@@ -383,7 +397,10 @@ void __cdecl GGPROTO::setavatarthread(void *param) file_fd = _topen(szFilename, _O_RDONLY | _O_BINARY, _S_IREAD);
if (file_fd == -1) {
- netlog("setavatarthread(): Failed to open avatar file (%s).", strerror(errno));
+ netlog("setavatarthread(): Failed to open avatar file errno=%d: %s.", errno, strerror(errno));
+ TCHAR error[512];
+ mir_sntprintf(error, SIZEOF(error), TranslateT("Can not open avatar file. ERROR: %d: %s\n%s"), errno, _tcserror(errno), szFilename);
+ showpopup(m_tszUserName, error, GG_POPUP_ERROR);
mir_free(szFilename);
int prevType = db_get_b(NULL, m_szModuleName, GG_KEY_AVATARTYPEPREV, -1);
if (prevType != -1)
diff --git a/protocols/Gadu-Gadu/src/core.cpp b/protocols/Gadu-Gadu/src/core.cpp index 24f237ca2c..cb31486925 100644 --- a/protocols/Gadu-Gadu/src/core.cpp +++ b/protocols/Gadu-Gadu/src/core.cpp @@ -436,7 +436,7 @@ retry: }
}
if (!perror) {
- mir_sntprintf(error, SIZEOF(error), TranslateT("Connection cannot be established because of error:\n\t%s"), _tcserror(errno));
+ mir_sntprintf(error, SIZEOF(error), TranslateT("Connection cannot be established. errno=%d: %s"),errno, strerror(errno));
perror = error;
}
netlog("mainthread() (%x): %s", this, perror);
diff --git a/protocols/Gadu-Gadu/src/filetransfer.cpp b/protocols/Gadu-Gadu/src/filetransfer.cpp index a111bbb022..f5436008a9 100644 --- a/protocols/Gadu-Gadu/src/filetransfer.cpp +++ b/protocols/Gadu-Gadu/src/filetransfer.cpp @@ -680,7 +680,10 @@ HANDLE GGPROTO::dccfileallow(HANDLE hTransfer, const PROTOCHAR* szPath) // Open file for appending and check if ok
if ((dcc->file_fd = _open(fileName, _O_WRONLY | _O_APPEND | _O_BINARY | _O_CREAT, _S_IREAD | _S_IWRITE)) == -1)
{
- netlog("dccfileallow(): Failed to create file \"%s\".", fileName);
+ netlog("dccfileallow(): Failed to create file \"%s\". errno=%d: %s", fileName, errno, strerror(errno));
+ TCHAR error[512];
+ mir_sntprintf(error, SIZEOF(error), TranslateT("Can not create transfer file. ERROR: %d: %s (dcc)\n%s"), errno, _tcserror(errno), szPath);
+ showpopup(m_tszUserName, error, GG_POPUP_ERROR);
ProtoBroadcastAck(m_szModuleName, dcc->contact, ACKTYPE_FILE, ACKRESULT_FAILED, dcc, 0);
// Free transfer
gg_free_dcc(dcc);
@@ -728,7 +731,10 @@ HANDLE GGPROTO::dcc7fileallow(HANDLE hTransfer, const PROTOCHAR* szPath) // Open file for appending and check if ok
if ((dcc7->file_fd = _open(fileName, _O_WRONLY | _O_APPEND | _O_BINARY | _O_CREAT, _S_IREAD | _S_IWRITE)) == -1)
{
- netlog("dcc7fileallow(): Failed to create file \"%s\".", fileName);
+ netlog("dcc7fileallow(): Failed to create file \"%s\". errno=%d: %s", fileName, errno, strerror(errno));
+ TCHAR error[512];
+ mir_sntprintf(error, SIZEOF(error), TranslateT("Can not create transfer file. ERROR: %d: %s (dcc7)\n%s"), errno, _tcserror(errno), szPath);
+ showpopup(m_tszUserName, error, GG_POPUP_ERROR);
gg_dcc7_reject(dcc7, GG_DCC7_REJECT_USER);
ProtoBroadcastAck(m_szModuleName, dcc7->contact, ACKTYPE_FILE, ACKRESULT_FAILED, dcc7, 0);
// Free transfer
diff --git a/protocols/Gadu-Gadu/src/image.cpp b/protocols/Gadu-Gadu/src/image.cpp index f3a36a4c3c..2ffb9e073c 100644 --- a/protocols/Gadu-Gadu/src/image.cpp +++ b/protocols/Gadu-Gadu/src/image.cpp @@ -272,11 +272,11 @@ int gg_img_saveimage(HWND hwnd, GGIMAGEENTRY *dat) {
fwrite(dat->lpData, dat->nSize, 1, fp);
fclose(fp);
- gg->netlog("gg_img_saveimage(): Image saved to %s.", szFileName);
+ gg->netlog("gg_img_saveimage(): Image saved to %S.", szFileName);
}
else
{
- gg->netlog("gg_img_saveimage(): Cannot save image to %s.", szFileName);
+ gg->netlog("gg_img_saveimage(): Cannot save image to %S.", szFileName);
MessageBox(hwnd, TranslateT("Image cannot be written to disk."), gg->m_tszUserName, MB_OK | MB_ICONERROR);
}
}
@@ -825,8 +825,17 @@ int GGPROTO::img_displayasmsg(HANDLE hContact, void *img) tPathLen = _tcslen(szPath);
}
- if ( _taccess(szPath, 0))
- CallService(MS_UTILS_CREATEDIRTREET, 0, (LPARAM)szPath);
+ if ( _taccess(szPath, 0)){
+ int ret = CallService(MS_UTILS_CREATEDIRTREET, 0, (LPARAM)szPath);
+ if (ret == 0){
+ netlog("getAvatarFilename(): Created new directory for image cache: %S.", szPath);
+ } else {
+ netlog("getAvatarFilename(): Can not create directory for image cache: %S. errno=%d: %s", szPath, errno, strerror(errno));
+ TCHAR error[512];
+ mir_sntprintf(error, SIZEOF(error), TranslateT("Can not create image cache directory. ERROR: %d: %s\n%s"), errno, _tcserror(errno), szPath);
+ showpopup(m_tszUserName, error, GG_POPUP_ERROR | GG_POPUP_ALLOW_MSGBOX | GG_POPUP_ONCE);
+ }
+ }
mir_sntprintf(szPath + tPathLen, MAX_PATH - tPathLen, _T("\\%s"), dat->lpszFileName);
if ((pImgext = gg_img_hasextension(szPath)) == NULL)
@@ -844,6 +853,12 @@ int GGPROTO::img_displayasmsg(HANDLE hContact, void *img) if (fp) {
res = fwrite(dat->lpData, dat->nSize, 1, fp) > 0;
fclose(fp);
+ } else {
+ netlog("img_displayasmsg(): Cannot open file %S for write image. errno=%d: %s", szPath, errno, strerror(errno));
+ TCHAR error[512];
+ mir_sntprintf(error, SIZEOF(error), TranslateT("Cannot save received image to file. ERROR: %d: %s\n%s"), errno, _tcserror(errno), szPath);
+ showpopup(m_tszUserName, error, GG_POPUP_ERROR);
+ return 0;
}
}
@@ -970,7 +985,10 @@ void* GGPROTO::img_loadpicture(gg_event* e, TCHAR *szFileName) FILE *fp = _tfopen(szFileName, _T("rb"));
if (!fp) {
free(dat);
- netlog("img_loadpicture(): fopen(\"%S\", \"rb\") failed.", szFileName);
+ netlog("img_loadpicture(): fopen(\"%S\", \"rb\") failed. errno=%d: %s", szFileName, errno, strerror(errno));
+ TCHAR error[512];
+ mir_sntprintf(error, SIZEOF(error), TranslateT("Can not open image file. ERROR: %d: %s\n%s"), errno, _tcserror(errno), szFileName);
+ showpopup(m_tszUserName, error, GG_POPUP_ERROR);
return NULL;
}
fseek(fp, 0, SEEK_END);
diff --git a/protocols/Gadu-Gadu/src/import.cpp b/protocols/Gadu-Gadu/src/import.cpp index 6e6d8aa155..c0ee96e5e9 100644 --- a/protocols/Gadu-Gadu/src/import.cpp +++ b/protocols/Gadu-Gadu/src/import.cpp @@ -362,9 +362,9 @@ INT_PTR GGPROTO::import_server(WPARAM wParam, LPARAM lParam) {
TCHAR error[128];
gg_LeaveCriticalSection(&sess_mutex, "import_server", 65, 1, "sess_mutex", 1);
- mir_sntprintf(error, SIZEOF(error), TranslateT("List cannot be imported because of error:\n\t%s"), _tcserror(errno));
+ mir_sntprintf(error, SIZEOF(error), TranslateT("List cannot be imported because of error:\n\t%s (Error: %d)"), _tcserror(errno), errno);
MessageBox(NULL, error, m_tszUserName, MB_OK | MB_ICONSTOP);
- netlog("import_server(): Cannot import list because of \"%s\".", strerror(errno));
+ netlog("import_server(): Cannot import list. errno:%d: %s", errno, strerror(errno));
}
gg_LeaveCriticalSection(&sess_mutex, "import_server", 65, 2, "sess_mutex", 1);
free(password);
@@ -409,9 +409,9 @@ INT_PTR GGPROTO::remove_server(WPARAM wParam, LPARAM lParam) {
TCHAR error[128];
gg_LeaveCriticalSection(&sess_mutex, "remove_server", 66, 1, "sess_mutex", 1);
- mir_sntprintf(error, SIZEOF(error), TranslateT("List cannot be removeed because of error:\n\t%s"), _tcserror(errno));
+ mir_sntprintf(error, SIZEOF(error), TranslateT("List cannot be removeed because of error: %s (Error: %d)"), _tcserror(errno), errno);
MessageBox(NULL, error, m_tszUserName, MB_OK | MB_ICONSTOP);
- netlog("remove_server(): Cannot remove list because of \"%s\".", strerror(errno));
+ netlog("remove_server(): Cannot remove list. errno=%d: %s", errno, strerror(errno));
}
gg_LeaveCriticalSection(&sess_mutex, "remove_server", 66, 2, "sess_mutex", 1);
@@ -483,10 +483,10 @@ INT_PTR GGPROTO::import_text(WPARAM wParam, LPARAM lParam) }
else
{
- TCHAR error[128];
- mir_sntprintf(error, SIZEOF(error), TranslateT("List cannot be imported from file \"%s\" because of error:\n\t%s"), str, _tcserror(errno));
+ TCHAR error[256];
+ mir_sntprintf(error, SIZEOF(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);
- netlog("import_text(): Cannot import list from file \"%S\" because of \"%s\".", str, strerror(errno));
+ netlog("import_text(): Cannot import list from file \"%S\". errno=%d: %s", str, errno, strerror(errno));
}
return 0;
@@ -545,9 +545,9 @@ INT_PTR GGPROTO::export_text(WPARAM wParam, LPARAM lParam) else
{
TCHAR error[128];
- mir_sntprintf(error, SIZEOF(error), TranslateT("List cannot be exported to file \"%s\" because of error:\n\t%s"), str, _tcserror(errno));
+ mir_sntprintf(error, SIZEOF(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);
- netlog("export_text(): Cannot export list to file \"%s\" because of \"%s\".", str, strerror(errno));
+ netlog("export_text(): Cannot export list to file \"%s\". errno=%d: %s", str, errno, strerror(errno));
}
return 0;
@@ -596,9 +596,9 @@ INT_PTR GGPROTO::export_server(WPARAM wParam, LPARAM lParam) {
TCHAR error[128];
gg_LeaveCriticalSection(&sess_mutex, "export_server", 67, 1, "sess_mutex", 1);
- mir_sntprintf(error, SIZEOF(error), TranslateT("List cannot be exported because of error:\n\t%s"), _tcserror(errno));
+ mir_sntprintf(error, SIZEOF(error), TranslateT("List cannot be exported because of error:\n\t%s (Error: %d)"), _tcserror(errno), errno);
MessageBox(NULL, error, m_tszUserName, MB_OK | MB_ICONSTOP);
- netlog("export_server(): Cannot export list because of \"%s\".", strerror(errno));
+ netlog("export_server(): Cannot export list. errno=%d: %s", errno, strerror(errno));
}
gg_LeaveCriticalSection(&sess_mutex, "export_server", 67, 2, "sess_mutex", 1);
diff --git a/protocols/Gadu-Gadu/src/ownerinfo.cpp b/protocols/Gadu-Gadu/src/ownerinfo.cpp index a0549f8316..4acf245682 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, SIZEOF(error), TranslateT("Password could not be reminded because of error:\n\t%s"), _tcserror(errno));
+ mir_sntprintf(error, SIZEOF(error), TranslateT("Password could not be reminded because of error:\n\t%s (Error: %d)"), _tcserror(errno), errno);
MessageBox(NULL, error, m_tszUserName, MB_OK | MB_ICONSTOP);
- netlog("remindpasswordthread(): Password could not be reminded because of \"%s\".", strerror(errno));
+ netlog("remindpasswordthread(): Password could not be reminded. errno=%d: %s", errno, strerror(errno));
}
else
{
diff --git a/protocols/Gadu-Gadu/src/userutils.cpp b/protocols/Gadu-Gadu/src/userutils.cpp index ff5e21088b..e92188fe59 100644 --- a/protocols/Gadu-Gadu/src/userutils.cpp +++ b/protocols/Gadu-Gadu/src/userutils.cpp @@ -50,7 +50,7 @@ void *gg_doregister(GGPROTO *gg, char *newPass, char *newEmail) gg->m_tszUserName,
MB_OK | MB_ICONSTOP
);
- gg->netlog("gg_doregister(): Cannot register because of \"%s\".", strerror(errno));
+ gg->netlog("gg_doregister(): Cannot register. errno=%d: %s", errno, strerror(errno));
}
else
{
@@ -97,7 +97,7 @@ void *gg_dounregister(GGPROTO *gg, uin_t uin, char *password) (h && !s) ? http_error_string(h ? h->error : 0) :
(s ? TranslateT("Bad number or password") : _tcserror(errno)));
MessageBox(NULL, error, gg->m_tszUserName, MB_OK | MB_ICONSTOP);
- gg->netlog("gg_dounregister(): Cannot remove account because of \"%s\".", strerror(errno));
+ gg->netlog("gg_dounregister(): Cannot remove account. errno=%d: %s", errno, strerror(errno));
}
else
{
@@ -149,7 +149,7 @@ void *gg_dochpass(GGPROTO *gg, uin_t uin, char *password, char *newPass) (h && !s) ? http_error_string(h ? h->error : 0) :
(s ? TranslateT("Invalid data entered") : _tcserror(errno)));
MessageBox(NULL, error, gg->m_tszUserName, MB_OK | MB_ICONSTOP);
- gg->netlog("gg_dochpass(): Cannot change password because of \"%s\".", strerror(errno));
+ gg->netlog("gg_dochpass(): Cannot change password. errno=%d: %s", errno, strerror(errno));
}
else
{
@@ -191,7 +191,7 @@ void *gg_dochemail(GGPROTO *gg, uin_t uin, char *password, char *email, char *ne mir_sntprintf(error, SIZEOF(error), TranslateT("Your e-mail cannot be changed because of error:\n\t%s"),
(h && !s) ? http_error_string(h ? h->error : 0) : (s ? TranslateT("Bad old e-mail or password") : _tcserror(errno)));
MessageBox(NULL, error, gg->m_tszUserName, MB_OK | MB_ICONSTOP);
- gg->netlog("gg_dochemail(): Cannot change e-mail because of \"%s\".", strerror(errno));
+ gg->netlog("gg_dochemail(): Cannot change e-mail. errno=%d: %s", errno, strerror(errno));
}
else
{
|