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.

201 lines
5.0 KiB

  1. #include "pch.hxx"
  2. #include "syncprop.h"
  3. #include "imnact.h"
  4. #include "grplist2.h"
  5. static CSyncPropDlg *s_pSyncPropDlg = NULL;
  6. CSyncPropDlg::CSyncPropDlg():
  7. m_cRef(1), m_pGrpList(NULL), m_pColumns(NULL), m_pszAcctName(NULL)
  8. {
  9. IF_DEBUG(m_fInit = FALSE;)
  10. }
  11. CSyncPropDlg::~CSyncPropDlg()
  12. {
  13. // We handed this out, so release it
  14. SafeRelease(m_pColumns);
  15. if (m_pGrpList)
  16. delete m_pGrpList;
  17. if (m_pszAcctName)
  18. MemFree(m_pszAcctName);
  19. }
  20. STDMETHODIMP CSyncPropDlg::QueryInterface(REFIID riid, LPVOID FAR *ppvObj)
  21. {
  22. TraceCall("CSyncPropDlg::QueryInterface");
  23. if(!ppvObj)
  24. return E_INVALIDARG;
  25. *ppvObj = NULL;
  26. if (IsEqualIID(riid, IID_IUnknown))
  27. *ppvObj = SAFECAST(this, IUnknown *);
  28. else if (IsEqualIID(riid, IID_IGroupListAdvise))
  29. *ppvObj = SAFECAST(this, IGroupListAdvise *);
  30. else
  31. return E_NOINTERFACE;
  32. InterlockedIncrement(&m_cRef);
  33. return NOERROR;
  34. }
  35. STDMETHODIMP_(ULONG) CSyncPropDlg::AddRef()
  36. {
  37. TraceCall("CSyncPropDlg::AddRef");
  38. return InterlockedIncrement(&m_cRef);
  39. }
  40. STDMETHODIMP_(ULONG) CSyncPropDlg::Release()
  41. {
  42. TraceCall("CSyncPropDlg::Release");
  43. LONG cRef = InterlockedDecrement(&m_cRef);
  44. if (cRef > 0)
  45. return (ULONG)cRef;
  46. delete this;
  47. return 0;
  48. }
  49. STDMETHODIMP CSyncPropDlg::ItemUpdate(void)
  50. {
  51. return S_OK;
  52. }
  53. STDMETHODIMP CSyncPropDlg::ItemActivate(FOLDERID id)
  54. {
  55. return S_OK;
  56. }
  57. BOOL CSyncPropDlg::Initialize(HWND hwnd, LPCSTR pszAcctID, LPCSTR pszAcctName, ACCTTYPE accttype)
  58. {
  59. Assert(g_hLocRes);
  60. Assert(pszAcctID);
  61. Assert(pszAcctName);
  62. if (!(m_pColumns = new CColumns) || !(m_pGrpList = new CGroupList))
  63. return FALSE;
  64. ZeroMemory(&m_pspage, sizeof(PROPSHEETPAGE));
  65. ZeroMemory(&m_pshdr, sizeof(PROPSHEETHEADER));
  66. m_accttype = accttype;
  67. ULONG cchAcctName = lstrlen(pszAcctName)+1;
  68. if (MemAlloc((LPVOID*) &m_pszAcctName, cchAcctName))
  69. {
  70. StrCpyNA(m_pszAcctName, pszAcctName, cchAcctName);
  71. }
  72. else
  73. m_pszAcctName = NULL;
  74. // BUGBUG: Need to get some sync icons here...
  75. switch (accttype)
  76. {
  77. case ACCT_MAIL:
  78. m_dwIconID = idiMail;
  79. break;
  80. case ACCT_NEWS:
  81. m_dwIconID = idiDLNews;
  82. break;
  83. default:
  84. m_dwIconID = idiPhone;
  85. }
  86. m_pspage.dwSize = sizeof(PROPSHEETPAGE);
  87. m_pspage.hInstance = g_hLocRes;
  88. m_pspage.pszTemplate = MAKEINTRESOURCE(iddSyncSettings);
  89. m_pspage.pfnDlgProc = DlgProc;
  90. m_pshdr.dwSize = sizeof(PROPSHEETHEADER);
  91. m_pshdr.dwFlags = PSH_USEICONID | PSH_PROPSHEETPAGE | PSH_USEPAGELANG;
  92. m_pshdr.hwndParent = hwnd;
  93. m_pshdr.hInstance = g_hLocRes;
  94. m_pshdr.pszCaption = (LPCSTR) m_pszAcctName;
  95. m_pshdr.nPages = 1;
  96. m_pshdr.nStartPage = 0;
  97. m_pshdr.ppsp = &m_pspage;
  98. m_pshdr.pszIcon = MAKEINTRESOURCE(m_dwIconID);
  99. IF_DEBUG(m_fInit = TRUE;)
  100. return TRUE;
  101. }
  102. void CSyncPropDlg::Show()
  103. {
  104. Assert(m_fInit);
  105. // Stash our this pointer somewhere where the static dlgproc can access it
  106. s_pSyncPropDlg = this;
  107. // Actually show the dlg (modal)
  108. PropertySheet(&m_pshdr);
  109. }
  110. BOOL CSyncPropDlg::InitDlg(HWND hwnd)
  111. {
  112. COLUMN_SET_TYPE set;
  113. m_hwndList = GetDlgItem(hwnd, idcList);
  114. m_pColumns->Initialize(m_hwndList, COLUMN_SET_OFFLINE);
  115. m_pColumns->ApplyColumns(COLUMN_LOAD_DEFAULT, NULL, 0);
  116. if (FAILED(m_pGrpList->Initialize((IGroupListAdvise *)this, m_pColumns, m_hwndList, m_accttype, FALSE)))
  117. return FALSE;
  118. SendDlgItemMessage (hwnd, idcIcon, STM_SETICON, (WPARAM)LoadIcon(g_hLocRes, MAKEINTRESOURCE(m_dwIconID)), 0);
  119. SendDlgItemMessageA(hwnd, idcAccountName, WM_SETTEXT, 0, (LPARAM)m_pszAcctName);
  120. return TRUE;
  121. }
  122. BOOL CALLBACK CSyncPropDlg::DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  123. {
  124. BOOL fHandledRet = TRUE;
  125. CSyncPropDlg *pThis = (CSyncPropDlg*)GetWindowLong(hwnd, GWL_USERDATA);
  126. switch (msg)
  127. {
  128. case WM_INITDIALOG:
  129. // Let the dlg know which CSyncPropDlg controls it
  130. Assert(s_pSyncPropDlg);
  131. SetWindowLong(hwnd, GWL_USERDATA, (LONG)(pThis = s_pSyncPropDlg));
  132. s_pSyncPropDlg = NULL;
  133. fHandledRet = pThis->InitDlg(hwnd);
  134. break;
  135. case WM_COMMAND:
  136. break;
  137. case WM_NOTIFY:
  138. {
  139. LPNMHDR pnmh = (LPNMHDR) lParam;
  140. }
  141. break;
  142. default:
  143. return FALSE;
  144. }
  145. return fHandledRet;
  146. }
  147. // Normal way to get a sync properties dlg
  148. void ShowPropSheet(HWND hwnd, LPCSTR pszAcctID, LPCSTR pszAcctName, ACCTTYPE accttype)
  149. {
  150. CSyncPropDlg *pDlg;
  151. if (pDlg = new CSyncPropDlg())
  152. {
  153. if (pDlg->Initialize(hwnd, pszAcctID, pszAcctName, accttype))
  154. pDlg->Show();
  155. delete pDlg;
  156. }
  157. }