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.

828 lines
26 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1998.
  5. //
  6. // File: autosync.cpp
  7. //
  8. // Contents: Offline AutoSync class
  9. //
  10. // Classes: CAutoSyncPage
  11. //
  12. // Notes:
  13. //
  14. // History: 14-Nov-97 SusiA Created.
  15. //
  16. //--------------------------------------------------------------------------
  17. #include "precomp.h"
  18. extern LANGID g_LangIdSystem; // LangId of system we are running on.
  19. extern HINSTANCE g_hmodThisDll; // Handle to this DLL itself.
  20. /*
  21. Both the Logon and Idle pages in the settings dialog share this class
  22. for performance reasons. i.e. don't have to enum handlers and setup
  23. ras combo twice. If we ever need to sepcify the difference between settings
  24. to handlers for logon/logoff and Idle then these would have to be separated
  25. */
  26. // initializes the specified hwnd.
  27. BOOL CAutoSyncPage::InitializeHwnd(HWND hwnd,SYNCTYPE syncType,DWORD dwDefaultConnection)
  28. {
  29. HRESULT hr;
  30. HWND hwndRasCombo;
  31. HWND hwndList;
  32. HIMAGELIST himage;
  33. LV_COLUMN columnInfo;
  34. WORD wHandlerID;
  35. CListView **ppListView = NULL;
  36. UINT ImageListflags;
  37. Assert(hwnd == m_hwndAutoSync || hwnd == m_hwndIdle);
  38. // make sure main class is initialized.
  39. if (FALSE == Initialize(hwnd,dwDefaultConnection))
  40. {
  41. return FALSE;
  42. }
  43. // Setup the Ras combo
  44. // !!!Must be done before Initializing the Handler queue.
  45. smBoolChk(hwndRasCombo = GetDlgItem(hwnd,IDC_AUTOUPDATECOMBO));
  46. m_pRas->FillRasCombo(hwndRasCombo,FALSE,TRUE);
  47. // now initialize the handler which will create queue
  48. // if necessary and fill in the values for the specified syncType
  49. smBoolChk(InitializeHandler(hwnd,syncType));
  50. Assert(m_HndlrQueue);
  51. // If initialization was successfull, read in connection info
  52. // based on th type.
  53. if ( FAILED(m_HndlrQueue->InitSyncSettings(syncType,hwndRasCombo)))
  54. {
  55. return FALSE;
  56. }
  57. hr = m_HndlrQueue->FindFirstHandlerInState (HANDLERSTATE_PREPAREFORSYNC,&wHandlerID);
  58. while (hr == S_OK)
  59. {
  60. m_HndlrQueue->ReadSyncSettingsPerConnection(syncType,wHandlerID);
  61. hr = m_HndlrQueue->FindNextHandlerInState(wHandlerID,HANDLERSTATE_PREPAREFORSYNC,
  62. &wHandlerID);
  63. }
  64. //initialize the item list and style
  65. smBoolChk(hwndList = GetDlgItem(hwnd,IDC_AUTOUPDATELIST));
  66. ppListView = (syncType == SYNCTYPE_AUTOSYNC) ? &m_pItemListViewAutoSync : &m_pItemListViewIdle;
  67. if (hwndList)
  68. {
  69. *ppListView = new CListView(hwndList,hwnd,IDC_AUTOUPDATELIST,WM_NOTIFYLISTVIEWEX);
  70. }
  71. if (NULL == *ppListView)
  72. {
  73. return FALSE;
  74. }
  75. (*ppListView)->SetExtendedListViewStyle(LVS_EX_CHECKBOXES
  76. | LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP );
  77. ImageListflags = ILC_COLOR | ILC_MASK;
  78. if (IsHwndRightToLeft(hwnd))
  79. {
  80. ImageListflags |= ILC_MIRROR;
  81. }
  82. // create an imagelist
  83. himage = ImageList_Create( GetSystemMetrics(SM_CXSMICON),
  84. GetSystemMetrics(SM_CYSMICON),ImageListflags,5,20);
  85. if (himage)
  86. {
  87. (*ppListView)->SetImageList(himage,LVSIL_SMALL);
  88. }
  89. // Insert the Proper columns
  90. columnInfo.mask = LVCF_FMT | LVCF_WIDTH;
  91. columnInfo.fmt = LVCFMT_LEFT;
  92. columnInfo.cx = CalcListViewWidth(hwndList,260);
  93. (*ppListView)->InsertColumn(0,&columnInfo);
  94. smBoolChk(ShowItemsOnThisConnection(hwnd,syncType,dwDefaultConnection));
  95. ShowWindow(hwnd, SW_SHOWNORMAL );
  96. UpdateWindow(hwnd);
  97. return TRUE;
  98. }
  99. //+-------------------------------------------------------------------------------
  100. //
  101. // FUNCTION: BOOL CAutoSyncPage::Initialize(DWORD dwDefaultConnection)
  102. //
  103. // PURPOSE: initialization for the autosync page
  104. //
  105. // RETURN VALUE: return TRUE if we process it ok.
  106. //
  107. // HISTORY: 01-01-98 SusiA Created.
  108. //
  109. //+-------------------------------------------------------------------------------
  110. BOOL CAutoSyncPage::Initialize(HWND hwnd ,DWORD dwDefaultConnection )
  111. {
  112. if (m_fInitialized)
  113. return TRUE;
  114. // Initialize Ras Combo box
  115. m_pRas= new CRasUI();
  116. if (NULL == m_pRas || FALSE == m_pRas->Initialize())
  117. {
  118. if (m_pRas)
  119. {
  120. delete m_pRas;
  121. m_pRas = NULL;
  122. }
  123. return FALSE;
  124. }
  125. m_fInitialized = TRUE;
  126. return TRUE;
  127. }
  128. //+-------------------------------------------------------------------------------
  129. //
  130. // FUNCTION: BOOL CAutoSyncPage::InitializeHandler()
  131. //
  132. // PURPOSE: initialization for the autosync page
  133. //
  134. // RETURN VALUE: return TRUE if we process it ok.
  135. //
  136. // HISTORY: 01-01-98 SusiA Created.
  137. //
  138. //+-------------------------------------------------------------------------------
  139. BOOL CAutoSyncPage::InitializeHandler(HWND hwnd,SYNCTYPE /* SyncType */)
  140. {
  141. SCODE sc = S_OK;
  142. TCHAR lpName[MAX_PATH];
  143. HKEY hkSyncMgr;
  144. CLSID clsid;
  145. WORD wHandlerID;
  146. HWND hwndRasCombo;
  147. Assert(hwnd == m_hwndAutoSync || hwnd == m_hwndIdle);
  148. if (NULL == (hwndRasCombo = GetDlgItem(hwnd,IDC_AUTOUPDATECOMBO)) )
  149. {
  150. return FALSE;
  151. }
  152. if (NULL == m_HndlrQueue) // if queue is already initialized, just return.
  153. {
  154. m_HndlrQueue = new CHndlrQueue(QUEUETYPE_SETTINGS);
  155. if (NULL == m_HndlrQueue)
  156. {
  157. return FALSE;
  158. }
  159. if (FAILED(m_HndlrQueue->Init()))
  160. {
  161. m_HndlrQueue->Release();
  162. m_HndlrQueue = NULL;
  163. return FALSE;
  164. }
  165. // loop through the reg getting the handlers and trying to
  166. // create them.
  167. if (hkSyncMgr = RegGetHandlerTopLevelKey(KEY_READ))
  168. {
  169. DWORD dwIndex = 0;
  170. while (ERROR_SUCCESS == RegEnumKey(hkSyncMgr,dwIndex,
  171. lpName,ARRAYSIZE(lpName)))
  172. {
  173. if (NOERROR == CLSIDFromString(lpName,&clsid) )
  174. {
  175. if (NOERROR == m_HndlrQueue->AddHandler(clsid, &wHandlerID))
  176. {
  177. m_HndlrQueue->CreateServer(wHandlerID,&clsid);
  178. }
  179. }
  180. dwIndex++;
  181. }
  182. RegCloseKey(hkSyncMgr);
  183. }
  184. // Initialize the items.
  185. sc = m_HndlrQueue->FindFirstHandlerInState(HANDLERSTATE_INITIALIZE,&wHandlerID);
  186. while (sc == S_OK)
  187. {
  188. m_HndlrQueue->Initialize(wHandlerID,0,SYNCMGRFLAG_SETTINGS,0,NULL);
  189. sc = m_HndlrQueue->FindNextHandlerInState(wHandlerID,
  190. HANDLERSTATE_INITIALIZE,
  191. &wHandlerID);
  192. }
  193. // loop through adding items
  194. sc = m_HndlrQueue->FindFirstHandlerInState (HANDLERSTATE_ADDHANDLERTEMS,&wHandlerID);
  195. while (sc == S_OK)
  196. {
  197. m_HndlrQueue->AddHandlerItemsToQueue(wHandlerID);
  198. sc = m_HndlrQueue->FindNextHandlerInState(wHandlerID,HANDLERSTATE_ADDHANDLERTEMS,
  199. &wHandlerID);
  200. }
  201. }
  202. Assert(m_HndlrQueue);
  203. return TRUE;
  204. }
  205. void CAutoSyncPage::SetAutoSyncHwnd(HWND hwnd)
  206. {
  207. m_hwndAutoSync = hwnd;
  208. }
  209. void CAutoSyncPage::SetIdleHwnd(HWND hwnd)
  210. {
  211. m_hwndIdle = hwnd;
  212. }
  213. //--------------------------------------------------------------------------------
  214. //
  215. // FUNCTION: CAutoSyncPage::CommitChanges()
  216. //
  217. // PURPOSE: Write all the current AutoSync Settings to the registry
  218. //
  219. // COMMENTS: Implemented on main thread.
  220. //
  221. // HISTORY: 01-01-98 SusiA Created.
  222. //
  223. //--------------------------------------------------------------------------------
  224. HRESULT CAutoSyncPage::CommitAutoSyncChanges(void)
  225. {
  226. HRESULT hr = S_FALSE;
  227. if (m_HndlrQueue)
  228. {
  229. hr = m_HndlrQueue->CommitSyncChanges(SYNCTYPE_AUTOSYNC,m_pRas);
  230. }
  231. return hr;
  232. }
  233. //--------------------------------------------------------------------------------
  234. //
  235. // FUNCTION: CAutoSyncPage::CommitIdleChanges()
  236. //
  237. // PURPOSE: Write all the current Idle Settings to the registry
  238. //
  239. //
  240. //
  241. // HISTORY: 02-23-98 rogerg Created.
  242. //
  243. //--------------------------------------------------------------------------------
  244. HRESULT CAutoSyncPage::CommitIdleChanges(void)
  245. {
  246. HRESULT hr = S_FALSE;
  247. if (m_HndlrQueue)
  248. {
  249. hr = m_HndlrQueue->CommitSyncChanges(SYNCTYPE_IDLE,m_pRas);
  250. }
  251. return hr;
  252. }
  253. //+-------------------------------------------------------------------------------
  254. //
  255. // FUNCTION: CAutoSyncPage::~CAutoSyncPage(HWND hwnd)
  256. //
  257. // PURPOSE: destructor
  258. //
  259. // COMMENTS: destructor for AutoSync page
  260. //
  261. //--------------------------------------------------------------------------------
  262. CAutoSyncPage::~CAutoSyncPage()
  263. {
  264. if (m_pRas)
  265. {
  266. delete m_pRas;
  267. m_pRas = NULL;
  268. }
  269. if (m_HndlrQueue)
  270. {
  271. m_HndlrQueue->Release();
  272. }
  273. Assert(NULL == m_pItemListViewAutoSync);
  274. Assert(NULL == m_pItemListViewIdle);
  275. }
  276. //--------------------------------------------------------------------------------
  277. //
  278. // FUNCTION: CAutoSyncPage::ShowProperties(int iItem)
  279. //
  280. // PURPOSE: Show the app specific properties Dialog
  281. //
  282. // COMMENTS: Implemented on main thread.
  283. //
  284. // HISTORY: 01-01-98 SusiA Created.
  285. //
  286. //--------------------------------------------------------------------------------
  287. SCODE CAutoSyncPage::ShowProperties(HWND hwnd,int iItem)
  288. {
  289. SCODE sc = E_UNEXPECTED;
  290. Assert(hwnd == m_hwndAutoSync || hwnd == m_hwndIdle);
  291. // review, what happens when a cancel comes in when properties are being shown??
  292. if (m_HndlrQueue)
  293. {
  294. sc = m_HndlrQueue->ShowProperties(hwnd,iItem);
  295. }
  296. return sc;
  297. }
  298. //+-------------------------------------------------------------------------------
  299. //
  300. // FUNCTION: BOOL CAutoSyncPage::SetItemCheckState(int iItem, BOOL fChecked)
  301. //
  302. // PURPOSE: set the selected check state
  303. //
  304. // RETURN VALUE: return TRUE if we process it ok.
  305. //
  306. // HISTORY: 01-01-98 SusiA Created.
  307. //
  308. //+-------------------------------------------------------------------------------
  309. BOOL CAutoSyncPage::SetItemCheckState(HWND hwnd,SYNCTYPE syncType,int iItem, BOOL fChecked,int iCheckCount)
  310. {
  311. HWND hwndRasCombo;
  312. int iConnectionItem;
  313. Assert(hwnd == m_hwndAutoSync || hwnd == m_hwndIdle);
  314. hwndRasCombo = GetDlgItem(hwnd,IDC_AUTOUPDATECOMBO);
  315. if (NULL == hwndRasCombo || NULL == m_HndlrQueue)
  316. {
  317. Assert(hwndRasCombo);
  318. Assert(m_HndlrQueue);
  319. return FALSE;
  320. }
  321. iConnectionItem = ComboBox_GetCurSel(hwndRasCombo);
  322. //The check state is message is getting flagged by us programmatically setting it,
  323. // until after we are done initializing.
  324. if (m_fItemsOnConnection)
  325. {
  326. BOOL fAnyChecked;
  327. CListView *pItemListView = (syncType == SYNCTYPE_AUTOSYNC) ? m_pItemListViewAutoSync : m_pItemListViewIdle;
  328. fAnyChecked = iCheckCount ? TRUE : FALSE;
  329. if (ERROR_SUCCESS == m_HndlrQueue->SetSyncCheckStateFromListViewItem(
  330. syncType,iItem,fChecked, iConnectionItem))
  331. {
  332. return TRUE;
  333. }
  334. return FALSE;
  335. }
  336. return TRUE;
  337. }
  338. //+-------------------------------------------------------------------------------
  339. //
  340. // FUNCTION: BOOL CAutoSyncPage::SetConnectionCheck(WORD wParam,DWORD dwCheckState)
  341. //
  342. // PURPOSE: set the selected check state
  343. //
  344. // RETURN VALUE: return TRUE if we process it ok.
  345. //
  346. // HISTORY: 01-01-98 SusiA Created.
  347. //
  348. //+-------------------------------------------------------------------------------
  349. BOOL CAutoSyncPage::SetConnectionCheck(HWND hwnd,SYNCTYPE syncType,WORD wParam, DWORD dwCheckState)
  350. {
  351. HWND hwndRasCombo ;
  352. int iConnectionItem;
  353. Assert(hwnd == m_hwndAutoSync || hwnd == m_hwndIdle);
  354. hwndRasCombo = GetDlgItem(hwnd,IDC_AUTOUPDATECOMBO);
  355. if (NULL == hwndRasCombo || NULL == m_HndlrQueue)
  356. {
  357. Assert(hwndRasCombo);
  358. Assert(m_HndlrQueue);
  359. return FALSE;
  360. }
  361. iConnectionItem = ComboBox_GetCurSel(hwndRasCombo);
  362. if (m_fItemsOnConnection)
  363. {
  364. CListView *pItemListView = (syncType == SYNCTYPE_AUTOSYNC) ? m_pItemListViewAutoSync : m_pItemListViewIdle;
  365. //Check changing for logon or logoff
  366. //So enable the prompt me first accordingly
  367. if (wParam != IDC_AUTOPROMPT_ME_FIRST)
  368. {
  369. HWND hwndLogon = GetDlgItem(hwnd,IDC_AUTOUPDATELIST);
  370. int iLogonCheck = Button_GetCheck(GetDlgItem(hwnd,IDC_AUTOLOGON));
  371. int iLogoffCheck = Button_GetCheck(GetDlgItem(hwnd,IDC_AUTOLOGOFF));
  372. }
  373. if (ERROR_SUCCESS == m_HndlrQueue->SetConnectionCheck(wParam,dwCheckState,iConnectionItem))
  374. {
  375. return TRUE;
  376. }
  377. return FALSE;
  378. }
  379. return TRUE;
  380. }
  381. //+-------------------------------------------------------------------------------
  382. //
  383. // FUNCTION: BOOL CAutoSyncPage::ShowItemsOnThisConnection(DWORD dwConnectionNum)
  384. //
  385. // PURPOSE: initialization for the autosync page
  386. //
  387. // RETURN VALUE: return TRUE if we process it ok.
  388. //
  389. // HISTORY: 01-01-98 SusiA Created.
  390. //
  391. //+-------------------------------------------------------------------------------
  392. BOOL CAutoSyncPage::ShowItemsOnThisConnection(HWND hwnd,SYNCTYPE syncType,DWORD dwConnectionNum)
  393. {
  394. TCHAR pszConnectionName[RAS_MaxEntryName+1];
  395. HWND hwndRasCombo;
  396. CListView *pItemListView = (syncType == SYNCTYPE_AUTOSYNC) ? m_pItemListViewAutoSync : m_pItemListViewIdle;
  397. BOOL *pListViewInitialize = (syncType == SYNCTYPE_AUTOSYNC) ? &m_pItemListViewAutoSyncInitialized : &m_fListViewIdleInitialized;
  398. Assert(hwnd == m_hwndAutoSync || hwnd == m_hwndIdle);
  399. hwndRasCombo = GetDlgItem(hwnd,IDC_AUTOUPDATECOMBO);
  400. if (NULL == hwndRasCombo || NULL == m_HndlrQueue || NULL == pItemListView)
  401. {
  402. Assert(m_HndlrQueue);
  403. Assert(hwndRasCombo);
  404. Assert(pItemListView);
  405. return FALSE;
  406. }
  407. *pListViewInitialize = FALSE; // reset initialized in case user switched connections.
  408. //first clear out the list view
  409. // Review - why not just recheck items based on new connection???
  410. m_fItemsOnConnection = FALSE;
  411. pItemListView->DeleteAllItems();
  412. HIMAGELIST himage;
  413. LVITEMEX lvItemInfo;
  414. WORD wHandlerID;
  415. //Note: Use text to "uniquely" identify connection on RAS
  416. DWORD dwNumConnections = (DWORD) ComboBox_GetCount(hwndRasCombo);
  417. // make sure dwConnectionNum is valid,
  418. if (dwConnectionNum >= dwNumConnections)
  419. {
  420. return FALSE;
  421. }
  422. COMBOBOXEXITEM comboItem;
  423. comboItem.mask = CBEIF_TEXT;
  424. comboItem.cchTextMax = ARRAYSIZE(pszConnectionName);
  425. comboItem.pszText = pszConnectionName;
  426. comboItem.iItem = dwConnectionNum;
  427. // Review, handle failures.
  428. SendMessage(hwndRasCombo, CBEM_GETITEM, (WPARAM) 0, (LPARAM) &comboItem);
  429. // loop through proxies initializing and adding to the list
  430. SYNCMGRITEMID ItemID;
  431. CLSID clsidHandler;
  432. WORD wItemID;
  433. // add same images over and over again. Should either just use the same listView
  434. // resetting the CheckBoxes according or clear the ImageList each time.
  435. himage = pItemListView->GetImageList(LVSIL_SMALL );
  436. HRESULT hr = m_HndlrQueue->FindFirstItemOnConnection
  437. (pszConnectionName, &clsidHandler,
  438. &ItemID,&wHandlerID,&wItemID);
  439. if (NOERROR == hr)
  440. {
  441. DWORD dwCheckState;
  442. do
  443. {
  444. INT iListViewItem;
  445. CLSID clsidDataHandler;
  446. SYNCMGRITEM offlineItem;
  447. ITEMCHECKSTATE ItemCheckState;
  448. // grab the offline item info.
  449. if (NOERROR == m_HndlrQueue->GetSyncItemDataOnConnection(
  450. dwConnectionNum,
  451. wHandlerID,wItemID,
  452. &clsidDataHandler,&offlineItem,
  453. &ItemCheckState,
  454. FALSE, FALSE))
  455. {
  456. LVHANDLERITEMBLOB lvHandlerItemBlob;
  457. int iParentItemId;
  458. BOOL fHandlerParent = TRUE; // always have a parent for now.
  459. // Check if item is already in the ListView and if so
  460. // go on
  461. lvHandlerItemBlob.cbSize = sizeof(LVHANDLERITEMBLOB);
  462. lvHandlerItemBlob.clsidServer = clsidDataHandler;
  463. lvHandlerItemBlob.ItemID = offlineItem.ItemID;
  464. if (-1 != pItemListView->FindItemFromBlob((LPLVBLOB) &lvHandlerItemBlob))
  465. {
  466. // already in ListView, go on to the next item.
  467. continue;
  468. }
  469. if (!fHandlerParent)
  470. {
  471. iParentItemId = LVI_ROOT;
  472. }
  473. else
  474. {
  475. // need to add to list so find parent and if one doesn't exist, create it.
  476. lvHandlerItemBlob.cbSize = sizeof(LVHANDLERITEMBLOB);
  477. lvHandlerItemBlob.clsidServer = clsidDataHandler;
  478. lvHandlerItemBlob.ItemID = GUID_NULL;
  479. iParentItemId = pItemListView->FindItemFromBlob((LPLVBLOB) &lvHandlerItemBlob);
  480. if (-1 == iParentItemId)
  481. {
  482. LVITEMEX itemInfoParent;
  483. SYNCMGRHANDLERINFO SyncMgrHandlerInfo;
  484. // if can't get the ParentInfo then don't add the Item
  485. if (NOERROR != m_HndlrQueue->GetHandlerInfo(clsidDataHandler,&SyncMgrHandlerInfo))
  486. {
  487. continue;
  488. }
  489. // Insert the Parent.
  490. itemInfoParent.mask = LVIF_TEXT;
  491. itemInfoParent.iItem = LVI_LAST;;
  492. itemInfoParent.iSubItem = 0;
  493. itemInfoParent.iImage = -1;
  494. itemInfoParent.pszText = SyncMgrHandlerInfo.wszHandlerName;
  495. if (himage)
  496. {
  497. HICON hIcon = SyncMgrHandlerInfo.hIcon ? SyncMgrHandlerInfo.hIcon : offlineItem.hIcon;
  498. // if have toplevel handler info icon use this else use the
  499. // items icon
  500. if (hIcon && (itemInfoParent.iImage =
  501. ImageList_AddIcon(himage,hIcon)) )
  502. {
  503. itemInfoParent.mask |= LVIF_IMAGE ;
  504. }
  505. }
  506. // save the blob
  507. itemInfoParent.maskEx = LVIFEX_BLOB;
  508. itemInfoParent.pBlob = (LPLVBLOB) &lvHandlerItemBlob;
  509. iParentItemId = pItemListView->InsertItem(&itemInfoParent);
  510. // if parent insert failed go onto the next item
  511. if (-1 == iParentItemId)
  512. {
  513. continue;
  514. }
  515. }
  516. }
  517. // now attemp to insert the item.
  518. lvItemInfo.mask = LVIF_TEXT;
  519. lvItemInfo.maskEx = LVIFEX_PARENT | LVIFEX_BLOB;
  520. lvItemInfo.iItem = LVI_LAST;
  521. lvItemInfo.iSubItem = 0;
  522. lvItemInfo.iParent = iParentItemId;
  523. lvItemInfo.pszText = offlineItem.wszItemName;
  524. lvItemInfo.iImage = -1; // set to -1 in case can't get image.
  525. // setup the blob
  526. lvHandlerItemBlob.ItemID = offlineItem.ItemID;
  527. lvItemInfo.pBlob = (LPLVBLOB) &lvHandlerItemBlob;
  528. if (himage && offlineItem.hIcon)
  529. {
  530. lvItemInfo.iImage =
  531. ImageList_AddIcon(himage,offlineItem.hIcon);
  532. }
  533. iListViewItem = pItemListView->InsertItem(&lvItemInfo);
  534. if (-1 == iListViewItem)
  535. {
  536. continue;
  537. }
  538. //Set the check state of the item
  539. lvItemInfo.mask = LVIF_STATE;
  540. lvItemInfo.maskEx = 0;
  541. lvItemInfo.iItem = iListViewItem;
  542. lvItemInfo.iSubItem = 0;
  543. dwCheckState = (syncType == SYNCTYPE_IDLE)
  544. ? ItemCheckState.dwIdle : ItemCheckState.dwAutoSync;
  545. lvItemInfo.stateMask= LVIS_STATEIMAGEMASK;
  546. lvItemInfo.state = (dwCheckState == SYNCMGRITEMSTATE_UNCHECKED) ?
  547. LVIS_STATEIMAGEMASK_UNCHECK : LVIS_STATEIMAGEMASK_CHECK;
  548. pItemListView->SetItem(&lvItemInfo);
  549. m_HndlrQueue->SetItemListViewID(clsidDataHandler,offlineItem.ItemID,iListViewItem);
  550. }
  551. } while (NOERROR == m_HndlrQueue->FindNextItemOnConnection
  552. (pszConnectionName,wHandlerID,wItemID,
  553. &clsidHandler,&ItemID,&wHandlerID,&wItemID, TRUE,
  554. &dwCheckState) );
  555. }
  556. if (pItemListView->GetItemCount())
  557. {
  558. pItemListView->SetItemState(0,LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED );
  559. }
  560. if (syncType == SYNCTYPE_AUTOSYNC)
  561. {
  562. int iLogonCheck = m_HndlrQueue->GetCheck(IDC_AUTOLOGON, dwConnectionNum);
  563. int iLogoffCheck = m_HndlrQueue->GetCheck(IDC_AUTOLOGOFF, dwConnectionNum);
  564. Button_SetCheck(GetDlgItem(hwnd,IDC_AUTOLOGON),iLogonCheck);
  565. Button_SetCheck(GetDlgItem(hwnd,IDC_AUTOLOGOFF),iLogoffCheck);
  566. Button_SetCheck(GetDlgItem(hwnd,IDC_AUTOPROMPT_ME_FIRST),
  567. m_HndlrQueue->GetCheck(IDC_AUTOPROMPT_ME_FIRST, dwConnectionNum));
  568. }
  569. else if (syncType == SYNCTYPE_IDLE)
  570. {
  571. int iIdleCheck = m_HndlrQueue->GetCheck(IDC_IDLECHECKBOX, dwConnectionNum);
  572. Button_SetCheck(GetDlgItem(hwnd,IDC_IDLECHECKBOX),iIdleCheck);
  573. }
  574. *pListViewInitialize = TRUE;
  575. m_fItemsOnConnection = TRUE;
  576. return TRUE;
  577. }
  578. //+-------------------------------------------------------------------------------
  579. //
  580. // FUNCTION: BOOL CAutoSyncPage::GetNumConnections(SYNCTYPE syncType))
  581. //
  582. // PURPOSE: returns the number of connections available to select for the
  583. // specified sync type
  584. //
  585. // RETURN number of connections.
  586. //
  587. // HISTORY: 03-10-98 rogerg Created.
  588. //
  589. //+-------------------------------------------------------------------------------
  590. DWORD CAutoSyncPage::GetNumConnections(HWND hwnd,SYNCTYPE syncType)
  591. {
  592. HWND hwndRasCombo;
  593. Assert(syncType == SYNCTYPE_IDLE || syncType == SYNCTYPE_AUTOSYNC);
  594. Assert(NULL != hwnd);
  595. hwndRasCombo = GetDlgItem(hwnd,IDC_AUTOUPDATECOMBO);
  596. Assert(hwndRasCombo);
  597. if (hwndRasCombo)
  598. {
  599. return ComboBox_GetCount(hwndRasCombo);
  600. }
  601. return 0;
  602. }
  603. //+-------------------------------------------------------------------------------
  604. //
  605. // FUNCTION: BOOL CAutoSyncPage::GetAdvancedIdleSettings(LPCONNECTIONSETTINGS *ppConnectionSettings)
  606. //
  607. // PURPOSE: fills in the ConnectionSettings Structure with the Advanced
  608. // Idle default settings.
  609. //
  610. // RETURN
  611. //
  612. // HISTORY: 03-10-98 rogerg Created.
  613. //
  614. //+-------------------------------------------------------------------------------
  615. HRESULT CAutoSyncPage::GetAdvancedIdleSettings(LPCONNECTIONSETTINGS pConnectionSettings)
  616. {
  617. Assert(pConnectionSettings);
  618. Assert(m_HndlrQueue);
  619. if (NULL == pConnectionSettings
  620. || NULL == m_HndlrQueue)
  621. {
  622. return S_FALSE;
  623. }
  624. return m_HndlrQueue->ReadAdvancedIdleSettings(pConnectionSettings);
  625. }
  626. //+-------------------------------------------------------------------------------
  627. //
  628. // FUNCTION: BOOL CAutoSyncPage::SetAdvancedidleSettings(LPCONNECTIONSETTINGS pConnectionSettings)
  629. //
  630. // PURPOSE: sets the advancedIdle Settings.
  631. //
  632. // RETURN
  633. //
  634. // HISTORY: 03-10-98 rogerg Created.
  635. //
  636. //+-------------------------------------------------------------------------------
  637. HRESULT CAutoSyncPage::SetAdvancedIdleSettings(LPCONNECTIONSETTINGS pConnectionSettings)
  638. {
  639. Assert(pConnectionSettings);
  640. Assert(m_HndlrQueue);
  641. if (NULL == pConnectionSettings
  642. || NULL == m_HndlrQueue)
  643. {
  644. return S_FALSE;
  645. }
  646. return m_HndlrQueue->WriteAdvancedIdleSettings(pConnectionSettings);
  647. }