// 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 ChatMediator()
{
this._gmailChat = null;
this._remoteChats = [];
this.setGmailChat = function(aGmailChat)
{
this._gmailChat = aGmailChat;
}
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.getConversation = function()
{
return this._gmailChat.getConversation();
}
this.getTextareaElement = function()
{
return this._gmailChat.getTextareaElement();
}
this.setTextareaValue = function(aString)
{
this._gmailChat.setTextareaValue(aString);
}
this.getLatestStatusMessage = function()
{
return this._gmailChat.getLatestStatusMessage();
}
this.getFriendlyName = function()
{
return this._gmailChat.getFriendlyName();
}
this.notifyNewChatEntry = function(aChatEntry)
{
for (var i = 0; i < this._remoteChats.length; i++)
if (this._remoteChats[i].isOpen())
this._remoteChats[i].notifyNewChatEntry(aChatEntry);
}
this.notifyRemoveChatEntry = function()
{
for (var i = 0; i < this._remoteChats.length; i++)
if (this._remoteChats[i].isOpen())
this._remoteChats[i].notifyRemoveChatEntry();
}
this.notifyUpdatedStatusMessage = function(aString)
{
for (var i = 0; i < this._remoteChats.length; i++)
if (this._remoteChats[i].isOpen())
this._remoteChats[i].notifyUpdatedStatusMessage(aString);
}
this.notifyUpdatedStatus = function(aPresence)
{
for (var i = 0; i < this._remoteChats.length; i++)
if (this._remoteChats[i].isOpen())
this._remoteChats[i].notifyUpdatedStatus(aPresence);
}
this.removeTemporaryChatEntryNode = function()
{
for (var i = 0; i < this._remoteChats.length; i++)
if (this._remoteChats[i].isOpen())
this._remoteChats[i].removeTemporaryChatEntryNode();
}
this.hiLiteAll = function()
{
for (var i = 0; i < this._remoteChats.length; i++)
this._remoteChats[i].hiLiteGui();
}
this.unHiLiteAll = function()
{
for (var i = 0; i < this._remoteChats.length; i++)
this._remoteChats[i].unHiLiteGui();
}
this.removeAssociatedRemoteChats = function()
{
for (var i = 0; i < this._remoteChats.length; i++)
this._remoteChats[i].expunge();
}
this.recipientOnline = function()
{
return this._gmailChat.isOnline();
}
this.recipientBusy = function()
{
return this._gmailChat.isBusy();
}
this.recipientIdle = function()
{
return this._gmailChat.isIdle();
}
this.expunge = function()
{
if (this._remoteChats != null || this._remoteChats.length > 0)
throw Exceptions.INTERNAL_ERROR;
this._gmailChat.expunge();
}
this.isActive = function()
{
return this._gmailChat.isActive();
}
}