Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev current [ci skip] #27

Merged
merged 4 commits into from
Sep 2, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
using Google;
using Google.Apis.Calendar.v3;
using Google.Apis.Calendar.v3.Data;
using Google.Apis.Drive.v2.Data;
using Google.Apis.Requests;
using log4net;

Expand Down Expand Up @@ -184,7 +185,12 @@ private Event CreateUpdatedGoogleCalendarEvent(Appointment calendarAppointment,
Description = calendarAppointment.GetDescriptionData(addDescription, attendeesToDescription),
Location = calendarAppointment.Location,
Visibility = calendarAppointment.Privacy,
Transparency = (calendarAppointment.BusyStatus == BusyStatusEnum.Free) ? "transparent" : "opaque"
Transparency = (calendarAppointment.BusyStatus == BusyStatusEnum.Free) ? "transparent" : "opaque",
Creator = new Event.CreatorData()
{
DisplayName = calendarAppointment.Organizer.Name,
Email = calendarAppointment.Organizer.Email,
},
};

if (EventCategory != null && !string.IsNullOrEmpty(EventCategory.ColorNumber))
Expand Down Expand Up @@ -276,6 +282,11 @@ private Event CreateGoogleCalendarEvent(Appointment calendarAppointment, bool ad
Summary = calendarAppointment.Subject,
Description = calendarAppointment.GetDescriptionData(addDescription, attendeesToDescription),
Location = calendarAppointment.Location,
Creator = new Event.CreatorData()
{
DisplayName = calendarAppointment.Organizer.Name,
Email = calendarAppointment.Organizer.Email,
},
Visibility = calendarAppointment.Privacy,
Transparency = (calendarAppointment.BusyStatus == BusyStatusEnum.Free) ? "transparent" : "opaque",
//Need to make recurring appointment IDs unique - append the item's date
Expand Down Expand Up @@ -443,6 +454,15 @@ private Appointment CreateAppointment(Event googleEvent)
}
}

if (googleEvent.Creator != null)
{
appointment.Organizer = new Recipient()
{
Name = googleEvent.Creator.DisplayName,
Email = googleEvent.Creator.Email
};
}

appointment.Created = googleEvent.Created;
appointment.LastModified = googleEvent.Updated;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,9 @@ private Appointment AddAppointment(bool addDescription, bool addReminder, bool a
}
else
{
appItem.MeetingStatus = OlMeetingStatus.olMeeting;
appItem.MeetingStatus = OlMeetingStatus.olMeetingReceived;

//appItem.MeetingStatus = OlMeetingStatus.olMeeting;
}

appItem.Location = calendarAppointment.Location;
Expand All @@ -228,7 +230,8 @@ private Appointment AddAppointment(bool addDescription, bool addReminder, bool a


appItem.Body = calendarAppointment.GetDescriptionData(addDescription, attendeesToDescription);


Recipient organizer = null;
if (addAttendees && !attendeesToDescription)
{
if (calendarAppointment.RequiredAttendees != null)
Expand All @@ -237,8 +240,18 @@ private Appointment AddAppointment(bool addDescription, bool addReminder, bool a
{
var recipient =
appItem.Recipients.Add(string.Format("{0}<{1}>", rcptName.Name, rcptName.Email));
recipient.Type = (int) OlMeetingRecipientType.olRequired;
recipient.Resolve();
if (calendarAppointment.Organizer != null &&
rcptName.Name.Equals(calendarAppointment.Organizer.Name))
{
recipient.Type = (int) OlMeetingRecipientType.olOrganizer;
recipient.Resolve();
organizer = recipient;
}
else
{
recipient.Type = (int) OlMeetingRecipientType.olRequired;
recipient.Resolve();
}
});
}

Expand All @@ -248,11 +261,31 @@ private Appointment AddAppointment(bool addDescription, bool addReminder, bool a
{
var recipient =
appItem.Recipients.Add(string.Format("{0}<{1}>", rcptName.Name, rcptName.Email));
recipient.Type = (int) OlMeetingRecipientType.olOptional;
recipient.Resolve();
if (calendarAppointment.Organizer != null &&
rcptName.Name.Equals(calendarAppointment.Organizer.Name))
{
recipient.Type = (int) OlMeetingRecipientType.olOrganizer;
recipient.Resolve();
organizer = recipient;
}
else
{
recipient.Type = (int)OlMeetingRecipientType.olOptional;
recipient.Resolve();
}
});
}
}
else if(calendarAppointment.Organizer != null)
{
var recipient =
appItem.Recipients.Add(string.Format("{0}<{1}>", calendarAppointment.Organizer.Name, calendarAppointment.Organizer.Email));
recipient.Type = (int)OlMeetingRecipientType.olOrganizer;
recipient.Resolve();
organizer = recipient;
}

SetOrganizer(appItem, organizer);

if (addReminder)
{
Expand Down Expand Up @@ -293,6 +326,30 @@ private Appointment AddAppointment(bool addDescription, bool addReminder, bool a
return createdAppointment;
}

private void SetOrganizer(AppointmentItem appItem, Recipient organizer)
{
try
{
if (appItem == null || organizer == null)
return;

const String PR_SENT_REPRESENTING_NAME = "http://schemas.microsoft.com/mapi/proptag/0x0042001F";
const String PR_SENT_REPRESENTING_ENTRY_ID = "http://schemas.microsoft.com/mapi/proptag/0x00410102";
const String PR_SENDER_ENTRYID = "http://schemas.microsoft.com/mapi/proptag/0x0C190102";

PropertyAccessor pa = appItem.PropertyAccessor;
pa.SetProperty(PR_SENDER_ENTRYID, pa.StringToBinary(organizer.EntryID));
pa.SetProperty(PR_SENT_REPRESENTING_NAME, organizer.Name);
pa.SetProperty(PR_SENT_REPRESENTING_ENTRY_ID, pa.StringToBinary(organizer.EntryID));

}
catch (Exception ex)
{
Logger.Error(ex);
}
}


private bool DeleteEvents(List<Appointment> calendarAppointments, List<Appointment> deletedAppointments)
{
var wrapper = DeleteEventsFromOutlook(calendarAppointments,deletedAppointments);
Expand Down Expand Up @@ -562,9 +619,10 @@ private bool UpdateAppointment(bool addDescription, bool addReminder, bool addAt
appItem.AllDayEvent = calendarAppointment.AllDayEvent;
}


appItem.Start = calendarAppointment.StartTime.GetValueOrDefault();
appItem.End = calendarAppointment.EndTime.GetValueOrDefault();
if (addDescription || attendeesToDescription)
if (addDescription)
{
appItem.Body = calendarAppointment.Description;
}
Expand All @@ -576,24 +634,31 @@ private bool UpdateAppointment(bool addDescription, bool addReminder, bool addAt
{
calendarAppointment.RequiredAttendees.ForEach(rcptName =>
{
var recipient =
appItem.Recipients.Add(string.Format("{0}<{1}>", rcptName.Name, rcptName.Email));
recipient.Type = (int) OlMeetingRecipientType.olRequired;
recipient.Resolve();
if (!CheckIfRecipientExists(recipients, rcptName))
{
var recipient =
appItem.Recipients.Add(string.Format("{0}<{1}>", rcptName.Name, rcptName.Email));
recipient.Type = (int) OlMeetingRecipientType.olRequired;
recipient.Resolve();
}
});
}

if (calendarAppointment.OptionalAttendees != null)
{
calendarAppointment.OptionalAttendees.ForEach(rcptName =>
{
var recipient =
appItem.Recipients.Add(string.Format("{0}<{1}>", rcptName.Name, rcptName.Email));
recipient.Type = (int) OlMeetingRecipientType.olOptional;
recipient.Resolve();
if (!CheckIfRecipientExists(recipients, rcptName))
{
var recipient =
appItem.Recipients.Add(string.Format("{0}<{1}>", rcptName.Name, rcptName.Email));
recipient.Type = (int) OlMeetingRecipientType.olOptional;
recipient.Resolve();
}
});
}
}


if (addReminder)
{
Expand Down Expand Up @@ -649,6 +714,27 @@ private bool UpdateAppointment(bool addDescription, bool addReminder, bool addAt
return true;
}

private bool CheckIfRecipientExists(Recipients recipients, Domain.Models.Recipient rcptName)
{
bool recipientFound = false;
foreach (Recipient attendee in recipients)
{
string name, email;
if (!attendee.GetEmailFromName(out name, out email))
{
name = attendee.Name;
email = GetSMTPAddressForRecipients(attendee);
}

if (rcptName.Email.Equals(email))
{
recipientFound = true;
break;
}
}
return recipientFound;
}

private void GetOutlookApplication(out bool disposeOutlookInstances,
out Application application,
out NameSpace nameSpace, string profileName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
\cf1\ul\b\f0\fs26 Highlights\par
\ulnone Release 1.4.1.x\f2\par
\pard\keep\keepn\nowidctlpar\s3\sb40\sl252\slmult1\cf2\lang9\b0\f0\fs24 Enhancement\par
\pard{\pntext\f3\'B7\tab}{\*\pn\pnlvlblt\pnf3\pnindent0{\pntxtb\'B7}}\nowidctlpar\fi-360\li720\cf0\f1\fs22 Preferences format changed to accomodate task sync\par
\pard{\pntext\f3\'B7\tab}{\*\pn\pnlvlblt\pnf3\pnindent0{\pntxtb\'B7}}\nowidctlpar\fi-360\li720\cf0\f1\fs22 Set Organizer in both Outlook and Google event entries\par
{\pntext\f3\'B7\tab}Preferences format changed to accomodate task sync\par
{\pntext\f3\'B7\tab}Cancel added in settings\par
{\pntext\f3\'B7\tab}Task sync one directional\par
{\pntext\f3\'B7\tab}Reset calendar - Unlink Outlook entries from Google entries and vice versa\par
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@
Visibility="{Binding IsLatestVersionAvailable,
Converter={StaticResource BooleanToVisibilityConverter}}">
<StackPanel Orientation="Horizontal">
<Rectangle Style="{StaticResource MenuRectangleStyle}">
<Rectangle Style="{StaticResource MenuRectangleStyle}" Fill="LawnGreen">
<Rectangle.OpacityMask>
<VisualBrush Stretch="Fill"
Visual="{StaticResource appbar_download}" />
Expand Down
4 changes: 2 additions & 2 deletions src/CalendarSyncPlus/Shared/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@

using System.Reflection;

[assembly: AssemblyVersion("1.4.1.4")]
[assembly: AssemblyFileVersion("1.4.1.4")]
[assembly: AssemblyVersion("1.4.1.6")]
[assembly: AssemblyFileVersion("1.4.1.6")]