Skip to content

Commit

Permalink
Squashed commit of the following GMeet development for #1076 :-
Browse files Browse the repository at this point in the history
commit 4b77326
Author: Paul Woolcock <[email protected]>
Date:   Sun Nov 19 14:22:22 2023 +0000

    Body comparison bug fixes.

commit 170139b
Author: Paul Woolcock <[email protected]>
Date:   Sat Nov 18 13:45:46 2023 +0000

    GMeet checkbox added to Google tab.
    Only sync GMeet if option enabled.

commit a5791df
Author: Paul Woolcock <[email protected]>
Date:   Fri Nov 17 17:28:44 2023 +0000

    Add, update and delete GMeet data from existing Event.
    New GoogleOgcs/GMeet class with GoogleMeet() method.

commit 8e2de1c
Author: Paul Woolcock <[email protected]>
Date:   Fri Nov 17 14:31:50 2023 +0000

    Add GMeet URL to new Google items, using PatchEvent()

commit a015c47
Author: Paul Woolcock <[email protected]>
Date:   Thu Nov 16 15:14:36 2023 +0000

    Resync just description if GMeet is removed.

commit 2df34b9
Author: Paul Woolcock <[email protected]>
Date:   Sun Nov 12 11:58:12 2023 +0000

    String extension method RemoveLineBreaks()
    Added GMeet logo as a resource.
    Injection of HTML info block support added.

commit 6fc1586
Author: Paul Woolcock <[email protected]>
Date:   Sun Nov 12 11:54:39 2023 +0000

    Update RTF GMeet section.

commit 2f81f65
Author: Paul Woolcock <[email protected]>
Date:   Fri Nov 10 10:16:31 2023 +0000

    Hold GMeetUrl in CustomProperty.
    Update Outlook GMeet URL.
    Extend AppointmentItem to a) surface BodyFormat by reflection; b) return RTFBodyAsString.

commit 290d6db
Author: Paul Woolcock <[email protected]>
Date:   Sun Nov 5 18:29:28 2023 +0000

    Create Outlook item adds RTF body.

commit 32e0cbd
Author: Paul Woolcock <[email protected]>
Date:   Sun Nov 5 16:28:53 2023 +0000

    Updating Outlook item with hard-coded RTF body.
  • Loading branch information
phw198 committed Nov 19, 2023
1 parent f503ccd commit 52ea95d
Show file tree
Hide file tree
Showing 16 changed files with 724 additions and 28 deletions.
9 changes: 9 additions & 0 deletions src/OutlookGoogleCalendarSync/Extensions/String.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System;

namespace OutlookGoogleCalendarSync {
public static class StringExtensions {
public static String RemoveLineBreaks(this String input) {
return input?.Replace("\r", "").Replace("\n", "");
}
}
}
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 (!this.LoadingProfileConfig && !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
58 changes: 58 additions & 0 deletions src/OutlookGoogleCalendarSync/GoogleOgcs/GMeet.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using Google.Apis.Calendar.v3.Data;
using log4net;
using System;
using System.Collections.Generic;
using System.Linq;

namespace OutlookGoogleCalendarSync.GoogleOgcs {
static class GMeet {
private static readonly ILog log = LogManager.GetLogger(typeof(GMeet));

/// <summary>
/// Add/update/delete Google Meet conference data in Google event
/// </summary>
/// <param name="ev">The Event to update</param>
/// <param name="outlookGMeetUrl">The GMeet URL detected in the Outlook appointment body</param>
public static void GoogleMeet(this Event ev, String outlookGMeetUrl) {
try {
if (String.IsNullOrEmpty(ev.HangoutLink)) {
log.Debug("Adding Google Meet conference data.");
log.Debug("Conference ID: " + outlookGMeetUrl);
ev.ConferenceData = new ConferenceData() {
ConferenceSolution = new ConferenceSolution() {
Key = new ConferenceSolutionKey { Type = "hangoutsMeet" }
},
EntryPoints = new List<EntryPoint>() { new EntryPoint() { EntryPointType = "video", Uri = outlookGMeetUrl } }
};

} else if (String.IsNullOrEmpty(outlookGMeetUrl)) {
log.Debug("Removing Google Meet conference data.");
if (ev.ConferenceData.ConferenceSolution.Key.Type != "hangoutsMeet") {
log.Warn("Unexpected conference solution type '" + ev.ConferenceData.ConferenceSolution.Key.Type + "'. Remove abandoned.");
} else {
EntryPoint ep = ev.ConferenceData.EntryPoints.Where(ep => ep.EntryPointType == "video").FirstOrDefault();
log.Fine("Removing the 'video' conference entry point.");
ev.ConferenceData.EntryPoints.Remove(ep);
ev.ConferenceData.ConferenceSolution.Name = null;
}

} else {
log.Debug("Updating Google Meet conference data.");
if (ev.ConferenceData.ConferenceSolution.Key.Type != "hangoutsMeet") {
log.Warn("Unexpected conference solution type '" + ev.ConferenceData.ConferenceSolution.Key.Type + "'. Update abandoned.");
} else {
EntryPoint ep = ev.ConferenceData.EntryPoints.Where(ep => ep.EntryPointType == "video").FirstOrDefault();
log.Fine("Replacing the 'video' conference entry point.");
ev.ConferenceData.EntryPoints.Remove(ep);
ep.Uri = outlookGMeetUrl;
ev.ConferenceData.EntryPoints.Add(ep);
ev.ConferenceData.ConferenceSolution.Name = null;
}
}

} catch (System.Exception ex) {
OGCSexception.Analyse("Could not alter Event conference data.", ex);
}
}
}
}
Loading

0 comments on commit 52ea95d

Please sign in to comment.