summaryrefslogtreecommitdiff
path: root/plugins/AvatarHistory/src/AvatarDlg.cpp
diff options
context:
space:
mode:
authorTobias Weimer <wishmaster51@googlemail.com>2013-04-04 19:11:23 +0000
committerTobias Weimer <wishmaster51@googlemail.com>2013-04-04 19:11:23 +0000
commit15c7496ae9887b36ad84cbc2dd48b2ca202a120a (patch)
tree2e75b7aa7d250cdfe1f633f3615eece15cedd110 /plugins/AvatarHistory/src/AvatarDlg.cpp
parentc814aae8a9ba7f85996792b9c283fcd6605e11ff (diff)
fixed ""avatar path is null." message on empty history
git-svn-id: http://svn.miranda-ng.org/main/trunk@4307 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/AvatarHistory/src/AvatarDlg.cpp')
-rw-r--r--plugins/AvatarHistory/src/AvatarDlg.cpp43
1 files changed, 21 insertions, 22 deletions
diff --git a/plugins/AvatarHistory/src/AvatarDlg.cpp b/plugins/AvatarHistory/src/AvatarDlg.cpp
index a98f0ecb9b..d4d5bdcb32 100644
--- a/plugins/AvatarHistory/src/AvatarDlg.cpp
+++ b/plugins/AvatarHistory/src/AvatarDlg.cpp
@@ -30,8 +30,7 @@ int FillAvatarListFromDB(HWND list, HANDLE hContact);
int FillAvatarListFromFolder(HWND list, HANDLE hContact);
int FillAvatarListFromFiles(HWND list, HANDLE hContact);
int CleanupAvatarPic(HWND hwnd);
-BOOL UpdateAvatarPic(HWND hwnd);
-TCHAR* GetCurrentSelFile(HWND list);
+bool UpdateAvatarPic(HWND hwnd);
TCHAR * GetContactFolder(TCHAR *fn, HANDLE hContact);
BOOL ResolveShortcut(TCHAR *shortcut, TCHAR *file);
@@ -477,24 +476,32 @@ int FillAvatarListFromDB(HWND list, HANDLE hContact)
return 0;
}
-BOOL UpdateAvatarPic(HWND hwnd)
+bool UpdateAvatarPic(HWND hwnd)
{
HWND hwndpic = GetDlgItem(hwnd, IDC_AVATAR);
if (!hwnd || !hwndpic)
- return -1;
+ return false;
HWND list = GetDlgItem(hwnd, IDC_AVATARLIST);
- TCHAR *filename = GetCurrentSelFile(list);
- if (!filename)
+ int cursel = SendMessage(list, LB_GETCURSEL, 0, 0);
+ if (cursel < 0)
+ {
+ SetDlgItemText(hwnd,IDC_AVATARPATH,TranslateT("Avatar History is empty!"));
+ return false;
+ }
+
+ ListEntry *le = (ListEntry*) SendMessage(list, LB_GETITEMDATA, cursel, 0);
+
+ if (!le || !le->filename)
{
SetDlgItemText(hwnd,IDC_AVATARPATH,TranslateT("avatar path is null."));
return 0;
}
- SetDlgItemText(hwnd,IDC_AVATARPATH,filename);
+ SetDlgItemText(hwnd,IDC_AVATARPATH,le->filename);
- HBITMAP avpic = (HBITMAP) CallService(MS_IMG_LOAD, (WPARAM)filename, IMGL_TCHAR);
+ HBITMAP avpic = (HBITMAP) CallService(MS_IMG_LOAD, (WPARAM)le->filename, IMGL_TCHAR);
- BOOL found_image = (avpic != NULL);
+ bool found_image = (avpic != NULL);
avpic = (HBITMAP)SendMessage(hwndpic, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)avpic);
if (avpic)
@@ -549,14 +556,6 @@ static INT_PTR ShowDialogSvc(WPARAM wParam, LPARAM lParam)
return 0;
}
-TCHAR* GetCurrentSelFile(HWND list)
-{
- int cursel = SendMessage(list, LB_GETCURSEL, 0, 0);
- if (cursel > -1)
- return ((ListEntry*) SendMessage(list, LB_GETITEMDATA, cursel, 0))->filename;
- else
- return NULL;
-}
int ShowSaveDialog(HWND hwnd, TCHAR* fn, HANDLE hContact)
{
@@ -564,8 +563,6 @@ int ShowSaveDialog(HWND hwnd, TCHAR* fn, HANDLE hContact)
TCHAR file[MAX_PATH];
OPENFILENAME ofn;
ZeroMemory(&ofn, sizeof(OPENFILENAME));
- DBVARIANT dbvInitDir = {0};
- bool ret = (DBGetContactSettingTString(hContact,MODULE_NAME,"SavedAvatarFolder",&dbvInitDir)== 0);
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hwnd;
ofn.hInstance = hInst;
@@ -591,10 +588,12 @@ int ShowSaveDialog(HWND hwnd, TCHAR* fn, HANDLE hContact)
ofn.nMaxFile = MAX_PATH;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_DONTADDTORECENT;
ofn.lpstrDefExt = _tcsrchr(fn, '.')+1;
- if (ret)
+
+ DBVARIANT dbvInitDir = {0};
+ if (!db_get_ts(hContact,MODULE_NAME,"SavedAvatarFolder",&dbvInitDir))
{
ofn.lpstrInitialDir = dbvInitDir.ptszVal;
- DBFreeVariant(&dbvInitDir);
+ db_free(&dbvInitDir);
}
else
{
@@ -603,7 +602,7 @@ int ShowSaveDialog(HWND hwnd, TCHAR* fn, HANDLE hContact)
if (GetSaveFileName(&ofn))
{
CopyFile(fn, file, FALSE);
- DBWriteContactSettingTString(hContact,MODULE_NAME,"SavedAvatarFolder",file);
+ db_set_ts(hContact,MODULE_NAME,"SavedAvatarFolder",file);
}
return 0;
}