Source code of Windows XP (NT5)
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.

2289 lines
51 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1994.
  5. //
  6. // File: ulsmeet.cpp
  7. //
  8. // Contents: MeetingPlace Object implementation
  9. //
  10. // Classes: CIlsMeetingPlace, CEnumMeetingPlace, CIlsAttendee, CEnumAttendee
  11. //
  12. // Functions:
  13. //
  14. // History: 11/25/96 Shishir Pardikar [shishirp] Created
  15. //
  16. // Notes:
  17. //
  18. //----------------------------------------------------------------------------
  19. #include "ulsp.h"
  20. #ifdef ENABLE_MEETING_PLACE
  21. #include "ulsmeet.h"
  22. #include "callback.h"
  23. #include "filter.h"
  24. /***************************************************************************
  25. Notification functions.
  26. These functions are called by the general purpose connectionpoint object.
  27. These are called for each Sink object attached to the connection point using
  28. "Advise" member function of the IConnectionPoint interface
  29. ****************************************************************************/
  30. //****************************************************************************
  31. //
  32. // HRESULT OnNotifyRegisterMeetingPlaceResult(IUnknown *pUnk, void *pv)
  33. //
  34. // Synopsis:
  35. //
  36. // Arguments:
  37. //
  38. // Returns:
  39. //
  40. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  41. //
  42. // Notes:
  43. //
  44. //****************************************************************************
  45. HRESULT
  46. OnNotifyRegisterMeetingPlaceResult(IUnknown *pUnk, void *pv)
  47. {
  48. POBJRINFO pobjri = (POBJRINFO)pv;
  49. ((IIlsMeetingPlaceNotify *)pUnk)->RegisterResult(pobjri->uReqID, pobjri->hResult);
  50. return S_OK;
  51. }
  52. //****************************************************************************
  53. //
  54. // HRESULT OnNotifyUnregisterMeetingPlaceResult(IUnknown *pUnk, void *pv)
  55. //
  56. // Synopsis:
  57. //
  58. // Arguments:
  59. //
  60. // Returns:
  61. //
  62. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  63. //
  64. // Notes:
  65. //
  66. //****************************************************************************
  67. HRESULT
  68. OnNotifyUnregisterMeetingPlaceResult(IUnknown *pUnk, void *pv)
  69. {
  70. POBJRINFO pobjri = (POBJRINFO)pv;
  71. ((IIlsMeetingPlaceNotify *)pUnk)->RegisterResult(pobjri->uReqID, pobjri->hResult);
  72. return S_OK;
  73. }
  74. //****************************************************************************
  75. //
  76. // HRESULT OnNotifyUpdateMeetingPlaceResult(IUnknown *pUnk, void *pv)
  77. //
  78. // Synopsis:
  79. //
  80. // Arguments:
  81. //
  82. // Returns:
  83. //
  84. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  85. //
  86. // Notes:
  87. //
  88. //****************************************************************************
  89. HRESULT
  90. OnNotifyUpdateMeetingPlaceResult(IUnknown *pUnk, void *pv)
  91. {
  92. POBJRINFO pobjri = (POBJRINFO)pv;
  93. ((IIlsMeetingPlaceNotify *)pUnk)->UpdateResult(pobjri->uReqID, pobjri->hResult);
  94. return S_OK;
  95. }
  96. //****************************************************************************
  97. //
  98. // HRESULT OnNotifyAddAttendeeResult(IUnknown *pUnk, void *pv)
  99. //
  100. // Synopsis:
  101. //
  102. // Arguments:
  103. //
  104. // Returns:
  105. //
  106. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  107. //
  108. // Notes:
  109. //
  110. //****************************************************************************
  111. HRESULT
  112. OnNotifyAddAttendeeResult(IUnknown *pUnk, void *pv)
  113. {
  114. POBJRINFO pobjri = (POBJRINFO)pv;
  115. ((IIlsMeetingPlaceNotify *)pUnk)->AttendeeChangeResult(pobjri->uReqID, pobjri->hResult);
  116. return S_OK;
  117. }
  118. //****************************************************************************
  119. //
  120. // HRESULT OnNotifyRemoveAttendeeResult(IUnknown *pUnk, void *pv)
  121. //
  122. // Synopsis:
  123. //
  124. // Arguments:
  125. //
  126. // Returns:
  127. //
  128. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  129. //
  130. // Notes:
  131. //
  132. //****************************************************************************
  133. HRESULT
  134. OnNotifyRemoveAttendeeResult(IUnknown *pUnk, void *pv)
  135. {
  136. POBJRINFO pobjri = (POBJRINFO)pv;
  137. ((IIlsMeetingPlaceNotify *)pUnk)->AttendeeChangeResult(pobjri->uReqID, pobjri->hResult);
  138. return S_OK;
  139. }
  140. //****************************************************************************
  141. //
  142. // HRESULT OnNotifyEnumAttendeeNamesResult(IUnknown *pUnk, void *pv)
  143. //
  144. // Synopsis:
  145. //
  146. // Arguments:
  147. //
  148. // Returns:
  149. //
  150. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  151. //
  152. // Notes:
  153. //
  154. //****************************************************************************
  155. HRESULT OnNotifyEnumAttendeeNamesResult(IUnknown *pUnk, void *pv)
  156. {
  157. CEnumNames *penum = NULL;
  158. PENUMRINFO peri = (PENUMRINFO)pv;
  159. HRESULT hr = peri->hResult;
  160. // Create the enumerator only when there is anything to be enumerated
  161. //
  162. if (hr == NOERROR)
  163. {
  164. ASSERT (peri->pv != NULL);
  165. // Create an AttendeeName enumerator
  166. //
  167. penum = new CEnumNames;
  168. if (penum != NULL)
  169. {
  170. hr = penum->Init((LPTSTR)peri->pv, peri->cItems);
  171. if (SUCCEEDED(hr))
  172. {
  173. penum->AddRef();
  174. }
  175. else
  176. {
  177. delete penum;
  178. penum = NULL;
  179. };
  180. }
  181. else
  182. {
  183. hr = ILS_E_MEMORY;
  184. };
  185. };
  186. // Notify the sink object
  187. //
  188. ((IIlsMeetingPlaceNotify*)pUnk)->EnumAttendeeNamesResult(peri->uReqID,
  189. penum != NULL ?
  190. (IEnumIlsNames *)penum :
  191. NULL,
  192. hr);
  193. if (penum != NULL)
  194. {
  195. penum->Release();
  196. };
  197. return hr;
  198. }
  199. //****************************************************************************
  200. //
  201. //CIlsMeetingPlace class implementation
  202. //
  203. //****************************************************************************
  204. //****************************************************************************
  205. // Method: CIlsMeetingPlace::CIlsMeetingPlace (void)
  206. //
  207. // Synopsis:
  208. //
  209. // Arguments:
  210. //
  211. // Returns:
  212. //
  213. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  214. //
  215. // Notes:
  216. //
  217. //****************************************************************************
  218. CIlsMeetingPlace::
  219. CIlsMeetingPlace ( VOID )
  220. :m_cRef (0),
  221. m_ulState (NULL),
  222. m_pszMeetingPlaceID (NULL),
  223. m_lMeetingPlaceType (UNDEFINED_TYPE),
  224. m_lAttendeeType (UNDEFINED_TYPE),
  225. m_pszHostName (NULL),
  226. m_pszHostIPAddress (NULL),
  227. m_pszDescription (NULL),
  228. m_hMeetingPlace (NULL),
  229. m_dwFlags (0),
  230. m_pIlsServer (NULL),
  231. m_pConnectionPoint (NULL)
  232. {
  233. m_ExtendedAttrs.SetAccessType (ILS_ATTRTYPE_NAME_VALUE);
  234. }
  235. //****************************************************************************
  236. // CIlsMeetingPlace::~CIlsMeetingPlace (void)
  237. //
  238. // Synopsis:
  239. //
  240. // Arguments:
  241. //
  242. // Returns:
  243. //
  244. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  245. //
  246. // Notes:
  247. //
  248. //****************************************************************************
  249. CIlsMeetingPlace::
  250. ~CIlsMeetingPlace ( VOID )
  251. {
  252. ::MemFree (m_pszMeetingPlaceID);
  253. ::MemFree (m_pszHostName);
  254. ::MemFree (m_pszHostIPAddress);
  255. ::MemFree (m_pszDescription);
  256. // Release the connection point
  257. //
  258. if (m_pConnectionPoint != NULL)
  259. {
  260. m_pConnectionPoint->ContainerReleased();
  261. ((IConnectionPoint*)m_pConnectionPoint)->Release();
  262. }
  263. // Free up the server object
  264. //
  265. if (m_pIlsServer != NULL)
  266. m_pIlsServer->Release ();
  267. }
  268. //****************************************************************************
  269. // STDMETHODIMP
  270. // CIlsMeetingPlace::AllocMeetInfo(PLDAP_MEETINFO *ppMeetInfo, ULONG ulMask)
  271. //
  272. // Synopsis:
  273. //
  274. // Arguments:
  275. //
  276. // Returns:
  277. //
  278. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  279. //
  280. // Notes:
  281. //
  282. //****************************************************************************
  283. STDMETHODIMP
  284. CIlsMeetingPlace::AllocMeetInfo(PLDAP_MEETINFO *ppMeetInfo, ULONG ulMask)
  285. {
  286. HRESULT hr = NOERROR;
  287. PLDAP_MEETINFO pMeetInfo = NULL;
  288. LPBYTE pBuffRunning;
  289. DWORD cbT, cbAttribSize, cntAttrs;
  290. DWORD cbTotalSize = sizeof(LDAP_MEETINFO);
  291. TCHAR *pszPairs = NULL;
  292. ASSERT(m_pIlsServer != NULL);
  293. ASSERT(m_pszMeetingPlaceID != NULL);
  294. cbTotalSize += lstrlen(m_pszMeetingPlaceID)+1;
  295. cbTotalSize += (
  296. (((ulMask & ILS_MEET_FLAG_DESCRIPTION_MODIFIED)
  297. && m_pszDescription)?(lstrlen(m_pszDescription)+1):0)
  298. +(((ulMask & ILS_MEET_FLAG_HOST_NAME_MODIFIED)
  299. && m_pszHostName)?(lstrlen(m_pszHostName)+1):0)
  300. +(((ulMask & ILS_MEET_FLAG_HOST_ADDRESS_MODIFIED)
  301. && m_pszHostIPAddress)?(lstrlen(m_pszHostIPAddress)+1):0)
  302. );
  303. cbTotalSize *= sizeof(TCHAR);
  304. // if we need to send in the extended attributes, do that
  305. cbAttribSize = 0;
  306. if ((ulMask & ILS_MEET_FLAG_EXTENDED_ATTRIBUTES_MODIFIED)) {
  307. hr = m_ExtendedAttrs.GetAttributePairs(&pszPairs, &cntAttrs, &cbAttribSize);
  308. if (!SUCCEEDED(hr)) {
  309. goto bailout;
  310. }
  311. }
  312. cbTotalSize += cbAttribSize;
  313. // zeroized buffer
  314. pMeetInfo = (PLDAP_MEETINFO) ::MemAlloc (cbTotalSize);
  315. if (pMeetInfo == NULL) {
  316. hr = ILS_E_MEMORY;
  317. goto bailout;
  318. }
  319. pMeetInfo->uSize = cbTotalSize;
  320. pMeetInfo->lMeetingPlaceType = m_lMeetingPlaceType;
  321. pMeetInfo->lAttendeeType = m_lAttendeeType;
  322. pBuffRunning = (LPBYTE)(pMeetInfo+1);
  323. memcpy(pBuffRunning, m_pszMeetingPlaceID, cbT = (lstrlen(m_pszMeetingPlaceID)+1)*sizeof(TCHAR));
  324. pMeetInfo->uOffsetMeetingPlaceID = (ULONG)((LPBYTE)pBuffRunning - (LPBYTE)pMeetInfo);
  325. pBuffRunning += cbT;
  326. if ((ulMask & ILS_MEET_FLAG_DESCRIPTION_MODIFIED) && m_pszDescription) {
  327. memcpy(pBuffRunning, m_pszDescription, cbT = (lstrlen(m_pszDescription)+1)*sizeof(TCHAR));
  328. pMeetInfo->uOffsetDescription = (ULONG)((LPBYTE)pBuffRunning - (LPBYTE)pMeetInfo);
  329. pBuffRunning += cbT;
  330. }
  331. if ((ulMask & ILS_MEET_FLAG_HOST_NAME_MODIFIED) && m_pszHostName) {
  332. memcpy(pBuffRunning, m_pszHostName, cbT = (lstrlen(m_pszHostName)+1)*sizeof(TCHAR));
  333. pMeetInfo->uOffsetHostName = (ULONG)((LPBYTE)pBuffRunning - (LPBYTE)pMeetInfo);
  334. pBuffRunning += cbT;
  335. }
  336. if ((ulMask & ILS_MEET_FLAG_HOST_ADDRESS_MODIFIED) && m_pszHostIPAddress) {
  337. memcpy(pBuffRunning, m_pszHostIPAddress, cbT = lstrlen(m_pszHostIPAddress)+1);
  338. pMeetInfo->uOffsetHostIPAddress = (ULONG)((LPBYTE)pBuffRunning - (LPBYTE)pMeetInfo);
  339. pBuffRunning += cbT;
  340. }
  341. if((ulMask & ILS_MEET_FLAG_EXTENDED_ATTRIBUTES_MODIFIED)) {
  342. if (pszPairs) {
  343. memcpy(pBuffRunning, pszPairs, cbAttribSize);
  344. pMeetInfo->uOffsetAttrsToAdd = (ULONG)((LPBYTE)pBuffRunning - (LPBYTE)pMeetInfo);
  345. pMeetInfo->cAttrsToAdd = cntAttrs;
  346. pBuffRunning += cbAttribSize;
  347. }
  348. }
  349. *ppMeetInfo = pMeetInfo;
  350. bailout:
  351. if (!SUCCEEDED(hr)) {
  352. if (pMeetInfo) {
  353. ::MemFree (pMeetInfo);
  354. }
  355. }
  356. // the attribute pairs list needs to be freed
  357. // whether we succeeded or not
  358. if (pszPairs) {
  359. ::MemFree (pszPairs);
  360. }
  361. return hr;
  362. }
  363. //****************************************************************************
  364. // STDMETHODIMP
  365. // CIlsMeetingPlace::Init(BSTR bstrMeetingPlaceID, LONG lMeetingPlaceType
  366. // , LONG lAttendeeType)
  367. //
  368. // Synopsis:
  369. //
  370. // Arguments:
  371. //
  372. // Returns:
  373. //
  374. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  375. //
  376. // Notes:
  377. //
  378. //****************************************************************************
  379. STDMETHODIMP
  380. CIlsMeetingPlace::Init(
  381. BSTR bstrMeetingPlaceID,
  382. LONG lMeetingPlaceType,
  383. LONG lAttendeeType)
  384. {
  385. HRESULT hr;
  386. if (bstrMeetingPlaceID==NULL){
  387. return (ILS_E_PARAMETER);
  388. }
  389. ASSERT(m_ulState == ILS_UNREGISTERED);
  390. ASSERT(m_pIlsServer == NULL);
  391. ASSERT(m_pszMeetingPlaceID == NULL);
  392. hr = BSTR_to_LPTSTR(&m_pszMeetingPlaceID, bstrMeetingPlaceID);
  393. if (!SUCCEEDED(hr)) {
  394. goto bailout;
  395. }
  396. // Make the single connection point
  397. // When enumerating the ConnectionPointContainer
  398. // he is the single guy we will give out
  399. if (SUCCEEDED(hr)) {
  400. m_pConnectionPoint = new CConnectionPoint (&IID_IIlsMeetingPlaceNotify,
  401. (IConnectionPointContainer *)this);
  402. if (m_pConnectionPoint != NULL)
  403. {
  404. ((IConnectionPoint*)m_pConnectionPoint)->AddRef();
  405. hr = S_OK;
  406. }
  407. else
  408. {
  409. hr = ILS_E_MEMORY;
  410. }
  411. }
  412. if (SUCCEEDED(hr)) {
  413. m_lMeetingPlaceType = lMeetingPlaceType;
  414. m_lAttendeeType = lAttendeeType;
  415. }
  416. bailout:
  417. if (!SUCCEEDED(hr)) {
  418. // do cleanup
  419. if (m_pszMeetingPlaceID) {
  420. ::MemFree (m_pszMeetingPlaceID);
  421. m_pszMeetingPlaceID = NULL; // general paranoia
  422. }
  423. if (m_pConnectionPoint) {
  424. delete m_pConnectionPoint;
  425. m_pConnectionPoint = NULL;
  426. }
  427. }
  428. return hr;
  429. }
  430. //****************************************************************************
  431. // STDMETHODIMP
  432. // CIlsMeetingPlace::Init(LPTSTR lpszServer, PLDAP_MEETINFO pmi);
  433. //
  434. // Synopsis: This initializes the MeetingPlace object based on the MEETINFO structure
  435. // This is used to stuff data into the meeting object from
  436. // the response obtained from the server to the query _MEETINFO
  437. //
  438. // Arguments:
  439. //
  440. // Returns:
  441. //
  442. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  443. //
  444. // Notes:
  445. //
  446. //****************************************************************************
  447. STDMETHODIMP
  448. CIlsMeetingPlace::Init(
  449. CIlsServer *pIlsServer,
  450. PLDAP_MEETINFO pmi
  451. )
  452. {
  453. HRESULT hr;
  454. ASSERT(NULL==m_pszMeetingPlaceID);
  455. ASSERT(NULL==m_pIlsServer);
  456. //validate bstrMeetingPlaceID
  457. hr = SafeSetLPTSTR(&m_pszMeetingPlaceID, (LPCTSTR)(((PBYTE)pmi)+pmi->uOffsetMeetingPlaceID));
  458. if (!SUCCEEDED(hr)){
  459. goto bailout;
  460. }
  461. // set the state to registered
  462. m_ulState = ILS_REGISTERED;
  463. // set the server field
  464. m_pIlsServer = pIlsServer;
  465. pIlsServer->AddRef ();
  466. hr = SafeSetLPTSTR(&m_pszDescription, (LPCTSTR)(((PBYTE)pmi)+pmi->uOffsetDescription));
  467. if (!SUCCEEDED(hr)) {
  468. goto bailout;
  469. }
  470. hr = SafeSetLPTSTR(&m_pszHostName, (LPCTSTR)(((PBYTE)pmi)+pmi->uOffsetHostName));
  471. if (!SUCCEEDED(hr)) {
  472. goto bailout;
  473. }
  474. hr = SafeSetLPTSTR(&m_pszHostIPAddress, (LPCTSTR)(((PBYTE)pmi)+pmi->uOffsetHostIPAddress));
  475. if (!SUCCEEDED(hr)) {
  476. goto bailout;
  477. }
  478. // Make the single connection point
  479. // When enumerating the ConnectionPointContainer
  480. // he is the single guy we will give out
  481. m_pConnectionPoint = new CConnectionPoint (&IID_IIlsMeetingPlaceNotify,
  482. (IConnectionPointContainer *)this);
  483. if (m_pConnectionPoint != NULL)
  484. {
  485. ((IConnectionPoint*)m_pConnectionPoint)->AddRef();
  486. hr = S_OK;
  487. }
  488. else
  489. {
  490. hr = ILS_E_MEMORY;
  491. }
  492. if (SUCCEEDED(hr)) {
  493. m_lMeetingPlaceType = pmi->lMeetingPlaceType;
  494. m_lAttendeeType = pmi->lAttendeeType;
  495. }
  496. bailout:
  497. if (!SUCCEEDED(hr)) {
  498. // do cleanup
  499. if (m_pIlsServer != NULL)
  500. {
  501. m_pIlsServer->Release ();
  502. m_pIlsServer = NULL;
  503. }
  504. if (m_pszMeetingPlaceID) {
  505. ::MemFree (m_pszMeetingPlaceID);
  506. m_pszMeetingPlaceID = NULL; // general paranoia
  507. }
  508. if (m_pszDescription) {
  509. ::MemFree (m_pszDescription);
  510. m_pszDescription = NULL; // general paranoia
  511. }
  512. if (m_pszHostName) {
  513. ::MemFree (m_pszHostName);
  514. m_pszHostName = NULL;
  515. }
  516. if (m_pszHostIPAddress) {
  517. ::MemFree (m_pszHostIPAddress);
  518. m_pszHostIPAddress = NULL;
  519. }
  520. if (m_pConnectionPoint) {
  521. delete m_pConnectionPoint;
  522. m_pConnectionPoint = NULL;
  523. }
  524. m_ulState = ILS_UNREGISTERED;
  525. }
  526. else {
  527. m_ulState = ILS_IN_SYNC;
  528. }
  529. return (hr);
  530. }
  531. //****************************************************************************
  532. // STDMETHODIMP
  533. // CIlsMeetingPlace::QueryInterface (REFIID riid, void **ppv)
  534. //
  535. // Synopsis:
  536. //
  537. // Arguments:
  538. //
  539. // Returns:
  540. //
  541. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  542. //
  543. // Notes:
  544. //
  545. //****************************************************************************
  546. STDMETHODIMP
  547. CIlsMeetingPlace::QueryInterface (REFIID riid, void **ppv)
  548. {
  549. *ppv = NULL;
  550. if (riid == IID_IIlsMeetingPlace || riid == IID_IUnknown)
  551. {
  552. *ppv = (IIlsUser *) this;
  553. }
  554. else
  555. {
  556. if (riid == IID_IConnectionPointContainer)
  557. {
  558. *ppv = (IConnectionPointContainer *) this;
  559. };
  560. };
  561. if (*ppv != NULL)
  562. {
  563. ((LPUNKNOWN)*ppv)->AddRef();
  564. return S_OK;
  565. }
  566. else
  567. {
  568. return ILS_E_NO_INTERFACE;
  569. };
  570. }
  571. //****************************************************************************
  572. // STDMETHODIMP_(ULONG)
  573. // CIlsMeetingPlace::AddRef (void)
  574. //
  575. // Synopsis:
  576. //
  577. // Arguments:
  578. //
  579. // Returns:
  580. //
  581. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  582. //
  583. // Notes:
  584. //
  585. //****************************************************************************
  586. STDMETHODIMP_(ULONG)
  587. CIlsMeetingPlace::AddRef (void)
  588. {
  589. DllLock();
  590. MyDebugMsg ((DM_REFCOUNT, "CIlsMeetingPlace::AddRef: ref=%ld\r\n", m_cRef));
  591. ::InterlockedIncrement (&m_cRef);
  592. return (ULONG) m_cRef;
  593. }
  594. //****************************************************************************
  595. // STDMETHODIMP_(ULONG)
  596. // CIlsMeetingPlace::Release (void)
  597. //
  598. // Synopsis:
  599. //
  600. // Arguments:
  601. //
  602. // Returns:
  603. //
  604. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  605. //
  606. // Notes:
  607. //
  608. //****************************************************************************
  609. STDMETHODIMP_(ULONG)
  610. CIlsMeetingPlace::Release (void)
  611. {
  612. DllRelease();
  613. ASSERT (m_cRef > 0);
  614. MyDebugMsg ((DM_REFCOUNT, "CIlsMeetingPlace::Release: ref=%ld\r\n", m_cRef));
  615. if(::InterlockedDecrement (&m_cRef) == 0)
  616. {
  617. delete this;
  618. return 0;
  619. }
  620. return (ULONG) m_cRef;
  621. }
  622. //****************************************************************************
  623. // STDMETHODIMP
  624. // CIlsMeetingPlace::NotifySink (void *pv, CONN_NOTIFYPROC pfn)
  625. //
  626. // Synopsis:
  627. //
  628. // Arguments:
  629. //
  630. // Returns:
  631. //
  632. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  633. //
  634. // Notes:
  635. //
  636. //****************************************************************************
  637. STDMETHODIMP
  638. CIlsMeetingPlace::NotifySink (void *pv, CONN_NOTIFYPROC pfn)
  639. {
  640. HRESULT hr = S_OK;
  641. if (m_pConnectionPoint != NULL)
  642. {
  643. hr = m_pConnectionPoint->Notify(pv, pfn);
  644. };
  645. return hr;
  646. }
  647. //****************************************************************************
  648. // STDMETHODIMP
  649. // CIlsMeetingPlace::GetState (ULONG *pulState)
  650. //
  651. // Synopsis:
  652. //
  653. // Arguments:
  654. //
  655. // Returns:
  656. //
  657. // History: 12/10/1996 Shishir Pardikar [shishirp] Created.
  658. //
  659. // Notes:
  660. //
  661. //****************************************************************************
  662. STDMETHODIMP
  663. CIlsMeetingPlace::GetState (ULONG *pulState)
  664. {
  665. // Validate parameter
  666. //
  667. *pulState = m_ulState;
  668. return NOERROR;
  669. }
  670. //****************************************************************************
  671. // STDMETHODIMP
  672. // CIlsMeetingPlace::GetMeetingPlaceType (LONG *plMeetingPlaceType)
  673. //
  674. // Synopsis:
  675. //
  676. // Arguments:
  677. //
  678. // Returns:
  679. //
  680. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  681. //
  682. // Notes:
  683. //
  684. //****************************************************************************
  685. STDMETHODIMP
  686. CIlsMeetingPlace::GetMeetingPlaceType (LONG *plMeetingPlaceType)
  687. {
  688. // Validate parameter
  689. //
  690. *plMeetingPlaceType = m_lMeetingPlaceType;
  691. return NOERROR;
  692. }
  693. //****************************************************************************
  694. // STDMETHODIMP
  695. // CIlsMeetingPlace::GetAttendeeType (LONG *plAttendeeType)
  696. //
  697. // Synopsis:
  698. //
  699. // Arguments:
  700. //
  701. // Returns:
  702. //
  703. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  704. //
  705. // Notes:
  706. //
  707. //****************************************************************************
  708. STDMETHODIMP
  709. CIlsMeetingPlace::GetAttendeeType (LONG *plAttendeeType)
  710. {
  711. // Validate parameter
  712. //
  713. *plAttendeeType = m_lAttendeeType;
  714. return NOERROR;
  715. }
  716. //****************************************************************************
  717. // STDMETHODIMP
  718. // CIlsMeetingPlace::GetStandardAttribute (ILS_STD_ATTR_NAME stdAttr, BSTR *pbstrStdAttr)
  719. //
  720. // History:
  721. // 1-16-97 Shishir Pardikar
  722. // Created.
  723. //****************************************************************************
  724. STDMETHODIMP
  725. CIlsMeetingPlace::GetStandardAttribute(
  726. ILS_STD_ATTR_NAME stdAttr,
  727. BSTR *pbstrStdAttr
  728. )
  729. {
  730. LPTSTR lpszAttr = NULL;
  731. BOOL fValid = TRUE;
  732. HRESULT hr;
  733. if (pbstrStdAttr == NULL) {
  734. return ILS_E_POINTER;
  735. }
  736. switch(stdAttr) {
  737. case ILS_STDATTR_MEETING_ID:
  738. lpszAttr = m_pszMeetingPlaceID;
  739. break;
  740. case ILS_STDATTR_MEETING_HOST_NAME:
  741. lpszAttr = m_pszHostName;
  742. break;
  743. case ILS_STDATTR_MEETING_HOST_IP_ADDRESS:
  744. lpszAttr = m_pszHostIPAddress;
  745. break;
  746. case ILS_STDATTR_MEETING_DESCRIPTION:
  747. lpszAttr = m_pszDescription;
  748. break;
  749. default:
  750. fValid = FALSE;
  751. break;
  752. }
  753. if (fValid) {
  754. if (lpszAttr){
  755. hr = LPTSTR_to_BSTR(pbstrStdAttr, lpszAttr);
  756. }
  757. else {
  758. *pbstrStdAttr = NULL;
  759. hr = NOERROR;
  760. }
  761. }
  762. else {
  763. hr = ILS_E_PARAMETER;
  764. }
  765. return (hr);
  766. }
  767. //****************************************************************************
  768. // STDMETHODIMP
  769. // CIlsMeetingPlace::SetStandardAttribute (ILS_STD_ATTR_NAME stdAttr, BSTR bstrStdAttr)
  770. //
  771. // History:
  772. // 1-16-97 Shishir Pardikar
  773. // Created.
  774. //****************************************************************************
  775. STDMETHODIMP
  776. CIlsMeetingPlace::SetStandardAttribute(
  777. ILS_STD_ATTR_NAME stdAttr,
  778. BSTR bstrStdAttr
  779. )
  780. {
  781. LPTSTR *ppszAttr = NULL, pszNewAttr;
  782. BOOL fValid = TRUE;
  783. ULONG ulModBit = 0;
  784. HRESULT hr;
  785. if (bstrStdAttr == NULL) {
  786. return ILS_E_POINTER;
  787. }
  788. switch(stdAttr) {
  789. case ILS_STDATTR_MEETING_HOST_NAME:
  790. ppszAttr = &m_pszHostName;
  791. ulModBit = ILS_MEET_FLAG_HOST_NAME_MODIFIED;
  792. break;
  793. case ILS_STDATTR_MEETING_HOST_IP_ADDRESS:
  794. ppszAttr = &m_pszHostIPAddress;
  795. ulModBit = ILS_MEET_FLAG_HOST_ADDRESS_MODIFIED;
  796. break;
  797. case ILS_STDATTR_MEETING_DESCRIPTION:
  798. ppszAttr = &m_pszDescription;
  799. ulModBit = ILS_MEET_FLAG_DESCRIPTION_MODIFIED;
  800. break;
  801. default:
  802. fValid = FALSE;
  803. break;
  804. }
  805. if (fValid) {
  806. // Duplicate the string
  807. //
  808. hr = BSTR_to_LPTSTR (&pszNewAttr, bstrStdAttr);
  809. if (SUCCEEDED(hr))
  810. {
  811. ::MemFree (*ppszAttr);
  812. *ppszAttr = pszNewAttr;
  813. m_dwFlags |= ulModBit;
  814. };
  815. }
  816. else {
  817. hr = ILS_E_PARAMETER;
  818. }
  819. return (hr);
  820. }
  821. //****************************************************************************
  822. // STDMETHODIMP
  823. // CIlsMeetingPlace::SetExtendedAttributes (IIlsAttributes *pAttributes, ULONG *puReqID)
  824. //
  825. // History:
  826. //****************************************************************************
  827. STDMETHODIMP CIlsMeetingPlace::
  828. SetExtendedAttribute ( BSTR bstrName, BSTR bstrValue )
  829. {
  830. m_dwFlags |= ILS_MEET_FLAG_EXTENDED_ATTRIBUTES_MODIFIED;
  831. return m_ExtendedAttrs.SetAttribute (bstrName, bstrValue);
  832. }
  833. //****************************************************************************
  834. // STDMETHODIMP
  835. // CIlsMeetingPlace::RemoveExtendedAttributes (IIlsAttributes *pAttributes, ULONG *puReqID)
  836. //
  837. // History:
  838. //****************************************************************************
  839. STDMETHODIMP CIlsMeetingPlace::
  840. RemoveExtendedAttribute ( BSTR bstrName )
  841. {
  842. m_dwFlags |= ILS_MEET_FLAG_EXTENDED_ATTRIBUTES_MODIFIED;
  843. return m_ExtendedAttrs.SetAttribute (bstrName, NULL);
  844. }
  845. //****************************************************************************
  846. // STDMETHODIMP
  847. // CIlsMeetingPlace::GetExtendedAttributes (IIlsAttributes **pAttributes)
  848. //
  849. //****************************************************************************
  850. STDMETHODIMP CIlsMeetingPlace::
  851. GetExtendedAttribute ( BSTR bstrName, BSTR *pbstrValue )
  852. {
  853. return m_ExtendedAttrs.GetAttribute (bstrName, pbstrValue);
  854. }
  855. //****************************************************************************
  856. // STDMETHODIMP
  857. // CIlsMeetingPlace::GetAllExtendedAttributes (IIlsAttributes **pAttributes)
  858. //
  859. //****************************************************************************
  860. STDMETHODIMP CIlsMeetingPlace::
  861. GetAllExtendedAttributes ( IIlsAttributes **ppAttributes )
  862. {
  863. if (ppAttributes == NULL)
  864. return ILS_E_PARAMETER;
  865. return m_ExtendedAttrs.CloneNameValueAttrib((CAttributes **) ppAttributes);
  866. }
  867. //****************************************************************************
  868. // STDMETHODIMP
  869. // CIlsMeetingPlace::Register (
  870. // BSTR bstrServerName,
  871. // BSTR bstrAuthInfo,
  872. // ILS_ENUM_AUTH_TYPE ulsAuthInfo,
  873. // ULONG *pulID)
  874. //
  875. // Synopsis:
  876. //
  877. // Arguments:
  878. // pulID - ID to identify the asynchronous transaction
  879. // Returns:
  880. //
  881. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  882. //
  883. // Notes:
  884. //
  885. //****************************************************************************
  886. STDMETHODIMP CIlsMeetingPlace::
  887. Register (
  888. IIlsServer *pServer,
  889. ULONG *pulID )
  890. {
  891. HRESULT hr;
  892. LDAP_ASYNCINFO ldai;
  893. ASSERT(m_pszMeetingPlaceID != NULL);
  894. // Validate parameters
  895. //
  896. if (::MyIsBadServer (pServer) || pulID == NULL)
  897. return ILS_E_POINTER;
  898. // Make sure we have not done registration before
  899. //
  900. if (m_pIlsServer != NULL)
  901. return ILS_E_FAIL;
  902. // Clone ther server object
  903. //
  904. CIlsServer *pis = ((CIlsServer *) pServer)->Clone ();
  905. if (pis == NULL)
  906. return ILS_E_MEMORY;
  907. // Free the old server object if any
  908. //
  909. ::MemFree (m_pIlsServer);
  910. // Keep the new server object
  911. //
  912. m_pIlsServer = pis;
  913. // Allocate memory for LDAP_MEETINFO structure
  914. //
  915. PLDAP_MEETINFO pMeetInfo = NULL;
  916. hr = AllocMeetInfo(&pMeetInfo, ILS_MEET_ALL_MODIFIED);
  917. if (SUCCEEDED(hr))
  918. {
  919. ASSERT(m_hMeetingPlace == NULL);
  920. hr = ::UlsLdap_RegisterMeeting ((DWORD) this,
  921. m_pIlsServer->GetServerInfo (),
  922. pMeetInfo,
  923. &m_hMeetingPlace,
  924. &ldai);
  925. if (SUCCEEDED(hr))
  926. {
  927. COM_REQ_INFO ri;
  928. ReqInfo_Init (&ri);
  929. // If updating server was successfully requested, wait for the response
  930. //
  931. ri.uReqType = WM_ILS_REGISTER_MEETING;
  932. ri.uMsgID = ldai.uMsgID;
  933. ReqInfo_SetMeeting (&ri, this);
  934. hr = g_pReqMgr->NewRequest(&ri);
  935. if (SUCCEEDED(hr))
  936. {
  937. // Make sure the objects do not disappear before we get the response
  938. //
  939. this->AddRef();
  940. // Return the request ID
  941. //
  942. *pulID = ri.uReqID;
  943. };
  944. };
  945. }
  946. ::MemFree (pMeetInfo);
  947. if (FAILED (hr))
  948. {
  949. m_pIlsServer->Release ();
  950. m_pIlsServer = NULL;
  951. }
  952. else
  953. {
  954. m_ulState = ILS_REGISTERING;
  955. }
  956. return hr;
  957. }
  958. //****************************************************************************
  959. // STDMETHODIMP
  960. // CIlsMeetingPlace::Unregister (ULONG *pulID)
  961. //
  962. // Synopsis:
  963. //
  964. // Arguments:
  965. //
  966. // Returns:
  967. //
  968. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  969. //
  970. // Notes:
  971. //
  972. //****************************************************************************
  973. STDMETHODIMP
  974. CIlsMeetingPlace::Unregister (ULONG *pulID)
  975. {
  976. LDAP_ASYNCINFO ldai;
  977. HRESULT hr = ILS_E_NOT_REGISTERED;
  978. ASSERT(m_pszMeetingPlaceID != NULL);
  979. // BUGBUG how about ILS_MEETING_PLACE_IN_SYNC
  980. if (m_ulState == ILS_REGISTERED)
  981. {
  982. ASSERT(m_pIlsServer != NULL);
  983. ASSERT(m_hMeetingPlace != NULL);
  984. hr = ::UlsLdap_UnRegisterMeeting(m_hMeetingPlace, &ldai);
  985. if (SUCCEEDED(hr))
  986. {
  987. COM_REQ_INFO ri;
  988. ReqInfo_Init (&ri);
  989. // If updating server was successfully requested, wait for the response
  990. //
  991. ri.uReqType = WM_ILS_UNREGISTER_MEETING;
  992. ri.uMsgID = ldai.uMsgID;
  993. ReqInfo_SetMeeting (&ri, this);
  994. hr = g_pReqMgr->NewRequest(&ri);
  995. if (SUCCEEDED(hr))
  996. {
  997. // Make sure the objects do not disappear before we get the response
  998. //
  999. this->AddRef();
  1000. // Return the request ID
  1001. //
  1002. *pulID = ri.uReqID;
  1003. };
  1004. m_ulState = ILS_UNREGISTERING;
  1005. }
  1006. }
  1007. else
  1008. {
  1009. hr = ILS_E_NOT_REGISTERED;
  1010. }
  1011. return (hr);
  1012. }
  1013. //****************************************************************************
  1014. // STDMETHODIMP
  1015. // CIlsMeetingPlace::Update (ULONG *pulID)
  1016. //
  1017. // Synopsis:
  1018. //
  1019. // Arguments:
  1020. //
  1021. // Returns:
  1022. //
  1023. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  1024. //
  1025. // Notes:
  1026. //
  1027. //****************************************************************************
  1028. STDMETHODIMP CIlsMeetingPlace::
  1029. Update ( ULONG *pulID )
  1030. {
  1031. HRESULT hr;
  1032. LDAP_ASYNCINFO ldai;
  1033. PLDAP_MEETINFO pMeetInfo = NULL;
  1034. if ((m_ulState!=ILS_REGISTERED)
  1035. &&(m_ulState!=ILS_IN_SYNC)) {
  1036. return (ILS_E_NOT_REGISTERED);
  1037. }
  1038. ASSERT(m_pIlsServer != NULL);
  1039. if (!(m_dwFlags & ILS_MEET_MODIFIED_MASK)) {
  1040. return NOERROR;
  1041. }
  1042. // allocate memory for LDAP_MEETINFO structure
  1043. pMeetInfo = NULL;
  1044. hr = AllocMeetInfo(&pMeetInfo, m_dwFlags & ILS_MEET_MODIFIED_MASK);
  1045. if (SUCCEEDED(hr)) {
  1046. ASSERT(m_hMeetingPlace != NULL);
  1047. pMeetInfo->uOffsetMeetingPlaceID =
  1048. pMeetInfo->uOffsetDescription = INVALID_OFFSET;
  1049. pMeetInfo->lMeetingPlaceType = INVALID_MEETING_TYPE;
  1050. pMeetInfo->lAttendeeType = INVALID_ATTENDEE_TYPE;
  1051. hr = ::UlsLdap_SetMeetingInfo ( m_pIlsServer->GetServerInfo (),
  1052. m_pszMeetingPlaceID,
  1053. pMeetInfo,
  1054. &ldai);
  1055. if (SUCCEEDED(hr))
  1056. {
  1057. COM_REQ_INFO ri;
  1058. ReqInfo_Init (&ri);
  1059. // If updating server was successfully requested, wait for the response
  1060. //
  1061. ri.uReqType = WM_ILS_SET_MEETING_INFO;
  1062. ri.uMsgID = ldai.uMsgID;
  1063. ReqInfo_SetMeeting (&ri, this);
  1064. hr = g_pReqMgr->NewRequest(&ri);
  1065. if (SUCCEEDED(hr))
  1066. {
  1067. // Make sure the objects do not disappear before we get the response
  1068. //
  1069. this->AddRef();
  1070. // Return the request ID
  1071. //
  1072. *pulID = ri.uReqID;
  1073. };
  1074. };
  1075. }
  1076. ::MemFree (pMeetInfo);
  1077. return hr;
  1078. }
  1079. //****************************************************************************
  1080. // STDMETHODIMP
  1081. // CIlsMeetingPlace::AddAttendee (BSTR bstrAttendeeID, ULONG *pulID)
  1082. //
  1083. // Synopsis:
  1084. //
  1085. // Arguments:
  1086. // pbstrAttendeeID - ID of the Attendee to be added, should conform to Attendeetype
  1087. // pulID - ID to identify the asynchronous transaction
  1088. // Returns:
  1089. //
  1090. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  1091. //
  1092. // Notes:
  1093. //
  1094. //****************************************************************************
  1095. STDMETHODIMP CIlsMeetingPlace::
  1096. AddAttendee ( BSTR bstrAttendeeID, ULONG *pulID )
  1097. {
  1098. LDAP_ASYNCINFO ldai;
  1099. HRESULT hr;
  1100. LPTSTR pszAttendeeID = NULL;
  1101. if ((m_ulState != ILS_REGISTERED)&&
  1102. (m_ulState != ILS_IN_SYNC))
  1103. {
  1104. return(ILS_E_FAIL); // BUGBUG refine the error
  1105. }
  1106. ASSERT(NULL != m_pIlsServer);
  1107. ASSERT(NULL != m_pszMeetingPlaceID);
  1108. hr = BSTR_to_LPTSTR(&pszAttendeeID, bstrAttendeeID);
  1109. if (SUCCEEDED(hr))
  1110. {
  1111. hr = ::UlsLdap_AddAttendee (m_pIlsServer->GetServerInfo (),
  1112. m_pszMeetingPlaceID,
  1113. 1,
  1114. pszAttendeeID,
  1115. &ldai);
  1116. if (SUCCEEDED(hr))
  1117. {
  1118. COM_REQ_INFO ri;
  1119. ReqInfo_Init (&ri);
  1120. // If the request was successfully sent to the server
  1121. // wait for the response
  1122. ri.uReqType = WM_ILS_ADD_ATTENDEE;
  1123. ri.uMsgID = ldai.uMsgID;
  1124. ReqInfo_SetMeeting (&ri, this);
  1125. hr = g_pReqMgr->NewRequest(&ri);
  1126. if (SUCCEEDED(hr))
  1127. {
  1128. // Make sure the objects do not disappear before we get the response
  1129. //
  1130. this->AddRef();
  1131. // Return the request ID
  1132. //
  1133. *pulID = ri.uReqID;
  1134. };
  1135. }
  1136. ::MemFree (pszAttendeeID);
  1137. }
  1138. return (hr);
  1139. }
  1140. //****************************************************************************
  1141. // STDMETHODIMP
  1142. // CIlsMeetingPlace::RemoveAttendee (BSTR bstrAttendeeID, ULONG *pulID)
  1143. //
  1144. // Synopsis:
  1145. //
  1146. // Arguments:
  1147. // pbstrAttendeeID - ID of the Attendee to be removed, should conform to Attendeetype
  1148. // pulID - ID to identify the asynchronous transaction
  1149. // Returns:
  1150. //
  1151. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  1152. //
  1153. // Notes:
  1154. //
  1155. //****************************************************************************
  1156. STDMETHODIMP CIlsMeetingPlace::
  1157. RemoveAttendee ( BSTR bstrAttendeeID, ULONG *pulID )
  1158. {
  1159. LDAP_ASYNCINFO ldai;
  1160. HRESULT hr;
  1161. LPTSTR pszAttendeeID = NULL;
  1162. if ((m_ulState != ILS_REGISTERED)&&
  1163. (m_ulState != ILS_IN_SYNC))
  1164. {
  1165. return(ILS_E_FAIL); // BUBGUG refine
  1166. }
  1167. ASSERT(NULL != m_pIlsServer);
  1168. ASSERT(NULL != m_pszMeetingPlaceID);
  1169. hr = BSTR_to_LPTSTR (&pszAttendeeID, bstrAttendeeID);
  1170. if (SUCCEEDED(hr))
  1171. {
  1172. hr = ::UlsLdap_RemoveAttendee ( m_pIlsServer->GetServerInfo (),
  1173. m_pszMeetingPlaceID,
  1174. 1,
  1175. pszAttendeeID,
  1176. &ldai);
  1177. if (SUCCEEDED(hr))
  1178. {
  1179. COM_REQ_INFO ri;
  1180. ReqInfo_Init (&ri);
  1181. // If the request was successfully sent to the server
  1182. // wait for the response
  1183. ri.uReqType = WM_ILS_REMOVE_ATTENDEE;
  1184. ri.uMsgID = ldai.uMsgID;
  1185. ReqInfo_SetMeeting (&ri, this);
  1186. hr = g_pReqMgr->NewRequest(&ri);
  1187. if (SUCCEEDED(hr))
  1188. {
  1189. // Make sure the objects do not disappear before we get the response
  1190. //
  1191. this->AddRef();
  1192. // Return the request ID
  1193. //
  1194. *pulID = ri.uReqID;
  1195. };
  1196. }
  1197. ::MemFree (pszAttendeeID);
  1198. }
  1199. return (hr);
  1200. }
  1201. //****************************************************************************
  1202. // STDMETHODIMP
  1203. // CIlsMeetingPlace::EnumAttendeeNames(IIlsFilter *pFilter, ULONG *pulID)
  1204. //
  1205. // Synopsis: enumerate attendees in a meeting based on a filter
  1206. //
  1207. // Arguments:
  1208. // [pFilter] specifies the filter to be used by the server
  1209. // NULL => no filter
  1210. // [pulID] request ID returned for keeping track of the
  1211. // asynchronous operation
  1212. // Returns:
  1213. //
  1214. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  1215. //
  1216. // Notes:
  1217. //
  1218. //****************************************************************************
  1219. STDMETHODIMP CIlsMeetingPlace::
  1220. EnumAttendeeNames ( IIlsFilter *pFilter, ULONG *pulID )
  1221. {
  1222. LDAP_ASYNCINFO ldai;
  1223. HRESULT hr;
  1224. if ((m_ulState != ILS_REGISTERED)&&
  1225. (m_ulState != ILS_IN_SYNC))
  1226. {
  1227. return(ILS_E_FAIL);
  1228. }
  1229. // Create a ldap-like filter
  1230. //
  1231. TCHAR *pszFilter = NULL;
  1232. hr = ::FilterToLdapString ((CFilter *) pFilter, &pszFilter);
  1233. if (hr != S_OK)
  1234. return hr;
  1235. // Send the request over the wire
  1236. //
  1237. hr = ::UlsLdap_EnumAttendees ( m_pIlsServer->GetServerInfo (),
  1238. m_pszMeetingPlaceID,
  1239. pszFilter,
  1240. &ldai);
  1241. ::MemFree (pszFilter);
  1242. if (SUCCEEDED(hr))
  1243. {
  1244. // If the request was successfully sent to the server
  1245. // wait for the response
  1246. //
  1247. COM_REQ_INFO ri;
  1248. ReqInfo_Init (&ri);
  1249. ri.uReqType = WM_ILS_ENUM_ATTENDEES;
  1250. ri.uMsgID = ldai.uMsgID;
  1251. ReqInfo_SetMeeting (&ri, this);
  1252. // Enter the request
  1253. //
  1254. hr = g_pReqMgr->NewRequest(&ri);
  1255. if (SUCCEEDED(hr))
  1256. {
  1257. // Make sure the objects do not disappear before we get the response
  1258. //
  1259. this->AddRef();
  1260. // Return the request ID
  1261. //
  1262. *pulID = ri.uReqID;
  1263. };
  1264. }
  1265. return (hr);
  1266. }
  1267. //****************************************************************************
  1268. // STDMETHODIMP
  1269. // CIlsMeetingPlace::RegisterResult(ULONG ulID, HRESULT hr)
  1270. //
  1271. // Synopsis:
  1272. //
  1273. // Arguments:
  1274. //
  1275. // Returns:
  1276. //
  1277. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  1278. //
  1279. // Notes:
  1280. //
  1281. //****************************************************************************
  1282. STDMETHODIMP
  1283. CIlsMeetingPlace::RegisterResult(ULONG uReqID, HRESULT hr)
  1284. {
  1285. OBJRINFO objri;
  1286. if (SUCCEEDED(hr)) {
  1287. m_dwFlags |= ILS_MEET_FLAG_REGISTERED;
  1288. m_ulState = ILS_REGISTERED;
  1289. }
  1290. else {
  1291. ASSERT(!(m_dwFlags & ILS_MEET_FLAG_REGISTERED));
  1292. m_hMeetingPlace = NULL; // null out the service provider's handle
  1293. m_ulState = ILS_UNREGISTERED;
  1294. }
  1295. objri.uReqID = uReqID;
  1296. objri.hResult = hr;
  1297. objri.pv = NULL;
  1298. NotifySink((VOID *)&objri, OnNotifyRegisterMeetingPlaceResult);
  1299. return NOERROR;
  1300. }
  1301. //****************************************************************************
  1302. // STDMETHODIMP
  1303. // CIlsMeetingPlace::UnregisterResult(ULONG ulID, HRESULT hr)
  1304. //
  1305. // Synopsis:
  1306. //
  1307. // Arguments:
  1308. //
  1309. // Returns:
  1310. //
  1311. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  1312. //
  1313. // Notes:
  1314. //
  1315. //****************************************************************************
  1316. STDMETHODIMP
  1317. CIlsMeetingPlace::UnregisterResult(ULONG uReqID, HRESULT hr)
  1318. {
  1319. OBJRINFO objri;
  1320. if (SUCCEEDED(hr)) {
  1321. m_dwFlags &= ~ILS_MEET_FLAG_REGISTERED;
  1322. m_ulState = ILS_UNREGISTERED;
  1323. }
  1324. else {
  1325. // BUGBUG, we need an m_oldState variable
  1326. m_ulState = ILS_REGISTERED;
  1327. }
  1328. objri.uReqID = uReqID;
  1329. objri.hResult = hr;
  1330. objri.pv = NULL;
  1331. NotifySink((VOID *)&objri, OnNotifyUnregisterMeetingPlaceResult);
  1332. return NOERROR;
  1333. }
  1334. //****************************************************************************
  1335. // STDMETHODIMP
  1336. // CIlsMeetingPlace::UpdateResult(ULONG ulID, HRESULT hr)
  1337. //
  1338. // Synopsis:
  1339. //
  1340. // Arguments:
  1341. //
  1342. // Returns:
  1343. //
  1344. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  1345. //
  1346. // Notes:
  1347. //
  1348. //****************************************************************************
  1349. STDMETHODIMP
  1350. CIlsMeetingPlace::UpdateResult(ULONG ulID, HRESULT hr)
  1351. {
  1352. OBJRINFO objri;
  1353. objri.uReqID = ulID;
  1354. objri.hResult = hr;
  1355. objri.pv = NULL;
  1356. if (SUCCEEDED(hr)) {
  1357. m_dwFlags &= ~ILS_MEET_MODIFIED_MASK;
  1358. }
  1359. NotifySink((VOID *)&objri, OnNotifyUpdateMeetingPlaceResult);
  1360. return NOERROR;
  1361. }
  1362. //****************************************************************************
  1363. // STDMETHODIMP
  1364. // CIlsMeetingPlace::AttendeeChangeResult(ULONG ulID, HRESULT hr)
  1365. //
  1366. // Synopsis:
  1367. //
  1368. // Arguments:
  1369. //
  1370. // Returns:
  1371. //
  1372. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  1373. //
  1374. // Notes:
  1375. //
  1376. //****************************************************************************
  1377. STDMETHODIMP
  1378. CIlsMeetingPlace::AddAttendeeResult(ULONG uReqID, HRESULT hr)
  1379. {
  1380. OBJRINFO objri;
  1381. objri.uReqID = uReqID;
  1382. objri.hResult = hr;
  1383. objri.pv = NULL;
  1384. NotifySink((VOID *)&objri, OnNotifyAddAttendeeResult);
  1385. return NOERROR;
  1386. }
  1387. //****************************************************************************
  1388. // STDMETHODIMP
  1389. // CIlsMeetingPlace::RemoveAttendeeResult(ULONG ulID, HRESULT hr)
  1390. //
  1391. // Synopsis:
  1392. //
  1393. // Arguments:
  1394. //
  1395. // Returns:
  1396. //
  1397. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  1398. //
  1399. // Notes:
  1400. //
  1401. //****************************************************************************
  1402. STDMETHODIMP
  1403. CIlsMeetingPlace::RemoveAttendeeResult(ULONG uReqID, HRESULT hr)
  1404. {
  1405. OBJRINFO objri;
  1406. objri.uReqID = uReqID;
  1407. objri.hResult = hr;
  1408. objri.pv = NULL;
  1409. NotifySink((VOID *)&objri, OnNotifyRemoveAttendeeResult);
  1410. return NOERROR;
  1411. }
  1412. //****************************************************************************
  1413. // STDMETHODIMP
  1414. // CIlsMeetingPlace::EnumAttendeeNamesResult(ULONG ulID, PLDAP_ENUM ple)
  1415. //
  1416. // Synopsis:
  1417. //
  1418. // Arguments:
  1419. //
  1420. // Returns:
  1421. //
  1422. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  1423. //
  1424. // Notes:
  1425. //
  1426. //****************************************************************************
  1427. STDMETHODIMP
  1428. CIlsMeetingPlace::EnumAttendeeNamesResult(ULONG uReqID, PLDAP_ENUM ple)
  1429. {
  1430. ENUMRINFO eri;
  1431. // Package the notification info
  1432. //
  1433. eri.uReqID = uReqID;
  1434. // PLDAP_ENUM is NULL when the enumeration is terminated successfully
  1435. //
  1436. if (ple != NULL)
  1437. {
  1438. eri.hResult = ple->hResult;
  1439. eri.cItems = ple->cItems;
  1440. eri.pv = (void *)(((PBYTE)ple)+ple->uOffsetItems);
  1441. }
  1442. else
  1443. {
  1444. eri.hResult = S_FALSE;
  1445. eri.cItems = 0;
  1446. eri.pv = NULL;
  1447. };
  1448. NotifySink((void *)&eri, OnNotifyEnumAttendeeNamesResult);
  1449. return NOERROR;
  1450. }
  1451. //****************************************************************************
  1452. // STDMETHODIMP
  1453. // CIlsMeetingPlace::EnumConnectionPoints(IEnumConnectionPoints **ppEnum)
  1454. //
  1455. // Synopsis:
  1456. //
  1457. // Arguments:
  1458. //
  1459. // Returns:
  1460. //
  1461. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  1462. //
  1463. // Notes:
  1464. //
  1465. //****************************************************************************
  1466. STDMETHODIMP
  1467. CIlsMeetingPlace::EnumConnectionPoints(IEnumConnectionPoints **ppEnum)
  1468. {
  1469. CEnumConnectionPoints *pecp;
  1470. HRESULT hr;
  1471. // Validate parameters
  1472. //
  1473. if (ppEnum == NULL)
  1474. {
  1475. return E_POINTER;
  1476. };
  1477. // Assume failure
  1478. //
  1479. *ppEnum = NULL;
  1480. // Create an enumerator
  1481. //
  1482. pecp = new CEnumConnectionPoints;
  1483. if (pecp == NULL)
  1484. return ILS_E_MEMORY;
  1485. // Initialize the enumerator
  1486. //
  1487. hr = pecp->Init((IConnectionPoint *)m_pConnectionPoint);
  1488. if (FAILED(hr))
  1489. {
  1490. delete pecp;
  1491. return hr;
  1492. };
  1493. // Give it back to the caller
  1494. //
  1495. pecp->AddRef();
  1496. *ppEnum = pecp;
  1497. return S_OK;
  1498. }
  1499. //****************************************************************************
  1500. // STDMETHODIMP
  1501. // CIlsMeetingPlace::FindConnectionPoint(REFIID riid, IConnectionPoint **ppcp)
  1502. //
  1503. // Synopsis:
  1504. //
  1505. // Arguments:
  1506. //
  1507. // Returns:
  1508. //
  1509. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  1510. //
  1511. // Notes:
  1512. //
  1513. //****************************************************************************
  1514. STDMETHODIMP
  1515. CIlsMeetingPlace::FindConnectionPoint(REFIID riid, IConnectionPoint **ppcp)
  1516. {
  1517. IID siid;
  1518. HRESULT hr;
  1519. // Validate parameters
  1520. //
  1521. if (ppcp == NULL)
  1522. {
  1523. return E_POINTER;
  1524. };
  1525. // Assume failure
  1526. //
  1527. *ppcp = NULL;
  1528. if (m_pConnectionPoint != NULL)
  1529. {
  1530. hr = m_pConnectionPoint->GetConnectionInterface(&siid);
  1531. if (SUCCEEDED(hr))
  1532. {
  1533. if (riid == siid)
  1534. {
  1535. *ppcp = (IConnectionPoint *)m_pConnectionPoint;
  1536. (*ppcp)->AddRef();
  1537. hr = S_OK;
  1538. }
  1539. else
  1540. {
  1541. hr = ILS_E_NO_INTERFACE;
  1542. };
  1543. };
  1544. }
  1545. else
  1546. {
  1547. hr = ILS_E_NO_INTERFACE;
  1548. };
  1549. return hr;
  1550. }
  1551. //****************************************************************************
  1552. //
  1553. //CEnumMeetingPlaces class implementation
  1554. //
  1555. //****************************************************************************
  1556. //****************************************************************************
  1557. // CEnumMeetingPlaces::CEnumMeetingPlaces (void)
  1558. //
  1559. // Synopsis:
  1560. //
  1561. // Arguments:
  1562. //
  1563. // Returns:
  1564. //
  1565. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  1566. //
  1567. // Notes:
  1568. //
  1569. //****************************************************************************
  1570. CEnumMeetingPlaces::CEnumMeetingPlaces (void)
  1571. {
  1572. m_cRef = 0;
  1573. m_ppMeetingPlaces = NULL;
  1574. m_cMeetingPlaces = 0;
  1575. m_iNext = 0;
  1576. return;
  1577. }
  1578. //****************************************************************************
  1579. // CEnumMeetingPlaces::~CEnumMeetingPlaces (void)
  1580. //
  1581. // Synopsis:
  1582. //
  1583. // Arguments:
  1584. //
  1585. // Returns:
  1586. //
  1587. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  1588. //
  1589. // Notes:
  1590. //
  1591. //****************************************************************************
  1592. CEnumMeetingPlaces::~CEnumMeetingPlaces (void)
  1593. {
  1594. ULONG i;
  1595. if (m_ppMeetingPlaces != NULL)
  1596. {
  1597. for (i = 0; i < m_cMeetingPlaces; i++)
  1598. {
  1599. m_ppMeetingPlaces[i]->Release();
  1600. };
  1601. ::MemFree (m_ppMeetingPlaces);
  1602. };
  1603. return;
  1604. }
  1605. //****************************************************************************
  1606. // STDMETHODIMP
  1607. // CEnumMeetingPlaces::Init (CIlsMeetingPlace **ppMeetingPlacesList, ULONG cMeetingPlaces)
  1608. //
  1609. // Synopsis:
  1610. //
  1611. // Arguments:
  1612. //
  1613. // Returns:
  1614. //
  1615. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  1616. //
  1617. // Notes:
  1618. //
  1619. //****************************************************************************
  1620. STDMETHODIMP
  1621. CEnumMeetingPlaces::Init (CIlsMeetingPlace **ppMeetingPlacesList, ULONG cMeetingPlaces)
  1622. {
  1623. HRESULT hr = NOERROR;
  1624. // If no list, do nothing
  1625. //
  1626. if (cMeetingPlaces != 0)
  1627. {
  1628. ASSERT(ppMeetingPlacesList != NULL);
  1629. // Allocate the snapshot buffer
  1630. //
  1631. m_ppMeetingPlaces = (CIlsMeetingPlace **) ::MemAlloc (cMeetingPlaces*sizeof(CIlsMeetingPlace *));
  1632. if (m_ppMeetingPlaces != NULL)
  1633. {
  1634. ULONG i;
  1635. // Snapshot the object list
  1636. //
  1637. for (i =0; i < cMeetingPlaces; i++)
  1638. {
  1639. m_ppMeetingPlaces[i] = ppMeetingPlacesList[i];
  1640. m_ppMeetingPlaces[i]->AddRef();
  1641. };
  1642. m_cMeetingPlaces = cMeetingPlaces;
  1643. }
  1644. else
  1645. {
  1646. hr = ILS_E_MEMORY;
  1647. };
  1648. };
  1649. return hr;
  1650. }
  1651. //****************************************************************************
  1652. // STDMETHODIMP
  1653. // CEnumMeetingPlaces::QueryInterface (REFIID riid, void **ppv)
  1654. //
  1655. // Synopsis:
  1656. //
  1657. // Arguments:
  1658. //
  1659. // Returns:
  1660. //
  1661. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  1662. //
  1663. // Notes:
  1664. //
  1665. //****************************************************************************
  1666. STDMETHODIMP
  1667. CEnumMeetingPlaces::QueryInterface (REFIID riid, void **ppv)
  1668. {
  1669. if (riid == IID_IEnumIlsMeetingPlaces || riid == IID_IUnknown)
  1670. {
  1671. *ppv = (IEnumIlsMeetingPlaces *) this;
  1672. AddRef();
  1673. return S_OK;
  1674. }
  1675. else
  1676. {
  1677. *ppv = NULL;
  1678. return ILS_E_NO_INTERFACE;
  1679. };
  1680. }
  1681. //****************************************************************************
  1682. // STDMETHODIMP_(ULONG)
  1683. // CEnumMeetingPlaces::AddRef (void)
  1684. //
  1685. // Synopsis:
  1686. //
  1687. // Arguments:
  1688. //
  1689. // Returns:
  1690. //
  1691. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  1692. //
  1693. // Notes:
  1694. //
  1695. //****************************************************************************
  1696. STDMETHODIMP_(ULONG)
  1697. CEnumMeetingPlaces::AddRef (void)
  1698. {
  1699. DllLock();
  1700. MyDebugMsg ((DM_REFCOUNT, "CEnumMeetingPlaces::AddRef: ref=%ld\r\n", m_cRef));
  1701. ::InterlockedIncrement ((LONG *) &m_cRef);
  1702. return m_cRef;
  1703. }
  1704. //****************************************************************************
  1705. // STDMETHODIMP_(ULONG)
  1706. // CEnumMeetingPlaces::Release (void)
  1707. //
  1708. // Synopsis:
  1709. //
  1710. // Arguments:
  1711. //
  1712. // Returns:
  1713. //
  1714. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  1715. //
  1716. // Notes:
  1717. //
  1718. //****************************************************************************
  1719. STDMETHODIMP_(ULONG)
  1720. CEnumMeetingPlaces::Release (void)
  1721. {
  1722. DllRelease();
  1723. ASSERT (m_cRef > 0);
  1724. MyDebugMsg ((DM_REFCOUNT, "CEnumMeetingPlaces::Release: ref=%ld\r\n", m_cRef));
  1725. if (::InterlockedDecrement ((LONG *) &m_cRef) == 0)
  1726. {
  1727. delete this;
  1728. return 0;
  1729. }
  1730. return m_cRef;
  1731. }
  1732. //****************************************************************************
  1733. // STDMETHODIMP
  1734. // CEnumMeetingPlaces::Next (ULONG cMeetingPlaces, IIlsMeetingPlace **rgpm, ULONG *pcFetched)
  1735. //
  1736. // Synopsis:
  1737. //
  1738. // Arguments:
  1739. //
  1740. // Returns:
  1741. //
  1742. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  1743. //
  1744. // Notes:
  1745. //
  1746. //****************************************************************************
  1747. STDMETHODIMP
  1748. CEnumMeetingPlaces::Next (ULONG cMeetingPlaces, IIlsMeetingPlace **rgpm, ULONG *pcFetched)
  1749. {
  1750. ULONG cCopied;
  1751. HRESULT hr;
  1752. // Validate the pointer
  1753. //
  1754. if (rgpm == NULL) {
  1755. return E_POINTER;
  1756. }
  1757. // Validate the parameters
  1758. //
  1759. if ((cMeetingPlaces == 0) ||
  1760. ((cMeetingPlaces > 1) && (pcFetched == NULL))) {
  1761. return ILS_E_PARAMETER;
  1762. }
  1763. // Check the enumeration index
  1764. //
  1765. cCopied = 0;
  1766. // Can copy if we still have more attribute names
  1767. //
  1768. while ((cCopied < cMeetingPlaces) &&
  1769. (m_iNext < this->m_cMeetingPlaces))
  1770. {
  1771. m_ppMeetingPlaces[m_iNext]->AddRef();
  1772. rgpm[cCopied++] = m_ppMeetingPlaces[m_iNext++];
  1773. };
  1774. // Determine the returned information based on other parameters
  1775. //
  1776. if (pcFetched != NULL)
  1777. {
  1778. *pcFetched = cCopied;
  1779. };
  1780. return (cMeetingPlaces == cCopied ? S_OK : S_FALSE);
  1781. }
  1782. //****************************************************************************
  1783. // STDMETHODIMP
  1784. // CEnumMeetingPlaces::Skip (ULONG cMeetingPlaces)
  1785. //
  1786. // Synopsis:
  1787. //
  1788. // Arguments:
  1789. //
  1790. // Returns:
  1791. //
  1792. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  1793. //
  1794. // Notes:
  1795. //
  1796. //****************************************************************************
  1797. STDMETHODIMP
  1798. CEnumMeetingPlaces::Skip (ULONG cMeetingPlaces)
  1799. {
  1800. ULONG iNewIndex;
  1801. // Validate the parameters
  1802. //
  1803. if (cMeetingPlaces == 0){
  1804. return ILS_E_PARAMETER;
  1805. }
  1806. // Check the enumeration index limit
  1807. //
  1808. iNewIndex = m_iNext+cMeetingPlaces;
  1809. if (iNewIndex <= m_cMeetingPlaces)
  1810. {
  1811. m_iNext = iNewIndex;
  1812. return S_OK;
  1813. }
  1814. else
  1815. {
  1816. m_iNext = m_cMeetingPlaces;
  1817. return S_FALSE;
  1818. };
  1819. }
  1820. //****************************************************************************
  1821. // STDMETHODIMP
  1822. // CEnumMeetingPlaces::Reset (void)
  1823. //
  1824. // Synopsis:
  1825. //
  1826. // Arguments:
  1827. //
  1828. // Returns:
  1829. //
  1830. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  1831. //
  1832. // Notes:
  1833. //
  1834. //****************************************************************************
  1835. STDMETHODIMP
  1836. CEnumMeetingPlaces::Reset (void)
  1837. {
  1838. m_iNext = 0;
  1839. return S_OK;
  1840. }
  1841. //****************************************************************************
  1842. // STDMETHODIMP
  1843. // CEnumMeetingPlaces::Clone(IEnumIlsMeetingPlaces **ppEnum)
  1844. //
  1845. // Synopsis:
  1846. //
  1847. // Arguments:
  1848. //
  1849. // Returns:
  1850. //
  1851. // History: 11/25/1996 Shishir Pardikar [shishirp] Created.
  1852. //
  1853. // Notes:
  1854. //
  1855. //****************************************************************************
  1856. STDMETHODIMP
  1857. CEnumMeetingPlaces::Clone(IEnumIlsMeetingPlaces **ppEnum)
  1858. {
  1859. CEnumMeetingPlaces *pEnumMeetingPlaces;
  1860. HRESULT hr;
  1861. // Validate parameters
  1862. //
  1863. if (ppEnum == NULL)
  1864. {
  1865. return E_POINTER;
  1866. };
  1867. *ppEnum = NULL;
  1868. // Create an enumerator
  1869. //
  1870. pEnumMeetingPlaces = new CEnumMeetingPlaces;
  1871. if (pEnumMeetingPlaces == NULL) {
  1872. return ILS_E_MEMORY;
  1873. }
  1874. // Clone the information
  1875. //
  1876. hr = pEnumMeetingPlaces->Init(m_ppMeetingPlaces, m_cMeetingPlaces);
  1877. if (SUCCEEDED(hr))
  1878. {
  1879. pEnumMeetingPlaces->m_iNext = m_iNext;
  1880. // Return the cloned enumerator
  1881. //
  1882. pEnumMeetingPlaces->AddRef();
  1883. *ppEnum = pEnumMeetingPlaces;
  1884. }
  1885. else
  1886. {
  1887. delete pEnumMeetingPlaces;
  1888. };
  1889. return hr;
  1890. }
  1891. #endif // ENABLE_MEETING_PLACE