2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
14 #include <afs/param.h>
19 #include "svr_install.h"
20 #include "propcache.h"
23 * PROTOTYPES _________________________________________________________________
27 BOOL WINAPI
Server_Install_DlgProc (HWND hDlg
, UINT msg
, WPARAM wp
, LPARAM lp
);
29 void Server_Install_OnInitDialog (HWND hDlg
, LPSVR_INSTALL_PARAMS lpp
);
30 void Server_Install_OnEndTask_InitDialog (HWND hDlg
, LPTASKPACKET ptp
, LPSVR_INSTALL_PARAMS lpp
);
31 void Server_Install_OnBrowse (HWND hDlg
);
32 void Server_Install_EnableOK (HWND hDlg
);
33 void Server_Install_OnOK (HWND hDlg
);
37 * ROUTINES ___________________________________________________________________
41 void Server_Install (LPIDENT lpiServer
)
45 if ((hCurrent
= PropCache_Search (pcSVR_INSTALL
, NULL
)) != NULL
)
51 LPSVR_INSTALL_PARAMS lpp
= New (SVR_INSTALL_PARAMS
);
52 lpp
->lpiServer
= lpiServer
;
53 lpp
->szSource
[0] = TEXT('\0');
54 lpp
->szTarget
[0] = TEXT('\0');
56 HWND hDlg
= ModelessDialogParam (IDD_SVR_INSTALL
, NULL
, (DLGPROC
)Server_Install_DlgProc
, (LPARAM
)lpp
);
57 ShowWindow (hDlg
, SW_SHOW
);
62 BOOL WINAPI
Server_Install_DlgProc (HWND hDlg
, UINT msg
, WPARAM wp
, LPARAM lp
)
64 if (AfsAppLib_HandleHelp (IDD_SVR_INSTALL
, hDlg
, msg
, wp
, lp
))
67 LPSVR_INSTALL_PARAMS lpp
;
69 if (msg
== WM_INITDIALOG
)
70 SetWindowLongPtr (hDlg
, DWLP_USER
, lp
);
72 if ((lpp
= (LPSVR_INSTALL_PARAMS
)GetWindowLongPtr(hDlg
,DWLP_USER
)) != NULL
)
77 PropCache_Add (pcSVR_INSTALL
, NULL
, hDlg
);
78 Server_Install_OnInitDialog (hDlg
, lpp
);
83 if ((ptp
= (LPTASKPACKET
)lp
) != NULL
)
85 if (ptp
->idTask
== taskSVR_ENUM_TO_COMBOBOX
)
86 Server_Install_OnEndTask_InitDialog (hDlg
, ptp
, lpp
);
95 Server_Install_OnOK (hDlg
);
103 Server_Install_OnBrowse (hDlg
);
109 Server_Install_EnableOK (hDlg
);
115 SetWindowLongPtr (hDlg
, DWLP_USER
, 0);
116 PropCache_Delete (pcSVR_INSTALL
, NULL
);
126 void Server_Install_OnInitDialog (HWND hDlg
, LPSVR_INSTALL_PARAMS lpp
)
128 LPTSTR pszText
= FormatString (IDS_INSTALL_DESC1
);
129 SetDlgItemText (hDlg
, IDC_INSTALL_DESC
, pszText
);
130 FreeString (pszText
);
132 LPSVR_ENUM_TO_COMBOBOX_PACKET lppEnum
= New (SVR_ENUM_TO_COMBOBOX_PACKET
);
133 lppEnum
->hCombo
= GetDlgItem (hDlg
, IDC_SERVER
);
134 lppEnum
->lpiSelect
= lpp
->lpiServer
;
135 StartTask (taskSVR_ENUM_TO_COMBOBOX
, hDlg
, lppEnum
);
137 EnableWindow (GetDlgItem (hDlg
, IDC_SERVER
), FALSE
);
138 EnableWindow (GetDlgItem (hDlg
, IDOK
), FALSE
);
142 void Server_Install_OnEndTask_InitDialog (HWND hDlg
, LPTASKPACKET ptp
, LPSVR_INSTALL_PARAMS lpp
)
144 EnableWindow (GetDlgItem (hDlg
, IDC_SERVER
), TRUE
);
145 Server_Install_EnableOK (hDlg
);
149 void Server_Install_EnableOK (HWND hDlg
)
151 LPIDENT lpiServer
= NULL
;
153 if (IsWindowEnabled (GetDlgItem (hDlg
, IDC_SERVER
)))
154 lpiServer
= (LPIDENT
)CB_GetSelectedData (GetDlgItem (hDlg
, IDC_SERVER
));
156 BOOL fEnable
= (lpiServer
!= NULL
) ? TRUE
: FALSE
;
160 TCHAR szName
[ MAX_PATH
];
161 GetDlgItemText (hDlg
, IDC_FILENAME
, szName
, MAX_PATH
);
162 if (szName
[0] == TEXT('\0'))
168 TCHAR szName
[ MAX_PATH
];
169 GetDlgItemText (hDlg
, IDC_DIRECTORY
, szName
, MAX_PATH
);
170 if (szName
[0] == TEXT('\0'))
174 EnableWindow (GetDlgItem (hDlg
, IDOK
), fEnable
);
178 void Server_Install_OnOK (HWND hDlg
)
180 LPSVR_INSTALL_PARAMS lpp
= New (SVR_INSTALL_PARAMS
);
181 lpp
->lpiServer
= (LPIDENT
)CB_GetSelectedData (GetDlgItem (hDlg
, IDC_SERVER
));
182 GetDlgItemText (hDlg
, IDC_FILENAME
, lpp
->szSource
, MAX_PATH
);
183 GetDlgItemText (hDlg
, IDC_DIRECTORY
, lpp
->szTarget
, MAX_PATH
);
185 StartTask (taskSVR_INSTALL
, NULL
, lpp
);
189 void Server_Install_OnBrowse (HWND hDlg
)
191 TCHAR szFilter
[ cchRESOURCE
];
192 GetString (szFilter
, IDS_FILTER_ALLFILES
);
193 TCHAR chFilter
= szFilter
[ lstrlen(szFilter
)-1 ];
194 for (LPTSTR pszFilter
= szFilter
;
195 (*pszFilter
) && ((pszFilter
= (LPTSTR
)lstrchr (pszFilter
, chFilter
)) != NULL
);
198 *pszFilter
= TEXT('\0');
201 TCHAR szFilename
[ MAX_PATH
];
202 GetDlgItemText (hDlg
, IDC_FILENAME
, szFilename
, MAX_PATH
);
205 memset (&ofn
, 0x00, sizeof(ofn
));
206 ofn
.lStructSize
= sizeof(ofn
);
207 ofn
.hwndOwner
= hDlg
;
208 ofn
.hInstance
= THIS_HINST
;
209 ofn
.lpstrFilter
= szFilter
;
210 ofn
.nFilterIndex
= 1;
211 ofn
.lpstrFile
= szFilename
;
212 ofn
.nMaxFile
= MAX_PATH
;
213 ofn
.Flags
= OFN_HIDEREADONLY
| OFN_PATHMUSTEXIST
| OFN_FILEMUSTEXIST
;
215 TCHAR szPath
[ MAX_PATH
];
216 GetCurrentDirectory (MAX_PATH
, szPath
);
218 BOOL rc
= GetOpenFileName (&ofn
);
220 SetCurrentDirectory (szPath
);
223 SetDlgItemText (hDlg
, IDC_FILENAME
, szFilename
);