Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

282 lines
7.1 KiB

  1. #include "pch.h"
  2. #include "extra.h"
  3. #include "resource.h"
  4. #include "recact.h"
  5. #include "list.h"
  6. #include "merge.h"
  7. #include "lib3.h"
  8. #include "utils.h"
  9. //
  10. AssertData;
  11. AssertError;
  12. //
  13. //
  14. extern HANDLE vhinstCur; // current instance (from reint.c)
  15. typedef struct tagINFO
  16. {
  17. HWND hwnd; // dialog handle.
  18. node *mergeList; // list of files to query
  19. } INFO, FAR * PINFO;
  20. BOOL APIENTRY NewDlg_DlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
  21. /* externs needed */
  22. BOOL GetWin32Info(LPSTR lpFile, LPWIN32_FIND_DATA lpFW32);
  23. char vszLocalCopy[] = "Local Database";
  24. /****************************************************************************
  25. * Caller entrypoint for merge conflicts dialog.
  26. */
  27. int doMergeDialog(HWND hWnd, node *aList)
  28. {
  29. int nRet=-1;
  30. INFO sInfo;
  31. static inited=FALSE;
  32. node *currItem=aList;
  33. // There is a chance that the view window may be closed before we put up UI
  34. // in this case, we abort any merging that we thought may have gone on.
  35. if( !IsWindow(hWnd) )
  36. {
  37. DEBUG_PRINT(("Merge: hwnd is no longer active\n"));
  38. return -1;
  39. }
  40. sInfo.mergeList = aList;
  41. DEBUG_PRINT(("attempt to open dialog\n"));
  42. if(!inited)
  43. {
  44. RecAct_Init(vhinstCur);
  45. InitCommonControls();
  46. InitializeAll(0); // bogus param, but same as in FileSync...
  47. inited = TRUE;
  48. }
  49. nRet = DialogBoxParam(vhinstCur, MAKEINTRESOURCE(IDD_MERGE_LIST), hWnd, NewDlg_DlgProc, (LPARAM) &sInfo);
  50. DEBUG_PRINT(("return = %d (0x%08x)\n", nRet, nRet));
  51. while(currItem)
  52. {
  53. char szBigBuf[2*MAX_PATH];
  54. if(currItem->iFileStatus == SI_NOEXIST)
  55. {
  56. strcpy(szBigBuf, currItem->lpCP->lpServerPath);
  57. strcat(szBigBuf, currItem->lpCP->lpRemotePath);
  58. DeleteFile(szBigBuf);
  59. DEBUG_PRINT(("temp file <%s> deleted\n", szBigBuf));
  60. }
  61. currItem= currItem->next;
  62. }
  63. // RecAct_Term(vhinstCur);
  64. return(nRet);
  65. }
  66. /****************************************************************************
  67. * dialog stuff
  68. */
  69. BOOL NEAR PASCAL NewDlg_OnInitDialog(
  70. PINFO this,
  71. HWND hwndFocus,
  72. LPARAM lParam)
  73. {
  74. int currCount=0;
  75. RA_ITEM item;
  76. node *currItem=this->mergeList;
  77. char szBigBuf[2*MAX_PATH];
  78. char *szTemp;
  79. DEBUG_PRINT(("Merge:OnInitDialog\n"));
  80. while(currItem)
  81. {
  82. // insert each item into the list...
  83. item.mask = RAIF_ALL; // One of RAIF_
  84. item.iItem = currCount++;
  85. item.uStyle=RAIS_CANMERGE; // One of RAIS_
  86. item.uAction=currItem->uAction; // One of RAIA_
  87. item.pszName = currItem->sFind32Local.cFileName;
  88. if (currItem->sFind32Local.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
  89. item.uStyle = RAIS_FOLDER;
  90. memcpy(&item.siInside.fs.ftMod,&currItem->sFind32Local.ftLastWriteTime, sizeof(FILETIME));
  91. item.siInside.fs.dwcbHighLength = currItem->sFind32Local.nFileSizeHigh;
  92. item.siInside.fs.dwcbLowLength = currItem->sFind32Local.nFileSizeLow;
  93. item.siInside.pszDir=vszLocalCopy;
  94. item.siInside.fs.fscond = FS_COND_EXISTS;
  95. item.siInside.uState=currItem->iShadowStatus;
  96. lstrcpy(szBigBuf, currItem->lpCP->lpServerPath);
  97. lstrcat(szBigBuf, currItem->lpCP->lpRemotePath);
  98. if(currItem->iFileStatus != SI_NOEXIST)
  99. {
  100. Assert(currItem->sFind32Remote.cFileName[0]);
  101. memcpy(&item.siOutside.fs.ftMod, &currItem->sFind32Remote.ftLastWriteTime, sizeof(FILETIME));
  102. item.siOutside.fs.dwcbHighLength = currItem->sFind32Remote.nFileSizeHigh;
  103. item.siOutside.fs.dwcbLowLength = currItem->sFind32Remote.nFileSizeLow;
  104. }
  105. else
  106. {
  107. HANDLE fh;
  108. // fake up a file for a little while.
  109. fh = CreateFile(szBigBuf, GENERIC_READ|GENERIC_WRITE,
  110. FILE_SHARE_READ|FILE_SHARE_WRITE,
  111. NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
  112. if(fh==INVALID_HANDLE_VALUE) {
  113. DEBUG_PRINT(("file not created\n"));
  114. } else {
  115. DEBUG_PRINT(("temp file <%s> created\n", szBigBuf));
  116. CloseHandle( fh );
  117. }
  118. }
  119. szTemp = StrRChr(szBigBuf, szBigBuf+lstrlen(szBigBuf)-1, '\\');
  120. Assert(szTemp);
  121. *szTemp = (char) 0;
  122. item.siOutside.pszDir=szBigBuf;
  123. item.siOutside.fs.fscond = FS_COND_EXISTS;
  124. item.siOutside.uState=currItem->iFileStatus;
  125. item.lParam=(LPARAM) currItem;
  126. DEBUG_PRINT(("inserting <%s> <%s %s> at %d\n", item.siInside.pszDir, item.siOutside.pszDir, item.pszName, item.iItem));
  127. if(-1 == RecAct_InsertItem(GetDlgItem(this->hwnd, IDC_RECACTION), &item))
  128. {
  129. #ifdef DEBUG
  130. DEBUG_PRINT(("RecAct_InsertItem failed\n"));
  131. #endif //DEBUG
  132. }
  133. else
  134. {
  135. #ifdef DEBUG
  136. DEBUG_PRINT(("RecAct_InsertItem done right!\n"));
  137. #endif //DEBUG
  138. }
  139. currItem = currItem->next;
  140. }
  141. DEBUG_PRINT(("done list\n"));
  142. return TRUE;
  143. }
  144. /*****************************************************************************
  145. * Purpose: NewDlg handle WM_COMMAND
  146. * Returns: --
  147. * Cond: --
  148. */
  149. VOID NEAR PASCAL NewDlg_OnCommand(
  150. PINFO this,
  151. int id,
  152. HWND hwndCtl,
  153. UINT uNotifyCode)
  154. {
  155. HWND hwnd = this->hwnd;
  156. switch (id)
  157. {
  158. case IDOK:
  159. EndDialog(hwnd,TRUE);
  160. break;
  161. case IDCANCEL:
  162. EndDialog(hwnd,FALSE);
  163. break;
  164. default:
  165. DEBUG_PRINT(("Merge:OnCommand - Unknown id %d\n",id));
  166. return;
  167. }
  168. }
  169. /*****************************************************************************
  170. * Purpose: NewDlg handle WM_NOTIFY
  171. * Returns: --
  172. * Cond: --
  173. */
  174. BOOL NEAR PASCAL NewDlg_OnNotify(
  175. PINFO this,
  176. int idFrom,
  177. NMHDR FAR * lpnmhdr)
  178. {
  179. node *currItem;
  180. HWND hwnd = this->hwnd;
  181. NM_RECACT *pnmrecact = (NM_RECACT *) lpnmhdr;
  182. Assert(lpnmhdr); Assert(this);
  183. switch (lpnmhdr->code)
  184. {
  185. case RN_SELCHANGED:
  186. DEBUG_PRINT(("RN_SELCHANGED received\n"));
  187. return FALSE;
  188. case RN_ITEMCHANGED:
  189. if(pnmrecact->mask & RAIF_ACTION)
  190. {
  191. currItem = (node *) pnmrecact->lParam;
  192. Assert(currItem);
  193. currItem->uAction = pnmrecact->uAction;
  194. DEBUG_PRINT(("RN_ITEMCHANGED on %08x received and delt with\n", currItem->lpCP->hShadow));
  195. }
  196. else
  197. DEBUG_PRINT(("RN_ITEMCHANGED: no RAIF_ACTION\n"));
  198. break;
  199. default:
  200. break;
  201. }
  202. return FALSE;
  203. }
  204. /*****************************************************************************
  205. * Purpose: Handle WM_DESTROY
  206. * Returns: --
  207. * Cond: --
  208. */
  209. void NEAR PASCAL NewDlg_OnDestroy(PINFO this)
  210. {
  211. }
  212. /*****************************************************************************
  213. * Purpose: random
  214. * Returns: mush
  215. * Cond: --
  216. */
  217. BOOL APIENTRY NewDlg_DlgProc(
  218. HWND hDlg,
  219. UINT message,
  220. WPARAM wParam,
  221. LPARAM lParam)
  222. {
  223. PINFO this;
  224. this = (PINFO)GetWindowLong(hDlg, DWL_USER);
  225. if(!this)
  226. if(message == WM_INITDIALOG)
  227. {
  228. // lparam = the pinfo we need. Allocated from above.
  229. this = (PINFO) lParam;
  230. this->hwnd = hDlg;
  231. SetWindowLong(hDlg, DWL_USER, (LONG) lParam);
  232. }
  233. else
  234. return FALSE; // ignore everthing until we get an initdialog
  235. switch (message)
  236. {
  237. HANDLE_MSG(this, WM_INITDIALOG, NewDlg_OnInitDialog);
  238. HANDLE_MSG(this, WM_COMMAND, NewDlg_OnCommand);
  239. HANDLE_MSG(this, WM_NOTIFY, NewDlg_OnNotify);
  240. HANDLE_MSG(this, WM_DESTROY, NewDlg_OnDestroy);
  241. default:
  242. return FALSE;
  243. }
  244. }