Skip to content

Commit 72bd96c

Browse files
wip
1 parent 573b7eb commit 72bd96c

31 files changed

+1872
-863
lines changed

JitsiMeetOutlook.sln

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.30002.166
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.2.32505.173
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JitsiMeetOutlook", "JitsiMeetOutlook\JitsiMeetOutlook.csproj", "{92DD44F5-9B8C-4D40-AE0E-9B1EDEE99449}"
77
EndProject
88
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "setup", "setup\setup.wixproj", "{85009CC8-078D-40E6-B4A5-F097D6B04C72}"
99
EndProject
1010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SettingsInstallerParameters", "SettingsInstallerParameters\SettingsInstallerParameters.csproj", "{1963A813-D744-49E1-B08B-9DB661C8850E}"
1111
EndProject
12+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JitsiMeetOutlookTests", "JitsiMeetOutlookTests\JitsiMeetOutlookTests.csproj", "{B355F03D-DB54-426C-BD96-59E3CF66EEA1}"
13+
EndProject
1214
Global
1315
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1416
Debug|Any CPU = Debug|Any CPU
@@ -41,6 +43,14 @@ Global
4143
{1963A813-D744-49E1-B08B-9DB661C8850E}.Release|Any CPU.Build.0 = Release|x86
4244
{1963A813-D744-49E1-B08B-9DB661C8850E}.Release|x86.ActiveCfg = Release|x86
4345
{1963A813-D744-49E1-B08B-9DB661C8850E}.Release|x86.Build.0 = Release|x86
46+
{B355F03D-DB54-426C-BD96-59E3CF66EEA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
47+
{B355F03D-DB54-426C-BD96-59E3CF66EEA1}.Debug|Any CPU.Build.0 = Debug|Any CPU
48+
{B355F03D-DB54-426C-BD96-59E3CF66EEA1}.Debug|x86.ActiveCfg = Debug|Any CPU
49+
{B355F03D-DB54-426C-BD96-59E3CF66EEA1}.Debug|x86.Build.0 = Debug|Any CPU
50+
{B355F03D-DB54-426C-BD96-59E3CF66EEA1}.Release|Any CPU.ActiveCfg = Release|Any CPU
51+
{B355F03D-DB54-426C-BD96-59E3CF66EEA1}.Release|Any CPU.Build.0 = Release|Any CPU
52+
{B355F03D-DB54-426C-BD96-59E3CF66EEA1}.Release|x86.ActiveCfg = Release|Any CPU
53+
{B355F03D-DB54-426C-BD96-59E3CF66EEA1}.Release|x86.Build.0 = Release|Any CPU
4454
EndGlobalSection
4555
GlobalSection(SolutionProperties) = preSolution
4656
HideSolutionNode = FALSE

JitsiMeetOutlook/AppointmentRibbonGroup.Designer.cs

+41-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

JitsiMeetOutlook/AppointmentRibbonGroup.controls.cs

+111-27
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System.Linq;
22
using Outlook = Microsoft.Office.Interop.Outlook;
33
using System.Text.RegularExpressions;
4+
using System.Threading.Tasks;
5+
using System.Windows.Forms;
46

57
namespace JitsiMeetOutlook
68
{
@@ -14,16 +16,89 @@ private void initialise()
1416
// Set language
1517
setLanguage();
1618

19+
// Assign the domain prevailing at appointment item launch
20+
Properties.Settings.Default.Reload();
21+
oldDomain = Properties.Settings.Default.Domain;
22+
1723
// Assign the relevant appointment item
1824
Outlook.Inspector inspector = (Outlook.Inspector)this.Context;
1925
appointmentItem = inspector.CurrentItem as Outlook.AppointmentItem;
2026

21-
// Assign the domain prevailing at appointment item launch
22-
Properties.Settings.Default.Reload();
23-
oldDomain = Properties.Settings.Default.Domain;
27+
// Display Ribbon if this is a Jitsi Meeting
28+
MessageBox.Show("DEBUG: " + appointmentItem.Location);
29+
30+
if (appointmentItem.Location == "Jitsi Meet")
31+
{
32+
groupJitsiMeetControls.Visible = true;
33+
groupNewMeeting.Visible = false;
34+
InitializeRibbonWithCurrentData();
35+
}
36+
else
37+
{
38+
groupNewMeeting.Visible = true;
39+
groupJitsiMeetControls.Visible = false;
40+
}
41+
42+
2443
}
2544

26-
public void setRoomId(string newRoomId)
45+
46+
private void InitializeRibbonWithCurrentData()
47+
{
48+
var roomId = Utils.findRoomId(appointmentItem.Body, oldDomain);
49+
if (roomId != string.Empty)
50+
{
51+
// The Meeting already exists
52+
// TODO: Not working correctly because edited body are in RTF Format
53+
// Update Conrol State from the embedded text
54+
setRoomIdText(roomId);
55+
56+
var url = Utils.GetUrl(appointmentItem.Body, oldDomain);
57+
if (Utils.SettingIsActive(url, "requireDisplayName"))
58+
{
59+
buttonRequireDisplayName.Checked = true;
60+
}
61+
if (Utils.SettingIsActive(url, "startWithAudioMuted"))
62+
{
63+
buttonStartWithAudioMuted.Checked = true;
64+
}
65+
if (Utils.SettingIsActive(url, "startWithVideoMuted"))
66+
{
67+
buttonStartWithVideoMuted.Checked = true;
68+
}
69+
70+
}
71+
else
72+
{
73+
// New Meeting
74+
if (Properties.Settings.Default.roomID.Length == 0)
75+
{
76+
randomiseRoomId();
77+
}
78+
else
79+
{
80+
setRoomId(Properties.Settings.Default.roomID);
81+
}
82+
if (Properties.Settings.Default.requireDisplayName)
83+
{
84+
toggleRequireName();
85+
buttonRequireDisplayName.Checked = true;
86+
}
87+
if (Properties.Settings.Default.startWithAudioMuted)
88+
{
89+
toggleMuteOnStart();
90+
buttonStartWithAudioMuted.Checked = true;
91+
}
92+
if (Properties.Settings.Default.startWithVideoMuted)
93+
{
94+
toggleVideoOnStart();
95+
buttonStartWithVideoMuted.Checked = true;
96+
}
97+
}
98+
99+
}
100+
101+
public async void setRoomId(string newRoomId)
27102
{
28103
string newDomain = JitsiUrl.getDomain();
29104
string oldBody = appointmentItem.Body;
@@ -35,51 +110,45 @@ public void setRoomId(string newRoomId)
35110
try
36111
{
37112
// Replace old domain for new domain
38-
newBody = oldBody.Replace(findRoomId(), newRoomIdLegal);
113+
newBody = oldBody.Replace(Utils.findRoomId(appointmentItem.Body, oldDomain), newRoomIdLegal);
39114
newBody = newBody.Replace(oldDomain, newDomain);
115+
newBody = await generateBody(newRoomIdLegal);
40116
}
41117
catch
42118
{
43119
// If replacement failed, append new message text
44120
if (string.IsNullOrWhiteSpace(oldBody))
45121
{
46-
newBody = NewJitsiAppointment.generateBody(newRoomIdLegal);
122+
newBody = await generateBody(newRoomIdLegal);
47123
}
48124
else
49125
{
50-
newBody = oldBody + "\n" + NewJitsiAppointment.generateBody(newRoomIdLegal);
126+
newBody = oldBody + "\n" + generateBody(newRoomIdLegal);
51127
}
52128

53129
this.buttonStartWithAudioMuted.Checked = false;
54130
this.buttonStartWithVideoMuted.Checked = false;
55131
this.buttonRequireDisplayName.Checked = false;
56-
57132
}
58133

59-
60134
fieldRoomID.Text = newRoomIdLegal;
61135
appointmentItem.Body = newBody;
62136

63137
oldDomain = newDomain;
64-
}
65-
66-
67-
private string escapeDomain()
68-
{
69-
string escapedDomain = Regex.Escape(oldDomain);
70-
if (!escapedDomain.EndsWith("/"))
71-
{
72-
escapedDomain += "/";
73-
}
74-
return escapedDomain;
75138
}
76139

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

151+
83152
public void randomiseRoomId()
84153
{
85154
setRoomId(JitsiUrl.generateRandomId());
@@ -99,19 +168,34 @@ public void toggleRequireName()
99168
toggleSetting("requireDisplayName");
100169
}
101170

171+
private void setRoomIdText(string roomIdText)
172+
{
173+
if (roomIdText != null)
174+
{
175+
fieldRoomID.Text = roomIdText;
176+
}
177+
}
178+
179+
private void addJitsiMeeting()
180+
{
181+
appointmentItem.Location = "Jitsi Meet";
182+
initialise();
183+
184+
}
185+
102186
private void toggleSetting(string setting)
103187
{
104188
// Find Jitsi URL in message
105189
string oldBody = appointmentItem.Body;
106-
string urlMatch = Regex.Match(oldBody, escapeDomain() + "\\S+").Value;
190+
string urlMatch = Utils.GetUrl(oldBody, oldDomain);
107191

108192
// Remove setting if present
109193
string urlNew;
110-
if (urlMatch.Contains("config." + setting + "=true"))
194+
if (Utils.SettingIsActive(urlMatch, setting))
111195
{
112196
urlNew = Regex.Replace(urlMatch, "(#|&)config\\." + setting + "=true", "");
113-
}
114-
197+
}
198+
115199
// Otherwise add
116200
else
117201
{

JitsiMeetOutlook/AppointmentRibbonGroup.cs

+2-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ public partial class AppointmentRibbonGroup
77

88
private void AppointmentRibbonGroup_Load(object sender, RibbonUIEventArgs e)
99
{
10-
displayRibbonGroup();
1110
initialise();
1211
}
1312

@@ -43,12 +42,9 @@ private void buttonStartWithVideoMuted_Click(object sender, RibbonControlEventAr
4342
toggleVideoOnStart();
4443
}
4544

46-
private void displayRibbonGroup()
45+
private void buttonNewJitsiMeeting_Click(object sender, RibbonControlEventArgs e)
4746
{
48-
if(Globals.ThisAddIn.ShowRibbonAppointment)
49-
{
50-
groupJitsiMeet.Visible = true;
51-
}
47+
addJitsiMeeting();
5248
}
5349
}
5450
}

0 commit comments

Comments
 (0)