예제 #1
0
void EkstraktorMainWindow::onStartDate(wxCommandEvent &event)
{
	DateChooserWidget *dat = 
		new DateChooserWidget(
				this,
				_("Select start date"),
				1,
				mainWidget->GetFirstDate(), 
				mainWidget->GetLastDate(),
				10
		);
		wxDateTime date = mainWidget->GetStartDate();
	
	if(dat->GetDate(date)) {
		delete dat;
	} else {
		delete dat;
		return;
	}
	mainWidget->SetStartDate(date.GetTicks());
	SetStartDate(date.GetTicks());
}
HRESULT MAPIAppointment::SetMAPIAppointmentValues()
{
    SizedSPropTagArray(C_NUMALLAPPTPROPS, appointmentProps) = {
	C_NUMALLAPPTPROPS, {
	    PR_MESSAGE_FLAGS, PR_SUBJECT, PR_BODY, PR_HTML, pr_clean_global_objid,
	    pr_appt_start, pr_appt_end, pr_location, pr_busystatus, pr_allday,
	    pr_isrecurring, pr_recurstream, pr_timezoneid, pr_responsestatus,
            PR_RESPONSE_REQUESTED,pr_exceptionreplacetime,
			pr_reminderminutes, pr_private, pr_reminderset
	}
    };

    HRESULT hr = S_OK;
    ULONG cVals = 0;
    bool bAllday = false;
    m_bHasAttachments = false;
    m_bIsRecurring = false;	

	// get the zimbra appt wrapper around the mapi message
 	Zimbra::Mapi::Appt appt(m_pMessage, m_mapiStore->GetInternalMAPIStore());

    // save off the default timezone info for this appointment
	try
	{
		hr = appt.GetTimezone(_olkTz, &_pTzString);
	}
	catch(...)
	{
		hr=E_FAIL;
	}
	if (SUCCEEDED(hr))
    {
		// get the timezone info for this appt
		pInvTz= new Zimbra::Mail::TimeZone(_pTzString);
		pInvTz->Initialize(_olkTz, _pTzString);
	}

    if (FAILED(hr = m_pMessage->GetProps((LPSPropTagArray) & appointmentProps, fMapiUnicode, &cVals,
            &m_pPropVals)))
        throw MAPIAppointmentException(hr, L"SetMAPIAppointmentValues(): GetProps Failed.",
		ERR_MAPI_APPOINTMENT, __LINE__, __FILE__);
    
    if (m_pPropVals[C_MESSAGE_FLAGS].ulPropTag == appointmentProps.aulPropTag[C_MESSAGE_FLAGS])
    {
        m_bHasAttachments = (m_pPropVals[C_MESSAGE_FLAGS].Value.l & MSGFLAG_HASATTACH) != 0;
    }
    if (m_pPropVals[C_ISRECUR].ulPropTag == appointmentProps.aulPropTag[C_ISRECUR]) // do this first to set dates correctly
    {
	m_bIsRecurring = (m_pPropVals[C_ISRECUR].Value.b == 1);
    }
    if (m_pPropVals[C_ALLDAY].ulPropTag == appointmentProps.aulPropTag[C_ALLDAY])
    {
        SetAllday(m_pPropVals[C_ALLDAY].Value.b);
        bAllday = (m_pPropVals[C_ALLDAY].Value.b == 1);
    }
    if (m_pPropVals[C_SUBJECT].ulPropTag == appointmentProps.aulPropTag[C_SUBJECT])
    {
	SetSubject(m_pPropVals[C_SUBJECT].Value.lpszW);
    }
    if (m_pPropVals[C_UID].ulPropTag == appointmentProps.aulPropTag[C_UID])
    {
	SetInstanceUID(&m_pPropVals[C_UID].Value.bin);
    }
    if (m_pPropVals[C_START].ulPropTag == appointmentProps.aulPropTag[C_START])
    {
	SetStartDate(m_pPropVals[C_START].Value.ft);
    }
    if (m_pPropVals[C_END].ulPropTag == appointmentProps.aulPropTag[C_END])
    {
        SetEndDate(m_pPropVals[C_END].Value.ft, bAllday);
    }
    if (m_pPropVals[C_LOCATION].ulPropTag == appointmentProps.aulPropTag[C_LOCATION])
    {
	SetLocation(m_pPropVals[C_LOCATION].Value.lpszW);
    }
    if (m_pPropVals[C_BUSYSTATUS].ulPropTag == appointmentProps.aulPropTag[C_BUSYSTATUS])
    {
	SetBusyStatus(m_pPropVals[C_BUSYSTATUS].Value.l);
    }
    if (m_pPropVals[C_RESPONSESTATUS].ulPropTag == appointmentProps.aulPropTag[C_RESPONSESTATUS])
    {
	SetResponseStatus(m_pPropVals[C_RESPONSESTATUS].Value.l);
    }
	 if (m_pPropVals[C_RESPONSEREQUESTED].ulPropTag == appointmentProps.aulPropTag[C_RESPONSEREQUESTED])
    {
	SetResponseRequested(m_pPropVals[C_RESPONSEREQUESTED].Value.b);
    }
	
	unsigned short usReminderSet=1;
	if (m_pPropVals[C_REMINDERSET].ulPropTag == appointmentProps.aulPropTag[C_REMINDERSET])
    {
		usReminderSet= m_pPropVals[C_REMINDERSET].Value.b;
    }
	if(usReminderSet)
	{
		if (m_pPropVals[C_REMINDERMINUTES].ulPropTag == appointmentProps.aulPropTag[C_REMINDERMINUTES])
		{
		SetReminderMinutes(m_pPropVals[C_REMINDERMINUTES].Value.l);
		}
	}
    if (m_pPropVals[C_PRIVATE].ulPropTag == appointmentProps.aulPropTag[C_PRIVATE])
    {
	SetPrivate(m_pPropVals[C_PRIVATE].Value.b);
    }
	
    SetTransparency(L"O");
    SetPlainTextFileAndContent();
    SetHtmlFileAndContent();

    if (m_bHasAttachments)
    {
        if (FAILED(ExtractAttachments()))
        {
            dlogw(L"Could not extract attachments");
        }
    }

    hr = SetOrganizerAndAttendees();
	if(FAILED(hr))
	{
		 dlogw(L"SetOrganizerAndAttendees failed");
	}

    if ((m_bIsRecurring) && (m_iExceptionType != CANCEL_EXCEPTION))
    {
	if (m_pPropVals[C_RECURSTREAM].ulPropTag == appointmentProps.aulPropTag[C_RECURSTREAM])
	{
	    // special case for timezone id
	    if (m_pPropVals[C_TIMEZONEID].ulPropTag == appointmentProps.aulPropTag[C_TIMEZONEID])
	    {
		SetTimezoneId(m_pPropVals[C_TIMEZONEID].Value.lpszW);
	    }
	    //

	    int numExceptions = SetRecurValues(); // returns null if no exceptions
            if (numExceptions > 0)
            {
                SetExceptions();
            }
	}
    }
    return hr;
}