AdobeCommonImplB.mesa
Copyright Ó 1990, 1991, 1992 by Xerox Corporation. All rights reserved.
Philip James, March 9, 1992 9:10 am PST
Bill Jackson (bj), March 28, 1990 8:01 pm PST
Christian Jacobi, April 7, 1992 5:38 pm PDT
DIRECTORY
AccessCH USING [GetFullLoginName, HostForDatabase, NSNameFromRope, Problem],
AdobeCommon,
AdobeCommonInternal USING [NoServer, NoService, SystemNotFound],
AdobeP75V2,
AdobeOps USING [ARSystemHandle, ARSystemObject],
Rope USING [Cat, Concat, Equal, FromChar, Fetch, Length, ROPE],
MailBasics,
XNSAdobeClientOps USING [GetDatabaseDescription--, server--, UnknownAddress];
AdobeCommonImplB: CEDAR MONITOR
IMPORTS AccessCH, AdobeCommon, AdobeCommonInternal, AdobeP75V2, Rope, XNSAdobeClientOps
EXPORTS AdobeCommon = {
OPEN Adobe2: AdobeP75V2;
ROPE: TYPE ~ Rope.ROPE;
SystemNotFound: PUBLIC SIGNAL[system: Rope.ROPE] = CODE;
NoCredentials: PUBLIC ERROR = CODE;
GetFullLoginName: PUBLIC PROC [h: AdobeCommon.Handle ¬ NIL] RETURNS[loginName: Rope.ROPE ¬ NIL] ~ {
loginName ¬ AccessCH.GetFullLoginName[h];
};
ServerForDatabase: PROC [system: Adobe2.Database] RETURNS [server: ROPE, local: ROPE] ~ {
nsName, sysNSName: AdobeP75V2.NSName ¬ NIL;
nsName ¬ AccessCH.NSNameFromRope[GetFullLoginName[]];
sysNSName ¬ AccessCH.NSNameFromRope[system];
IF sysNSName.domain = NIL THEN {
sysNSName.domain ¬ nsName.domain;
system ¬ system.Cat[":", nsName.domain];
};
IF sysNSName.org = NIL THEN {
sysNSName.org ¬ nsName.org;
system ¬ system.Cat[":", nsName.org];
};
server ¬ AccessCH.HostForDatabase[system]; -- default rather than computed!
RETURN[server, sysNSName.local];
};
LocateSystemInKnownSystems: PUBLIC PROCEDURE [name: Rope.ROPE,
systems: AdobeCommon.SystemsHandle]
RETURNS [system: CARDINAL ¬ 0] = {
IF systems = NIL THEN SIGNAL AdobeCommonInternal.SystemNotFound[system: name];
FOR i: CARD IN [0..systems.next) DO
IF Rope.Equal[systems.system[i], name] THEN
RETURN[i];
ENDLOOP;
SIGNAL AdobeCommonInternal.SystemNotFound[system: name];
};
AddSystemToKnownSystems: PUBLIC PROCEDURE[name: Rope.ROPE,
systems: AdobeCommon.SystemsHandle] ~ {
store: REF AdobeCommon.SysList ¬ systems.system;
systems.system ¬ NEW[AdobeCommon.SysList[systems.next + 1]];
FOR i: CARD IN [0..systems.next) DO
systems.system[i] ¬ store[i];
ENDLOOP;
systems.system[systems.next] ¬ name;
systems.next ¬ systems.next + 1;
};
FindSystemInternal: ENTRY PROC [systemName: ROPE]
RETURNS
[arSH: AdobeOps.ARSystemHandle] = {
ENABLE { UNWIND => NULL };
local, host: ROPE ¬ NIL;
system: Adobe2.Database ~ systemName;
desc: Adobe2.Description;
[host, local] ¬ ServerForDatabase[system];
desc ¬ XNSAdobeClientOps.GetDatabaseDescription[host, local];
arSH ¬ NEW[AdobeOps.ARSystemObject ¬ [
name: desc.name,
host: desc.host,
directory: desc.directory,
refCount: 0,
sysQL: NIL,
otherQLs: NIL,
version: desc.version,
service: host,
fieldList: desc.fieldList
]];
};
FindSystem: PUBLIC PROC [head: AdobeCommon.LockedSysDescPtr, toolData: AdobeCommon.Handle, systemName: Rope.ROPE, useDescList: BOOLEAN]
RETURNS [arSH: AdobeOps.ARSystemHandle] = {
ENABLE {
UNWIND => NULL;
NoCredentials => GOTO noLogin;
XNSAdobeClientOps.UnknownAddress => GOTO badServer;
AdobeP75V2.ServerUnreachable, AdobeP75V2.ServerDown => GOTO noServer;
AdobeP75V2.NoAdobeServiceAtServer => GOTO noService;
AdobeP75V2.UnknownSystem => GOTO unknownSystem;
AdobeP75V2.IllegalLogin => GOTO illegalLogin;
AdobeP75V2.SysDescChanging => {
AdobeCommon.PostMessage[toolData, FALSE, "The Adobe database is changing. Contact support for more information."];
ERROR ABORTED};
AdobeP75V2.TooManyConnections => {
AdobeCommon.PostMessage[toolData, FALSE, "Too many connections to Adobe service. Try again later."];
ERROR ABORTED};
AdobeP75V2.Spare1 => {
AdobeCommon.PostMessage[toolData, FALSE, "Protocol version mismatch with server."];
ERROR ABORTED};
AdobeP75V2.Others => {
AdobeCommon.PostMessage[toolData, FALSE, "Server problem."];
ERROR ABORTED};
AccessCH.Problem => SELECT type FROM
badDatabaseName => GOTO unknownSystem;
ENDCASE
};
localName: Rope.ROPE ¬ NIL;
IF ( systemName = NIL ) THEN GOTO unknownSystem;
For searching in known descs
FOR i: INTEGER IN [0..systemName.Length[]) DO
ch: CHAR ~ systemName.Fetch[i];
IF ( ch = ': ) THEN EXIT;
localName ¬ localName.Concat[Rope.FromChar[ch]];
ENDLOOP;
arSH ¬ FindSystemInternal[systemName];
EXITS
unknownSystem => {
AdobeCommon.PostMessage[toolData, TRUE, "Bad system."];
RETURN WITH ERROR AdobeCommonInternal.SystemNotFound[systemName];
};
illegalLogin => AdobeCommon.PostMessage[toolData, FALSE, "Invalid login. "];
noService => RETURN WITH ERROR AdobeCommonInternal.NoService;
noServer => RETURN WITH ERROR AdobeCommonInternal.NoServer;
badServer => AdobeCommon.PostMessage[toolData, TRUE, "Invalid server. "];
noLogin => {
AdobeCommon.PostMessage[toolData, TRUE, "You must xnslogin first."];
toolData.system ¬ LAST[CARDINAL];
toolData.assistLogin[];
};
};
}.