Skip to content

Commit

Permalink
GMeet checkbox added to Google tab.
Browse files Browse the repository at this point in the history
Only sync GMeet if option enabled.
  • Loading branch information
phw198 committed Nov 18, 2023
1 parent a5791df commit 170139b
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 29 deletions.
24 changes: 20 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.

48 changes: 37 additions & 11 deletions src/OutlookGoogleCalendarSync/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ private void updateGUIsettings() {
"Include hidden calendars in the above drop down.");
ToolTips.SetToolTip(cbDeleteWhenColourExcl,
"If items are already synced in Outlook and subsequently excluded by a colour filter.");
ToolTips.SetToolTip(cbAddGMeet,
"Sync conference details embedded in Outlook appointment body.");

//Settings
ToolTips.SetToolTip(tbInterval,
Expand Down Expand Up @@ -443,7 +445,8 @@ public void UpdateGUIsettings_Profile() {
cbExcludeDeclinedInvites.Checked = profile.ExcludeDeclinedInvites;
cbExcludeGoals.Checked = profile.ExcludeGoals;
cbExcludeGoals.Enabled = GoogleOgcs.Calendar.IsDefaultCalendar() ?? true;

cbAddGMeet.Checked = profile.AddGMeet;

if (Settings.Instance.UsingPersonalAPIkeys()) {
cbShowDeveloperOptions.Checked = true;
tbClientID.Text = Settings.Instance.PersonalClientIdentifier;
Expand Down Expand Up @@ -607,23 +610,37 @@ public void FeaturesBlockedByCorpPolicy(Boolean isTrue) {
}
}
if (isTrue) {
SetControlPropertyThreadSafe(cbAddAttendees, "Checked", false);
SetControlPropertyThreadSafe(cbAddDescription, "Checked", false);
SetControlPropertyThreadSafe(rbOutlookSharedCal, "Checked", false);
//Mimic appearance of disabled control - but can't disable else tooltip doesn't work
cbAddAttendees.ForeColor = SystemColors.GrayText;
cbAddDescription.ForeColor = SystemColors.GrayText;
rbOutlookSharedCal.ForeColor = SystemColors.GrayText;
checkboxSoftRestrict(cbAddAttendees, true);
checkboxSoftRestrict(cbAddDescription, true);
checkboxSoftRestrict(rbOutlookSharedCal, true);
checkboxSoftRestrict(cbAddGMeet, true);
//If a sync is running, disable relevant config in that profile
SettingsStore.Calendar activeProfile = Settings.Profile.InPlay();
if (activeProfile != null) {
activeProfile.AddAttendees = false;
activeProfile.AddDescription = false;
activeProfile.AddGMeet = false;
}
} else {
cbAddAttendees.ForeColor = SystemColors.ControlText;
cbAddDescription.ForeColor = SystemColors.ControlText;
rbOutlookSharedCal.ForeColor = SystemColors.ControlText;
checkboxSoftRestrict(cbAddAttendees, false);
checkboxSoftRestrict(cbAddDescription, false);
checkboxSoftRestrict(rbOutlookSharedCal, false);
checkboxSoftRestrict(cbAddGMeet, false);
}
}

/// <summary>
/// Make a checkbox look disabled, but still able to show a tooltip
/// </summary>
/// <param name="cb">The form control</param>
/// <param name="disable">Disable or enable</param>
private void checkboxSoftRestrict(Control cb, Boolean disable) {
if (disable) {
cb.ForeColor = SystemColors.GrayText;
SetControlPropertyThreadSafe(cb, "Checked", false);
} else {
cb.ForeColor = SystemColors.ControlText;
}
}

Expand Down Expand Up @@ -1255,7 +1272,7 @@ private void groupboxSizing(GroupBox section, PictureBox sectionImage, Boolean?
switch (section.Name.ToString().Split('_').LastOrDefault()) {
//Google
case "Account": section.Height = 242; break;
case "GConfig": section.Height = 122; break;
case "GConfig": section.Height = 130; break;
case "OAuth": section.Height = 174; break;
//Settings
case "How": section.Height = btCloseRegexRules.Visible ? 251 : 198; break;
Expand Down Expand Up @@ -1667,6 +1684,13 @@ private void cbExcludeDeclinedInvites_CheckedChanged(object sender, EventArgs e)
private void cbExcludeGoals_CheckedChanged(object sender, EventArgs e) {
ActiveCalendarProfile.ExcludeGoals = cbExcludeGoals.Checked;
}
private void cbGMeet_CheckedChanged(object sender, EventArgs e) {
if (!cbAddDescription.Checked) {
cbAddGMeet.Checked = false;
}
ActiveCalendarProfile.AddGMeet = cbAddGMeet.Checked;
}

#endregion

#region Developer Options
Expand Down Expand Up @@ -2161,6 +2185,8 @@ private void cbAddDescription_CheckedChanged(object sender, EventArgs e) {
}
ActiveCalendarProfile.AddDescription = cbAddDescription.Checked;
cbAddDescription_OnlyToGoogle.Enabled = cbAddDescription.Checked;
checkboxSoftRestrict(cbAddGMeet, !cbAddDescription.Checked);
ToolTips.SetToolTip(cbAddGMeet, cbAddDescription.Checked ? "Sync conference details embedded in Outlook appointment body." : "Requires sync of Description (under Options > What)");
showWhatPostit("Description");
}
private void cbAddDescription_OnlyToGoogle_CheckedChanged(object sender, EventArgs e) {
Expand Down
20 changes: 11 additions & 9 deletions src/OutlookGoogleCalendarSync/GoogleOgcs/GoogleCalendar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ private Event createCalendarEntry_save(Event ev, AppointmentItem ai) {
ai.Save();
}

if (OutlookOgcs.GMeet.BodyHasGmeetUrl(ai)) {
if (profile.AddGMeet && OutlookOgcs.GMeet.BodyHasGmeetUrl(ai)) {
log.Info("Adding GMeet conference details.");
String outlookGMeet = OutlookOgcs.GMeet.RgxGmeetUrl().Match(ai.Body).Value;
GMeet.GoogleMeet(createdEvent, outlookGMeet);
Expand Down Expand Up @@ -904,14 +904,16 @@ public Event UpdateCalendarEntry(AppointmentItem ai, Event ev, ref int itemModif
if (Sync.Engine.CompareAttribute("Description", Sync.Direction.OutlookToGoogle, ev.Description, bodyObfuscated, sb, ref itemModified))
ev.Description = bodyObfuscated;

String outlookGMeet = OutlookOgcs.GMeet.RgxGmeetUrl().Match(ai.Body)?.Value;
if (Sync.Engine.CompareAttribute("Google Meet", Sync.Direction.OutlookToGoogle, ev.HangoutLink, outlookGMeet, sb, ref itemModified)) {
try {
GMeet.GoogleMeet(ev, outlookGMeet);
ev = patchEvent(ev) ?? ev;
log.Fine("Conference data change successfully saved.");
} catch (System.Exception ex) {
OGCSexception.Analyse("Could not update conference data in existing Event.", ex);
if (profile.AddGMeet) {
String outlookGMeet = OutlookOgcs.GMeet.RgxGmeetUrl().Match(ai.Body)?.Value;
if (Sync.Engine.CompareAttribute("Google Meet", Sync.Direction.OutlookToGoogle, ev.HangoutLink, outlookGMeet, sb, ref itemModified)) {
try {
GMeet.GoogleMeet(ev, outlookGMeet);
ev = patchEvent(ev) ?? ev;
log.Fine("Conference data change successfully saved.");
} catch (System.Exception ex) {
OGCSexception.Analyse("Could not update conference data in existing Event.", ex);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@
<DependentUpon>TimezoneMap.cs</DependentUpon>
</Compile>
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="GoogleOgcs\GMeet.cs" />
<Compile Include="OutlookOgcs\GMeet.cs" />
<Compile Include="GoogleOgcs\ErrorReporting.cs" />
<Compile Include="GoogleOgcs\CustomProperty.cs" />
Expand Down
12 changes: 7 additions & 5 deletions src/OutlookGoogleCalendarSync/OutlookOgcs/OutlookCalendar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ private void createCalendarEntry(Event ev, ref AppointmentItem ai) {
}
} else ai.ReminderSet = profile.UseOutlookDefaultReminder;

if (!String.IsNullOrEmpty(ev.HangoutLink)) {
if (profile.AddGMeet && !String.IsNullOrEmpty(ev.HangoutLink)) {
ai.GoogleMeet(ev.HangoutLink);
}

Expand Down Expand Up @@ -610,11 +610,13 @@ public Boolean UpdateCalendarEntry(ref AppointmentItem ai, Event ev, ref int ite
if (descriptionChanged = Sync.Engine.CompareAttribute("Description", Sync.Direction.GoogleToOutlook, bodyObfuscated, aiBody, sb, ref itemModified))
ai.Body = bodyObfuscated;
}
if (Sync.Engine.CompareAttribute("Google Meet", Sync.Direction.GoogleToOutlook, ev.HangoutLink, oGMeetUrl, sb, ref itemModified)) {
ai.GoogleMeet(ev.HangoutLink);
if (String.IsNullOrEmpty(ev.HangoutLink) && !String.IsNullOrEmpty(oGMeetUrl) && !descriptionChanged)
log.Debug("Removing GMeet information from body.");
if (profile.AddGMeet) {
if (Sync.Engine.CompareAttribute("Google Meet", Sync.Direction.GoogleToOutlook, ev.HangoutLink, oGMeetUrl, sb, ref itemModified)) {
ai.GoogleMeet(ev.HangoutLink);
if (String.IsNullOrEmpty(ev.HangoutLink) && !String.IsNullOrEmpty(oGMeetUrl) && !descriptionChanged)
log.Debug("Removing GMeet information from body.");
ai.Body = bodyObfuscated;
}
}
}
}
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 @@ -52,6 +52,7 @@ private void setDefaults() {
Colours = new List<String>();
ExcludeDeclinedInvites = true;
ExcludeGoals = true;
AddGMeet = true;

//Sync Options
//How
Expand Down Expand Up @@ -137,6 +138,7 @@ [DataMember] public Boolean OutlookGalBlocked {
[DataMember] public List<string> Colours { get; set; }
[DataMember] public Boolean ExcludeDeclinedInvites { get; set; }
[DataMember] public Boolean ExcludeGoals { get; set; }
[DataMember] public Boolean AddGMeet { get; set; }
#endregion
#region Sync Options
/// <summary>For O->G match on signatures. Useful for Appled iCals where immutable Outlook IDs change every sync.</summary>
Expand Down Expand Up @@ -288,6 +290,7 @@ public void LogSettings() {
log.Info(" Colours: " + String.Join(",", Colours.ToArray()));
log.Info(" Exclude Declined Invites: " + ExcludeDeclinedInvites);
log.Info(" Exclude Goals: " + ExcludeGoals);
log.Info(" Include Google Meet: " + AddGMeet);
log.Info(" Cloak Email: " + CloakEmail);

log.Info("SYNC OPTIONS:-");
Expand Down

0 comments on commit 170139b

Please sign in to comment.