summaryrefslogtreecommitdiff
path: root/protocols/Gadu-Gadu/src/image.cpp
diff options
context:
space:
mode:
authorSzymon Tokarz <wsx22@o2.pl>2012-12-31 13:22:28 +0000
committerSzymon Tokarz <wsx22@o2.pl>2012-12-31 13:22:28 +0000
commitfd19769f410fe114451ea1329f676ed28c555b2f (patch)
tree5b521f080dcb3b7e785c9c14edce80249dfc51d0 /protocols/Gadu-Gadu/src/image.cpp
parent6410348ada83ca5fea19f706506ae4afaf8f4a89 (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/Gadu-Gadu/src/image.cpp')
-rw-r--r--protocols/Gadu-Gadu/src/image.cpp28
1 files changed, 23 insertions, 5 deletions
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);