[WINESYNC] msi: Add support for control event DirectoryListNew.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=25687
Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id 97a7a4ff0c8895c3ef1979eeee988c4c121d9839 by Hans Leidekker <hans@codeweavers.com>
This commit is contained in:
winesync 2022-03-13 00:04:01 +01:00 committed by Mark Jansen
parent eab017d18f
commit b608ba9798
No known key found for this signature in database
GPG key ID: B39240EE84BEAE8B
29 changed files with 150 additions and 45 deletions

View file

@ -2151,23 +2151,27 @@ struct msi_pathedit_info
WNDPROC oldproc;
};
static WCHAR *get_path_property( msi_dialog *dialog, msi_control *control )
{
WCHAR *prop, *path;
BOOL indirect = control->attributes & msidbControlAttributesIndirect;
if (!(prop = msi_dialog_dup_property( dialog, control->property, indirect ))) return NULL;
path = msi_dialog_dup_property( dialog, prop, TRUE );
msi_free( prop );
return path;
}
static void msi_dialog_update_pathedit( msi_dialog *dialog, msi_control *control )
{
LPWSTR prop, path;
BOOL indirect;
WCHAR *path;
if (!control && !(control = msi_dialog_find_control_by_type( dialog, szPathEdit )))
return;
indirect = control->attributes & msidbControlAttributesIndirect;
prop = msi_dialog_dup_property( dialog, control->property, indirect );
path = msi_dialog_dup_property( dialog, prop, TRUE );
if (!(path = get_path_property( dialog, control ))) return;
SetWindowTextW( control->hwnd, path );
SendMessageW( control->hwnd, EM_SETSEL, 0, -1 );
msi_free( path );
msi_free( prop );
}
/* FIXME: test when this should fail */
@ -2921,16 +2925,12 @@ static UINT msi_dialog_list_box( msi_dialog *dialog, MSIRECORD *rec )
static void msi_dialog_update_directory_combo( msi_dialog *dialog, msi_control *control )
{
LPWSTR prop, path;
BOOL indirect;
WCHAR *path;
if (!control && !(control = msi_dialog_find_control_by_type( dialog, szDirectoryCombo )))
return;
indirect = control->attributes & msidbControlAttributesIndirect;
prop = msi_dialog_dup_property( dialog, control->property, indirect );
path = msi_dialog_dup_property( dialog, prop, TRUE );
if (!(path = get_path_property( dialog, control ))) return;
PathStripPathW( path );
PathRemoveBackslashW( path );
@ -2938,7 +2938,6 @@ static void msi_dialog_update_directory_combo( msi_dialog *dialog, msi_control *
SendMessageW( control->hwnd, CB_SETCURSEL, 0, 0 );
msi_free( path );
msi_free( prop );
}
static UINT msi_dialog_directory_combo( msi_dialog *dialog, MSIRECORD *rec )
@ -2967,31 +2966,28 @@ static UINT msi_dialog_directory_combo( msi_dialog *dialog, MSIRECORD *rec )
static void msi_dialog_update_directory_list( msi_dialog *dialog, msi_control *control )
{
WCHAR dir_spec[MAX_PATH];
static const WCHAR asterisk[] = {'*',0};
WCHAR dir_spec[MAX_PATH], *path;
WIN32_FIND_DATAW wfd;
LPWSTR prop, path;
BOOL indirect;
LVITEMW item;
HANDLE file;
static const WCHAR asterisk[] = {'*',0};
if (!control && !(control = msi_dialog_find_control_by_type( dialog, szDirectoryList )))
return;
/* clear the list-view */
SendMessageW( control->hwnd, LVM_DELETEALLITEMS, 0, 0 );
indirect = control->attributes & msidbControlAttributesIndirect;
prop = msi_dialog_dup_property( dialog, control->property, indirect );
path = msi_dialog_dup_property( dialog, prop, TRUE );
if (!(path = get_path_property( dialog, control ))) return;
lstrcpyW( dir_spec, path );
lstrcatW( dir_spec, asterisk );
file = FindFirstFileW( dir_spec, &wfd );
if ( file == INVALID_HANDLE_VALUE )
if (file == INVALID_HANDLE_VALUE)
{
msi_free( path );
return;
}
do
{
@ -3010,7 +3006,6 @@ static void msi_dialog_update_directory_list( msi_dialog *dialog, msi_control *c
SendMessageW( control->hwnd, LVM_INSERTITEMW, 0, (LPARAM)&item );
} while ( FindNextFileW( file, &wfd ) );
msi_free( prop );
msi_free( path );
FindClose( file );
}
@ -3043,38 +3038,110 @@ static UINT msi_dialog_directorylist_up( msi_dialog *dialog )
return ERROR_SUCCESS;
}
static UINT msi_dialog_dirlist_handler( msi_dialog *dialog,
msi_control *control, WPARAM param )
static WCHAR *get_unique_folder_name( const WCHAR *root, int *ret_len )
{
LPNMHDR nmhdr = (LPNMHDR)param;
WCHAR new_path[MAX_PATH];
WCHAR text[MAX_PATH];
LPWSTR path, prop;
BOOL indirect;
static const WCHAR fmtW[] = {'%','s','%','s',' ','%','u',0};
WCHAR newfolder[MAX_PATH], *path, *ptr;
int len, count = 2;
len = LoadStringW( msi_hInstance, IDS_NEWFOLDER, newfolder, ARRAY_SIZE(newfolder) );
len += strlenW(root) + 1;
if (!(path = msi_alloc( (len + 4) * sizeof(WCHAR) ))) return NULL;
strcpyW( path, root );
strcatW( path, newfolder );
for (;;)
{
if (GetFileAttributesW( path ) == INVALID_FILE_ATTRIBUTES) break;
if (count > 99)
{
msi_free( path );
return NULL;
}
len = sprintfW( path, fmtW, root, newfolder, count++ ) + 1;
}
ptr = strrchrW( path, '\\' ) + 1;
*ret_len = len - (ptr - path);
memmove( path, ptr, *ret_len * sizeof(WCHAR) );
return path;
}
static UINT msi_dialog_directorylist_new( msi_dialog *dialog )
{
msi_control *control;
WCHAR *path;
LVITEMW item;
int index;
if (nmhdr->code != LVN_ITEMACTIVATE)
return ERROR_SUCCESS;
control = msi_dialog_find_control_by_type( dialog, szDirectoryList );
index = SendMessageW( control->hwnd, LVM_GETNEXTITEM, -1, LVNI_SELECTED );
if ( index < 0 )
{
ERR("No list-view item selected!\n");
return ERROR_FUNCTION_FAILED;
}
if (!(path = get_path_property( dialog, control ))) return ERROR_OUTOFMEMORY;
item.mask = LVIF_TEXT;
item.iItem = 0;
item.iSubItem = 0;
item.pszText = text;
item.cchTextMax = MAX_PATH;
SendMessageW( control->hwnd, LVM_GETITEMTEXTW, index, (LPARAM)&item );
item.pszText = get_unique_folder_name( path, &item.cchTextMax );
index = SendMessageW( control->hwnd, LVM_INSERTITEMW, 0, (LPARAM)&item );
SendMessageW( control->hwnd, LVM_ENSUREVISIBLE, index, 0 );
SendMessageW( control->hwnd, LVM_EDITLABELW, index, -1 );
msi_free( path );
msi_free( item.pszText );
return ERROR_SUCCESS;
}
static UINT msi_dialog_dirlist_handler( msi_dialog *dialog, msi_control *control, WPARAM param )
{
NMHDR *nmhdr = (NMHDR *)param;
WCHAR text[MAX_PATH], *new_path, *path, *prop;
BOOL indirect;
switch (nmhdr->code)
{
case LVN_ENDLABELEDITW:
{
NMLVDISPINFOW *info = (NMLVDISPINFOW *)param;
if (!info->item.pszText) return ERROR_SUCCESS;
lstrcpynW( text, info->item.pszText, ARRAY_SIZE(text) );
text[ARRAY_SIZE(text) - 1] = 0;
break;
}
case LVN_ITEMACTIVATE:
{
LVITEMW item;
int index = SendMessageW( control->hwnd, LVM_GETNEXTITEM, -1, LVNI_SELECTED );
if (index < 0)
{
ERR("no list-view item selected\n");
return ERROR_FUNCTION_FAILED;
}
item.iSubItem = 0;
item.pszText = text;
item.cchTextMax = MAX_PATH;
SendMessageW( control->hwnd, LVM_GETITEMTEXTW, index, (LPARAM)&item );
text[ARRAY_SIZE(text) - 1] = 0;
break;
}
default:
return ERROR_SUCCESS;
}
indirect = control->attributes & msidbControlAttributesIndirect;
prop = msi_dialog_dup_property( dialog, control->property, indirect );
path = msi_dialog_dup_property( dialog, prop, TRUE );
if (!(new_path = msi_alloc( (strlenW(path) + strlenW(text) + 2) * sizeof(WCHAR) )))
{
msi_free( prop );
msi_free( path );
return ERROR_OUTOFMEMORY;
}
lstrcpyW( new_path, path );
lstrcatW( new_path, text );
if (nmhdr->code == LVN_ENDLABELEDITW) CreateDirectoryW( new_path, NULL );
lstrcatW( new_path, szBackSlash );
msi_dialog_set_property( dialog->package, prop, new_path );
@ -3085,6 +3152,8 @@ static UINT msi_dialog_dirlist_handler( msi_dialog *dialog,
msi_free( prop );
msi_free( path );
msi_free( new_path );
return ERROR_SUCCESS;
}
@ -3094,7 +3163,7 @@ static UINT msi_dialog_directory_list( msi_dialog *dialog, MSIRECORD *rec )
LPCWSTR prop;
DWORD style;
style = LVS_LIST | WS_VSCROLL | LVS_SHAREIMAGELISTS |
style = LVS_LIST | WS_VSCROLL | LVS_SHAREIMAGELISTS | LVS_EDITLABELS |
LVS_AUTOARRANGE | LVS_SINGLESEL | WS_BORDER |
LVS_SORTASCENDING | WS_CHILD | WS_GROUP | WS_TABSTOP;
control = msi_dialog_add_control( dialog, rec, WC_LISTVIEWW, style );
@ -4533,6 +4602,11 @@ static UINT event_directory_list_up( msi_dialog *dialog, const WCHAR *argument )
return msi_dialog_directorylist_up( dialog );
}
static UINT event_directory_list_new( msi_dialog *dialog, const WCHAR *argument )
{
return msi_dialog_directorylist_new( dialog );
}
static UINT event_reinstall_mode( msi_dialog *dialog, const WCHAR *argument )
{
return msi_set_property( dialog->package->db, szReinstallMode, argument, -1 );
@ -4560,6 +4634,7 @@ static const WCHAR set_target_pathW[] = {'S','e','t','T','a','r','g','e','t','P'
static const WCHAR resetW[] = {'R','e','s','e','t',0};
static const WCHAR set_install_levelW[] = {'S','e','t','I','n','s','t','a','l','l','L','e','v','e','l',0};
static const WCHAR directory_list_upW[] = {'D','i','r','e','c','t','o','r','y','L','i','s','t','U','p',0};
static const WCHAR directory_list_newW[] = {'D','i','r','e','c','t','o','r','y','L','i','s','t','N','e','w',0};
static const WCHAR selection_browseW[] = {'S','e','l','e','c','t','i','o','n','B','r','o','w','s','e',0};
static const WCHAR reinstall_modeW[] = {'R','e','i','n','s','t','a','l','l','M','o','d','e',0};
static const WCHAR reinstallW[] = {'R','e','i','n','s','t','a','l','l',0};
@ -4579,6 +4654,7 @@ static const struct control_event control_events[] =
{ resetW, event_reset },
{ set_install_levelW, event_set_install_level },
{ directory_list_upW, event_directory_list_up },
{ directory_list_newW, event_directory_list_new },
{ selection_browseW, event_spawn_dialog },
{ reinstall_modeW, event_reinstall_mode },
{ reinstallW, event_reinstall },

View file

@ -31,6 +31,7 @@ STRINGTABLE
13 "ìðåæîâîòî óñòðîéñòâà íóæíî çà ôóíêöèîíàëíîñòòà ëèïñâà "
14 "ôóíêöèîíàëíîñò îò:"
15 "èçáåðåòå ïàïêàòà, êîÿòî ñúäúðæà %s"
100 "New Folder"
}
/* Error messages */

View file

@ -31,6 +31,7 @@ STRINGTABLE
13 "featurens netværksdrev mangler."
14 "feature fra:"
15 "Vælg kataloget som indeholder '%s'."
100 "New Folder"
}
/* Error messages */

View file

@ -32,6 +32,7 @@ STRINGTABLE
13 "Das Netzwerklaufwerk für das Feature fehlt."
14 "Feature von:"
15 "Wählen Sie das Verzeichnis aus, dass %s enthält."
100 "New Folder"
}
/* Error messages */

View file

@ -32,6 +32,7 @@ STRINGTABLE
13 "network drive for feature missing"
14 "feature from:"
15 "choose which folder contains %s"
100 "New Folder"
}
/* Error messages */

View file

@ -31,6 +31,7 @@ STRINGTABLE
13 "unidad de red para característica ausente"
14 "característica de:"
15 "elija qué carpeta contiene %s"
100 "New Folder"
}
/* Error messages */

View file

@ -31,6 +31,7 @@ STRINGTABLE
13 "Ominaisuuden verkkolevy puuttuu."
14 "Ominaisuus:"
15 "Valitse kansio, jossa on %s"
100 "New Folder"
}
/* Error messages */

View file

@ -32,6 +32,7 @@ STRINGTABLE
13 "lecteur réseau pour la fonctionnalité manquante"
14 "fonctionnalité depuis :"
15 "sélectionnez le dossier contenant %s"
100 "New Folder"
}
/* Error messages */

View file

@ -34,6 +34,7 @@ STRINGTABLE
13 "כונן רשת עבור התכונה חסר"
14 "מהתקן מ:"
15 "בחר איזו תיקיה מכילה את %s"
100 "New Folder"
}
/* Error messages */

View file

@ -31,6 +31,7 @@ STRINGTABLE
13 "hiányzó tulajdonság a hálózati meghajtóhoz"
14 "tulajdonság innen:"
15 "válassza ki, melyik mappa tartalmazza ezt: %s"
100 "New Folder"
}
/* Error messages */

View file

@ -31,6 +31,7 @@ STRINGTABLE
13 "drive jatingan untuk fitur hilang"
14 "fitur dari:"
15 "pilih folder yang berisi %s"
100 "New Folder"
}
/* Error messages */

View file

@ -31,6 +31,7 @@ STRINGTABLE
13 "periferica di rete per la funzionalità mancante"
14 "funzionalità da:"
15 "selezionare la cartella che contiene %s"
100 "New Folder"
}
/* Error messages */

View file

@ -10,6 +10,7 @@ STRINGTABLE
13 "機能があるネットワーク ドライブがありません"
14 "機能の場所:"
15 "%s のあるフォルダを選択してください"
100 "New Folder"
}
/* Error messages */

View file

@ -33,6 +33,7 @@ STRINGTABLE
13 "빠진 부분(feature)을 위한 네트워크 드라이브"
14 "부분(feature)에서:"
15 " %s를 포함하는 폴더 선택"
100 "New Folder"
}
/* Error messages */

View file

@ -31,6 +31,7 @@ STRINGTABLE
13 "trūksta tinklo disko komponentui"
14 "komponentas iš:"
15 "parinkite aplanką, kuris turi %s"
100 "New Folder"
}
/* Error messages */

View file

@ -31,6 +31,7 @@ STRINGTABLE
13 "De netwerkschijf met de feature ontbreekt"
14 "Feature van:"
15 "Kies de map die %s bevat"
100 "New Folder"
}
/* Error messages */

View file

@ -31,6 +31,7 @@ STRINGTABLE
13 "Egenskapens nettverksstasjon mangler."
14 "Egenskap fra::"
15 "Velg katalogen som inneholder '%s'."
100 "New Folder"
}
/* Error messages */

View file

@ -32,6 +32,7 @@ STRINGTABLE
13 "dysk siecowy zawierający żądaną funckje jest niedostępny"
14 "funkcja z:"
15 "wybierz folder zawierający '%s'"
100 "New Folder"
}
/* Error messages */

View file

@ -33,6 +33,7 @@ STRINGTABLE
13 "faltando drive de rede para característica"
14 "origem da característica:"
15 "escolha a pasta que contém %s"
100 "New Folder"
}
/* Error messages */

View file

@ -45,6 +45,7 @@ STRINGTABLE
13 "lipsește unitatea de rețea pentru această caracteristică"
14 "caracteristică de la:"
15 "selectați fișierul care conține %s"
100 "New Folder"
}
/* Error messages */

View file

@ -31,6 +31,7 @@ STRINGTABLE
13 "сетевой диск для данной возможности не указан"
14 "возможность из:"
15 "выберите каталог, содержащий %s"
100 "New Folder"
}
/* Error messages */

View file

@ -31,6 +31,7 @@ STRINGTABLE
13 "manjkajoč omrežni pogon za namestitev funkcijo"
14 "funkcija z:"
15 "izberite mapo, ki vsebuje %s"
100 "New Folder"
}
/* Error messages */

View file

@ -32,6 +32,7 @@ STRINGTABLE
13 "rrjet drive-ri për funksionin e munguar"
14 "funksione nga:"
15 "zgjidhni dosjen që përmban %s"
100 "New Folder"
}
/* Error messages */

View file

@ -32,6 +32,7 @@ STRINGTABLE
13 "mrežni drajv nedostaje"
14 "dodatak sa:"
15 "izaberite koji folder sadrži %s"
100 "New Folder"
}
/* Error messages */

View file

@ -31,6 +31,7 @@ STRINGTABLE
13 "nätverksenhet för funktion saknar"
14 "funktion från:"
15 "välj den mapp som innehåller %s"
100 "New Folder"
}
/* Error messages */

View file

@ -31,6 +31,7 @@ STRINGTABLE
13 "Eksik özellik için ağ sürücüsü"
14 "Şuradan özellik:"
15 "%s içeren dizini seçiniz."
100 "New Folder"
}
/* Error messages */

View file

@ -33,6 +33,7 @@ STRINGTABLE
13 "мережевий диск для даної можливості не вказаний"
14 "можливість з:"
15 "виберіть папку, що містить %s"
100 "New Folder"
}
/* Error messages */

View file

@ -34,6 +34,7 @@ STRINGTABLE
13 "本功能的网络驱动器不存在"
14 "功能来自:"
15 "选择包含 %s 的文件夹"
100 "New Folder"
}
/* Error messages */

View file

@ -25,6 +25,8 @@
#define MSIERR_INFO_ACTIONSTART 14
#define MSIERR_INFO_ACTIONENDED 15
#define IDS_NEWFOLDER 100
#define MSIERR_INSERTDISK 1302
#define MSIERR_CABNOTFOUND 1311