// Firefox extension enabling the use of Gmail chat across multiple tabs. // Copyright (C) 2007 Jack Wootton . // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . function TabMediator() { this._tab = null; this._remoteChats = []; this.setTab = function(aTab) { this._tab = aTab; } this.getTab = function() { return this._tab; } this.addRemoteChat = function(aRemoteChat) { var i = this._remoteChats.length; this._remoteChats[i] = aRemoteChat; } this.removeRemoteChat = function(aRemoteChat) { var index = this._remoteChats.indexOf(aRemoteChat); var remoteChatArray = this._remoteChats.splice(index,1); for (var i = 0; i < remoteChatArray.length; i++) remoteChatArray[i] = null; } this.isTabRegistered = function(aXulTab) { return this._tab.usesXulTab(aXulTab); } this.alreadyDisplaysChat = function(aChatMediator) { var isDuplicate = false; for (var i = 0; i < this._remoteChats.length; i++) { isDuplicate = this._remoteChats[i].usesChatMediator(aChatMediator); if (isDuplicate) return true; } return false; } this.reloadRemoteChats = function(aNewDocument) { for (var i=0; i < this._remoteChats.length; i++) this._remoteChats[i].reload(aNewDocument); } this.getRemoteChatPosition = function() { return this._tab.getXPosition(); } this.resetRemoteChatPositions = function() { for (var i = 0; i < this._remoteChats[i].length; i++) { if (this._remoteChats[i].isOpen()) this._remoteChats[i].reloadXPosition( this._tab.getXPosition() ); } } this.hideRemoteChat = function() { this._tab.notifyRemoteChatRemoved(); } this.removeAssociatedRemoteChats = function() { for (var i = 0; i < this._remoteChats.length; i++) this._remoteChats[i].expunge(); } this.expunge = function() { if (this._remoteChats != null || this._remoteChats.length > 0) throw Exceptions.INTERNAL_ERROR; if (this._tab != null) { this.tab.expunge(); this._tab = null; } } }