/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ 'use strict'; import { TPromise } from 'vs/base/common/winjs.base'; import { IChannel } from 'vs/base/parts/ipc/common/ipc'; import { Event, buffer } from 'vs/base/common/event'; import { ILocalizationsService, LanguageType } from 'vs/platform/localizations/common/localizations'; export interface ILocalizationsChannel extends IChannel { listen(event: 'onDidLanguagesChange'): Event; listen(event: string, arg?: any): Event; call(command: 'getLanguageIds'): TPromise; call(command: string, arg?: any): TPromise; } export class LocalizationsChannel implements ILocalizationsChannel { onDidLanguagesChange: Event; constructor(private service: ILocalizationsService) { this.onDidLanguagesChange = buffer(service.onDidLanguagesChange, true); } listen(event: string): Event { switch (event) { case 'onDidLanguagesChange': return this.onDidLanguagesChange; } throw new Error('No event found'); } call(command: string, arg?: any): TPromise { switch (command) { case 'getLanguageIds': return this.service.getLanguageIds(arg); } return undefined; } } export class LocalizationsChannelClient implements ILocalizationsService { _serviceBrand: any; constructor(private channel: ILocalizationsChannel) { } get onDidLanguagesChange(): Event { return this.channel.listen('onDidLanguagesChange'); } getLanguageIds(type?: LanguageType): TPromise { return this.channel.call('getLanguageIds', type); } }