home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2005 July & August
/
PCWorld_2005-07-08_cd.bin
/
komunikace
/
netscape
/
nsb-install-8-0.exe
/
chrome
/
aim.jar
/
content
/
aim
/
AimBuddy.js
< prev
next >
Wrap
Text File
|
2004-12-02
|
6KB
|
216 lines
/* XXXVISHY - lets try to keep it all in aimHelpers
var allEnums = null;
function getEnums( myInterface )
{
var enums = { };
for ( var i in myInterface ) {
if ( typeof myInterface[i] == "number" ) {
enums[i] = myInterface[i];
}
}
return enums;
}
function aimBuddyObject()
{
var pIIMManager = aimManager();
if(pIIMManager)
return pIIMManager.QueryInterface(Components.interfaces.nsIAimBuddy);
else
return null;
}
*/
function aimBuddyIsOnline(screenName)
{
var pIAimBuddy = aimBuddyManager();
if ( !screenName || screenName == "" )
return false;
if(pIAimBuddy)
return pIAimBuddy.IsBuddyOnline(screenName);
}
function aimBuddyAddBuddyGroup(groupName, beforeGroup)
{
if (beforeGroup == "")
beforeGroup = null;
dump('AddBuddyGroup: ' + groupName + ', before: ' + beforeGroup + '\n');
var pIAimBuddy = aimBuddyManager();
var isInList = new Object();
pIAimBuddy.GroupIsInList(groupName, isInList);
if ( isInList.value == true ) {
aimErrorBox(aimString("msg.GroupAlreadyInList"));
return 1;
}
if ( beforeGroup == "" )
beforeGroup = null;
if(pIAimBuddy)
pIAimBuddy.AddGroup(groupName, beforeGroup);
return 0;
}
function aimBuddyRemoveBuddyGroup(groupName)
{
dump('RemoveBuddyGroup: ' + groupName + '\n');
var pIAimBuddy = aimBuddyManager();
if(pIAimBuddy)
pIAimBuddy.RemoveGroup(groupName);
}
function aimBuddyRenameBuddyGroup(oldName, newName)
{
dump('RenameBuddyGroup: ' + oldName + ' -> ' + newName + '\n');
var pIAimBuddy = aimBuddyManager();
if(pIAimBuddy)
pIAimBuddy.RenameGroup(oldName, newName);
}
function aimBuddyAddBuddyBefore(groupName, screenName, beforeBuddy)
{
dump('AddBuddy: ' + groupName + '/' + screenName + ', buddy: ' + beforeBuddy + '\n');
var pIAimBuddy = aimBuddyManager();
if ( beforeBuddy == "" ) {
beforeBuddy = null;
}
/*
if ( allEnums == null )
allEnums = getEnums( Components.interfaces.nsAimInsertionStyles );
*/
if(pIAimBuddy) {
var inBudList = pIAimBuddy.BuddyIsInGroup(screenName, groupName);
if ( inBudList ) {
var msg = aimString("msg.BuddyAlreadyInGroup") + " " +
groupName;
aimErrorBox(msg);
return 1;
}
if (beforeBuddy)
pIAimBuddy.AddBuddy(groupName, screenName, beforeBuddy, aimInsertionStyles().InsertBefore);
else
pIAimBuddy.AddBuddy(groupName, screenName, beforeBuddy, aimInsertionStyles().InsertEnd);
}
return 0;
}
function aimBuddyAddBuddyAfter(groupName, screenName, afterBuddy, dispname, service, emailaddress)
{
var pIAimBuddy = aimBuddyManager();
if (afterBuddy == "")
afterBuddy = null;
if(pIAimBuddy) {
var inBudList = pIAimBuddy.BuddyIsInGroup(screenName, groupName);
if (inBudList) {
var msg = aimString("msg.BuddyAlreadyInGroup") + " " + groupName;
aimErrorBox(msg);
return 1;
}
if(!isIcq())
{
var cp = new String(screenName);
if (!IsValidChar(cp)){
// Cannot contain invalid characters
aimErrorBox(aimString("msg.BadScreenName"));
return 1;
}
}
if (afterBuddy)
pIAimBuddy.AddBuddy(groupName, screenName, afterBuddy, aimInsertionStyles().InsertAfter, dispname, emailaddress);
else
pIAimBuddy.AddBuddy(groupName, screenName, afterBuddy, aimInsertionStyles().InsertEnd, dispname, emailaddress);
if((!isIcq()) && (emailaddress != null)) {
aimFeedbagManager().SetEmailId(screenName, emailaddress);
}
}
if (service == 1) {
// user entered all numbers, so icq service
aimBuddyManager().SetIfIcqUserinDS(screenName, true);
aimFeedbagManager().SetDisplay(groupName, screenName, dispname);
}
else
aimBuddyManager().SetIfIcqUserinDS(screenName, false);
return 0;
}
function aimBuddyRemoveBuddy(groupName, screenName)
{
var pIAimBuddy = aimBuddyManager();
if(pIAimBuddy)
pIAimBuddy.RemoveBuddy(groupName, screenName);
}
function aimBuddyMoveGroup(group, beforeGroup)
{
var pIAimBuddy = aimBuddyManager();
if(pIAimBuddy)
pIAimBuddy.MoveGroup(group, beforeGroup);
}
function aimBuddyMoveBuddy(group, buddy, beforeGroup, beforeBuddy)
{
var pIAimBuddy = aimBuddyManager();
if(pIAimBuddy)
pIAimBuddy.MoveBuddy(group, buddy, beforeGroup, beforeBuddy);
}
// false means failure
function aimBuddyImportBuddyList(fileSpec)
{
var myStatus = new Object();
var mask = new Object();
var pIAimBuddy = aimBuddyManager();
if(pIAimBuddy) {
pIAimBuddy.ImportBuddyListPrepare(fileSpec, myStatus, mask);
if ( myStatus.value == true ) {
var groups = new Object();
pIAimBuddy.ImportBuddyListGetGroups(groups);
importBuddyListArgsObj = {
mask: mask,
groups: groups,
}
window.openDialog('chrome://aim/content/ImportBuddyList.xul','_blank','modal=yes,titlebar,chrome', importBuddyListArgsObj);
}
return( myStatus.value );
}
return false;
}
// false means failure
function aimBuddyExportBuddyList(fileSpec, status)
{
exportBuddyListArgsObj = {
fileSpec: fileSpec,
}
window.openDialog('chrome://aim/content/ExportBuddyList.xul','_blank','modal=yes,titlebar,chrome', exportBuddyListArgsObj);
return true;
/*
var myStatus = new Object();
var pIAimBuddy = aimBuddyManager();
if(pIAimBuddy) {
pIAimBuddy.ExportBuddyList(fileSpec, myStatus);
return( myStatus.value );
}
return false;
*/
}