XTPCalendarData.cpp
上传用户:szled88
上传日期:2015-04-09
资源大小:43957k
文件大小:34k
源码类别:

对话框与窗口

开发平台:

Visual C++

  1. // XTPCalendarData.cpp: implementation of the CXTPCalendarData class.
  2. //
  3. // This file is a part of the XTREME CALENDAR MFC class library.
  4. // (c)1998-2008 Codejock Software, All Rights Reserved.
  5. //
  6. // THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE
  7. // RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN
  8. // CONSENT OF CODEJOCK SOFTWARE.
  9. //
  10. // THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED
  11. // IN THE XTREME TOOLKIT PRO LICENSE AGREEMENT. CODEJOCK SOFTWARE GRANTS TO
  12. // YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A
  13. // SINGLE COMPUTER.
  14. //
  15. // CONTACT INFORMATION:
  16. // support@codejock.com
  17. // http://www.codejock.com
  18. //
  19. /////////////////////////////////////////////////////////////////////////////
  20. #include "stdafx.h"
  21. #include "XTPCalendarData.h"
  22. #include "XTPCalendarMemoryDataProvider.h"
  23. #include "XTPCalendarCustomProperties.h"
  24. #include "Common/XTPNotifyConnection.h"
  25. #include "Common/XTPVC50Helpers.h"
  26. #include "Common/XTPPropExchange.h"
  27. #include "XTPCalendarControl.h"
  28. #include "XTPCalendarRecurrencePattern.h"
  29. #include "XTPCalendarEvent.h"
  30. #include "XTPCalendarEventLabel.h"
  31. #include "XTPCalendarNotifications.h"
  32. #include "XTPCalendarOptions.h"
  33. #include "XTPCalendarResource.h"
  34. #ifdef _DEBUG
  35. #define new DEBUG_NEW
  36. #undef THIS_FILE
  37. static char THIS_FILE[] = __FILE__;
  38. #endif
  39. #define DBG_CACHE_ASSERT ASSERT
  40. #ifndef DBG_CACHE_ASSERT
  41. #define DBG_CACHE_ASSERT
  42. #endif
  43. //===========================================================================
  44. // Summary:
  45. //     Define data provider cache hash table size. Should be a prime number!
  46. //     like: 503, 1021, 1511, 2003, 3001, 4001, 5003, 6007, 8009, 12007,
  47. //     16001, 32003, 48017, 64007
  48. // See Also: CMap overview
  49. //===========================================================================
  50. #define XTP_DP_CACHE_HASH_TABLE_SIZE 1021
  51. long VAR2long(const COleVariant& oleVar)
  52. {
  53. try
  54. {
  55. _variant_t vtValue((const VARIANT*)&oleVar);
  56. return (long)vtValue;
  57. }
  58. //catch(_com_error e)
  59. catch(...)
  60. {
  61. ASSERT(FALSE);
  62. }
  63. return 0;
  64. }
  65. ////////////////////////////////////////////////////////////////////////////
  66. CXTPCalendarData::CXTPDPCache::CXTPDPCache()
  67. {
  68. m_pCacheDP = NULL;
  69. m_eCacheMode = xtpCalendarDPCacheModeOff;
  70. m_mapIsDayInCache.InitHashTable(XTP_DP_CACHE_HASH_TABLE_SIZE, FALSE);
  71. }
  72. CXTPCalendarData::CXTPDPCache::~CXTPDPCache()
  73. {
  74. SafeClose();
  75. }
  76. void CXTPCalendarData::CXTPDPCache::SafeClose()
  77. {
  78. if (m_pCacheDP)
  79. {
  80. if (m_pCacheDP->IsOpen())
  81. {
  82. m_pCacheDP->Close();
  83. }
  84. }
  85. CMDTARGET_RELEASE(m_pCacheDP);
  86. m_eCacheMode = xtpCalendarDPCacheModeOff;
  87. }
  88. void CXTPCalendarData::CXTPDPCache::SafeRemoveAll()
  89. {
  90. if (m_pCacheDP)
  91. {
  92. m_pCacheDP->RemoveAllEvents();
  93. }
  94. m_mapIsDayInCache.RemoveAll();
  95. }
  96. BOOL CXTPCalendarData::CXTPDPCache::IsDayInCache(COleDateTime dtDay)
  97. {
  98. BOOL bIs = FALSE;
  99. return m_mapIsDayInCache.Lookup((DWORD)(DATE)dtDay, bIs) && bIs;
  100. }
  101. void CXTPCalendarData::CXTPDPCache::SetDayInCache(COleDateTime dtDay, BOOL bSet)
  102. {
  103. if (bSet)
  104. {
  105. m_mapIsDayInCache.SetAt((DWORD)(DATE)dtDay, TRUE);
  106. }
  107. else
  108. {
  109. m_mapIsDayInCache.RemoveKey((DWORD)(DATE)dtDay);
  110. }
  111. }
  112. BOOL CXTPCalendarData::CXTPDPCache::IsEventInCache(CXTPCalendarEvent* pEvent)
  113. {
  114. if (!pEvent || !m_pCacheDP)
  115. {
  116. ASSERT(FALSE);
  117. return FALSE;
  118. }
  119. int nRState = pEvent->GetRecurrenceState();
  120. if (nRState == xtpCalendarRecurrenceNotRecurring ||
  121. nRState == xtpCalendarRecurrenceMaster)
  122. {
  123. DWORD dwEventID = pEvent->GetEventID();
  124. CXTPCalendarEventPtr ptrEvInCache = m_pCacheDP->GetEvent(dwEventID);
  125. return ptrEvInCache != NULL;
  126. }
  127. else
  128. {
  129. ASSERT(nRState == xtpCalendarRecurrenceOccurrence || nRState == xtpCalendarRecurrenceException);
  130. DWORD dwRPatternID = pEvent->GetRecurrencePatternID();
  131. CXTPCalendarRecurrencePatternPtr ptrRPattern = m_pCacheDP->GetRecurrencePattern(dwRPatternID);
  132. return ptrRPattern != NULL;
  133. }
  134. }
  135. void CXTPCalendarData::CXTPDPCache::_AddToCacheIfNeed(CXTPCalendarRecurrencePattern* pPattern)
  136. {
  137. ASSERT(pPattern);
  138. if (!pPattern || !m_pCacheDP)
  139. {
  140. return;
  141. }
  142. DWORD dwRPatternID = pPattern->GetPatternID();
  143. CXTPCalendarRecurrencePatternPtr ptrRPattern = m_pCacheDP->GetRecurrencePattern(dwRPatternID);
  144. if (ptrRPattern)
  145. {
  146. return;
  147. }
  148. #ifdef _DEBUG
  149. {
  150. DWORD dwMasterEventID = pPattern->GetMasterEventID();
  151. CXTPCalendarEventPtr ptrMasterEvent = m_pCacheDP->GetEvent(dwMasterEventID);
  152. ASSERT(ptrMasterEvent == NULL);
  153. }
  154. #endif
  155. CXTPCalendarEventPtr ptrMasterEvent = pPattern->GetMasterEvent(); // this call also add master event to cache
  156. ASSERT(ptrMasterEvent);
  157. if (ptrMasterEvent)
  158. {
  159. // Must be added to cache in call: pPattern->GetMasterEvent();
  160. //
  161. DWORD dwMasterEventID = ptrMasterEvent->GetEventID();
  162. CXTPCalendarEventPtr ptrEvInCache = m_pCacheDP->GetEvent(dwMasterEventID);
  163. DBG_CACHE_ASSERT(ptrEvInCache);
  164. if (!ptrEvInCache)
  165. {
  166. // this strange, but add if it is still not here
  167. VERIFY(m_pCacheDP->AddEvent(ptrMasterEvent));
  168. }
  169. }
  170. }
  171. void CXTPCalendarData::CXTPDPCache::AddToCacheIfNeed(CXTPCalendarEvent* pEvent)
  172. {
  173. ASSERT(pEvent);
  174. if (!pEvent || !m_pCacheDP)
  175. {
  176. return;
  177. }
  178. int nRState = pEvent->GetRecurrenceState();
  179. if (nRState == xtpCalendarRecurrenceNotRecurring ||
  180. nRState == xtpCalendarRecurrenceMaster)
  181. {
  182. DWORD dwEventID = pEvent->GetEventID();
  183. CXTPCalendarEventPtr ptrEvInCache = m_pCacheDP->GetEvent(dwEventID);
  184. if (!ptrEvInCache)
  185. {
  186. VERIFY(m_pCacheDP->AddEvent(pEvent));
  187. }
  188. }
  189. else
  190. {
  191. // From previous version.
  192. // Non-Optimal. Should not be called.
  193. ASSERT(FALSE);
  194. }
  195. }
  196. void CXTPCalendarData::CXTPDPCache::AddToCache(CXTPCalendarEvents* pEvents, COleDateTime dtDay)
  197. {
  198. if (!pEvents)
  199. {
  200. return;
  201. }
  202. int nCount = pEvents->GetCount();
  203. for (int i = 0; i < nCount; i++)
  204. {
  205. CXTPCalendarEvent* pEvent = pEvents->GetAt(i ,FALSE);
  206. AddToCacheIfNeed(pEvent);
  207. }
  208. SetDayInCache(dtDay, TRUE);
  209. }
  210. void CXTPCalendarData::SetCacheMode(int eCacheMode, CXTPCalendarData* pCacheDataProvider)
  211. {
  212. if (eCacheMode == xtpCalendarDPCacheModeOff)
  213. {
  214. m_cache.SafeClose();
  215. }
  216. else
  217. {
  218. if (!m_cache.m_pCacheDP && !pCacheDataProvider)
  219. {
  220. m_cache.m_pCacheDP = new CXTPCalendarMemoryDataProvider();
  221. }
  222. else if (!m_cache.m_pCacheDP && pCacheDataProvider)
  223. {
  224. m_cache.m_pCacheDP = pCacheDataProvider;
  225. }
  226. else if (m_cache.m_pCacheDP && pCacheDataProvider)
  227. {
  228. m_cache.SafeClose();
  229. m_cache.m_pCacheDP = pCacheDataProvider;
  230. }
  231. else
  232. {
  233. ASSERT(m_cache.m_pCacheDP && !pCacheDataProvider);
  234. }
  235. if (!m_cache.m_pCacheDP)
  236. {
  237. return;
  238. }
  239. if (!m_cache.m_pCacheDP->IsOpen())
  240. {
  241. VERIFY( m_cache.m_pCacheDP->Open() );
  242. }
  243. m_cache.SafeRemoveAll();
  244. m_cache.m_eCacheMode = eCacheMode;
  245. }
  246. }
  247. void CXTPCalendarData::ClearCache()
  248. {
  249. m_cache.SafeRemoveAll();
  250. }
  251. void CXTPCalendarData::RemoveAllEvents()
  252. {
  253. if (!IsOpen())
  254. {
  255. ASSERT(FALSE);
  256. return;
  257. }
  258. m_cache.SafeRemoveAll();
  259. DoRemoveAllEvents();
  260. }
  261. //////////////////////////////////////////////////////////////////////////
  262. DWORD CXTPCalendarData::ms_dwNextFreeTempID = DWORD(-1);
  263. //===========================================================================
  264. IMPLEMENT_DYNAMIC(CXTPCalendarData, CCmdTarget)
  265. CXTPCalendarData::CXTPCalendarData()
  266. {
  267. m_pCalendarOptions = NULL;
  268. m_bOpened = FALSE;
  269. m_pConnect = new CXTPNotifyConnection();
  270. m_bDisableNotificationsSending = FALSE;
  271. m_pLabelList = new CXTPCalendarEventLabels();
  272. m_pLabelList->InitDefaultValues();
  273. m_typeProvider = xtpCalendarDataProviderUnknown;
  274. m_pCustomProperties = new CXTPCalendarCustomProperties();
  275. m_pSchedules = new CXTPCalendarSchedules();
  276. m_pEventCategories = new CXTPCalendarEventCategories();
  277. m_pEventCategories->InitDefaultValues();
  278. }
  279. CXTPCalendarData::~CXTPCalendarData()
  280. {
  281. if (m_pCalendarOptions)
  282. {
  283. m_pCalendarOptions->SetDataProvider(NULL);
  284. }
  285. ASSERT(!m_pCalendarOptions);
  286. //CMDTARGET_RELEASE(m_pCalendarOptions);
  287. CMDTARGET_RELEASE(m_pLabelList);
  288. CMDTARGET_RELEASE(m_pConnect);
  289. CMDTARGET_RELEASE(m_pCustomProperties);
  290. CMDTARGET_RELEASE(m_pSchedules);
  291. CMDTARGET_RELEASE(m_pEventCategories);
  292. }
  293. void CXTPCalendarData::SetLabelList(CXTPCalendarEventLabels* pLabelList)
  294. {
  295. CMDTARGET_RELEASE(m_pLabelList);
  296. m_pLabelList = pLabelList;
  297. CMDTARGET_ADDREF(m_pLabelList);
  298. }
  299. CXTPCalendarEventPtr CXTPCalendarData::CreateNewEvent(DWORD dwEventID)
  300. {
  301. CXTPCalendarEventPtr ptrEvent = new CXTPCalendarEvent(this);
  302. if (ptrEvent)
  303. {
  304. DWORD dwTempID = dwEventID != XTP_CALENDAR_UNKNOWN_EVENT_ID ? dwEventID: GetNextFreeTempID();
  305. ptrEvent->SetEventID(dwTempID);
  306. }
  307. return ptrEvent;
  308. }
  309. CXTPCalendarRecurrencePatternPtr CXTPCalendarData::CreateNewRecurrencePattern(DWORD dwPatternID)
  310. {
  311. CXTPCalendarRecurrencePatternPtr ptrPattern = new CXTPCalendarRecurrencePattern(this);
  312. if (ptrPattern)
  313. {
  314. DWORD dwTempID = dwPatternID != XTP_CALENDAR_UNKNOWN_RECURRENCE_PATTERN_ID? dwPatternID : GetNextFreeTempID();
  315. ptrPattern->SetPatternID(dwTempID);
  316. }
  317. return ptrPattern;
  318. }
  319. CString CXTPCalendarData::GetDataSource()
  320. {
  321. return CXTPCalendarControl::DataSourceFromConStr(m_strConnectionString);
  322. }
  323. CXTPCalendarEventsPtr CXTPCalendarData::RetrieveDayEvents(COleDateTime dtDay)
  324. {
  325. if (!IsOpen())
  326. {
  327. DBG_DATA_ASSERT(FALSE);
  328. return NULL;
  329. }
  330. dtDay = CXTPCalendarUtils::ResetTime(dtDay);
  331. CXTPCalendarEventsPtr ptrResult = NULL;
  332. if ((m_cache.m_eCacheMode & xtpCalendarDPCacheModeOnMask) &&
  333. m_cache.IsDayInCache(dtDay))
  334. {
  335. ASSERT(m_cache.m_pCacheDP);
  336. ptrResult = m_cache.m_pCacheDP->RetrieveDayEvents(dtDay);
  337. }
  338. else
  339. {
  340. ptrResult = DoRetrieveDayEvents(dtDay);
  341. if (!ptrResult)
  342. {
  343. return NULL;
  344. }
  345. _PostProcessRecurrenceIfNeed(ptrResult);
  346. if (m_cache.m_eCacheMode & xtpCalendarDPCacheModeOnMask)
  347. {
  348. ASSERT(m_cache.m_pCacheDP);
  349. m_cache.AddToCache(ptrResult, dtDay);
  350. }
  351. _PostProcessOccurrencesFromMaster(dtDay, ptrResult);
  352. _FilterDayEventsInstancesByEndTime(dtDay, ptrResult);
  353. }
  354. return ptrResult;
  355. }
  356. BOOL CXTPCalendarData::AddEvents(CXTPCalendarEvents* pEvents)
  357. {
  358. BOOL bResult = TRUE;
  359. int nEventsCount = pEvents->GetCount();
  360. for (int i = 0; i < nEventsCount; i++)
  361. {
  362. CXTPCalendarEvent* pEvent = pEvents->GetAt(i, FALSE);
  363. if (!AddEvent(pEvent))
  364. {
  365. bResult = FALSE;
  366. }
  367. }
  368. return bResult;
  369. }
  370. BOOL CXTPCalendarData::AddEvent(CXTPCalendarEvent* pEvent)
  371. {
  372. if (!IsOpen())
  373. {
  374. return FALSE;
  375. }
  376. if (!pEvent)
  377. {
  378. ASSERT(FALSE);
  379. return FALSE;
  380. }
  381. pEvent->ClearIntermediateData();
  382. COleDateTime dtNow = CXTPCalendarUtils::GetCurrentTime();
  383. pEvent->SetLastModificationTime(dtNow);
  384. DWORD dwNewEventID = pEvent->GetEventID();
  385. if (!DoCreate_Event(pEvent, dwNewEventID))
  386. {
  387. DBG_DATA_ASSERT(FALSE);
  388. return FALSE;
  389. }
  390. ASSERT(dwNewEventID != XTP_CALENDAR_UNKNOWN_EVENT_ID);
  391. pEvent->SetEventID(dwNewEventID);
  392. int nRState = (long)pEvent->GetRecurrenceState();
  393. BOOL bSendPatternAddedEvent = FALSE;
  394. DWORD dwPatternID = XTP_CALENDAR_UNKNOWN_RECURRENCE_PATTERN_ID;
  395. //- Process Recurrence Pattern for Master event -------------------------
  396. if (nRState == xtpCalendarRecurrenceMaster)
  397. {
  398. CXTPCalendarRecurrencePattern* pPatternRef = pEvent->GetRPatternRef();
  399. if (!pPatternRef)
  400. {
  401. ASSERT(FALSE);
  402. return FALSE;
  403. }
  404. pPatternRef->SetMasterEventID(dwNewEventID);
  405. //pPatternRef->ResetReminderForOccFromThePast(pEvent);
  406. VERIFY( pPatternRef->GetOccReminders()->Save(pPatternRef->GetCustomProperties(), pPatternRef) );
  407. BOOL bRes = DoCreate_RPattern(pPatternRef, dwPatternID);
  408. DBG_DATA_ASSERT(bRes);
  409. pPatternRef->GetOccReminders()->ClearProperties(pPatternRef->GetCustomProperties());
  410. if (!bRes)
  411. {
  412. return FALSE;
  413. }
  414. ASSERT(dwPatternID != XTP_CALENDAR_UNKNOWN_RECURRENCE_PATTERN_ID);
  415. DWORD dwPatternID_prev = pEvent->GetRecurrencePatternID();
  416. pEvent->SetRecurrencePatternID(dwPatternID);
  417. if (dwPatternID_prev != dwPatternID)
  418. {
  419. bRes = DoUpdate_Event(pEvent);
  420. DBG_DATA_ASSERT(bRes);
  421. if (!bRes)
  422. {
  423. return FALSE;
  424. }
  425. }
  426. bSendPatternAddedEvent = TRUE;
  427. }
  428. //---------------------------------------------------------------------------
  429. if (m_cache.m_eCacheMode == xtpCalendarDPCacheModeOnRepeat)
  430. {
  431. ASSERT(m_cache.m_pCacheDP);
  432. if (m_cache.m_pCacheDP) VERIFY( m_cache.m_pCacheDP->AddEvent(pEvent) );
  433. }
  434. else if (m_cache.m_eCacheMode == xtpCalendarDPCacheModeOnClear)
  435. {
  436. ASSERT(m_cache.m_pCacheDP);
  437. //m_cache.m_pCacheDP->RemoveAllEvents();
  438. m_cache.SafeRemoveAll();
  439. }
  440. //---------------------------------------------------------------------------
  441. SendNotification(XTP_NC_CALENDAREVENTWASADDED, (WPARAM)pEvent->GetEventID(), (LPARAM)pEvent);
  442. if (bSendPatternAddedEvent)
  443. {
  444. SendNotification(XTP_NC_CALENDARPATTERNWASADDED, dwPatternID, 0);
  445. }
  446. return TRUE;
  447. }
  448. BOOL CXTPCalendarData::ChangeEvent(CXTPCalendarEvent* pEvent)
  449. {
  450. if (!IsOpen())
  451. {
  452. return FALSE;
  453. }
  454. if (!pEvent)
  455. {
  456. ASSERT(FALSE);
  457. return FALSE;
  458. }
  459. pEvent->ClearIntermediateData();
  460. COleDateTime dtNow = CXTPCalendarUtils::GetCurrentTime();
  461. pEvent->SetLastModificationTime(dtNow);
  462. DWORD dwEventID = pEvent->GetEventID();
  463. ASSERT(dwEventID != XTP_CALENDAR_UNKNOWN_EVENT_ID);
  464. //- new recurrence state ---------------------------
  465. CXTPCalendarRecurrencePatternPtr ptrPattern_new;
  466. int nRState_new = pEvent->GetRecurrenceState();
  467. // - Add/Update/Remove Recurrence Exception --------------------
  468. if (nRState_new == xtpCalendarRecurrenceException ||
  469. nRState_new == xtpCalendarRecurrenceOccurrence)
  470. {
  471. return _ChangeRExceptionOccurrence_nf(pEvent, FALSE);
  472. }
  473. //===========================================================================
  474. //CXTPCalendarEventPtr ptrEventPrev = _GetEvent_UseCache(dwEventID);
  475. CXTPCalendarEventPtr ptrEventPrev = GetEvent(dwEventID);
  476. if (!ptrEventPrev)
  477. {
  478. ASSERT(FALSE);
  479. return FALSE;
  480. }
  481. //************************************************************
  482. CXTPCalendarRecurrencePatternPtr ptrPattern_prev;
  483. BOOL bSendPatternAddedEvent = FALSE;
  484. BOOL bSendPatternChangedEvent = FALSE;
  485. BOOL bSendPatternDeletedEvent = FALSE;
  486. DWORD dwPatternID = XTP_CALENDAR_UNKNOWN_RECURRENCE_PATTERN_ID;
  487. //- previous recurrence state ---------------------
  488. int nRState_prev = ptrEventPrev->GetRecurrenceState();
  489. //=== Update Event Recurrence Properties. IF NEED.
  490. //
  491. // 1.Event become recurrence
  492. if (nRState_prev == xtpCalendarRecurrenceNotRecurring &&
  493. nRState_new == xtpCalendarRecurrenceMaster)
  494. {
  495. ptrPattern_new.SetPtr(pEvent->GetRPatternRef(), TRUE);
  496. //      ptrPattern_new->ResetReminderForOccFromThePast(pEvent);
  497. if (!_AddRPatternWithExceptions(ptrPattern_new))
  498. {
  499. ASSERT(FALSE);
  500. return FALSE;
  501. }
  502. dwPatternID = ptrPattern_new->GetPatternID();
  503. ASSERT(dwPatternID != XTP_CALENDAR_UNKNOWN_RECURRENCE_PATTERN_ID);
  504. pEvent->SetRecurrencePatternID(dwPatternID);
  505. bSendPatternAddedEvent = TRUE;
  506. }
  507. // 2.Event become Not Recurrence
  508. else if (nRState_prev == xtpCalendarRecurrenceMaster &&
  509. nRState_new == xtpCalendarRecurrenceNotRecurring)
  510. {
  511. ptrPattern_prev.SetPtr(ptrEventPrev->GetRPatternRef(), TRUE);
  512. dwPatternID = ptrPattern_prev->GetPatternID();
  513. bSendPatternDeletedEvent = TRUE;
  514. if (!_RemoveRPatternWithExceptions(ptrPattern_prev))
  515. {
  516. ASSERT(FALSE);
  517. return FALSE;
  518. }
  519. }
  520. // 3. Update Recurrence Event
  521. else if (nRState_prev == xtpCalendarRecurrenceMaster &&
  522. nRState_new == xtpCalendarRecurrenceMaster)
  523. {
  524. ptrPattern_new.SetPtr(pEvent->GetRPatternRef(), TRUE);
  525. //ptrPattern_new->ResetReminderForOccFromThePast(pEvent);
  526. if (!_ChangeRPatternWithExceptions(ptrPattern_new))
  527. {
  528. DBG_DATA_ASSERT(FALSE);
  529. return FALSE;
  530. }
  531. dwPatternID = ptrPattern_new->GetPatternID();
  532. bSendPatternChangedEvent = TRUE;
  533. }
  534. // Update Event properties
  535. BOOL bRes = DoUpdate_Event(pEvent);
  536. DBG_DATA_ASSERT(bRes);
  537. if (!bRes)
  538. {
  539. return FALSE;
  540. }
  541. //---------------------------------------------------------------------------
  542. if (m_cache.m_eCacheMode == xtpCalendarDPCacheModeOnRepeat)
  543. {
  544. ASSERT(m_cache.m_pCacheDP);
  545. if (m_cache.IsEventInCache(pEvent))
  546. {
  547. if (m_cache.m_pCacheDP) VERIFY( m_cache.m_pCacheDP->ChangeEvent(pEvent) );
  548. }
  549. }
  550. else if (m_cache.m_eCacheMode == xtpCalendarDPCacheModeOnClear)
  551. {
  552. ASSERT(m_cache.m_pCacheDP);
  553. //m_cache.m_pCacheDP->RemoveAllEvents();
  554. m_cache.SafeRemoveAll();
  555. }
  556. //---------------------------------------------------------------------------
  557. SendNotification(XTP_NC_CALENDAREVENTWASCHANGED, (WPARAM)pEvent->GetEventID(), (LPARAM)pEvent);
  558. if (bSendPatternAddedEvent)
  559. {
  560. SendNotification(XTP_NC_CALENDARPATTERNWASADDED, dwPatternID, 0);
  561. }
  562. else if (bSendPatternChangedEvent)
  563. {
  564. SendNotification(XTP_NC_CALENDARPATTERNWASCHANGED, dwPatternID, 0);
  565. }
  566. else if (bSendPatternDeletedEvent)
  567. {
  568. SendNotification(XTP_NC_CALENDARPATTERNWASDELETED, dwPatternID, 0);
  569. }
  570. return TRUE;
  571. }
  572. BOOL CXTPCalendarData::DeleteEvent(CXTPCalendarEvent* pEvent)
  573. {
  574. if (!IsOpen())
  575. {
  576. return FALSE;
  577. }
  578. if (!pEvent)
  579. {
  580. ASSERT(FALSE);
  581. return FALSE;
  582. }
  583. DWORD dwEventID = pEvent->GetEventID();
  584. ASSERT(dwEventID != XTP_CALENDAR_UNKNOWN_EVENT_ID);
  585. BOOL bRes = TRUE;
  586. BOOL bSendPatternDeletedEvent = FALSE;
  587. DWORD dwPatternID = XTP_CALENDAR_UNKNOWN_RECURRENCE_PATTERN_ID;
  588. //- recurrence state ---------------------
  589. int nRState = pEvent->GetRecurrenceState();
  590. //1. remove occurrence (set deleted property to exception)
  591. if (nRState == xtpCalendarRecurrenceOccurrence || nRState == xtpCalendarRecurrenceException)
  592. {
  593. CXTPCalendarEventPtr ptrException = pEvent->CloneEvent();
  594. if (!ptrException)
  595. {
  596. return FALSE;
  597. }
  598. if (nRState == xtpCalendarRecurrenceOccurrence)
  599. {
  600. // make exception from Occurrence
  601. ptrException->MakeAsRException();
  602. }
  603. ptrException->SetRExceptionDeleted(TRUE);
  604. return _ChangeRExceptionOccurrence_nf(ptrException, TRUE);
  605. }
  606. else
  607. {
  608. if (!DoDelete_Event(pEvent))
  609. {
  610. bRes = FALSE;
  611. }
  612. //-----------------------------------------------------------------
  613. if (nRState == xtpCalendarRecurrenceMaster)
  614. {
  615. dwPatternID = pEvent->GetRecurrencePatternID();
  616. CXTPCalendarRecurrencePattern* pPattern = pEvent->GetRPatternRef();
  617. if (!_RemoveRPatternWithExceptions(pPattern))
  618. {
  619. bRes = FALSE;
  620. }
  621. bSendPatternDeletedEvent = bRes;
  622. }
  623. }
  624. //---------------------------------------------------------------------------
  625. if (m_cache.m_eCacheMode == xtpCalendarDPCacheModeOnRepeat)
  626. {
  627. ASSERT(m_cache.m_pCacheDP);
  628. if (m_cache.IsEventInCache(pEvent))
  629. {
  630. if (m_cache.m_pCacheDP) VERIFY( m_cache.m_pCacheDP->DeleteEvent(pEvent) );
  631. }
  632. }
  633. else if (m_cache.m_eCacheMode == xtpCalendarDPCacheModeOnClear)
  634. {
  635. ASSERT(m_cache.m_pCacheDP);
  636. //m_cache.m_pCacheDP->RemoveAllEvents();
  637. m_cache.SafeRemoveAll();
  638. }
  639. //---------------------------------------------------------------------------
  640. if (bRes)
  641. {
  642. SendNotification(XTP_NC_CALENDAREVENTWASDELETED, (WPARAM)pEvent->GetEventID(), (LPARAM)pEvent);
  643. }
  644. if (bSendPatternDeletedEvent)
  645. {
  646. SendNotification(XTP_NC_CALENDARPATTERNWASDELETED, dwPatternID, 0);
  647. }
  648. return bRes;
  649. }
  650. CXTPCalendarEventPtr CXTPCalendarData::GetEvent(DWORD dwEventID)
  651. {
  652. if (!IsOpen())
  653. {
  654. return NULL;
  655. }
  656. CXTPCalendarEventPtr ptrEvent;
  657. if ((m_cache.m_eCacheMode & xtpCalendarDPCacheModeOnMask))
  658. {
  659. ASSERT(m_cache.m_pCacheDP);
  660. if (m_cache.m_pCacheDP) ptrEvent = m_cache.m_pCacheDP->GetEvent(dwEventID);
  661. }
  662. if (!ptrEvent)
  663. {
  664. ptrEvent = _GetEvent_raw(dwEventID);
  665. if (!ptrEvent)
  666. return NULL;
  667. if (ptrEvent->GetRecurrenceState() != xtpCalendarRecurrenceNotRecurring &&
  668. ptrEvent->GetRecurrenceState() != xtpCalendarRecurrenceMaster)
  669. {
  670. return NULL;
  671. }
  672. if (m_cache.m_eCacheMode & xtpCalendarDPCacheModeOnMask)
  673. {
  674. ASSERT(m_cache.m_pCacheDP);
  675. m_cache.AddToCacheIfNeed(ptrEvent);
  676. }
  677. }
  678. return ptrEvent;
  679. }
  680. BOOL CXTPCalendarData::_PostProcessRecurrenceIfNeed(CXTPCalendarEvent* pEvent)
  681. {
  682. COleVariant varRState;
  683. COleVariant varRPatternID;
  684. BOOL bRState_prop = pEvent->GetCustomProperties()->GetProperty(cszProcess_RecurrenceState, varRState);
  685. BOOL bRPatternID_prop = pEvent->GetCustomProperties()->GetProperty(cszProcess_RecurrencePatternID, varRPatternID);
  686. pEvent->GetCustomProperties()->RemoveProperty(cszProcess_RecurrenceState);
  687. pEvent->GetCustomProperties()->RemoveProperty(cszProcess_RecurrencePatternID);
  688. if (!bRState_prop)
  689. {
  690. return FALSE;
  691. }
  692. int nRState = VAR2long(varRState);
  693. if (xtpCalendarRecurrenceMaster == nRState)
  694. {
  695. if (!bRPatternID_prop)
  696. {
  697. ASSERT(FALSE);
  698. return FALSE;
  699. }
  700. DWORD dwRPatternID = (DWORD)VAR2long(varRPatternID);
  701. CXTPCalendarRecurrencePatternPtr ptrPattern = _GetRecurrencePattern_raw(dwRPatternID);
  702. if (!ptrPattern)
  703. {
  704. ASSERT(FALSE);
  705. return FALSE;
  706. }
  707. VERIFY( pEvent->MakeEventAsRecurrence() );
  708. pEvent->SetRecurrencePatternID(dwRPatternID);
  709. VERIFY( pEvent->UpdateRecurrence(ptrPattern) );
  710. return TRUE;
  711. }
  712. else if (xtpCalendarRecurrenceException == nRState)
  713. {
  714. DWORD dwRPatternID = bRPatternID_prop ? (DWORD)VAR2long(varRPatternID) : 0;
  715. pEvent->SetRecurrencePatternID(dwRPatternID);
  716. if (pEvent->GetRecurrenceState() != xtpCalendarRecurrenceException)
  717. {
  718. pEvent->MakeAsRException(dwRPatternID);
  719. }
  720. }
  721. return FALSE;
  722. }
  723. void CXTPCalendarData::_PostProcessRecurrenceIfNeed(CXTPCalendarEvents* pEvents)
  724. {
  725. int nCount = pEvents ? pEvents->GetCount() : 0;
  726. for (int i = 0; i < nCount; i++)
  727. {
  728. CXTPCalendarEvent* pEvent = pEvents->GetAt(i, FALSE);
  729. ASSERT(pEvent);
  730. if (pEvent)
  731. {
  732. _PostProcessRecurrenceIfNeed(pEvent);
  733. }
  734. }
  735. }
  736. CXTPCalendarEventPtr CXTPCalendarData::_GetEvent_raw(DWORD dwEventID)
  737. {
  738. if (!IsOpen())
  739. {
  740. return NULL;
  741. }
  742. CXTPCalendarEventPtr ptrEvent = DoRead_Event(dwEventID);
  743. if (!ptrEvent)
  744. {
  745. return NULL;
  746. }
  747. _PostProcessRecurrenceIfNeed(ptrEvent);
  748. return ptrEvent;
  749. }
  750. CXTPCalendarRecurrencePatternPtr CXTPCalendarData::_GetRecurrencePattern_raw(DWORD dwPatternID)
  751. {
  752. CXTPCalendarRecurrencePatternPtr ptrPattern = DoRead_RPattern(dwPatternID);
  753. if (ptrPattern)
  754. {
  755. VERIFY( ptrPattern->GetOccReminders()->Load(ptrPattern->GetCustomProperties()) );
  756. ptrPattern->GetOccReminders()->ClearProperties(ptrPattern->GetCustomProperties());
  757. }
  758. return ptrPattern;
  759. }
  760. CXTPCalendarRecurrencePatternPtr CXTPCalendarData::GetRecurrencePattern(DWORD dwPatternID)
  761. {
  762. if (!IsOpen())
  763. {
  764. return NULL;
  765. }
  766. CXTPCalendarRecurrencePatternPtr ptrPattern;
  767. if ((m_cache.m_eCacheMode & xtpCalendarDPCacheModeOnMask))
  768. {
  769. ASSERT(m_cache.m_pCacheDP);
  770. if (m_cache.m_pCacheDP) ptrPattern = m_cache.m_pCacheDP->GetRecurrencePattern(dwPatternID);
  771. }
  772. if (!ptrPattern)
  773. {
  774. ptrPattern = _GetRecurrencePattern_raw(dwPatternID);
  775. if (ptrPattern && (m_cache.m_eCacheMode & xtpCalendarDPCacheModeOnMask))
  776. {
  777. m_cache._AddToCacheIfNeed(ptrPattern);
  778. }
  779. }
  780. return ptrPattern;
  781. }
  782. BOOL CXTPCalendarData::_AddRPatternWithExceptions(CXTPCalendarRecurrencePattern* pPattern)
  783. {
  784. if (!IsOpen())
  785. {
  786. return FALSE;
  787. }
  788. if (!pPattern)
  789. {
  790. ASSERT(FALSE);
  791. return FALSE;
  792. }
  793. VERIFY( pPattern->GetOccReminders()->Save(pPattern->GetCustomProperties(), pPattern) );
  794. DWORD dwNewPatternID = XTP_CALENDAR_UNKNOWN_RECURRENCE_PATTERN_ID;
  795. BOOL bRes = DoCreate_RPattern(pPattern, dwNewPatternID);
  796. DBG_DATA_ASSERT(bRes);
  797. pPattern->GetOccReminders()->ClearProperties(pPattern->GetCustomProperties());
  798. if (!bRes)
  799. {
  800. return FALSE;
  801. }
  802. ASSERT(dwNewPatternID != XTP_CALENDAR_UNKNOWN_RECURRENCE_PATTERN_ID);
  803. pPattern->SetPatternID(dwNewPatternID);
  804. BOOL bResult = TRUE;
  805. //-- Process exceptions ---------------------------------------------------
  806. CXTPCalendarEventsPtr prtExceptions = pPattern->GetExceptions();
  807. pPattern->RemoveAllExceptions();
  808. int nCount = prtExceptions ? prtExceptions->GetCount() : 0;
  809. for (int i = 0; i < nCount; i++)
  810. {
  811. CXTPCalendarEvent* pExc = prtExceptions->GetAt(i);
  812. ASSERT(pExc);
  813. if (!pExc)
  814. continue;
  815. DWORD dwNewEventID = XTP_CALENDAR_UNKNOWN_EVENT_ID;
  816. if (!DoCreate_Event(pExc, dwNewEventID))
  817. {
  818. bResult = FALSE;
  819. continue;
  820. }
  821. ASSERT(dwNewEventID != XTP_CALENDAR_UNKNOWN_EVENT_ID);
  822. pExc->SetEventID(dwNewEventID);
  823. pPattern->SetException(pExc);
  824. }
  825. //-------------------------------------------
  826. return bResult;
  827. }
  828. BOOL CXTPCalendarData::_RemoveRPatternWithExceptions(CXTPCalendarRecurrencePattern* pPattern)
  829. {
  830. if (!IsOpen())
  831. {
  832. return FALSE;
  833. }
  834. if (!pPattern)
  835. {
  836. ASSERT(FALSE);
  837. return FALSE;
  838. }
  839. BOOL bResult = TRUE;
  840. //-- Process exceptions ---------------------------------------------------
  841. CXTPCalendarEventsPtr prtExceptions = pPattern->GetExceptions();
  842. int nCount = prtExceptions ? prtExceptions->GetCount() : 0;
  843. for (int i = 0; i < nCount; i++)
  844. {
  845. CXTPCalendarEvent *pExc = prtExceptions->GetAt(i);
  846. ASSERT(pExc);
  847. if (!DoDelete_Event(pExc))
  848. {
  849. bResult = FALSE;
  850. }
  851. }
  852. //-------------------------------------------
  853. if (!DoDelete_RPattern(pPattern))
  854. {
  855. return FALSE;
  856. }
  857. //-------------------------------------------
  858. return bResult;
  859. }
  860. BOOL CXTPCalendarData::_ChangeRPatternWithExceptions(CXTPCalendarRecurrencePattern* pPattern)
  861. {
  862. if (!IsOpen())
  863. {
  864. return FALSE;
  865. }
  866. if (!pPattern)
  867. {
  868. ASSERT(FALSE);
  869. return FALSE;
  870. }
  871. DWORD dwPatternID = pPattern->GetPatternID();
  872. //CXTPCalendarRecurrencePatternPtr ptrPatternPrev = _GetRecurrencePattern_UseCache(dwPatternID);
  873. CXTPCalendarRecurrencePatternPtr ptrPatternPrev = GetRecurrencePattern(dwPatternID);
  874. if (!ptrPatternPrev)
  875. {
  876. ASSERT(FALSE);
  877. return FALSE;
  878. }
  879. //-------------------------------------
  880. VERIFY( pPattern->GetOccReminders()->Save(pPattern->GetCustomProperties(), pPattern) );
  881. BOOL bRes = DoUpdate_RPattern(pPattern);
  882. pPattern->GetOccReminders()->ClearProperties(pPattern->GetCustomProperties());
  883. if (!bRes)
  884. {
  885. return FALSE;
  886. }
  887. //-------------------------------------
  888. BOOL bResult = TRUE;
  889. //-- Process exceptions ---------------------------------------------------
  890. CXTPCalendarEventsPtr prtExceptions_prev = ptrPatternPrev->GetExceptions();
  891. CXTPCalendarEventsPtr prtExceptions_new = pPattern->GetExceptions();
  892. //-- find deleted exceptions and remove them from DB
  893. int nCount = (prtExceptions_prev && prtExceptions_new) ? prtExceptions_prev->GetCount() : 0;
  894. int i;
  895. for (i = 0; i < nCount; i++)
  896. {
  897. CXTPCalendarEvent* pExc = prtExceptions_prev->GetAt(i);
  898. DWORD dwExcID = pExc ? pExc->GetEventID() : XTP_CALENDAR_UNKNOWN_EVENT_ID;
  899. int nFIndex = prtExceptions_new->Find(dwExcID);
  900. if (nFIndex < 0)
  901. {
  902. if (!DoDelete_Event(pExc))
  903. {
  904. bResult = FALSE;
  905. }
  906. }
  907. }
  908. //-- update existing or add new exceptions (int DB)
  909. nCount = (prtExceptions_prev && prtExceptions_new) ? prtExceptions_new->GetCount() : 0;
  910. for (i = 0; i < nCount; i++)
  911. {
  912. CXTPCalendarEvent* pExc = prtExceptions_new->GetAt(i);
  913. if (!pExc)
  914. {
  915. ASSERT(FALSE);
  916. continue;
  917. }
  918. DWORD dwExcID = pExc->GetEventID();
  919. int nFIndex = prtExceptions_prev->Find(dwExcID);
  920. if (nFIndex < 0)
  921. {
  922. // Add new exception
  923. DWORD dwNewEventID = XTP_CALENDAR_UNKNOWN_EVENT_ID;
  924. if (!DoCreate_Event(pExc, dwNewEventID))
  925. {
  926. bResult = FALSE;
  927. continue;
  928. }
  929. ASSERT(dwNewEventID != XTP_CALENDAR_UNKNOWN_EVENT_ID);
  930. pExc->SetEventID(dwNewEventID);
  931. VERIFY( pPattern->RemoveException(pExc) );
  932. if (!pPattern->SetException(pExc))
  933. {
  934. bResult = FALSE;
  935. }
  936. }
  937. else
  938. {
  939. // Update existing exception
  940. if (!DoUpdate_Event(pExc))
  941. {
  942. bResult = FALSE;
  943. }
  944. }
  945. }
  946. return bResult;
  947. }
  948. BOOL CXTPCalendarData::_ChangeRExceptionOccurrence_nf(CXTPCalendarEvent* pExcOcc,
  949.  BOOL bSend_EventDeleted)
  950. {
  951. if (!pExcOcc)
  952. {
  953. ASSERT(FALSE);
  954. return FALSE;
  955. }
  956. pExcOcc->ClearIntermediateData();
  957. DWORD dwEventID = pExcOcc->GetEventID();
  958. ASSERT(dwEventID != XTP_CALENDAR_UNKNOWN_EVENT_ID);
  959. //- new recurrence state ---------------------------
  960. CXTPCalendarRecurrencePatternPtr ptrPattern;
  961. int nRState_new = pExcOcc->GetRecurrenceState();
  962. // - Add/Update/Remove Recurrence Exception --------------------
  963. if (nRState_new != xtpCalendarRecurrenceException &&
  964. nRState_new != xtpCalendarRecurrenceOccurrence)
  965. {
  966. ASSERT(FALSE);
  967. return FALSE;
  968. }
  969. DWORD dwPatternID_new = pExcOcc->GetRecurrencePatternID();
  970. //ptrPattern = _GetRecurrencePattern_UseCache(dwPatternID_new);
  971. ptrPattern = GetRecurrencePattern(dwPatternID_new);
  972. if (!ptrPattern)
  973. {
  974. ASSERT(FALSE);
  975. return FALSE;
  976. }
  977. DWORD dwMasterEventID = ptrPattern->GetMasterEventID();
  978. //CXTPCalendarEventPtr ptrMasterEvent = _GetEvent_UseCache(dwMasterEventID);
  979. CXTPCalendarEventPtr ptrMasterEvent = GetEvent(dwMasterEventID);
  980. if (!ptrMasterEvent)
  981. {
  982. ASSERT(FALSE);
  983. return FALSE;
  984. }
  985. ptrPattern.SetPtr(ptrMasterEvent->GetRPatternRef(), TRUE);
  986. if (!ptrPattern)
  987. {
  988. ASSERT(FALSE);
  989. return FALSE;
  990. }
  991. BOOL bSendPatternChangedEvent = FALSE;
  992. BOOL bRes = FALSE;
  993. if (nRState_new == xtpCalendarRecurrenceException)
  994. {
  995. bRes = ptrPattern->SetException(pExcOcc, ptrMasterEvent);
  996. }
  997. else if (nRState_new == xtpCalendarRecurrenceOccurrence)
  998. {
  999. bRes = ptrPattern->RemoveException(pExcOcc, ptrMasterEvent);
  1000. }
  1001. else
  1002. {
  1003. ASSERT(FALSE);
  1004. }
  1005. if (bRes)
  1006. {
  1007. bRes = _ChangeRPatternWithExceptions(ptrPattern);
  1008. bSendPatternChangedEvent = bRes;
  1009. }
  1010. if (bRes)
  1011. {
  1012. bRes = DoUpdate_Event(ptrMasterEvent);
  1013. }
  1014. //---------------------------------------------------------------------------
  1015. if (m_cache.m_eCacheMode == xtpCalendarDPCacheModeOnRepeat)
  1016. {
  1017. ASSERT(m_cache.m_pCacheDP);
  1018. if (m_cache.IsEventInCache(ptrMasterEvent))
  1019. {
  1020. if (m_cache.m_pCacheDP) VERIFY( m_cache.m_pCacheDP->ChangeEvent(ptrMasterEvent) );
  1021. }
  1022. }
  1023. else if (m_cache.m_eCacheMode == xtpCalendarDPCacheModeOnClear)
  1024. {
  1025. ASSERT(m_cache.m_pCacheDP);
  1026. //m_cache.m_pCacheDP->RemoveAllEvents();
  1027. m_cache.SafeRemoveAll();
  1028. }
  1029. //---------------------------------------------------------------------------
  1030. if (bRes)
  1031. {
  1032. XTP_NOTIFY_CODE nfCode = bSend_EventDeleted ?
  1033. XTP_NC_CALENDAREVENTWASDELETED : XTP_NC_CALENDAREVENTWASCHANGED;
  1034. SendNotification(nfCode, (WPARAM)pExcOcc->GetEventID(), (LPARAM)pExcOcc);
  1035. }
  1036. if (bSendPatternChangedEvent)
  1037. {
  1038. SendNotification(XTP_NC_CALENDARPATTERNWASCHANGED, ptrPattern->GetPatternID(), 0);
  1039. }
  1040. return bRes;
  1041. }
  1042. void CXTPCalendarData::_PostProcessOccurrencesFromMaster(COleDateTime dtDay, CXTPCalendarEvents* pEvents)
  1043. {
  1044. _PostProcessOccurrencesFromMaster2(dtDay, dtDay, pEvents);
  1045. }
  1046. void CXTPCalendarData::_PostProcessOccurrencesFromMaster2(COleDateTime dtDayFrom, COleDateTime dtDayTo, CXTPCalendarEvents* pEvents)
  1047. {
  1048. if (!pEvents)
  1049. {
  1050. return;
  1051. }
  1052. int nCount = pEvents->GetCount();
  1053. for (int i = nCount-1; i >= 0; i--)
  1054. {
  1055. CXTPCalendarEventPtr ptrEvent = pEvents->GetAt(i, TRUE);
  1056. if (!ptrEvent)
  1057. {
  1058. ASSERT(FALSE);
  1059. continue;
  1060. }
  1061. int nRState = ptrEvent->GetRecurrenceState();
  1062. if (xtpCalendarRecurrenceMaster == nRState)
  1063. {
  1064. pEvents->RemoveAt(i);
  1065. CXTPCalendarRecurrencePattern* pPattern = ptrEvent->GetRPatternRef();
  1066. if (!pPattern)
  1067. {
  1068. ASSERT(FALSE);
  1069. continue;
  1070. }
  1071. VERIFY(pPattern->GetOccurrences(pEvents, dtDayFrom, dtDayTo, ptrEvent));
  1072. }
  1073. }
  1074. }
  1075. void CXTPCalendarData::_FilterDayEventsInstancesByEndTime(COleDateTime dtDay,
  1076. CXTPCalendarEvents* pEvents)
  1077. {
  1078. ASSERT(pEvents);
  1079. if (!pEvents)
  1080. {
  1081. return;
  1082. }
  1083. dtDay = CXTPCalendarUtils::ResetTime(dtDay);
  1084. // filter events;
  1085. int nCount = pEvents->GetCount();
  1086. for (int i = nCount-1; i >= 0; i--)
  1087. {
  1088. CXTPCalendarEvent* pEvent = pEvents->GetAt(i);
  1089. if (!pEvent)
  1090. {
  1091. ASSERT(FALSE);
  1092. continue;
  1093. }
  1094. if (pEvent->GetRecurrenceState() == xtpCalendarRecurrenceMaster)
  1095. {
  1096. continue;
  1097. }
  1098. if (CXTPCalendarUtils::ResetTime(pEvent->GetStartTime()) < dtDay &&
  1099. CXTPCalendarUtils::IsEqual(pEvent->GetEndTime(), dtDay) )
  1100. {
  1101. pEvents->RemoveAt(i);
  1102. }
  1103. }
  1104. }
  1105. void CXTPCalendarData::SendNotification(XTP_NOTIFY_CODE EventCode, WPARAM wParam , LPARAM lParam)
  1106. {
  1107. if (m_pConnect && !m_bDisableNotificationsSending)
  1108. {
  1109. m_pConnect->SendEvent(EventCode, wParam, lParam);
  1110. }
  1111. }
  1112. CXTPCalendarEventsPtr CXTPCalendarData::GetUpcomingEvents(COleDateTime dtFrom, COleDateTimeSpan spPeriod)
  1113. {
  1114. CXTPCalendarEventsPtr ptrEvents = DoGetUpcomingEvents(dtFrom, spPeriod);
  1115. _PostProcessRecurrenceIfNeed(ptrEvents);
  1116. return ptrEvents;
  1117. }
  1118. CXTPCalendarEventsPtr CXTPCalendarData::GetAllEvents_raw()
  1119. {
  1120. CXTPCalendarEventsPtr ptrEvents = DoGetAllEvents_raw();
  1121. _PostProcessRecurrenceIfNeed(ptrEvents);
  1122. return ptrEvents;
  1123. }
  1124. void CXTPCalendarData::SetOptionsToUpdate(CXTPCalendarOptions* pOptions)
  1125. {
  1126. CMDTARGET_ADDREF(pOptions);
  1127. CMDTARGET_RELEASE(m_pCalendarOptions);
  1128. m_pCalendarOptions = pOptions;
  1129. }
  1130. CXTPCalendarEventsPtr CXTPCalendarData::DoGetAllEvents_raw()
  1131. {
  1132. return NULL;
  1133. }
  1134. CXTPCalendarEventsPtr CXTPCalendarData::DoGetUpcomingEvents(
  1135. COleDateTime dtFrom, COleDateTimeSpan spPeriod)
  1136. {
  1137. UNREFERENCED_PARAMETER(dtFrom); UNREFERENCED_PARAMETER(spPeriod);
  1138. //return DoRetrieveAllEvents_raw();
  1139. return NULL;
  1140. }
  1141. CXTPCalendarEventsPtr CXTPCalendarData::DoRetrieveDayEvents(COleDateTime dtDay)
  1142. {
  1143. UNREFERENCED_PARAMETER(dtDay);
  1144. return NULL;
  1145. }
  1146. void CXTPCalendarData::DoRemoveAllEvents()
  1147. {
  1148. }
  1149. CXTPCalendarEventPtr CXTPCalendarData::DoRead_Event(DWORD dwEventID)
  1150. {
  1151. UNREFERENCED_PARAMETER(dwEventID);
  1152. return NULL;
  1153. }
  1154. CXTPCalendarRecurrencePatternPtr CXTPCalendarData::DoRead_RPattern(DWORD dwPatternID)
  1155. {
  1156. UNREFERENCED_PARAMETER(dwPatternID);
  1157. return NULL;
  1158. }
  1159. BOOL CXTPCalendarData::DoCreate_Event(CXTPCalendarEvent* pEvent, DWORD& rdwNewEventID)
  1160. {
  1161. UNREFERENCED_PARAMETER(pEvent);
  1162. UNREFERENCED_PARAMETER(rdwNewEventID);
  1163. return TRUE;
  1164. }
  1165. BOOL CXTPCalendarData::DoUpdate_Event(CXTPCalendarEvent* pEvent)
  1166. {
  1167. UNREFERENCED_PARAMETER(pEvent);
  1168. return TRUE;
  1169. }
  1170. BOOL CXTPCalendarData::DoDelete_Event(CXTPCalendarEvent* pEvent)
  1171. {
  1172. UNREFERENCED_PARAMETER(pEvent);
  1173. return TRUE;
  1174. }
  1175. BOOL CXTPCalendarData::DoCreate_RPattern(CXTPCalendarRecurrencePattern* pPattern, DWORD& rdwNewPatternID)
  1176. {
  1177. UNREFERENCED_PARAMETER(pPattern);
  1178. UNREFERENCED_PARAMETER(rdwNewPatternID);
  1179. return TRUE;
  1180. }
  1181. BOOL CXTPCalendarData::DoUpdate_RPattern(CXTPCalendarRecurrencePattern* pPattern)
  1182. {
  1183. UNREFERENCED_PARAMETER(pPattern);
  1184. return TRUE;
  1185. }
  1186. BOOL CXTPCalendarData::DoDelete_RPattern(CXTPCalendarRecurrencePattern* pPattern)
  1187. {
  1188. UNREFERENCED_PARAMETER(pPattern);
  1189. return TRUE;
  1190. }