Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielHabenicht committed Jul 5, 2022
1 parent 573b7eb commit 72bd96c
Show file tree
Hide file tree
Showing 31 changed files with 1,872 additions and 863 deletions.
14 changes: 12 additions & 2 deletions JitsiMeetOutlook.sln
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30002.166
# Visual Studio Version 17
VisualStudioVersion = 17.2.32505.173
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JitsiMeetOutlook", "JitsiMeetOutlook\JitsiMeetOutlook.csproj", "{92DD44F5-9B8C-4D40-AE0E-9B1EDEE99449}"
EndProject
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "setup", "setup\setup.wixproj", "{85009CC8-078D-40E6-B4A5-F097D6B04C72}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SettingsInstallerParameters", "SettingsInstallerParameters\SettingsInstallerParameters.csproj", "{1963A813-D744-49E1-B08B-9DB661C8850E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JitsiMeetOutlookTests", "JitsiMeetOutlookTests\JitsiMeetOutlookTests.csproj", "{B355F03D-DB54-426C-BD96-59E3CF66EEA1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -41,6 +43,14 @@ Global
{1963A813-D744-49E1-B08B-9DB661C8850E}.Release|Any CPU.Build.0 = Release|x86
{1963A813-D744-49E1-B08B-9DB661C8850E}.Release|x86.ActiveCfg = Release|x86
{1963A813-D744-49E1-B08B-9DB661C8850E}.Release|x86.Build.0 = Release|x86
{B355F03D-DB54-426C-BD96-59E3CF66EEA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B355F03D-DB54-426C-BD96-59E3CF66EEA1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B355F03D-DB54-426C-BD96-59E3CF66EEA1}.Debug|x86.ActiveCfg = Debug|Any CPU
{B355F03D-DB54-426C-BD96-59E3CF66EEA1}.Debug|x86.Build.0 = Debug|Any CPU
{B355F03D-DB54-426C-BD96-59E3CF66EEA1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B355F03D-DB54-426C-BD96-59E3CF66EEA1}.Release|Any CPU.Build.0 = Release|Any CPU
{B355F03D-DB54-426C-BD96-59E3CF66EEA1}.Release|x86.ActiveCfg = Release|Any CPU
{B355F03D-DB54-426C-BD96-59E3CF66EEA1}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
57 changes: 41 additions & 16 deletions JitsiMeetOutlook/AppointmentRibbonGroup.Designer.cs

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

138 changes: 111 additions & 27 deletions JitsiMeetOutlook/AppointmentRibbonGroup.controls.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System.Linq;
using Outlook = Microsoft.Office.Interop.Outlook;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace JitsiMeetOutlook
{
Expand All @@ -14,16 +16,89 @@ private void initialise()
// Set language
setLanguage();

// Assign the domain prevailing at appointment item launch
Properties.Settings.Default.Reload();
oldDomain = Properties.Settings.Default.Domain;

// Assign the relevant appointment item
Outlook.Inspector inspector = (Outlook.Inspector)this.Context;
appointmentItem = inspector.CurrentItem as Outlook.AppointmentItem;

// Assign the domain prevailing at appointment item launch
Properties.Settings.Default.Reload();
oldDomain = Properties.Settings.Default.Domain;
// Display Ribbon if this is a Jitsi Meeting
MessageBox.Show("DEBUG: " + appointmentItem.Location);

if (appointmentItem.Location == "Jitsi Meet")
{
groupJitsiMeetControls.Visible = true;
groupNewMeeting.Visible = false;
InitializeRibbonWithCurrentData();
}
else
{
groupNewMeeting.Visible = true;
groupJitsiMeetControls.Visible = false;
}


}

public void setRoomId(string newRoomId)

private void InitializeRibbonWithCurrentData()
{
var roomId = Utils.findRoomId(appointmentItem.Body, oldDomain);
if (roomId != string.Empty)
{
// The Meeting already exists
// TODO: Not working correctly because edited body are in RTF Format
// Update Conrol State from the embedded text
setRoomIdText(roomId);

var url = Utils.GetUrl(appointmentItem.Body, oldDomain);
if (Utils.SettingIsActive(url, "requireDisplayName"))
{
buttonRequireDisplayName.Checked = true;
}
if (Utils.SettingIsActive(url, "startWithAudioMuted"))
{
buttonStartWithAudioMuted.Checked = true;
}
if (Utils.SettingIsActive(url, "startWithVideoMuted"))
{
buttonStartWithVideoMuted.Checked = true;
}

}
else
{
// New Meeting
if (Properties.Settings.Default.roomID.Length == 0)
{
randomiseRoomId();
}
else
{
setRoomId(Properties.Settings.Default.roomID);
}
if (Properties.Settings.Default.requireDisplayName)
{
toggleRequireName();
buttonRequireDisplayName.Checked = true;
}
if (Properties.Settings.Default.startWithAudioMuted)
{
toggleMuteOnStart();
buttonStartWithAudioMuted.Checked = true;
}
if (Properties.Settings.Default.startWithVideoMuted)
{
toggleVideoOnStart();
buttonStartWithVideoMuted.Checked = true;
}
}

}

public async void setRoomId(string newRoomId)
{
string newDomain = JitsiUrl.getDomain();
string oldBody = appointmentItem.Body;
Expand All @@ -35,51 +110,45 @@ public void setRoomId(string newRoomId)
try
{
// Replace old domain for new domain
newBody = oldBody.Replace(findRoomId(), newRoomIdLegal);
newBody = oldBody.Replace(Utils.findRoomId(appointmentItem.Body, oldDomain), newRoomIdLegal);
newBody = newBody.Replace(oldDomain, newDomain);
newBody = await generateBody(newRoomIdLegal);
}
catch
{
// If replacement failed, append new message text
if (string.IsNullOrWhiteSpace(oldBody))
{
newBody = NewJitsiAppointment.generateBody(newRoomIdLegal);
newBody = await generateBody(newRoomIdLegal);
}
else
{
newBody = oldBody + "\n" + NewJitsiAppointment.generateBody(newRoomIdLegal);
newBody = oldBody + "\n" + generateBody(newRoomIdLegal);
}

this.buttonStartWithAudioMuted.Checked = false;
this.buttonStartWithVideoMuted.Checked = false;
this.buttonRequireDisplayName.Checked = false;

}


fieldRoomID.Text = newRoomIdLegal;
appointmentItem.Body = newBody;

oldDomain = newDomain;
}


private string escapeDomain()
{
string escapedDomain = Regex.Escape(oldDomain);
if (!escapedDomain.EndsWith("/"))
{
escapedDomain += "/";
}
return escapedDomain;
}

public string findRoomId()
public static async Task<string> generateBody(string roomId)
{
string roomId = Regex.Match(appointmentItem.Body, "(?<=" + escapeDomain() + ")\\S+?(?=(#config|&config|\\s))").Value; // Match all non-blanks after jitsi url and before config or end
return roomId;
return Globals.ThisAddIn.getElementTranslation("appointmentItem", "textBodyMessage")
+ (JitsiUrl.getUrlBase() + roomId)
+ Globals.ThisAddIn.getElementTranslation("appointmentItem", "textBodyMessagePhone")
+ await Globals.ThisAddIn.JitsiApiService.getPhoneNumbers(roomId)
+ Globals.ThisAddIn.getElementTranslation("appointmentItem", "textBodyPin")
+ await Globals.ThisAddIn.JitsiApiService.getPIN(roomId)
+ Globals.ThisAddIn.getElementTranslation("appointmentItem", "textBodyDisclaimer");
}


public void randomiseRoomId()
{
setRoomId(JitsiUrl.generateRandomId());
Expand All @@ -99,19 +168,34 @@ public void toggleRequireName()
toggleSetting("requireDisplayName");
}

private void setRoomIdText(string roomIdText)
{
if (roomIdText != null)
{
fieldRoomID.Text = roomIdText;
}
}

private void addJitsiMeeting()
{
appointmentItem.Location = "Jitsi Meet";
initialise();

}

private void toggleSetting(string setting)
{
// Find Jitsi URL in message
string oldBody = appointmentItem.Body;
string urlMatch = Regex.Match(oldBody, escapeDomain() + "\\S+").Value;
string urlMatch = Utils.GetUrl(oldBody, oldDomain);

// Remove setting if present
string urlNew;
if (urlMatch.Contains("config." + setting + "=true"))
if (Utils.SettingIsActive(urlMatch, setting))
{
urlNew = Regex.Replace(urlMatch, "(#|&)config\\." + setting + "=true", "");
}
}

// Otherwise add
else
{
Expand Down
8 changes: 2 additions & 6 deletions JitsiMeetOutlook/AppointmentRibbonGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ public partial class AppointmentRibbonGroup

private void AppointmentRibbonGroup_Load(object sender, RibbonUIEventArgs e)
{
displayRibbonGroup();
initialise();
}

Expand Down Expand Up @@ -43,12 +42,9 @@ private void buttonStartWithVideoMuted_Click(object sender, RibbonControlEventAr
toggleVideoOnStart();
}

private void displayRibbonGroup()
private void buttonNewJitsiMeeting_Click(object sender, RibbonControlEventArgs e)
{
if(Globals.ThisAddIn.ShowRibbonAppointment)
{
groupJitsiMeet.Visible = true;
}
addJitsiMeeting();
}
}
}
Loading

0 comments on commit 72bd96c

Please sign in to comment.