?? appointmentbuilder.cpp
字號:
dummyEvent = getElementContent(ptrData, TEXT ("End"), NULL);
isAllDayFormat = isDateForAllDayEventFormat(dummyEvent);
if (isAllDayFormat) {
systemTimeToDoubleBirthFormat(dummyEvent, &st, TEXT("END"));
} else { // the date is in the usual format
isUTC = FALSE;
isUTC = getDateAndTimeAsIs(dummyEvent, &st);
VariantTimeToSystemTime(st, &systemTime);
if (isUTC) {
UTCToLocalTime2(systemTime);
}
systemTime.wHour = 23;
systemTime.wMinute = 59;
systemTime.wMilliseconds = 0;
SystemTimeToVariantTime(&systemTime, &st);
}
pAppointment->put_End(st);
delete [] dummyEvent;dummyEvent=NULL;
isNotAllDayEvent = FALSE;
}
else {
pAppointment->put_AllDayEvent(VARIANT_FALSE);
}
delete [] dummyEvent;dummyEvent=NULL;
//VARIANT_BOOL -- ReminderSet
dummyEvent = getElementContent(ptrData, TEXT ("ReminderSet"), NULL);
if (dummyEvent != NULL &&
(wcscmp(dummyEvent, TEXT("1")) == 0 ||
wcscmp(dummyEvent, TEXT("-1")) == 0 || // kept to be compliant with old client. Now TRUE is represented
wcscmp(dummyEvent, TEXT("True")) == 0)) { // with "1" only
pAppointment->put_ReminderSet(VARIANT_TRUE);
}
else {
pAppointment->put_ReminderSet(VARIANT_FALSE);
}
delete [] dummyEvent;dummyEvent=NULL;
// BSTR
dummyEvent = getElementContent(ptrData, TEXT ("Subject"), NULL);
if (dummyEvent != NULL) {
dummyEvent_s = wstring(dummyEvent); decodeSpecialChar(dummyEvent_s);
pAppointment->put_Subject ((wchar_t*)dummyEvent_s.data());
delete [] dummyEvent;dummyEvent=NULL;
}
dummyEvent = getElementContent(ptrData, TEXT ("Location"), NULL);
if (dummyEvent != NULL) {
dummyEvent_s = wstring(dummyEvent); decodeSpecialChar(dummyEvent_s);
pAppointment->put_Location ((wchar_t*)dummyEvent_s.data());
delete [] dummyEvent;dummyEvent=NULL;
}
dummyEvent = getElementContent(ptrData, TEXT ("ReminderSoundFile"), NULL);
if (dummyEvent != NULL) {
dummyEvent_s = wstring(dummyEvent); decodeSpecialChar(dummyEvent_s);
pAppointment->put_ReminderSoundFile ((wchar_t*)dummyEvent_s.data());
delete [] dummyEvent;dummyEvent=NULL;
}
dummyEvent = getElementContent(ptrData, TEXT ("Categories"), NULL);
if (dummyEvent != NULL) {
dummyEvent_s = wstring(dummyEvent); decodeSpecialChar(dummyEvent_s);
pAppointment->put_Categories ((wchar_t*)dummyEvent_s.data());
delete [] dummyEvent;dummyEvent=NULL;
}
dummyEvent = getElementContent(ptrData, TEXT ("Body"), NULL);
if (dummyEvent != NULL) {
dummyEvent_s = wstring(dummyEvent); decodeSpecialChar(dummyEvent_s);
convertNewlines(dummyEvent_s); // BUG #1562
pAppointment->put_Body ((wchar_t*)dummyEvent_s.data());
delete [] dummyEvent;dummyEvent=NULL;
}
DATE start = 0;
// Read the start date
if (isNotAllDayEvent) {
//DATE
dummyEvent = getElementContent(ptrData, TEXT ("Start"), NULL);
if (dummyEvent && (wcscmp(dummyEvent, TEXT("")) != 0)) {
SYSTEMTIME systemTime;
//
// to handle properly the RecurrencePattern
//
BOOL isUTC = FALSE;
isUTC = getDateAndTimeAsIs(dummyEvent, &start);
VariantTimeToSystemTime(start, &systemTime);
x = systemTime.wHour;
if (isUTC) {
UTCToLocalTime2(systemTime);
}
y = systemTime.wHour;
systemTimeToDouble(dummyEvent, &start, NULL);
pAppointment->put_Start(start);
delete [] dummyEvent;
}
dummyEvent = getElementContent(ptrData, TEXT ("End"), NULL);
if (dummyEvent != NULL && (wcscmp(dummyEvent, TEXT("")) != 0)) {
DATE en;
systemTimeToDouble(dummyEvent, &en, NULL);
pAppointment->put_End(en);
delete [] dummyEvent;
}
}
else {
// TODO: which is the start for an ALLDAY????!!!!!!!!!
}
//long
//dummyEvent = getElementContent(ptrData, TEXT ("Duration"), NULL);
//if (dummyEvent != NULL) {
// pAppointment->put_Duration(wcstol(dummyEvent, &dummy, 0));
// delete [] dummyEvent;dummyEvent=NULL;
//}
dummyEvent = getElementContent(ptrData, TEXT ("BusyStatus"), NULL);
if (dummyEvent != NULL) {
pAppointment->put_BusyStatus(wcstol(dummyEvent, &dummy, 0));
delete [] dummyEvent;dummyEvent=NULL;
}
dummyEvent = getElementContent(ptrData, TEXT ("Sensitivity"), NULL);
if (dummyEvent != NULL) {
pAppointment->put_Sensitivity(wcstol(dummyEvent, &dummy, 0));
delete [] dummyEvent;dummyEvent=NULL;
}
dummyEvent = getElementContent(ptrData, TEXT ("ReminderOptions"), NULL);
if (dummyEvent != NULL) {
pAppointment->put_ReminderOptions (wcstol(dummyEvent, &dummy, 0));
delete [] dummyEvent;dummyEvent=NULL;
}
dummyEvent = getElementContent(ptrData, TEXT ("ReminderMinutesBeforeStart"), NULL);
if (dummyEvent != NULL) {
pAppointment->put_ReminderMinutesBeforeStart (wcstol(dummyEvent, &dummy, 0));
delete [] dummyEvent;dummyEvent=NULL;
}
/****************************************************/
//Recurrence
dummyEvent = getElementContent(ptrData, TEXT ("IsRecurring"), NULL);
if (dummyEvent != NULL &&
(wcscmp(dummyEvent, TEXT("1")) == 0 ||
wcscmp(dummyEvent, TEXT("-1")) == 0 || // kept to be compliant with old client. Now TRUE is represented
wcscmp(dummyEvent, TEXT("True")) == 0)) { // with "1" only
pAppointment->ClearRecurrencePattern ();
/*
* This save the appointment with no recurrence pattern and no exceptions too
* If there are some before it deletes the old one and replace with the new just came
*/
pAppointment->Save();
IRecurrencePattern *pRecurrence;
pAppointment->GetRecurrencePattern (&pRecurrence);
//
// Parse the recurrence tags
//
parseRecurrenceTags(pRecurrence, ptrData, start, x, y);
//
// ------------ EXCEPTIONS --------------------------
//
//
// Parse the exception tags
//
parseExceptionTags(pRecurrence, pAppointment, ptrData, polApp, path);
pRecurrence->Release();
}
}
BOOL isAllDayEvent(DATE startdate, DATE enddate) {
SYSTEMTIME ststart, stend;
VariantTimeToSystemTime(startdate, &ststart);
VariantTimeToSystemTime(enddate, &stend);
BOOL ret = FALSE;
if (ststart.wHour == 0 && ststart.wMinute == 0 &&
stend.wHour == 23 && stend.wMinute == 59)
ret = TRUE;
return ret;
}
/**
* The method change the property AllDayEvent to False if set to true.
* This because changing AllDayEvent changes OID too. So
* if AllDayEvent == YES (-1) ---> AllDayEvent = No, start = 0, end = 24
*
* @param pAppointment : the appointment object that contain every value
* @param dataType : the data type to get retrieve appointments
*
* NOTE: this function is not used on Windows Mobile 5.0 devices because
* the OID remains the same even if the property changes.
*
*/
void normalizeAppointment(IP_OUTLOOK_APP *polApp, int dataType, wchar_t* path) {
IPOutlookItemCollection *pItems;
IAppointment *pAppointment;
IFolder *pFolder;
VARIANT_BOOL variantBool = FALSE;
wchar_t tempDate [30];
DATE date = NULL, startdate = NULL;
polApp->GetDefaultFolder (dataType, &pFolder);
pFolder->get_Items (&pItems);
int currentCountItems = 0;
pItems->get_Count(¤tCountItems);
BOOL isWinMob5 = isWindowsMobile5();
for (int i = 0; i < currentCountItems; i++) {
pItems->Item (i + 1, (IDispatch**)&pAppointment);
pAppointment->get_AllDayEvent(&variantBool);
wsprintf(tempDate, TEXT("%i"), variantBool);
if (wcscmp(tempDate, TEXT("-1")) == 0) {
SYSTEMTIME t;
// DATE
// START****************
pAppointment->get_Start(&startdate);
VariantTimeToSystemTime(startdate, &t);
t.wHour = 0;
t.wMinute = 0;
SystemTimeToVariantTime(&t, &startdate);
IRecurrencePattern* pRec;
pAppointment->GetRecurrencePattern(&pRec);
wstring recurrence = getRecurrenceTags(pRec, -1, 0, 0, olFolderCalendar, startdate, TRUE);
pAppointment->put_Start(startdate);
//END*************
pAppointment->get_End(&date);
VariantTimeToSystemTime(date, &t);
if (isWinMob5) {
if (startdate == date && !isPocketPC()){
// on smartphone wm5 the modification from all day -> not all day -> all day
// change the normal behaviour all day handling and the end date is different.
// this fix doesn't permit the day change but can be problem with all day events of may days.
// next releases change this feature and consider all day event as is.
t.wHour = 23;
t.wMinute = 59;
} else {
SYSTEMTIME s;
s = DT_AddDiff(nano100SecInMin, -(1), &t);
t.wDay = s.wDay ;
t.wDayOfWeek = s.wDayOfWeek ;
t.wHour = s.wHour ;
t.wMilliseconds = s.wMilliseconds ;
t.wMinute = s.wMinute ;
t.wMonth = s.wMonth ;
t.wSecond = s.wSecond ;
t.wYear = s.wYear ;
}
} else {
t.wHour = 23;
t.wMinute = 59;
}
SystemTimeToVariantTime(&t, &date);
pAppointment->put_End(date);
pAppointment->put_AllDayEvent(FALSE);
pRec->Release();
HRESULT resu = pAppointment->Save();
pAppointment->ClearRecurrencePattern();
pAppointment->GetRecurrencePattern(&pRec);
parseRecurrenceTags(pRec, recurrence.c_str(), startdate, 0, 0);
parseExceptionTags(pRec, pAppointment, recurrence.c_str(), polApp, path);
pRec->Release();
}
pAppointment->Release ();
}
pFolder->Release();
pItems->Release();
}
void copyFields(IAppointment *pAppointmentExc, IAppointment *pAppointmentCopy) {
BSTR element = NULL;
pAppointmentExc->get_Subject(&element);
pAppointmentCopy->put_Subject(element);
SysFreeString(element);
pAppointmentExc->get_Location(&element);
pAppointmentCopy->put_Location(element);
SysFreeString(element);
pAppointmentExc->get_Body(&element);
pAppointmentCopy->put_Body(element);
SysFreeString(element);
DATE d;
pAppointmentExc->get_Start(&d);
pAppointmentCopy->put_Start(d);
pAppointmentExc->get_End(&d);
pAppointmentCopy->put_End(d);
VARIANT_BOOL vbool;
pAppointmentExc->get_AllDayEvent(&vbool);
pAppointmentCopy->put_AllDayEvent(vbool);
pAppointmentExc->get_ReminderSet(&vbool);
pAppointmentCopy->put_ReminderSet(vbool);
long elementLong = 0;
pAppointmentExc->get_BusyStatus(&elementLong);
pAppointmentCopy->put_BusyStatus(elementLong);
pAppointmentExc->get_ReminderMinutesBeforeStart(&elementLong);
pAppointmentCopy->put_ReminderMinutesBeforeStart(elementLong);
}
/*
* . Scan all the appointment and get the ones with recurrences
* . If there are any that are with exceptions remove them
* .
*/
BOOL normalizeAppointmentExceptions(IP_OUTLOOK_APP* polApp) {
IPOutlookItemCollection *pItems;
IAppointment *pAppointment;
IFolder *pFolder;
VARIANT_BOOL variantBool = FALSE;
polApp->GetDefaultFolder (olFolderCalendar, &pFolder);
pFolder->get_Items (&pItems);
int currentCountItems = 0;
pItems->get_Count(¤tCountItems);
for (int i = 0; i < currentCountItems; i++) {
VARIANT_BOOL isRecurring;
pItems->Item (i + 1, (IDispatch**)&pAppointment);
pAppointment->get_IsRecurring(&isRecurring);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -