Skip to content

Commit

Permalink
removing more teams-v1 logic
Browse files Browse the repository at this point in the history
  • Loading branch information
IsmaelMartinez committed Nov 25, 2024
2 parents 9cbcd55 + 4d87ad1 commit 614a72f
Show file tree
Hide file tree
Showing 13 changed files with 115 additions and 404 deletions.
10 changes: 6 additions & 4 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ For that reason, decided to refork it and fix a few things that where not workin

To be able to use a few github functionalities, it was decided to unfork the project [#87](https://github.com/IsmaelMartinez/teams-for-linux/issues/87).

The original idea was to let the project die when Microsoft would implement a desktop client for linux, as requested on the [Microsoft Suggestions Forum](https://microsoftteams.uservoice.com/forums/555103-public/suggestions/16911565-linux-client). Microsoft released a linux client on February 13, 2020 ([Download](https://www.microsoft.com/en-us/microsoft-365/microsoft-teams/download-app#desktopAppDownloadregion), [Instructions](https://docs.microsoft.com/en-us/microsoftteams/get-clients#linux)).
However, the development of this project continued, as it is suprior on some aspects (screen share able to share single windows, normal window border [#281](https://github.com/IsmaelMartinez/teams-for-linux/issues/281#issuecomment-601578412), command-line interface, and, of course, open-source).
The original idea was to let the project die when Microsoft implemented a desktop client for Linux, as requested on the [Microsoft Suggestions Forum](https://microsoftteams.uservoice.com/forums/555103-public/suggestions/16911565-linux-client). Microsoft did released a Linux client on early 2020.

Currently, the project is in a stable condition, and should continue as long as needed. Non stable versions are released as pre-release.
IsmaelMartinez is not "implementing new features, only fixing issues, but happy to help and accept new PRs" ([351](https://github.com/IsmaelMartinez/teams-for-linux/issues/351#issuecomment-626590582)).
However, by the [end of 2022](https://learn.microsoft.com/en-us/answers/questions/1791839/where-is-teams-for-linux) Microsoft stopped its support, urging users to use the [PWA version](https://techcommunity.microsoft.com/blog/microsoftteamsblog/microsoft-teams-progressive-web-app-now-available-on-linux/3669846).

Support for this project continues as some users still prefer this open-source version. Their contributions keep the project alive and are a significant part of this growing community.

Currently, the project is stable and will continue as long as the community needs it. Non-stable versions are released as pre-releases. We appreciate any contributions, whether they are issues, ideas, PRs, or anything in between. These contributions are what keep this project thriving.
2 changes: 0 additions & 2 deletions app/browser/notifications/activityManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ class ActivityManager {

start() {
setActivityHandlers(this);
activityHub.start();
activityHub.setDefaultTitle(this.config.appTitle);
this.watchSystemIdleState();
}

Expand Down
247 changes: 0 additions & 247 deletions app/browser/tools/activityHub.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const instance = require('./instance');
const ReactHandler = require('./reactHandler');
const eventHandlers = [];

Expand All @@ -23,20 +22,6 @@ class ActivityHub {
return removeEventHandler(event, handle);
}

start() {
instance.whenReady().then(assignEventHandlers).catch(() => {
console.error('Failed to start Activity Hub by assigning Event Handlers');
});
}

setDefaultTitle(title) {
instance.whenReady().then(inst => {
inst.controller.pageTitleDefault = title;
}).catch(() => {
console.error('Failed to set Default Title');
});
}

setMachineState(state) {
const teams2IdleTracker = ReactHandler.getTeams2IdleTracker();
if (teams2IdleTracker) {
Expand All @@ -50,16 +35,6 @@ class ActivityHub {
} catch (e) {
console.error('Failed to set teams2 Machine State', e);
}
} else {
instance.whenReady().then((inst) => {
if (state === 1) {
this.refreshAppState(inst.controller, state);
} else {
inst.controller.appStateService.setMachineState(state);
}
}).catch(() => {
console.error('Failed to set Machine State');
});
}
}

Expand All @@ -76,12 +51,6 @@ class ActivityHub {
} catch (e) {
console.error('Failed to set teams2 User Status', e);
}
} else {
instance.whenReady().then((inst) => {
inst.injector.get('presenceService').setMyStatus(status, null, true);
}).catch(() => {
console.error('Failed to set User Status');
});
}
}

Expand Down Expand Up @@ -135,222 +104,6 @@ function removeEventHandler(event, handle) {
return null;
}

function getEventHandlers(event) {
return eventHandlers.filter(e => {
return e.event === event;
});
}

function assignEventHandlers(inst) {
assignActivitiesCountUpdateHandler(inst.controller);
assignIncomingCallCreatedHandler(inst.controller);
assignIncomingCallConnectingHandler(inst.controller);
assignIncomingCallDisconnectingHandler(inst.controller);
assignCallConnectedHandler(inst.controller);
assignCallDisconnectedHandler(inst.controller);
assignWorkerMessagingUpdatesHandler(inst.controller);
assignMyStatusChangedHandler(inst.controller);
performPlatformTweaks(inst.controller);
}

function performPlatformTweaks(controller) {
const isRunningOnWindows = process.platform === 'win32' || process.platform === 'linux';
controller.callingService.callingAlertsService.isRunningOnWindows = () => isRunningOnWindows;
}

function getMeetingEvents(data) {
return data.filter(d => {
return d.messagetype === 'Event/Call' && d.content === '<partlist alt =""></partlist>';
});
}

async function getActiveCaledarEvents(controller) {
await refreshCalendarEvents(controller);
const calendarEvents = controller.calendarService.getCachedEvents();
const rightNow = new Date();
return calendarEvents.filter(ce => {
return new Date(ce.endTime) - rightNow > 0;
});
}


async function refreshCalendarEvents(controller) {
const c = controller.calendarService.refreshCalendarEvents();
do {
await new Promise(r => setTimeout(r, 1000));
} while (c.$$state.status == 0);
return c.$$state.status;
}

async function getActiveMeetingEvents(controller, data) {
const workerEvents = getMeetingEvents(data);
if (workerEvents.length > 0) {
const calendarEvents = await getActiveCaledarEvents(controller);
return getMeetingNotificationList(workerEvents, calendarEvents);
} else {
return [];
}
}

function getMeetingNotificationList(workerEvents, calendarEvents) {
const notificationList = [];
for (const we of workerEvents) {
const meetingId = we.conversationLink.split('/')[1].split(';')[0];
addEligibleCalendarEvents(calendarEvents, meetingId, notificationList);
}
return notificationList;
}

function addEligibleCalendarEvents(calendarEvents, meetingId, notificationList) {
for (const ce of calendarEvents) {
if (ce.skypeTeamsData && JSON.parse(ce.skypeTeamsData).cid === meetingId) {
notificationList.push(ce);
break;
}
}
}

function assignActivitiesCountUpdateHandler(controller) {
controller.eventingService.$on(
controller.$scope,
controller.constants.events.notifications.bellCountUpdated,
() => onActivitiesCountUpdated(controller));

controller.chatListService.safeSubscribe(
controller.$scope,
() => onActivitiesCountUpdated(controller),
window.teamspace.services.ChatListServiceEvents.EventType_UnreadCount);
onActivitiesCountUpdated(controller);
}

function assignIncomingCallCreatedHandler(controller) {
controller.eventingService.$on(
controller.$scope,
controller.constants.events.calling.callCreated,
(e, data) => {
if (data.signalingSession.isIncomingCall) {
onIncomingCallCreated({ caller: data.signalingSession.remoteCaller.displayName });
}
});
}

function assignIncomingCallConnectingHandler(controller) {
controller.eventingService.$on(
controller.$scope,
controller.constants.events.calling.callConnecting,
(e, data) => {
if (data.signalingSession.isIncomingCall) {
onIncomingCallConnecting();
}
});
}

function assignIncomingCallDisconnectingHandler(controller) {
controller.eventingService.$on(
controller.$scope,
controller.constants.events.calling.callDisconnecting,
(e, data) => {
if (data.signalingSession.isIncomingCall) {
onIncomingCallDisconnecting();
}
});
}

function assignCallConnectedHandler(controller) {
controller.eventingService.$on(
controller.$scope,
controller.constants.events.calling.callConnected,
() => onCallConnected());
}

function assignCallDisconnectedHandler(controller) {
controller.eventingService.$on(
controller.$scope,
controller.constants.events.calling.callDisposed,
() => onCallDisconnected());
}

function assignWorkerMessagingUpdatesHandler(controller) {
controller.eventingService.$on(
controller.$scope,
controller.constants.events.workerMessagingUpdates.messageUpdatesFromWorker,
(event, data) => onMessageUpdatesFromWorker(controller, data));
}

function assignMyStatusChangedHandler(controller) {
controller.eventingService.$on(
controller.$scope,
controller.constants.events.presence.myStatusChanged,
(event, data) => onMyStatusChanged(controller, data));
}

async function onActivitiesCountUpdated(controller) {
const count = controller.bellNotificationsService.getNewActivitiesCount() + controller.chatListService.getUnreadCountFromChatList();
const handlers = getEventHandlers('activities-count-updated');
for (const handler of handlers) {
handler.handler({ count: count });
}
}

async function onIncomingCallCreated(data) {
const handlers = getEventHandlers('incoming-call-created');
for (const handler of handlers) {
handler.handler(data);
}
}

async function onIncomingCallConnecting() {
const handlers = getEventHandlers('incoming-call-connecting');
for (const handler of handlers) {
handler.handler({});
}
}

async function onIncomingCallDisconnecting() {
const handlers = getEventHandlers('incoming-call-disconnecting');
for (const handler of handlers) {
handler.handler({});
}
}

async function onCallConnected() {
const handlers = getEventHandlers('call-connected');
for (const handler of handlers) {
handler.handler({});
}
}

async function onCallDisconnected() {
const handlers = getEventHandlers('call-disconnected');
for (const handler of handlers) {
handler.handler({});
}
}

async function onMessageUpdatesFromWorker(controller, data) {
if (Array.isArray(data)) {
const handlers = getEventHandlers('meeting-started');
const events = await getActiveMeetingEvents(controller, data);
for (const e of events) {
callMeetingStartedEventHandlers(handlers, e);
}
}
}

function callMeetingStartedEventHandlers(handlers, e) {
for (const handler of handlers) {
handler.handler({
title: e.subject
});
}
}

async function onMyStatusChanged(controller, data) {
const handlers = getEventHandlers('my-status-changed');
for (const handler of handlers) {
handler.handler({ data: data, isInactive: window.teamspace.services.ApplicationState[controller.appStateService.current] === 'Inactive' || window.teamspace.services.ApplicationState[controller.appStateService.current] === 'LongInactive' });
}
}

const activityHub = new ActivityHub();
module.exports = activityHub;
42 changes: 2 additions & 40 deletions app/browser/tools/settings.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const instance = require('./instance');
const ReactHandler = require('./reactHandler');

class Settings {
Expand All @@ -11,21 +10,7 @@ class Settings {
async function retrieve(event) {
const clientPreferences = ReactHandler.getTeams2ClientPreferences();

if (!clientPreferences) {
console.warn('Failed to retrieve Teams settings from react');
const inst = await instance.whenReady().catch(() => {
console.warn('Failed to retrieve Teams settings from angular');
});
const settings = {
theme: inst.controller.layoutService.getTheme(),
chatDensity: inst.controller.layoutService.getChatDensity(),
devices: inst.controller.callingService._deviceManagerService.deviceManager.getSelectedDevices()
};
settings.devices.camera = getDeviceLabelFromId(inst.controller, settings.devices.camera, 1);
settings.devices.microphone = getDeviceLabelFromId(inst.controller, settings.devices.microphone, 2);
settings.devices.speaker = getDeviceLabelFromId(inst.controller, settings.devices.speaker, 3);
event.sender.send('get-teams-settings', settings);
} else {
if (clientPreferences) {
const settings = {
theme: clientPreferences.theme.userTheme,
chatDensity: clientPreferences.density.chatDensity,
Expand All @@ -34,37 +19,14 @@ async function retrieve(event) {
}
}

function getDeviceLabelFromId(controller, id, kind) {
const item = controller.callingService._deviceManagerService.devices.filter(f => f.id === id && f.kind === kind)[0];
return item ? item.label : '';
}

async function restore(event, ...args) {
const clientPreferences = ReactHandler.getTeams2ClientPreferences();

if (!clientPreferences) {
console.warn('Failed to retrieve Teams settings from react');
const inst = await instance.whenReady().catch(() => {
console.warn('Failed to retrieve Teams settings from angular');
});

inst.controller.layoutService.setTheme(args[0].theme);
inst.controller.layoutService.setChatDensity(args[0].chatDensity);
args[0].devices.camera = getDeviceIdFromLabel(inst.controller,args[0].devices.camera,1);
args[0].devices.microphone = getDeviceIdFromLabel(inst.controller,args[0].devices.microphone,2);
args[0].devices.speaker = getDeviceIdFromLabel(inst.controller,args[0].devices.speaker,3);
inst.controller.callingService._deviceManagerService.deviceManager.selectDevices(args[0].devices);
event.sender.send('set-teams-settings', true);
} else {
if (clientPreferences) {
clientPreferences.theme.userTheme = args[0].theme;
clientPreferences.density.chatDensity = args[0].chatDensity;
event.sender.send('set-teams-settings', true);
}
}

function getDeviceIdFromLabel(controller, label, kind) {
const item = controller.callingService._deviceManagerService.devices.filter(f => f.label === label && f.kind === kind)[0];
return item ? item.id : '';
}

module.exports = new Settings();
Loading

0 comments on commit 614a72f

Please sign in to comment.