Pārlūkot izejas kodu

Clean up types (#162)

Instead of using interfaces, we can just as well import the ES2015 types. It also reduces problems when importing external TS libraries. (The Threema type declarations predate ES2015 import support for Typescript.)
Danilo Bargen 8 gadi atpakaļ
vecāks
revīzija
4ae159b9d8

+ 4 - 2
src/controller_model/avatar.ts

@@ -15,14 +15,16 @@
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  */
  */
 
 
-export class AvatarControllerModel implements threema.AvatarControllerModel {
+import {WebClientService} from '../services/webclient';
+
+export class AvatarControllerModel {
     private $log: ng.ILogService;
     private $log: ng.ILogService;
     private avatar: ArrayBuffer = null;
     private avatar: ArrayBuffer = null;
     private loadAvatar: Promise<string>;
     private loadAvatar: Promise<string>;
     public onChangeAvatar: (image: ArrayBuffer) => void;
     public onChangeAvatar: (image: ArrayBuffer) => void;
 
 
     constructor($log: ng.ILogService,
     constructor($log: ng.ILogService,
-                webClientService: threema.WebClientService,
+                webClientService: WebClientService,
                 receiver: threema.Receiver) {
                 receiver: threema.Receiver) {
         this.$log = $log;
         this.$log = $log;
         this.loadAvatar = new Promise((resolve, reject) => {
         this.loadAvatar = new Promise((resolve, reject) => {

+ 4 - 3
src/controller_model/contact.ts

@@ -15,6 +15,7 @@
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  */
  */
 
 
+import {WebClientService} from '../services/webclient';
 import {ControllerModelMode} from '../types/enums';
 import {ControllerModelMode} from '../types/enums';
 import {AvatarControllerModel} from './avatar';
 import {AvatarControllerModel} from './avatar';
 
 
@@ -34,13 +35,13 @@ export class ContactControllerModel implements threema.ControllerModel {
     public isLoading = false;
     public isLoading = false;
 
 
     private contact: threema.ContactReceiver;
     private contact: threema.ContactReceiver;
-    private webClientService: threema.WebClientService;
+    private webClientService: WebClientService;
     private firstNameLabel: string;
     private firstNameLabel: string;
-    private avatarController: threema.AvatarControllerModel;
+    private avatarController: AvatarControllerModel;
     private mode = ControllerModelMode.NEW;
     private mode = ControllerModelMode.NEW;
 
 
     constructor($log: ng.ILogService, $translate: ng.translate.ITranslateService, $mdDialog: ng.material.IDialogService,
     constructor($log: ng.ILogService, $translate: ng.translate.ITranslateService, $mdDialog: ng.material.IDialogService,
-                webClientService: threema.WebClientService,
+                webClientService: WebClientService,
                 mode: ControllerModelMode,
                 mode: ControllerModelMode,
                 contact: threema.ContactReceiver = undefined) {
                 contact: threema.ContactReceiver = undefined) {
         this.$log = $log;
         this.$log = $log;

+ 3 - 2
src/controller_model/distributionList.ts

@@ -15,6 +15,7 @@
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  */
  */
 
 
+import {WebClientService} from '../services/webclient';
 import {ControllerModelMode} from '../types/enums';
 import {ControllerModelMode} from '../types/enums';
 
 
 export class DistributionListControllerModel implements threema.ControllerModel {
 export class DistributionListControllerModel implements threema.ControllerModel {
@@ -29,12 +30,12 @@ export class DistributionListControllerModel implements threema.ControllerModel
 
 
     private addContactPlaceholder: string;
     private addContactPlaceholder: string;
     private distributionList: threema.DistributionListReceiver;
     private distributionList: threema.DistributionListReceiver;
-    private webClientService: threema.WebClientService;
+    private webClientService: WebClientService;
     private mode: ControllerModelMode;
     private mode: ControllerModelMode;
     private onRemovedCallback: any;
     private onRemovedCallback: any;
 
 
     constructor($log: ng.ILogService, $translate: ng.translate.ITranslateService, $mdDialog: ng.material.IDialogService,
     constructor($log: ng.ILogService, $translate: ng.translate.ITranslateService, $mdDialog: ng.material.IDialogService,
-                webClientService: threema.WebClientService,
+                webClientService: WebClientService,
                 mode: ControllerModelMode,
                 mode: ControllerModelMode,
                 distributionList: threema.DistributionListReceiver = undefined) {
                 distributionList: threema.DistributionListReceiver = undefined) {
         this.$log = $log;
         this.$log = $log;

+ 4 - 3
src/controller_model/group.ts

@@ -15,6 +15,7 @@
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  */
  */
 
 
+import {WebClientService} from '../services/webclient';
 import {ControllerModelMode} from '../types/enums';
 import {ControllerModelMode} from '../types/enums';
 import {AvatarControllerModel} from './avatar';
 import {AvatarControllerModel} from './avatar';
 
 
@@ -30,13 +31,13 @@ export class GroupControllerModel implements threema.ControllerModel {
 
 
     private addContactPlaceholder: string;
     private addContactPlaceholder: string;
     private group: threema.GroupReceiver;
     private group: threema.GroupReceiver;
-    private webClientService: threema.WebClientService;
-    private avatarController: threema.AvatarControllerModel;
+    private webClientService: WebClientService;
+    private avatarController: AvatarControllerModel;
     private mode: ControllerModelMode;
     private mode: ControllerModelMode;
     private onRemovedCallback: any;
     private onRemovedCallback: any;
 
 
     constructor($log: ng.ILogService, $translate: ng.translate.ITranslateService, $mdDialog: ng.material.IDialogService,
     constructor($log: ng.ILogService, $translate: ng.translate.ITranslateService, $mdDialog: ng.material.IDialogService,
-                webClientService: threema.WebClientService,
+                webClientService: WebClientService,
                 mode: ControllerModelMode,
                 mode: ControllerModelMode,
                 group: threema.GroupReceiver = undefined) {
                 group: threema.GroupReceiver = undefined) {
         this.$log = $log;
         this.$log = $log;

+ 9 - 5
src/controllers/status.ts

@@ -15,6 +15,10 @@
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  */
  */
 
 
+import {ControllerService} from '../services/controller';
+import {StateService} from '../services/state';
+import {WebClientService} from '../services/webclient';
+
 /**
 /**
  * This controller handles state changes globally.
  * This controller handles state changes globally.
  *
  *
@@ -41,15 +45,15 @@ export class StatusController {
     private $log: ng.ILogService;
     private $log: ng.ILogService;
 
 
     // Custom services
     // Custom services
-    private stateService: threema.StateService;
-    private webClientService: threema.WebClientService;
-    private controllerService: threema.ControllerService;
+    private stateService: StateService;
+    private webClientService: WebClientService;
+    private controllerService: ControllerService;
 
 
     public static $inject = ['$scope', '$timeout', '$log', '$state', 'StateService',
     public static $inject = ['$scope', '$timeout', '$log', '$state', 'StateService',
         'WebClientService', 'ControllerService'];
         'WebClientService', 'ControllerService'];
     constructor($scope, $timeout: ng.ITimeoutService, $log: ng.ILogService, $state: ng.ui.IStateService,
     constructor($scope, $timeout: ng.ITimeoutService, $log: ng.ILogService, $state: ng.ui.IStateService,
-                stateService: threema.StateService, webClientService: threema.WebClientService,
-                controllerService: threema.ControllerService) {
+                stateService: StateService, webClientService: WebClientService,
+                controllerService: ControllerService) {
 
 
         // Angular services
         // Angular services
         this.$timeout = $timeout;
         this.$timeout = $timeout;

+ 3 - 1
src/directives/avatar.ts

@@ -15,13 +15,15 @@
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  */
  */
 
 
+import {WebClientService} from '../services/webclient';
+
 export default [
 export default [
     '$rootScope',
     '$rootScope',
     '$timeout',
     '$timeout',
     'WebClientService',
     'WebClientService',
     function($rootScope: ng.IRootScopeService,
     function($rootScope: ng.IRootScopeService,
              $timeout: ng.ITimeoutService,
              $timeout: ng.ITimeoutService,
-             webClientService: threema.WebClientService) {
+             webClientService: WebClientService) {
         return {
         return {
             restrict: 'E',
             restrict: 'E',
             scope: {},
             scope: {},

+ 5 - 2
src/directives/compose_area.ts

@@ -15,6 +15,9 @@
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  */
  */
 
 
+import {BrowserService} from '../services/browser';
+import {StringService} from '../services/string';
+
 /**
 /**
  * The compose area where messages are written.
  * The compose area where messages are written.
  */
  */
@@ -27,8 +30,8 @@ export default [
     '$mdDialog',
     '$mdDialog',
     '$filter',
     '$filter',
     '$log',
     '$log',
-    function(browserService: threema.BrowserService,
-             stringService: threema.StringService,
+    function(browserService: BrowserService,
+             stringService: StringService,
              $window, $timeout: ng.ITimeoutService,
              $window, $timeout: ng.ITimeoutService,
              $translate: ng.translate.ITranslateService,
              $translate: ng.translate.ITranslateService,
              $mdDialog: ng.material.IDialogService,
              $mdDialog: ng.material.IDialogService,

+ 3 - 1
src/directives/contact_badge.ts

@@ -17,13 +17,15 @@
 
 
 // tslint:disable:max-line-length
 // tslint:disable:max-line-length
 
 
+import {WebClientService} from '../services/webclient';
+
 /**
 /**
  * Show a contact receiver with small avatar, name and verification level
  * Show a contact receiver with small avatar, name and verification level
  */
  */
 export default [
 export default [
     'WebClientService',
     'WebClientService',
     '$state',
     '$state',
-    function(webClientService: threema.WebClientService, $state: ng.ui.IStateService) {
+    function(webClientService: WebClientService, $state: ng.ui.IStateService) {
         return {
         return {
             restrict: 'EA',
             restrict: 'EA',
             scope: {},
             scope: {},

+ 4 - 1
src/directives/latest_message.ts

@@ -15,9 +15,12 @@
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  */
  */
 
 
+import {ReceiverService} from '../services/receiver';
+import {WebClientService} from '../services/webclient';
+
 export default [
 export default [
     'WebClientService', 'ReceiverService',
     'WebClientService', 'ReceiverService',
-    function(webClientService: threema.WebClientService, receiverService: threema.ReceiverService) {
+    function(webClientService: WebClientService, receiverService: ReceiverService) {
         return {
         return {
             restrict: 'EA',
             restrict: 'EA',
             scope: {},
             scope: {},

+ 3 - 1
src/directives/member_list_editor.ts

@@ -15,9 +15,11 @@
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  */
  */
 
 
+import {WebClientService} from '../services/webclient';
+
 export default [
 export default [
     'WebClientService',
     'WebClientService',
-    function(webClientService: threema.WebClientService) {
+    function(webClientService: WebClientService) {
         return {
         return {
             restrict: 'EA',
             restrict: 'EA',
             scope: {},
             scope: {},

+ 6 - 2
src/directives/message.ts

@@ -15,6 +15,10 @@
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  */
  */
 
 
+import {MessageService} from '../services/message';
+import {ReceiverService} from '../services/receiver';
+import {WebClientService} from '../services/webclient';
+
 export default [
 export default [
     'WebClientService',
     'WebClientService',
     'MessageService',
     'MessageService',
@@ -23,8 +27,8 @@ export default [
     '$translate',
     '$translate',
     '$rootScope',
     '$rootScope',
     '$log',
     '$log',
-    function(webClientService: threema.WebClientService, messageService: threema.MessageService,
-             receiverService: threema.ReceiverService,
+    function(webClientService: WebClientService, messageService: MessageService,
+             receiverService: ReceiverService,
              $mdDialog: ng.material.IDialogService, $translate: ng.translate.ITranslateService,
              $mdDialog: ng.material.IDialogService, $translate: ng.translate.ITranslateService,
              $rootScope: ng.IRootScopeService, $log: ng.ILogService) {
              $rootScope: ng.IRootScopeService, $log: ng.ILogService) {
 
 

+ 4 - 1
src/directives/message_media.ts

@@ -15,6 +15,9 @@
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  */
  */
 
 
+import {MessageService} from '../services/message';
+import {WebClientService} from '../services/webclient';
+
 export default [
 export default [
     'WebClientService',
     'WebClientService',
     'MessageService',
     'MessageService',
@@ -23,7 +26,7 @@ export default [
     '$timeout',
     '$timeout',
     '$log',
     '$log',
     '$filter',
     '$filter',
-    function(webClientService: threema.WebClientService, messageService: threema.MessageService,
+    function(webClientService: WebClientService, messageService: MessageService,
              $rootScope: ng.IRootScopeService,
              $rootScope: ng.IRootScopeService,
              $mdDialog: ng.material.IDialogService,
              $mdDialog: ng.material.IDialogService,
              $timeout: ng.ITimeoutService, $log: ng.ILogService,
              $timeout: ng.ITimeoutService, $log: ng.ILogService,

+ 3 - 1
src/directives/message_quote.ts

@@ -15,11 +15,13 @@
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  */
  */
 
 
+import {WebClientService} from '../services/webclient';
+
 // tslint:disable:max-line-length
 // tslint:disable:max-line-length
 
 
 export default [
 export default [
     'WebClientService',
     'WebClientService',
-    function(webClientService: threema.WebClientService) {
+    function(webClientService: WebClientService) {
         return {
         return {
             restrict: 'EA',
             restrict: 'EA',
             scope: {},
             scope: {},

+ 5 - 2
src/directives/status_bar.ts

@@ -15,6 +15,9 @@
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  */
  */
 
 
+import {TrustedKeyStoreService} from '../services/keystore';
+import {StateService} from '../services/state';
+
 // tslint:disable:max-line-length
 // tslint:disable:max-line-length
 
 
 export default [
 export default [
@@ -22,8 +25,8 @@ export default [
     'TrustedKeyStore',
     'TrustedKeyStore',
     'StateService',
     'StateService',
     function($window: ng.IWindowService,
     function($window: ng.IWindowService,
-             trustedKeyStore: threema.TrustedKeyStoreService,
-             stateService: threema.StateService) {
+             trustedKeyStore: TrustedKeyStoreService,
+             stateService: StateService) {
         return {
         return {
             restrict: 'E',
             restrict: 'E',
             scope: {},
             scope: {},

+ 5 - 3
src/filters.ts

@@ -16,6 +16,8 @@
  */
  */
 
 
 import {filter} from './helpers';
 import {filter} from './helpers';
+import {MimeService} from './services/mime';
+import {WebClientService} from './services/webclient';
 
 
 angular.module('3ema.filters', [])
 angular.module('3ema.filters', [])
 
 
@@ -141,7 +143,7 @@ angular.module('3ema.filters', [])
 /**
 /**
  * Return whether contact is not me.
  * Return whether contact is not me.
  */
  */
-.filter('isNotMe', ['WebClientService', function(webClientService: threema.WebClientService) {
+.filter('isNotMe', ['WebClientService', function(webClientService: WebClientService) {
     return function(obj: threema.Receiver) {
     return function(obj: threema.Receiver) {
         const valid = (contact: threema.Receiver) => contact.id !== webClientService.receivers.me.id;
         const valid = (contact: threema.Receiver) => contact.id !== webClientService.receivers.me.id;
         return filter(obj, valid);
         return filter(obj, valid);
@@ -234,7 +236,7 @@ angular.module('3ema.filters', [])
         return (x + ' ' + ['B', 'kB', 'MB', 'GB', 'TB'][i]);
         return (x + ' ' + ['B', 'kB', 'MB', 'GB', 'TB'][i]);
     };
     };
 })
 })
-.filter('mimeType', ['MimeService', function(mimeService: threema.MimeService) {
+.filter('mimeType', ['MimeService', function(mimeService: MimeService) {
     return (mimeType: string, asText: boolean = true) => {
     return (mimeType: string, asText: boolean = true) => {
         if (asText) {
         if (asText) {
             return mimeService.getLabel(mimeType);
             return mimeService.getLabel(mimeType);
@@ -247,7 +249,7 @@ angular.module('3ema.filters', [])
 /**
 /**
  * Convert ID-Array to (Display-)Name-String, separated by ','
  * Convert ID-Array to (Display-)Name-String, separated by ','
  */
  */
-.filter('idsToNames', ['WebClientService', function (webClientService: threema.WebClientService) {
+.filter('idsToNames', ['WebClientService', function (webClientService: WebClientService) {
     return(ids: string[]) => {
     return(ids: string[]) => {
         let names: string[] = [];
         let names: string[] = [];
         for (let id of ids) {
         for (let id of ids) {

+ 40 - 29
src/partials/messenger.ts

@@ -17,7 +17,18 @@
 
 
 import {ContactControllerModel} from '../controller_model/contact';
 import {ContactControllerModel} from '../controller_model/contact';
 import {supportsPassive, throttle} from '../helpers';
 import {supportsPassive, throttle} from '../helpers';
+import {ContactService} from '../services/contact';
+import {ControllerService} from '../services/controller';
+import {ControllerModelService} from '../services/controller_model';
 import {ExecuteService} from '../services/execute';
 import {ExecuteService} from '../services/execute';
+import {FingerPrintService} from '../services/fingerprint';
+import {TrustedKeyStoreService} from '../services/keystore';
+import {MimeService} from '../services/mime';
+import {NotificationService} from '../services/notification';
+import {ReceiverService} from '../services/receiver';
+import {SettingsService} from '../services/settings';
+import {StateService} from '../services/state';
+import {WebClientService} from '../services/webclient';
 import {ControllerModelMode} from '../types/enums';
 import {ControllerModelMode} from '../types/enums';
 
 
 abstract class DialogController {
 abstract class DialogController {
@@ -88,8 +99,8 @@ class SettingsController {
 
 
     public $mdDialog: ng.material.IDialogService;
     public $mdDialog: ng.material.IDialogService;
     public $window: ng.IWindowService;
     public $window: ng.IWindowService;
-    public settingsService: threema.SettingsService;
-    private notificationService: threema.NotificationService;
+    public settingsService: SettingsService;
+    private notificationService: NotificationService;
     public activeElement: HTMLElement | null;
     public activeElement: HTMLElement | null;
 
 
     private desktopNotifications: boolean;
     private desktopNotifications: boolean;
@@ -99,8 +110,8 @@ class SettingsController {
 
 
     constructor($mdDialog: ng.material.IDialogService,
     constructor($mdDialog: ng.material.IDialogService,
                 $window: ng.IWindowService,
                 $window: ng.IWindowService,
-                settingsService: threema.SettingsService,
-                notificationService: threema.NotificationService) {
+                settingsService: SettingsService,
+                notificationService: NotificationService) {
         this.$mdDialog = $mdDialog;
         this.$mdDialog = $mdDialog;
         this.$window = $window;
         this.$window = $window;
         this.settingsService = settingsService;
         this.settingsService = settingsService;
@@ -150,10 +161,10 @@ class ConversationController {
     private $scope: ng.IScope;
     private $scope: ng.IScope;
 
 
     // Own services
     // Own services
-    private webClientService: threema.WebClientService;
-    private receiverService: threema.ReceiverService;
-    private stateService: threema.StateService;
-    private mimeService: threema.MimeService;
+    private webClientService: WebClientService;
+    private receiverService: ReceiverService;
+    private stateService: StateService;
+    private mimeService: MimeService;
 
 
     // Third party services
     // Third party services
     private $mdDialog: ng.material.IDialogService;
     private $mdDialog: ng.material.IDialogService;
@@ -201,10 +212,10 @@ class ConversationController {
                 $mdToast: ng.material.IToastService,
                 $mdToast: ng.material.IToastService,
                 $location,
                 $location,
                 $translate: ng.translate.ITranslateService,
                 $translate: ng.translate.ITranslateService,
-                webClientService: threema.WebClientService,
-                stateService: threema.StateService,
-                receiverService: threema.ReceiverService,
-                mimeService: threema.MimeService) {
+                webClientService: WebClientService,
+                stateService: StateService,
+                receiverService: ReceiverService,
+                mimeService: MimeService) {
         this.$stateParams = $stateParams;
         this.$stateParams = $stateParams;
         this.$timeout = $timeout;
         this.$timeout = $timeout;
         this.$log = $log;
         this.$log = $log;
@@ -577,10 +588,10 @@ class NavigationController {
 
 
     public name = 'navigation';
     public name = 'navigation';
 
 
-    private webClientService: threema.WebClientService;
-    private receiverService: threema.ReceiverService;
-    private stateService: threema.StateService;
-    private trustedKeyStoreService: threema.TrustedKeyStoreService;
+    private webClientService: WebClientService;
+    private receiverService: ReceiverService;
+    private stateService: StateService;
+    private trustedKeyStoreService: TrustedKeyStoreService;
 
 
     private activeTab: 'contacts' | 'conversations' = 'conversations';
     private activeTab: 'contacts' | 'conversations' = 'conversations';
     private searchVisible = false;
     private searchVisible = false;
@@ -597,9 +608,9 @@ class NavigationController {
 
 
     constructor($log: ng.ILogService, $state: ng.ui.IStateService,
     constructor($log: ng.ILogService, $state: ng.ui.IStateService,
                 $mdDialog: ng.material.IDialogService, $translate: ng.translate.ITranslateService,
                 $mdDialog: ng.material.IDialogService, $translate: ng.translate.ITranslateService,
-                webClientService: threema.WebClientService, stateService: threema.StateService,
-                receiverService: threema.ReceiverService,
-                trustedKeyStoreService: threema.TrustedKeyStoreService) {
+                webClientService: WebClientService, stateService: StateService,
+                receiverService: ReceiverService,
+                trustedKeyStoreService: TrustedKeyStoreService) {
 
 
         // Redirect to welcome if necessary
         // Redirect to welcome if necessary
         if (stateService.state === 'error') {
         if (stateService.state === 'error') {
@@ -783,9 +794,9 @@ class NavigationController {
 
 
 class MessengerController {
 class MessengerController {
     public name = 'messenger';
     public name = 'messenger';
-    private receiverService: threema.ReceiverService;
+    private receiverService: ReceiverService;
     private $state;
     private $state;
-    private webClientService: threema.WebClientService;
+    private webClientService: WebClientService;
 
 
     public static $inject = [
     public static $inject = [
         '$scope', '$state', '$log', '$mdDialog', '$translate',
         '$scope', '$state', '$log', '$mdDialog', '$translate',
@@ -793,8 +804,8 @@ class MessengerController {
     ];
     ];
     constructor($scope, $state, $log: ng.ILogService, $mdDialog: ng.material.IDialogService,
     constructor($scope, $state, $log: ng.ILogService, $mdDialog: ng.material.IDialogService,
                 $translate: ng.translate.ITranslateService,
                 $translate: ng.translate.ITranslateService,
-                stateService: threema.StateService, receiverService: threema.ReceiverService,
-                webClientService: threema.WebClientService, controllerService: threema.ControllerService) {
+                stateService: StateService, receiverService: ReceiverService,
+                webClientService: WebClientService, controllerService: ControllerService) {
         // Redirect to welcome if necessary
         // Redirect to welcome if necessary
         if (stateService.state === 'error') {
         if (stateService.state === 'error') {
             $log.debug('MessengerController: WebClient not yet running, redirecting to welcome screen');
             $log.debug('MessengerController: WebClient not yet running, redirecting to welcome screen');
@@ -859,8 +870,8 @@ class ReceiverDetailController {
     public receiver: threema.Receiver;
     public receiver: threema.Receiver;
     public title: string;
     public title: string;
     public fingerPrint?: string;
     public fingerPrint?: string;
-    private fingerPrintService: threema.FingerPrintService;
-    private contactService: threema.ContactService;
+    private fingerPrintService: FingerPrintService;
+    private contactService: ContactService;
     private showGroups = false;
     private showGroups = false;
     private showDistributionLists = false;
     private showDistributionLists = false;
     private inGroups: threema.GroupReceiver[] = [];
     private inGroups: threema.GroupReceiver[] = [];
@@ -875,8 +886,8 @@ class ReceiverDetailController {
         'WebClientService', 'FingerPrintService', 'ContactService', 'ControllerModelService',
         'WebClientService', 'FingerPrintService', 'ContactService', 'ControllerModelService',
     ];
     ];
     constructor($log: ng.ILogService, $stateParams, $state: ng.ui.IStateService, $mdDialog: ng.material.IDialogService,
     constructor($log: ng.ILogService, $stateParams, $state: ng.ui.IStateService, $mdDialog: ng.material.IDialogService,
-                webClientService: threema.WebClientService, fingerPrintService: threema.FingerPrintService,
-                contactService: threema.ContactService, controllerModelService: threema.ControllerModelService) {
+                webClientService: WebClientService, fingerPrintService: FingerPrintService,
+                contactService: ContactService, controllerModelService: ControllerModelService) {
 
 
         this.$mdDialog = $mdDialog;
         this.$mdDialog = $mdDialog;
         this.$state = $state;
         this.$state = $state;
@@ -983,7 +994,7 @@ class ReceiverEditController {
     ];
     ];
     constructor($log: ng.ILogService, $stateParams, $state: ng.ui.IStateService,
     constructor($log: ng.ILogService, $stateParams, $state: ng.ui.IStateService,
                 $mdDialog, $timeout: ng.ITimeoutService, $translate: ng.translate.ITranslateService,
                 $mdDialog, $timeout: ng.ITimeoutService, $translate: ng.translate.ITranslateService,
-                webClientService: threema.WebClientService, controllerModelService: threema.ControllerModelService) {
+                webClientService: WebClientService, controllerModelService: ControllerModelService) {
 
 
         this.$mdDialog = $mdDialog;
         this.$mdDialog = $mdDialog;
         this.$state = $state;
         this.$state = $state;
@@ -1073,7 +1084,7 @@ class ReceiverCreateController {
 
 
     constructor($stateParams: threema.CreateReceiverStateParams, $mdDialog, $mdToast, $translate,
     constructor($stateParams: threema.CreateReceiverStateParams, $mdDialog, $mdToast, $translate,
                 $timeout: ng.ITimeoutService, $state: ng.ui.IStateService, $log: ng.ILogService,
                 $timeout: ng.ITimeoutService, $state: ng.ui.IStateService, $log: ng.ILogService,
-                controllerModelService: threema.ControllerModelService) {
+                controllerModelService: ControllerModelService) {
         this.$mdDialog = $mdDialog;
         this.$mdDialog = $mdDialog;
         this.$timeout = $timeout;
         this.$timeout = $timeout;
         this.$state = $state;
         this.$state = $state;

+ 12 - 8
src/partials/welcome.ts

@@ -15,8 +15,12 @@
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  */
  */
 
 
-import {AvatarControllerModel} from '../controller_model/avatar';
+import {BrowserService} from '../services/browser';
+import {ControllerService} from '../services/controller';
 import {TrustedKeyStoreService} from '../services/keystore';
 import {TrustedKeyStoreService} from '../services/keystore';
+import {PushService} from '../services/push';
+import {StateService} from '../services/state';
+import {WebClientService} from '../services/webclient';
 
 
 class DialogController {
 class DialogController {
     // TODO: This is also used in partials/messenger.ts. We could somehow
     // TODO: This is also used in partials/messenger.ts. We could somehow
@@ -51,10 +55,10 @@ class WelcomeController {
     private $translate: ng.translate.ITranslateService;
     private $translate: ng.translate.ITranslateService;
 
 
     // Custom services
     // Custom services
-    private webClientService: threema.WebClientService;
+    private webClientService: WebClientService;
     private TrustedKeyStore: TrustedKeyStoreService;
     private TrustedKeyStore: TrustedKeyStoreService;
-    private pushService: threema.PushService;
-    private stateService: threema.StateService;
+    private pushService: PushService;
+    private stateService: StateService;
 
 
     // Other
     // Other
     public name = 'welcome';
     public name = 'welcome';
@@ -71,11 +75,11 @@ class WelcomeController {
                 $timeout: ng.ITimeoutService, $interval: ng.IIntervalService,
                 $timeout: ng.ITimeoutService, $interval: ng.IIntervalService,
                 $log: ng.ILogService, $window: ng.IWindowService, $mdDialog: ng.material.IDialogService,
                 $log: ng.ILogService, $window: ng.IWindowService, $mdDialog: ng.material.IDialogService,
                 $translate: ng.translate.ITranslateService,
                 $translate: ng.translate.ITranslateService,
-                webClientService: threema.WebClientService, TrustedKeyStore: TrustedKeyStoreService,
-                stateService: threema.StateService, pushService: threema.PushService,
-                browserService: threema.BrowserService,
+                webClientService: WebClientService, TrustedKeyStore: TrustedKeyStoreService,
+                stateService: StateService, pushService: PushService,
+                browserService: BrowserService,
                 minVersions: threema.BrowserMinVersions,
                 minVersions: threema.BrowserMinVersions,
-                controllerService: threema.ControllerService) {
+                controllerService: ControllerService) {
         controllerService.setControllerName('welcome');
         controllerService.setControllerName('welcome');
         // Angular services
         // Angular services
         this.$scope = $scope;
         this.$scope = $scope;

+ 1 - 1
src/services/browser.ts

@@ -15,7 +15,7 @@
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  */
  */
 
 
-export class BrowserService implements threema.BrowserService {
+export class BrowserService {
     private browser: threema.BrowserInfo;
     private browser: threema.BrowserInfo;
     private $log: ng.ILogService;
     private $log: ng.ILogService;
     private isPageVisible = true;
     private isPageVisible = true;

+ 5 - 3
src/services/contact.ts

@@ -15,11 +15,13 @@
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  */
  */
 
 
-export class ContactService implements threema.ContactService {
-    private webClientService: threema.WebClientService;
+import {WebClientService} from './webclient';
+
+export class ContactService {
+    private webClientService: WebClientService;
 
 
     public static $inject = ['WebClientService'];
     public static $inject = ['WebClientService'];
-    constructor(webClientService: threema.WebClientService) {
+    constructor(webClientService: WebClientService) {
         this.webClientService = webClientService;
         this.webClientService = webClientService;
     }
     }
 
 

+ 1 - 1
src/services/controller.ts

@@ -18,7 +18,7 @@
 /**
 /**
  * controller states
  * controller states
  */
  */
-export class ControllerService implements threema.ControllerService {
+export class ControllerService {
     private currentController: string;
     private currentController: string;
     private $log: ng.ILogService;
     private $log: ng.ILogService;
     public static $inject = ['$log'];
     public static $inject = ['$log'];

+ 4 - 3
src/services/controller_model.ts

@@ -19,19 +19,20 @@ import {ContactControllerModel} from '../controller_model/contact';
 import {DistributionListControllerModel} from '../controller_model/distributionList';
 import {DistributionListControllerModel} from '../controller_model/distributionList';
 import {GroupControllerModel} from '../controller_model/group';
 import {GroupControllerModel} from '../controller_model/group';
 import {ControllerModelMode} from '../types/enums';
 import {ControllerModelMode} from '../types/enums';
+import {WebClientService} from './webclient';
 
 
 /**
 /**
  * Factory to create ControllerModels
  * Factory to create ControllerModels
  */
  */
-export class ControllerModelService implements threema.ControllerModelService {
+export class ControllerModelService {
     private $log: ng.ILogService;
     private $log: ng.ILogService;
     private $translate: ng.translate.ITranslateService;
     private $translate: ng.translate.ITranslateService;
     private $mdDialog: ng.material.IDialogService;
     private $mdDialog: ng.material.IDialogService;
-    private webClientService: threema.WebClientService;
+    private webClientService: WebClientService;
 
 
     public static $inject = ['$log', '$translate', '$mdDialog', 'WebClientService'];
     public static $inject = ['$log', '$translate', '$mdDialog', 'WebClientService'];
     constructor($log: ng.ILogService, $translate: ng.translate.ITranslateService,
     constructor($log: ng.ILogService, $translate: ng.translate.ITranslateService,
-                $mdDialog: ng.material.IDialogService, webClientService: threema.WebClientService) {
+                $mdDialog: ng.material.IDialogService, webClientService: WebClientService) {
         this.$log = $log;
         this.$log = $log;
         this.$translate = $translate;
         this.$translate = $translate;
         this.$mdDialog = $mdDialog;
         this.$mdDialog = $mdDialog;

+ 1 - 1
src/services/fingerprint.ts

@@ -15,7 +15,7 @@
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  */
  */
 
 
-export class FingerPrintService implements threema.FingerPrintService {
+export class FingerPrintService {
     private $log: ng.ILogService;
     private $log: ng.ILogService;
 
 
     public static $inject = ['$log'];
     public static $inject = ['$log'];

+ 1 - 1
src/services/keystore.ts

@@ -37,7 +37,7 @@ import {stringToUtf8a, utf8aToString} from '../helpers';
  *     "<nonceHexString>:<encryptedHexString>"
  *     "<nonceHexString>:<encryptedHexString>"
  *
  *
  */
  */
-export class TrustedKeyStoreService implements threema.TrustedKeyStoreService {
+export class TrustedKeyStoreService {
     private static STORAGE_KEY = 'trusted';
     private static STORAGE_KEY = 'trusted';
 
 
     private logTag: string = '[TrustedKeyStoreService]';
     private logTag: string = '[TrustedKeyStoreService]';

+ 6 - 4
src/services/message.ts

@@ -15,7 +15,9 @@
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  */
  */
 
 
-class MessageAccess implements threema.MessageAccess {
+import {ReceiverService} from './receiver';
+
+export class MessageAccess {
     public quote = false;
     public quote = false;
     public ack = false;
     public ack = false;
     public dec = false;
     public dec = false;
@@ -24,13 +26,13 @@ class MessageAccess implements threema.MessageAccess {
     public copy = false;
     public copy = false;
 }
 }
 
 
-export class MessageService implements threema.MessageService {
+export class MessageService {
 
 
     private $log: ng.ILogService;
     private $log: ng.ILogService;
-    private receiverService: threema.ReceiverService;
+    private receiverService: ReceiverService;
 
 
     public static $inject = ['$log', 'ReceiverService'];
     public static $inject = ['$log', 'ReceiverService'];
-    constructor($log: ng.ILogService, receiverService: threema.ReceiverService) {
+    constructor($log: ng.ILogService, receiverService: ReceiverService) {
         this.$log = $log;
         this.$log = $log;
         this.receiverService = receiverService;
         this.receiverService = receiverService;
     }
     }

+ 1 - 1
src/services/mime.ts

@@ -15,7 +15,7 @@
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  */
  */
 
 
-export class MimeService implements threema.MimeService {
+export class MimeService {
     public static $inject = ['$log', '$translate'];
     public static $inject = ['$log', '$translate'];
 
 
     private $log: ng.ILogService;
     private $log: ng.ILogService;

+ 3 - 3
src/services/notification.ts

@@ -15,9 +15,9 @@
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  */
  */
 
 
-import Receiver = threema.Receiver;
-import SettingsService = threema.SettingsService;
-export class NotificationService implements threema.NotificationService {
+import {SettingsService} from './settings';
+
+export class NotificationService {
 
 
     private static SETTINGS_NOTIFICATIONS = 'notifications';
     private static SETTINGS_NOTIFICATIONS = 'notifications';
     private static SETTINGS_NOTIFICATION_PREVIEW = 'notificationPreview';
     private static SETTINGS_NOTIFICATION_PREVIEW = 'notificationPreview';

+ 1 - 1
src/services/push.ts

@@ -15,7 +15,7 @@
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  */
  */
 
 
-export class PushService implements threema.PushService {
+export class PushService {
     private static ARG_TOKEN = 'token';
     private static ARG_TOKEN = 'token';
     private static ARG_SESSION = 'session';
     private static ARG_SESSION = 'session';
     private static ARG_VERSION = 'version';
     private static ARG_VERSION = 'version';

+ 1 - 1
src/services/qrcode.ts

@@ -20,7 +20,7 @@ import {stringToUtf8a} from '../helpers';
 /**
 /**
  * Functionality related to the initial QR code.
  * Functionality related to the initial QR code.
  */
  */
-export class QrCodeService implements threema.QrCodeService {
+export class QrCodeService {
 
 
     private config: threema.Config;
     private config: threema.Config;
     private protocolVersion: number;
     private protocolVersion: number;

+ 1 - 1
src/services/receiver.ts

@@ -15,7 +15,7 @@
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  */
  */
 
 
-export class ReceiverService implements threema.ReceiverService {
+export class ReceiverService {
     private $log: ng.ILogService;
     private $log: ng.ILogService;
     private activeReceiver: threema.Receiver;
     private activeReceiver: threema.Receiver;
     public static $inject = ['$log'];
     public static $inject = ['$log'];

+ 1 - 1
src/services/settings.ts

@@ -19,7 +19,7 @@
  * The settings service can update variables for settings and persist them to
  * The settings service can update variables for settings and persist them to
  * LocalStorage.
  * LocalStorage.
  */
  */
-export class SettingsService implements threema.SettingsService {
+export class SettingsService {
     private $log: ng.ILogService;
     private $log: ng.ILogService;
 
 
     private static STORAGE_KEY_PREFIX = 'settings-';
     private static STORAGE_KEY_PREFIX = 'settings-';

+ 1 - 1
src/services/state.ts

@@ -15,7 +15,7 @@
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  */
  */
 
 
-export class StateService implements threema.StateService {
+export class StateService {
 
 
     // Angular services
     // Angular services
     private $log: ng.ILogService;
     private $log: ng.ILogService;

+ 1 - 1
src/services/string.ts

@@ -15,7 +15,7 @@
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  */
  */
 
 
-export class StringService implements threema.StringService {
+export class StringService {
     public byteChunk(str: string, byteLength: number, offset: number = null): string[] {
     public byteChunk(str: string, byteLength: number, offset: number = null): string[] {
         let chars = [...str];
         let chars = [...str];
         let chunks = [''];
         let chunks = [''];

+ 1 - 1
src/services/title.ts

@@ -18,7 +18,7 @@
 /**
 /**
  * The title service can update the window title.
  * The title service can update the window title.
  */
  */
-export class TitleService implements threema.TitleService {
+export class TitleService {
 
 
     private $log: ng.ILogService;
     private $log: ng.ILogService;
     private $document: ng.IDocumentService;
     private $document: ng.IDocumentService;

+ 33 - 23
src/services/webclient.ts

@@ -17,10 +17,20 @@
 
 
 import * as msgpack from 'msgpack-lite';
 import * as msgpack from 'msgpack-lite';
 import {hexToU8a} from '../helpers';
 import {hexToU8a} from '../helpers';
+import {BrowserService} from './browser';
+import {FingerPrintService} from './fingerprint';
 import {TrustedKeyStoreService} from './keystore';
 import {TrustedKeyStoreService} from './keystore';
+import {MessageService} from './message';
+import {MimeService} from './mime';
+import {NotificationService} from './notification';
 import {PeerConnectionHelper} from './peerconnection';
 import {PeerConnectionHelper} from './peerconnection';
+import {PushService} from './push';
+import {QrCodeService} from './qrcode';
+import {ReceiverService} from './receiver';
+import {StateService} from './state';
+import {TitleService} from './title';
 
 
-class WebClientDefault implements threema.WebClientDefault {
+class WebClientDefault {
     private avatar: threema.AvatarRegistry = {
     private avatar: threema.AvatarRegistry = {
         group: {
         group: {
             low: 'img/ic_group_t.png',
             low: 'img/ic_group_t.png',
@@ -53,7 +63,7 @@ class WebClientDefault implements threema.WebClientDefault {
 /**
 /**
  * This service handles everything related to the communication with the peer.
  * This service handles everything related to the communication with the peer.
  */
  */
-export class WebClientService implements threema.WebClientService {
+export class WebClientService {
     private static AVATAR_LOW_MAX_SIZE = 48;
     private static AVATAR_LOW_MAX_SIZE = 48;
     private static MAX_TEXT_LENGTH = 3500;
     private static MAX_TEXT_LENGTH = 3500;
     private static MAX_FILE_SIZE = 15 * 1024 * 1024;
     private static MAX_FILE_SIZE = 15 * 1024 * 1024;
@@ -124,15 +134,15 @@ export class WebClientService implements threema.WebClientService {
     private $timeout: ng.ITimeoutService;
     private $timeout: ng.ITimeoutService;
 
 
     // Custom services
     // Custom services
-    private notificationService: threema.NotificationService;
-    private messageService: threema.MessageService;
-    private pushService: threema.PushService;
-    private browserService: threema.BrowserService;
-    private titleService: threema.TitleService;
-    private fingerPrintService: threema.FingerPrintService;
-    private qrCodeService: threema.QrCodeService;
-    private mimeService: threema.MimeService;
-    private receiverService: threema.ReceiverService;
+    private notificationService: NotificationService;
+    private messageService: MessageService;
+    private pushService: PushService;
+    private browserService: BrowserService;
+    private titleService: TitleService;
+    private fingerPrintService: FingerPrintService;
+    private qrCodeService: QrCodeService;
+    private mimeService: MimeService;
+    private receiverService: ReceiverService;
 
 
     // State handling
     // State handling
     private startupPromise: ng.IDeferred<{}>; // TODO: deferred type
     private startupPromise: ng.IDeferred<{}>; // TODO: deferred type
@@ -140,7 +150,7 @@ export class WebClientService implements threema.WebClientService {
     private pendingInitializationStepRoutines: threema.InitializationStepRoutine[] = [];
     private pendingInitializationStepRoutines: threema.InitializationStepRoutine[] = [];
     private initialized: Set<threema.InitializationStep> = new Set();
     private initialized: Set<threema.InitializationStep> = new Set();
     private initializedThreshold = 3;
     private initializedThreshold = 3;
-    private state: threema.StateService;
+    private state: StateService;
 
 
     // SaltyRTC
     // SaltyRTC
     private saltyRtcHost: string = null;
     private saltyRtcHost: string = null;
@@ -153,7 +163,7 @@ export class WebClientService implements threema.WebClientService {
     public conversations: threema.Container.Conversations;
     public conversations: threema.Container.Conversations;
     public receivers: threema.Container.Receivers;
     public receivers: threema.Container.Receivers;
     public alerts: threema.Alert[] = [];
     public alerts: threema.Alert[] = [];
-    public defaults: threema.WebClientDefault;
+    public defaults: WebClientDefault;
     private myIdentity: threema.Identity;
     private myIdentity: threema.Identity;
     private pushToken: string = null;
     private pushToken: string = null;
 
 
@@ -196,16 +206,16 @@ export class WebClientService implements threema.WebClientService {
                 $timeout: ng.ITimeoutService,
                 $timeout: ng.ITimeoutService,
                 container: threema.Container.Factory,
                 container: threema.Container.Factory,
                 trustedKeyStore: TrustedKeyStoreService,
                 trustedKeyStore: TrustedKeyStoreService,
-                stateService: threema.StateService,
-                notificationService: threema.NotificationService,
-                messageService: threema.MessageService,
-                pushService: threema.PushService,
-                browserService: threema.BrowserService,
-                titleService: threema.TitleService,
-                fingerPrintService: threema.FingerPrintService,
-                qrCodeService: threema.QrCodeService,
-                mimeService: threema.MimeService,
-                receiverService: threema.ReceiverService,
+                stateService: StateService,
+                notificationService: NotificationService,
+                messageService: MessageService,
+                pushService: PushService,
+                browserService: BrowserService,
+                titleService: TitleService,
+                fingerPrintService: FingerPrintService,
+                qrCodeService: QrCodeService,
+                mimeService: MimeService,
+                receiverService: ReceiverService,
                 CONFIG: threema.Config) {
                 CONFIG: threema.Config) {
 
 
         // Angular services
         // Angular services

+ 0 - 216
src/threema.d.ts

@@ -44,8 +44,6 @@ declare namespace threema {
         data?: any;
         data?: any;
     }
     }
 
 
-    type WireMessageCallback = (message: WireMessage, result: any) => boolean;
-
     type MessageType = 'text' | 'image' | 'video' | 'audio' | 'location' | 'status' | 'ballot' | 'file';
     type MessageType = 'text' | 'image' | 'video' | 'audio' | 'location' | 'status' | 'ballot' | 'file';
     type MessageState = 'delivered' | 'read' | 'send-failed' | 'sent' | 'user-ack' | 'user-dec' | 'pending' | 'sending';
     type MessageState = 'delivered' | 'read' | 'send-failed' | 'sent' | 'user-ack' | 'user-dec' | 'pending' | 'sending';
     type InitializationStep = 'client info' | 'conversations' |  'receivers';
     type InitializationStep = 'client info' | 'conversations' |  'receivers';
@@ -265,11 +263,6 @@ declare namespace threema {
      */
      */
     type MessageContentType = 'text' | 'file';
     type MessageContentType = 'text' | 'file';
 
 
-    /**
-     * Possible message types sent to the receiver.
-     */
-    type MessageDataType = 'text' | 'file';
-
     interface MessageData {
     interface MessageData {
         // optional quote object
         // optional quote object
         quote?: Quote;
         quote?: Quote;
@@ -313,65 +306,6 @@ declare namespace threema {
         initParams: null | {identity: null};
         initParams: null | {identity: null};
     }
     }
 
 
-    /**
-     * State service.
-     */
-    interface StateService {
-        // WebRTC states
-        signalingConnectionState: saltyrtc.SignalingState;
-        rtcConnectionState: RTCConnectionState;
-
-        // Global connection state
-        state: 'ok' | 'warning' | 'error';
-        stage: 'signaling' | 'rtc';
-        wasConnected: boolean;
-
-        // Connection buildup
-        connectionBuildupState: ConnectionBuildupState;
-        progress: number;
-        slowConnect: boolean;
-
-        // Update states
-        updateSignalingConnectionState(state: saltyrtc.SignalingState): void;
-        updateRtcConnectionState(state: RTCConnectionState): void;
-        updateConnectionBuildupState(state: ConnectionBuildupState): void;
-
-        reset(): void;
-    }
-
-    /**
-     * Notification service.
-     */
-    interface NotificationService {
-        getNotificationPermission(): boolean;
-        getWantsNotifications(): boolean;
-        setWantsNotifications(wantsNotifications: boolean): void;
-        setWantsPreview(wantsPreview: boolean): void;
-        getWantsPreview(): boolean;
-        init(): void;
-        isNotificationApiAvailable(): boolean;
-        showNotification(id: string, title: string, body: string,
-                         avatar: string | null, clickCallback: any | null): boolean;
-        clearCache(tag: string): void;
-        hideNotification(tag: string): boolean;
-    }
-
-    interface MessageService {
-        getAccess(message: Message, receiver: Receiver): MessageAccess;
-        createTemporary(receiver: Receiver, type: string, messageData: MessageData): Message;
-        showStatusIcon(message: Message, receiver: Receiver): boolean;
-        getFileName(message: Message): string;
-    }
-
-    interface MessageAccess {
-        quote: boolean;
-        ack: boolean;
-        dec: boolean;
-        delete: boolean;
-        download: boolean;
-        copy: boolean;
-    }
-
     interface Quote {
     interface Quote {
         identity: string;
         identity: string;
         text: string;
         text: string;
@@ -391,22 +325,6 @@ declare namespace threema {
         pushToken: string | null;
         pushToken: string | null;
     }
     }
 
 
-    interface TrustedKeyStoreService {
-        blocked: boolean;
-        storeTrustedKey(ownPublicKey: Uint8Array, ownSecretKey: Uint8Array, peerPublicKey: Uint8Array,
-                        pushToken: string | null, password: string): void;
-        hasTrustedKey(): boolean;
-        retrieveTrustedKey(password: string): TrustedKeyStoreData;
-        clearTrustedKey(): void;
-    }
-
-    interface PushService {
-        init(pushToken: string): void;
-        reset(): void;
-        isAvailable(): boolean;
-        sendPush(session: Uint8Array): Promise<boolean>;
-    }
-
     interface BrowserInfo {
     interface BrowserInfo {
         chrome: boolean;
         chrome: boolean;
         firefox: boolean;
         firefox: boolean;
@@ -417,35 +335,6 @@ declare namespace threema {
         textInfo: string;
         textInfo: string;
     }
     }
 
 
-    interface BrowserService {
-        getBrowser(): BrowserInfo;
-        isVisible(): boolean;
-    }
-
-    interface TitleService {
-        updateUnreadCount(count: number): void;
-    }
-
-    interface FingerPrintService {
-        generate(publicKey: ArrayBuffer): string;
-    }
-
-    interface ContactService {
-        requiredDetails(contactReceiver: ContactReceiver): Promise<ContactReceiver>;
-    }
-
-    interface ControllerModelService {
-        contact(receiver: ContactReceiver, mode: any): ControllerModel;
-        group(receiver: GroupReceiver, mode: any): ControllerModel;
-        distributionList(receiver: DistributionListReceiver, mode: any): ControllerModel;
-    }
-
-    interface QrCodeService {
-        buildQrCodePayload(initiatorKey: Uint8Array, authToken: Uint8Array, serverKey: Uint8Array | null,
-                           host: string, port: number,
-                           persistent: boolean): string;
-    }
-
     interface PromiseCallbacks {
     interface PromiseCallbacks {
         resolve: (arg: any) => void;
         resolve: (arg: any) => void;
         reject: (arg: any) => void;
         reject: (arg: any) => void;
@@ -467,11 +356,6 @@ declare namespace threema {
         setOnRemoved(callback: any): void;
         setOnRemoved(callback: any): void;
     }
     }
 
 
-    interface AvatarControllerModel {
-        onChangeAvatar: (image: ArrayBuffer) => void;
-        getAvatar(): ArrayBuffer | null;
-    }
-
     interface Alert {
     interface Alert {
         source: string;
         source: string;
         type: string;
         type: string;
@@ -499,106 +383,6 @@ declare namespace threema {
         OPERA: number;
         OPERA: number;
     }
     }
 
 
-    interface MimeService {
-        isImage(mimeType: string): boolean;
-        isAudio(mimeType: string): boolean;
-        isVideo(mimeType: string): boolean;
-        getLabel(mimeType: string): string;
-        getIconUrl(mimeType: string): string;
-    }
-
-    interface ReceiverService {
-        setActive(activeReceiver: Receiver): void;
-        getActive(): Receiver;
-        isConversationActive(conversation: Conversation): boolean;
-        compare(a: Conversation | Receiver, b: Conversation| Receiver): boolean;
-        isContact(receiver: Receiver): boolean;
-        isGroup(receiver: Receiver): boolean;
-        isDistributionList(receiver: Receiver): boolean;
-        isBusinessContact(receiver: Receiver): boolean;
-    }
-
-    interface SettingsService {
-        storeUntrustedKeyValuePair(key: string, value: string): void;
-        retrieveUntrustedKeyValuePair(key: string): string;
-    }
-
-    interface WebClientDefault {
-        getAvatar(type: string, highResolution: boolean): string;
-    }
-
-    interface WebClientService {
-        salty: saltyrtc.SaltyRTC;
-        messages: Container.Messages;
-        conversations: Container.Conversations;
-        receivers: Container.Receivers;
-        alerts: Alert[];
-        defaults: WebClientDefault;
-        receiverListener: ReceiverListener[];
-
-        me: MeReceiver;
-        contacts: Map<string, ContactReceiver>;
-        groups: Map<string, GroupReceiver>;
-        distributionLists: Map<string, DistributionListReceiver>;
-        typing: Container.Typing;
-
-        buildQrCodePayload(persistent: boolean): string;
-        init(keyStore?: saltyrtc.KeyStore, peerTrustedKey?: Uint8Array, resetField?: boolean): void;
-        start(): ng.IPromise<any>;
-        stop(requestedByUs: boolean, deleteStoredData?: boolean, resetPush?: boolean, redirect?: boolean): void;
-        registerInitializationStep(name: string): void;
-        setReceiverListener(listener: ReceiverListener): void;
-        requestClientInfo(): void;
-        requestReceivers(): void;
-        requestConversations(): void;
-        requestMessages(receiver: Receiver, reloadExisting?: boolean): number;
-        requestAvatar(receiver: Receiver, highResolution: boolean): Promise<any>;
-        requestThumbnail(receiver: Receiver, message: Message): Promise<any>;
-        requestBlob(msgId: number, receiver: Receiver): Promise<ArrayBuffer>;
-        requestRead(receiver, newestMessageId: number): void;
-        requestContactDetail(contactReceiver: ContactReceiver): Promise<any>;
-        sendMessage(receiver, type: MessageContentType, message: MessageData): Promise<Promise<any>>;
-        ackMessage(receiver, message: Message, acknowledged?: boolean): void;
-        deleteMessage(receiver, message: Message): void;
-        sendMeIsTyping(receiver, isTyping: boolean): void;
-        sendKeyPersisted(): void;
-        addContact(threemaId: String): Promise<ContactReceiver>;
-        modifyContact(threemaId: String, firstName: String, lastName: String, avatar?: ArrayBuffer):
-            Promise<ContactReceiver>;
-        createGroup(members: String[], name: String, avatar?: ArrayBuffer): Promise<GroupReceiver>;
-        modifyGroup(id: string, members: String[], name: String, avatar?: ArrayBuffer): Promise<GroupReceiver>;
-        leaveGroup(group: GroupReceiver): Promise<any>;
-        deleteGroup(group: GroupReceiver): Promise<any>;
-        syncGroup(group: GroupReceiver): Promise<any>;
-        createDistributionList(members: String[], name: String): Promise<DistributionListReceiver>;
-        modifyDistributionList(id: string, members: String[], name: String): Promise<DistributionListReceiver>;
-        deleteDistributionList(distributionList: DistributionListReceiver): Promise<any>;
-        isTyping(receiver: ContactReceiver): boolean;
-        getMyIdentity(): Identity;
-        getQuote(receiver: Receiver): Quote;
-        setQuote(receiver: Receiver, message?: Message): void;
-        setDraft(receiver: Receiver, message: string): void;
-        getDraft(receiver: Receiver): string;
-        setPassword(password: string): void;
-        clearCache(): void;
-        getMaxTextLength(): number;
-    }
-
-    interface ControllerService {
-        setControllerName(name: string): void;
-        getControllerName(): string;
-    }
-
-    interface StringService {
-        /**
-         * create chunks of a string by counting the used bytes
-         * @param str
-         * @param byteLength
-         * @param offset
-         */
-        byteChunk(str: string, byteLength: number, offset: number): string[];
-    }
-
     namespace Container {
     namespace Container {
         interface ReceiverData {
         interface ReceiverData {
             me: MeReceiver;
             me: MeReceiver;

+ 3 - 1
src/threema/container.ts

@@ -15,6 +15,8 @@
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  */
  */
 
 
+import {ReceiverService} from '../services/receiver';
+
 /**
 /**
  * A simple HashSet implementation based on a JavaScript object.
  * A simple HashSet implementation based on a JavaScript object.
  *
  *
@@ -49,7 +51,7 @@ class StringHashSet {
 
 
 angular.module('3ema.container', [])
 angular.module('3ema.container', [])
 .factory('Container', ['$filter', '$log', 'ReceiverService',
 .factory('Container', ['$filter', '$log', 'ReceiverService',
-    function($filter, $log, receiverService: threema.ReceiverService) {
+    function($filter, $log, receiverService: ReceiverService) {
     type ContactMap = Map<string, threema.ContactReceiver>;
     type ContactMap = Map<string, threema.ContactReceiver>;
     type GroupMap = Map<string, threema.GroupReceiver>;
     type GroupMap = Map<string, threema.GroupReceiver>;
     type DistributionListMap = Map<string, threema.DistributionListReceiver>;
     type DistributionListMap = Map<string, threema.DistributionListReceiver>;