Skip to content

Commit

Permalink
Merge branch 'feature/issue-415/privacy' into release
Browse files Browse the repository at this point in the history
Closes #415
  • Loading branch information
phw198 committed Jul 29, 2023
2 parents e9b5c36 + d2bc89a commit 690f6bb
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 13 deletions.
38 changes: 34 additions & 4 deletions src/OutlookGoogleCalendarSync/Forms/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 23 additions & 8 deletions src/OutlookGoogleCalendarSync/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,7 @@ public void UpdateGUIsettings_Profile() {
cbExcludeFreeAllDays.Enabled = cbExcludeAllDays.Checked;
cbExcludeFree.Checked = profile.ExcludeFree;
cbExcludeTentative.Checked = profile.ExcludeTentative;
cbExcludePrivate.Checked = profile.ExcludePrivate;
this.gbSyncOptions_What.ResumeLayout();
#endregion
#endregion
Expand Down Expand Up @@ -1577,7 +1578,7 @@ private void syncOptionSizing(GroupBox section, PictureBox sectionImage, Boolean
switch (section.Name.ToString().Split('_').LastOrDefault()) {
case "How": section.Height = btCloseRegexRules.Visible ? 251 : 198; break;
case "When": section.Height = 119; break;
case "What": section.Height = 210; break;
case "What": section.Height = 228; break;
case "Logging": section.Height = 111; break;
case "Proxy": section.Height = 197; break;
}
Expand Down Expand Up @@ -1970,6 +1971,12 @@ private void lWhatInfo_MouseHover(object sender, EventArgs e) {
private void lWhatInfo_MouseLeave(object sender, EventArgs e) {
showWhatPostit("Description");
}
private void lWhatExcludeInfo_MouseHover(object sender, EventArgs e) {
showWhatPostit("AffectedExcludeItems");
}
private void lWhatExcludeInfo_MouseLeave(object sender, EventArgs e) {
showWhatPostit("Description");
}
private void showWhatPostit(String info) {
switch (info) {
case "Description": {
Expand All @@ -1985,6 +1992,12 @@ private void showWhatPostit(String info) {
WhatPostit.Visible = true;
break;
}
case "AffectedExcludeItems": {
tbWhatHelp.Text = "Excluding items will delete those previously synced.\r" +
"For more fine-grained control, consider filtering on categories.";
WhatPostit.Visible = true;
break;
}
}
tbWhatHelp.SelectAll();
tbWhatHelp.SelectionAlignment = HorizontalAlignment.Center;
Expand Down Expand Up @@ -2075,6 +2088,15 @@ private void cbSingleCategoryOnly_CheckedChanged(object sender, EventArgs e) {
ActiveCalendarProfile.SingleCategoryOnly = cbSingleCategoryOnly.Checked;
}

private void cbExcludeFree_CheckedChanged(object sender, EventArgs e) {
ActiveCalendarProfile.ExcludeFree = cbExcludeFree.Checked;
}
private void cbExcludeTentative_CheckedChanged(object sender, EventArgs e) {
ActiveCalendarProfile.ExcludeTentative = cbExcludeTentative.Checked;
}
private void cbExcludePrivate_CheckedChanged(object sender, EventArgs e) {
ActiveCalendarProfile.ExcludePrivate = cbExcludePrivate.Checked;
}
private void cbExcludeAllDays_CheckedChanged(object sender, EventArgs e) {
ActiveCalendarProfile.ExcludeAllDays = cbExcludeAllDays.Checked;
cbExcludeFreeAllDays.Enabled = cbExcludeAllDays.Checked;
Expand All @@ -2083,13 +2105,6 @@ private void cbExcludeAllDays_CheckedChanged(object sender, EventArgs e) {
private void cbExcludeFreeAllDays_CheckedChanged(object sender, EventArgs e) {
ActiveCalendarProfile.ExcludeFreeAllDays = cbExcludeFreeAllDays.Checked;
}

private void cbExcludeTentative_CheckedChanged(object sender, EventArgs e) {
ActiveCalendarProfile.ExcludeTentative = cbExcludeTentative.Checked;
}
private void cbExcludeFree_CheckedChanged(object sender, EventArgs e) {
ActiveCalendarProfile.ExcludeFree = cbExcludeFree.Checked;
}
#endregion
#endregion
#region Application settings
Expand Down
7 changes: 7 additions & 0 deletions src/OutlookGoogleCalendarSync/GoogleOgcs/GoogleCalendar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,13 @@ public List<Event> GetCalendarEntriesInRange(DateTime from, DateTime to) {
result = result.Except(allDays).ToList();
}
}
if (profile.ExcludePrivate) {
List<Event> privacy = result.Where(ev => profile.ExcludePrivate && ev.Visibility == "private").ToList();
if (privacy.Count > 0) {
log.Debug(privacy.Count + " Google Private items excluded.");
result = result.Except(privacy).ToList();
}
}
}

if (profile.ExcludeDeclinedInvites) {
Expand Down
7 changes: 6 additions & 1 deletion src/OutlookGoogleCalendarSync/OutlookOgcs/OutlookCalendar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ public List<AppointmentItem> FilterCalendarEntries(SettingsStore.Calendar profil

Int32 allDayFiltered = 0;
Int32 availabilityFiltered = 0;
Int32 privacyFiltered = 0;
Int32 responseFiltered = 0;

foreach (Object obj in IOutlook.FilterItems(OutlookItems, filter)) {
Expand Down Expand Up @@ -214,7 +215,7 @@ public List<AppointmentItem> FilterCalendarEntries(SettingsStore.Calendar profil
else {
Boolean filtered = false;

//Availability
//Availability, Privacy
if (profile.SyncDirection.Id != Sync.Direction.GoogleToOutlook.Id) { //Sync direction means O->G will delete previously synced excluded items
if ((profile.ExcludeTentative && ai.BusyStatus == OlBusyStatus.olTentative) ||
(profile.ExcludeFree && ai.BusyStatus == OlBusyStatus.olFree)) {
Expand All @@ -228,6 +229,10 @@ public List<AppointmentItem> FilterCalendarEntries(SettingsStore.Calendar profil
filtered = true;
if (filtered) { allDayFiltered++; continue; }
}

if (profile.ExcludePrivate && ai.Sensitivity == OlSensitivity.olPrivate) {
privacyFiltered++; continue;
}
}

//Categories
Expand Down
3 changes: 3 additions & 0 deletions src/OutlookGoogleCalendarSync/SettingsStore/Calendar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ private void setDefaults() {
ColourMaps = new ColourMappingDictionary();
ExcludeFree = false;
ExcludeTentative = false;
ExcludePrivate = false;
ExcludeAllDays = false;
ExcludeFreeAllDays = false;

Expand Down Expand Up @@ -184,6 +185,7 @@ [DataMember] public Boolean OutlookGalBlocked {
public class ColourMappingDictionary : Dictionary<String, String> { }
[DataMember] public bool ExcludeFree { get; set; }
[DataMember] public bool ExcludeTentative { get; set; }
[DataMember] public bool ExcludePrivate { get; set; }
[DataMember] public bool ExcludeAllDays { get; set; }
[DataMember] public bool ExcludeFreeAllDays { get; set; }
#endregion
Expand Down Expand Up @@ -320,6 +322,7 @@ public void LogSettings() {
log.Info(" ReminderDND: " + ReminderDND + " (" + ReminderDNDstart.ToString("HH:mm") + "-" + ReminderDNDend.ToString("HH:mm") + ")");
log.Info(" ExcludeFree: " + ExcludeFree);
log.Info(" ExcludeTentative: " + ExcludeTentative);
log.Info(" ExcludePrivate: " + ExcludePrivate);
log.Info(" ExcludeAllDay: " + ExcludeAllDays + "; that are marked Free: " + ExcludeFreeAllDays);
}

Expand Down

0 comments on commit 690f6bb

Please sign in to comment.