iowafrontier.c

Go to the documentation of this file.
00001 
00002 /*  $Id: iowafrontier.c 355 2005-01-11 22:48:55Z andreradke $    */
00003 
00004 /******************************************************************************
00005 
00006     UserLand Frontier(tm) -- High performance Web content management,
00007     object database, system-level and Internet scripting environment,
00008     including source code editing and debugging.
00009 
00010     Copyright (C) 1992-2004 UserLand Software, Inc.
00011 
00012     This program is free software; you can redistribute it and/or modify
00013     it under the terms of the GNU General Public License as published by
00014     the Free Software Foundation; either version 2 of the License, or
00015     (at your option) any later version.
00016 
00017     This program is distributed in the hope that it will be useful,
00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020     GNU General Public License for more details.
00021 
00022     You should have received a copy of the GNU General Public License
00023     along with this program; if not, write to the Free Software
00024     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025 
00026 ******************************************************************************/
00027 
00028 #include "frontier.h"
00029 #include "standard.h"
00030 
00031 #include <iac.h>
00032 #include "shelltypes.h"
00033 #include "iowacore.h"
00034 #include "iowascript.h"
00035 #include "iowaruntime.h"
00036 #include "iowafrontier.h"
00037 
00038 #if TARGET_API_MAC_CARBON == 1 /*PBS 03/14/02: AE OS X fix.*/
00039     #include "aeutils.h" /*PBS 03/14/02: AE OS X fix.*/
00040 #endif
00041 
00042 /*a little code ghetto for stuff that depends on Frontier or Runtime*/
00043 
00044 #ifdef macBirdPlugin
00045     #ifdef fldebug
00046         #define alertdialog(s)      DebugStr (s)
00047     #else
00048         #define alertdialog(s)      ((void *)0)
00049     #endif
00050 #endif
00051 
00052 #ifdef isFrontier
00053     #define idscriptresource    1024
00054 #else
00055     #define idscriptresource    128
00056 #endif
00057 
00058 #define startcardtoken          'init'
00059 #define setcardtoken            'sett'
00060 #define closecardtoken          'clos'
00061 #define edittabletoken          'edtb'
00062 #define getttabletoken          'gett'
00063 
00064 #ifdef claybasket
00065     #define doscripttoken           'dosc' /*DW 9/28/95*/
00066     #define addtoglossarytoken      'addg' /*DW 10/9/95*/
00067     #define editglossarytoken       'edtg' /*DW 10/9/95*/
00068     #define refglossarytoken        'refg' /*DW 10/9/95*/
00069     #define editobjecttoken         'edto' /*DW 10/17/95*/
00070     #define runuserscripttoken      'russ' /*DW 11/4/95*/
00071     #define runlinkfiltertoken      'rulf' /*DW 11/4/95*/
00072     #define copytopagetabletoken    'ctpt' /*DW 11/5/95*/
00073     #define copyfrompagetabletoken  'cfpt' /*DW 11/5/95*/
00074     #define runpagefiltertoken      'rupf' /*DW 11/5/95*/
00075     #define runfinalfiltertoken     'ruff' /*DW 12/7/95*/
00076 #endif
00077 
00078 
00079 /*
00080 static bigstring lasttablename = "\p";
00081 
00082 static boolean lasttablewasmajor = false;
00083 */
00084 
00085 
00086 #define scriptmodebits kOSANullMode
00087 
00088 
00089 
00090 
00091 static void getappspec (FSSpec *fs) {
00092     
00093     ProcessSerialNumber psn;
00094     ProcessInfoRec info;
00095     Str255 s;
00096     
00097     GetCurrentProcess (&psn);
00098     
00099     info.processInfoLength = (long) sizeof (info);
00100     
00101     info.processName = s; /*place to store process name*/
00102     
00103     info.processAppSpec = fs; /*place to store process filespec*/
00104     
00105     GetProcessInformation (&psn, &info);
00106     } /*getappspec*/
00107     
00108     
00109 static void componenterrormessage (OSErr ec, bigstring errormessage) {
00110 
00111     copystring ("\pComponent Manager error. Its code number is ", errormessage);
00112     
00113     pushlong (ec, errormessage);
00114     
00115     pushstring ("\p.", errormessage);
00116     } /*componenterrormessage*/
00117 
00118 
00119 static boolean getcompiledscript (OSAID *scriptid, ComponentInstance *scriptcomp, bigstring errormessage) {
00120     
00121     /*
00122     the original version saves as much as possible from call to 
00123     call, using statics. not safe to multi-process card running.
00124     
00125     dmb 1.0b23: when we're running in Frontier, this can be called in any of our 
00126     client contexts. findlangcomponent already handle this, but we 
00127     need to make sure the we don't try to share the same script ID 
00128     between the component instances we have open in each client 
00129     process. We could maintain some kind of list, but now that we 
00130     make this call less often (we only SetRuntimeCard for major
00131     switches), it's fine to simple recompile the script each time. so 
00132     we don't use statics except for the script source resource.
00133     */
00134     
00135     static Handle hcompiledscript = nil;
00136     #ifdef isFrontier
00137         boolean flinitialized = false;
00138         ComponentInstance comp = 0;
00139         OSAID id = 0;
00140     #else
00141         static boolean flinitialized = false;
00142         static ComponentInstance comp = 0;
00143         static OSAID id = 0;
00144     #endif
00145     
00146     if (flinitialized) { /*dmb 6.19.96: make sure the component is still around*/
00147         
00148         if (GetComponentVersion (comp) == badComponentInstance) { /*no longer valid*/
00149             
00150             comp = 0;
00151             
00152             id = 0;
00153             
00154             flinitialized = false;
00155             }
00156         }
00157     
00158     if (!flinitialized) { /*first time we're called, load the script from resource fork*/
00159         
00160         if (hcompiledscript == nil) {
00161         
00162             hcompiledscript = GetResource ('scpt', idscriptresource);
00163         
00164             if (hcompiledscript == nil) {
00165             
00166                 copystring ("\pThere's no 'scpt' 128 resource available", errormessage);
00167             
00168                 return (false);
00169                 }
00170             }
00171         
00172         if (comp == 0) {
00173         
00174             comp = findlangcomponent (idfrontier);
00175         
00176             if (comp == 0)  {
00177             
00178                 copystring ("\pFrontier 3.0 or greater isn't running.", errormessage);
00179             
00180                 return (false);
00181                 }
00182             }
00183         
00184         if (id == 0) {
00185         
00186             AEDesc scriptdesc;
00187             OSErr ec;
00188             //Code change by Timothy Paustian Wednesday, August 9, 2000 10:20:26 AM
00189             //I think I found the problem YAHOO!
00190             //in carbon we cannot do this because it is an opaque data structure.
00191             #if TARGET_API_MAC_CARBON == 1
00192             SInt32  hSize = GetHandleSize(hcompiledscript);
00193             HLock(hcompiledscript);
00194             ec = AECreateDesc('scpt', *hcompiledscript, hSize, &scriptdesc);
00195             HUnlock(hcompiledscript);
00196             #else
00197             scriptdesc.descriptorType = /*typeOSAGenericStorage*/ 'scpt';
00198             scriptdesc.dataHandle = hcompiledscript; 
00199             #endif
00200             ec = OSALoad (comp, &scriptdesc, kOSANullMode, &id);
00201     
00202             if (ec != noErr) {
00203             
00204                 componenterrormessage (ec, errormessage);
00205             
00206                 return (false);
00207                 }
00208             }
00209         
00210         flinitialized = true;
00211         }
00212     
00213     *scriptcomp = comp;
00214     
00215     *scriptid = id;
00216     
00217     return (true);
00218     } /*getcompiledscript*/
00219 
00220 
00221 static boolean callcompiledscript (AppleEvent *message, OSType resulttype, bigstring errormessage, Handle *hreturned) {
00222     
00223     /*
00224     dmb 1.0b23: must delete scriptid when running in Frontier; it can't be 
00225     shared from call to call.
00226     */
00227     
00228     ComponentInstance scriptcomp;
00229     OSAID scriptid, resultid;
00230     AEDesc resultdesc = {typeNull, nil};
00231     OSErr ec;
00232     
00233     setstringlength (errormessage, 0);
00234     
00235     *hreturned = nil;
00236     
00237     if (!getcompiledscript (&scriptid, &scriptcomp, errormessage))
00238         return (false);
00239     
00240     ec = OSAExecuteEvent (scriptcomp, message, scriptid, scriptmodebits, &resultid);
00241     
00242 #ifdef isFrontier
00243     OSADispose (scriptcomp, scriptid); /*1.0b23*/
00244 #endif
00245 
00246     if (ec == noErr) {
00247         
00248         ec = OSACoerceToDesc (scriptcomp, resultid, resulttype, kOSANullMode, &resultdesc);
00249         
00250         OSADispose (scriptcomp, resultid);
00251         }
00252     
00253     /*DW 11/17/95 -- site of a former memory leak*/ {
00254         
00255         AEDisposeDesc (message);    
00256         }
00257     
00258     switch (ec) {
00259         
00260         case noErr: 
00261         
00262             #if TARGET_API_MAC_CARBON == 1 /*PBS 03/14/02: AE OS X fix.*/
00263             
00264                 copydatahandle (&resultdesc, hreturned);
00265 
00266             #else
00267             
00268                 copyhandle (resultdesc.dataHandle, hreturned); /*script ran without error*/
00269             
00270             #endif
00271             
00272             break;
00273         
00274         case errOSAScriptError: 
00275             if (OSAScriptError (scriptcomp, kOSAErrorMessage, typeChar, &resultdesc) == noErr)
00276             
00277                 #if TARGET_API_MAC_CARBON == 1 /*PBS 03/14/02: AE OS X fix.*/
00278                 
00279                     datahandletostring (&resultdesc, errormessage);
00280                 
00281                 #else
00282 
00283                     texthandletostring (resultdesc.dataHandle, errormessage);
00284                 
00285                 #endif
00286             else
00287                 copystring ("\pThe script generated an error, but no message was provided.", errormessage);
00288             
00289             break;
00290         
00291         default: 
00292             componenterrormessage (ec, errormessage);
00293             
00294             break;
00295         } /*switch*/
00296     
00297     AEDisposeDesc (&resultdesc);
00298     
00299     return (*hreturned != nil);
00300     } /*callcompiledscript*/
00301     
00302     
00303 static boolean newevent (OSType token, AppleEvent *event) {
00304 
00305     AEAddressDesc selfAddress; 
00306     ProcessSerialNumber psn;
00307     OSErr ec;
00308 
00309     psn.highLongOfPSN = 0;
00310 
00311     psn.lowLongOfPSN = kCurrentProcess;
00312 
00313     ec = AECreateDesc (typeProcessSerialNumber, (Ptr) &psn, sizeof (psn), &selfAddress);
00314     
00315     if (ec != noErr)
00316         return (false);
00317     
00318     ec = AECreateAppleEvent ('abcd', token, &selfAddress, kAutoGenerateReturnID, kAnyTransactionID, event);
00319     
00320     AEDisposeDesc (&selfAddress);
00321     
00322     return (ec == noErr);
00323     } /*newevent*/
00324 
00325 
00326 boolean findfrontiercomponent (void) {
00327     
00328     return (findlangcomponent (idfrontier) != 0);
00329     } /*findfrontiercomponent*/
00330 
00331 
00332 boolean frontStartCard (AEDesc *filelist) {
00333     
00334     /*
00335     a card is starting up. we call the script at system.verbs.traps.IRUN.stcd
00336     to create a table for it, unpack the packed table at that location, and 
00337     copy in the filespec for the application and any files that were dragged
00338     onto the app.
00339     
00340     if tablename is empty, the script assigns a name and returns it. we return
00341     it to the caller, who is expected to link it into iowadata.
00342     
00343     dmb 1.0b19: manage the embedded table more carefully. don't release the 
00344     packed data until we successfully transfer ownership to frontier. in that 
00345     case, dispose of our version and set tablestoredinfrontier to true here.
00346     
00347     dmb 1.0b20: use tablestoredinfrontier as flfrontcardstarted flag, and 
00348     return true if we've already been started. This allows other routines 
00349     to try starting the card in case Frontier was launched after MacBird. 
00350     also, don't dispose and nil the embedded table field; we might still 
00351     need it if Frontier goes away before we have a chance to retrieve it.
00352     
00353     dmb 1.0b20: added runmode parameter so Frontier will tolerate errors in
00354     startup script
00355     
00356     dmb 1.0b23: removed runmode parameter. Frontier will no longer call the 
00357     startCard script. It's too soon. We now call it directly after doing 
00358     default initialization in cardcheckinit in iowaruntime.c
00359     */
00360     
00361     bigstring tablename;
00362     boolean flcopyname;
00363     FSSpec fsapp;
00364     AppleEvent event;
00365     
00366     if ((**iowadata).tablestoredinfrontier)
00367         return (true);
00368     
00369     getappspec (&fsapp);
00370         
00371     /*pull the table name from the tablename handle*/ {
00372     
00373         if ((**iowadata).tablename == nil) { /*let the script assign a name to the table*/
00374             
00375             setstringlength (tablename, 0);
00376             
00377             flcopyname = true;
00378             }
00379         else {
00380             texthandletostring ((**iowadata).tablename, tablename);
00381             
00382             flcopyname = false;
00383             }
00384         }
00385     
00386     if (!newevent (startcardtoken, &event))
00387         return (false);
00388         
00389     IACglobals.event = &event;
00390     
00391     if (!IACpushstringparam (tablename, 'prm1'))
00392         goto error;
00393     
00394     IACglobals.dontdisposenextparam = true; /*dmb 1.0b19*/
00395     
00396     if (!IACpushbinaryparam ((**iowadata).embeddedtable, 'tabl', 'prm2'))
00397         goto error;
00398     
00399     if (!IACpushfilespecparam (&fsapp, 'prm3'))
00400         goto error;
00401     
00402     if (filelist == nil) {
00403         
00404         AEDesc desc;
00405         
00406         #if TARGET_API_MAC_CARBON == 1 /*PBS 03/14/02: AE OS X fix.*/
00407         
00408             newdescnull (&desc, typeNull);
00409         
00410         #else
00411         
00412             desc.descriptorType = typeNull;
00413         
00414             desc.dataHandle = nil;
00415         
00416         #endif
00417         
00418         if (AEPutParamDesc (IACglobals.event, 'prm4', &desc) != noErr)
00419             goto error;
00420         }
00421     else
00422         if (AEPutParamDesc (IACglobals.event, 'prm4', filelist) != noErr)
00423             goto error;
00424     
00425     /*
00426     if (!IACpushbooleanparam ((**iowadata).runmode, 'runm'))
00427         goto error;
00428     */
00429     
00430     /*send the event to the compiled script*/ {
00431         
00432         hdlcard savediowadata = iowadata; /*if startCard script calls a cardEditor verb, iowadata will be smashed*/
00433         bigstring errormessage;
00434         Handle htablename;
00435         
00436         installRuntimeEventHandlers (); /*1.0b20 dmb: init script may call back to card*/
00437         
00438         if (!callcompiledscript (&event, typeChar, errormessage, &htablename)) {
00439             
00440             iowadata = savediowadata;
00441             
00442             alertdialog (errormessage);
00443             
00444             return (false);
00445             }
00446             
00447         iowadata = savediowadata;
00448         
00449         (**iowadata).tablename = htablename;
00450         
00451         /*
00452         texthandletostring (htablename, lasttablename);
00453         
00454         lasttablewasmajor = true;
00455         */
00456         }
00457     
00458     (**iowadata).tablestoredinfrontier = true;
00459     
00460     return (true);
00461     
00462     error:
00463     
00464     AEDisposeDesc (&event); 
00465     
00466     return (false);
00467     } /*frontStartCard*/
00468     
00469 
00470 boolean frontSetRuntimeCard (boolean flswitchingin, boolean flmajorswitch) {
00471     
00472     /*
00473     iowadata contains a card that's running. call the script at
00474     system.verbs.traps.IRUN.sett to make it the current card, 
00475     all the items in its table are global. and if it's a major
00476     switch, it's menubar is installed at system.menubars.DRPb.
00477     
00478     1.0b19 dmb: now take flswitchingin parameter so Frontier can 
00479     remove menus when a window is deactivated
00480     
00481     1.0b20 dmb: call frontStartCard, which will now do nothing if
00482     its already been started, but will start it if Frontier wasn't
00483     running before.
00484     
00485     1.0b21 dmb: must track majorswitch parameter along with table 
00486     name for optimization where we don't call the script
00487     
00488     1.0b22 dmb: removed logic to avoid calling frontier. a card 
00489     running inside of frontier can change the global table without
00490     our knowing it. besides, it's a component call now, so it's fast.
00491     
00492     1.0b23 dmb: big change: runlangscript now runs all scripts inside 
00493     a "with" statement, so we no longer need to have Frontier point 
00494     to our table in system.misc.paths. Do we only need to makek this 
00495     call for major switches
00496     */
00497 
00498     AppleEvent event;
00499     bigstring tablename;
00500     
00501     if (!flmajorswitch) /*dmb 1.0b23*/
00502         return (true);
00503     
00504     if ((**iowadata).notscriptedcard)
00505         return (true);
00506     
00507     if (!findfrontiercomponent () || !frontStartCard (nil)) /*1.0b20 dmb*/
00508         return (false);
00509     
00510     if (flswitchingin)
00511         texthandletostring ((**iowadata).tablename, tablename);
00512     else
00513         tablename [0] = 0;
00514     
00515     /*
00516     if (equalstrings (tablename, lasttablename) && (lasttablewasmajor || !flmajorswitch)) /%minimize AE traffic%/
00517         return (true);
00518     
00519     copystring (tablename, lasttablename);
00520     
00521     lasttablewasmajor = flmajorswitch;
00522     */
00523     
00524     if (!newevent (setcardtoken, &event))
00525         goto error;
00526         
00527     IACglobals.event = &event;
00528     
00529     if (!IACpushstringparam (tablename, 'prm1'))
00530         goto error;
00531     
00532     if (!IACpushbooleanparam (flmajorswitch, 'prm2'))
00533         goto error;
00534     
00535     /*send the event to the compiled script*/ {
00536         
00537         bigstring errormessage;
00538         Handle hresult;
00539         
00540         if (!callcompiledscript (&event, typeChar, errormessage, &hresult)) {
00541             
00542             alertdialog (errormessage);
00543             
00544             return (false);
00545             }
00546             
00547         disposehandle (hresult);
00548         }
00549         
00550     return (true);
00551     
00552     error:
00553     
00554     AEDisposeDesc (&event); 
00555     
00556     return (false);
00557     } /*frontSetRuntimeCard*/
00558     
00559     
00560 boolean frontEditTable (bigstring tablewindowtitle) {
00561     
00562     AppleEvent event;
00563     bigstring bs;
00564     
00565     if ((**iowadata).notscriptedcard)
00566         return (true);
00567         
00568     if (!frontStartCard (nil)) /*1.0b20 dmb*/
00569         return (false);
00570     
00571     if (!newevent (edittabletoken, &event))
00572         goto error;
00573         
00574     IACglobals.event = &event;
00575     
00576     texthandletostring ((**iowadata).tablename, bs);
00577     
00578     if (!IACpushstringparam (bs, 'prm1'))
00579         goto error;
00580     
00581     if (!IACpushstringparam (tablewindowtitle, 'prm2'))
00582         goto error;
00583     
00584     /*send the event to the compiled script*/ {
00585         
00586         bigstring errormessage;
00587         Handle hresult;
00588         
00589         if (!callcompiledscript (&event, typeChar, errormessage, &hresult)) {
00590             
00591             alertdialog (errormessage);
00592             
00593             return (false);
00594             }
00595             
00596         disposehandle (hresult);
00597         }
00598         
00599     return (true);
00600     
00601     error:
00602     
00603     AEDisposeDesc (&event); 
00604     
00605     return (false);
00606     } /*frontEditTable*/
00607     
00608     
00609 boolean frontGetTable (void) { 
00610     
00611     /*
00612     send a message to Frontier requesting the table associated with
00613     the card in iowadata.
00614     */
00615     
00616     AppleEvent event;
00617     bigstring bs;
00618     
00619     if ((**iowadata).notscriptedcard)
00620         return (true);
00621     
00622     if (!(**iowadata).tablestoredinfrontier)  /*1.0b20 dmb - maybe Frontier wasn't running before*/
00623         return (true);
00624     
00625     if (!newevent (getttabletoken, &event))
00626         return (false);
00627         
00628     IACglobals.event = &event;
00629     
00630     texthandletostring ((**iowadata).tablename, bs);
00631     
00632     if (!IACpushstringparam (bs, 'prm1'))
00633         goto error;
00634         
00635     /*send the event to the compiled script*/ {
00636         
00637         bigstring errormessage;
00638         Handle hpackedtable;
00639         
00640         if (!callcompiledscript (&event, 'tabl', errormessage, &hpackedtable)) {
00641             
00642             alertdialog (errormessage);
00643             
00644             return (false);
00645             }
00646         
00647         assert (hpackedtable != nil);
00648         
00649         disposehandle ((**iowadata).embeddedtable); /*1.0b19 dmb: make sure old version is gone*/
00650         
00651         (**iowadata).embeddedtable = hpackedtable;
00652         }
00653         
00654     return (true);
00655     
00656     error:
00657     
00658     AEDisposeDesc (&event); 
00659     
00660     return (false);
00661     } /*frontGetTable*/
00662     
00663 
00664 boolean frontDeleteCardTable (void) {
00665     
00666     /*
00667     iowadata contains a running card that is being terminated. we call
00668     system.verbs.traps.IRUN.delt to delete the table for this card.
00669     */
00670 
00671     AppleEvent event;
00672     bigstring bs;
00673     
00674     if ((**iowadata).notscriptedcard) /*this card is handled by C code*/
00675         return (true);
00676     
00677     if (!(**iowadata).tablestoredinfrontier)  /*1.0b20 dmb - maybe Frontier wasn't running before*/
00678         return (true);
00679     
00680     if (!newevent (closecardtoken, &event))
00681         goto error;
00682         
00683     IACglobals.event = &event;
00684     
00685     texthandletostring ((**iowadata).tablename, bs);
00686     
00687     if (!IACpushstringparam (bs, 'prm1'))
00688         goto error;
00689     
00690     /*send the event to the compiled script*/ {
00691         
00692         bigstring errormessage;
00693         Handle hresult;
00694         
00695         if (!callcompiledscript (&event, typeChar, errormessage, &hresult)) {
00696             
00697             alertdialog (errormessage);
00698             
00699             return (false);
00700             }
00701             
00702         disposehandle (hresult);
00703         }
00704         
00705     return (true);
00706     
00707     error:
00708     
00709     AEDisposeDesc (&event); 
00710     
00711     return (false);
00712     } /*frontDeleteCardTable*/
00713     
00714 #ifdef claybasket
00715 
00716 boolean frontRunMacro (bigstring macro, bigstring errorstring, Handle *hresult) {
00717     
00718     AppleEvent event;
00719     
00720     if (!newevent (doscripttoken, &event))
00721         goto error;
00722         
00723     IACglobals.event = &event;
00724     
00725     if (!IACpushstringparam (macro, 'prm1'))
00726         goto error;
00727     
00728     if (!callcompiledscript (&event, typeChar, errorstring, hresult))
00729         return (false);
00730         
00731     return (true);
00732     
00733     error:
00734     
00735     AEDisposeDesc (&event); 
00736     
00737     return (false);
00738     } /*frontRunMacro*/
00739     
00740     
00741 boolean frontRunUserScript (bigstring macro, bigstring path, bigstring errorstring, Handle *hresult) {
00742     
00743     AppleEvent event;
00744     
00745     if (!newevent (runuserscripttoken, &event))
00746         goto error;
00747         
00748     IACglobals.event = &event;
00749     
00750     if (!IACpushstringparam (macro, 'prm1'))
00751         goto error;
00752     
00753     if (!IACpushstringparam (path, 'prm2'))
00754         goto error;
00755     
00756     if (!callcompiledscript (&event, typeChar, errorstring, hresult))
00757         return (false);
00758         
00759     return (true);
00760     
00761     error:
00762     
00763     AEDisposeDesc (&event); 
00764     
00765     return (false);
00766     } /*frontRunUserScript*/
00767     
00768     
00769 boolean frontRunLinkFilter (Handle hlinkstring, short linktype, bigstring errorstring, Handle *hresult) {
00770     
00771     AppleEvent event;
00772     
00773     if (!newevent (runlinkfiltertoken, &event))
00774         return (false);
00775         
00776     IACglobals.event = &event;
00777     
00778     if (!IACpushtextparam (hlinkstring, 'prm1'))
00779         goto error;
00780     
00781     if (!IACpushshortparam (linktype, 'prm2'))
00782         goto error;
00783     
00784     if (!callcompiledscript (&event, typeChar, errorstring, hresult))
00785         return (false);
00786         
00787     return (true);
00788     
00789     error:
00790     
00791     AEDisposeDesc (&event); 
00792     
00793     return (false);
00794     } /*frontRunLinkFilter*/
00795     
00796     
00797 boolean frontRunPageFilter (bigstring errorstring) {
00798     
00799     AppleEvent event;
00800     Handle hresult;
00801     
00802     setstringlength (errorstring, 0);
00803     
00804     if (!newevent (runpagefiltertoken, &event))
00805         return (false);
00806         
00807     if (!callcompiledscript (&event, typeChar, errorstring, &hresult))
00808         goto error;
00809     
00810     disposehandle (hresult);
00811     
00812     return (true);
00813     
00814     error:
00815     
00816     AEDisposeDesc (&event); 
00817     
00818     return (false);
00819     } /*frontRunPageFilter*/
00820     
00821     
00822 boolean frontRunFinalFilter (Handle htext, bigstring errorstring, Handle *hresult) {
00823     
00824     AppleEvent event;
00825     
00826     setstringlength (errorstring, 0);
00827     
00828     if (!newevent (runfinalfiltertoken, &event))
00829         return (false);
00830         
00831     IACglobals.event = &event;
00832     
00833     if (!IACpushtextparam (htext, 'prm1'))
00834         goto error;
00835     
00836     if (!callcompiledscript (&event, typeChar, errorstring, hresult))
00837         goto error;
00838     
00839     return (true);
00840     
00841     error:
00842     
00843     AEDisposeDesc (&event); 
00844     
00845     return (false);
00846     } /*frontRunFinalFilter*/
00847     
00848     
00849 boolean frontCopyToPageTable (AERecord *rec) {
00850     
00851     AppleEvent event;
00852     bigstring errorstring;
00853     Handle hresult;
00854     
00855     if (!newevent (copytopagetabletoken, &event))
00856         goto error;
00857         
00858     IACglobals.event = &event;
00859     
00860     if (!IACpushrecordparam (rec, 'prm1'))
00861         goto error;
00862     
00863     if (!callcompiledscript (&event, typeChar, errorstring, &hresult))
00864         return (false);
00865     
00866     disposehandle (hresult);
00867     
00868     return (true);
00869     
00870     error:
00871     
00872     AEDisposeDesc (&event); 
00873     
00874     return (false);
00875     } /*frontCopyToPageTable*/
00876     
00877     
00878 boolean frontCopyFromPageTable (AERecord *rec) {
00879 
00880     AppleEvent event;
00881     bigstring errorstring;
00882     Handle hresult;
00883     
00884     if (!newevent (copyfrompagetabletoken, &event))
00885         return (false);
00886         
00887     if (!callcompiledscript (&event, typeAERecord, errorstring, &hresult))
00888         goto error;
00889         
00890     (*rec).descriptorType = typeAERecord;
00891     
00892     #if TARGET_API_MAC_CARBON == 1 /*PBS 03/14/02: AE OS X fix.*/
00893     
00894         putdeschandle (rec, hresult);
00895     
00896     #else
00897     
00898         (*rec).dataHandle = hresult;
00899         
00900     #endif
00901     
00902     return (true);
00903     
00904     error:
00905     
00906     AEDisposeDesc (&event); 
00907     
00908     return (false);
00909     } /*frontCopyFromPageTable*/
00910     
00911     
00912 boolean frontAddToGlossary (void *name, bigstring value, short type, bigstring errorstring) {
00913     
00914     AppleEvent event;
00915     Handle hresult = nil;
00916     
00917     if (!newevent (addtoglossarytoken, &event))
00918         goto error;
00919         
00920     IACglobals.event = &event;
00921     
00922     if (!IACpushstringparam (name, 'prm1'))
00923         goto error;
00924     
00925     if (!IACpushstringparam (value, 'prm2'))
00926         goto error;
00927     
00928     if (!IACpushshortparam (type, 'prm3'))
00929         goto error;
00930     
00931     if (!callcompiledscript (&event, typeChar, errorstring, &hresult))
00932         return (false);
00933         
00934     disposehandle (hresult);
00935 
00936     return (true);
00937     
00938     error:
00939     
00940     AEDisposeDesc (&event); 
00941     
00942     disposehandle (hresult);
00943     
00944     return (false);
00945     } /*frontAddToGlossary*/
00946 
00947 
00948 boolean frontEditGlossary (bigstring errorstring) {
00949     
00950     AppleEvent event;
00951     Handle hresult = nil;
00952     
00953     if (!newevent (editglossarytoken, &event))
00954         goto error;
00955         
00956     IACglobals.event = &event;
00957     
00958     if (!callcompiledscript (&event, typeChar, errorstring, &hresult))
00959         return (false);
00960         
00961     disposehandle (hresult);
00962 
00963     return (true);
00964     
00965     error:
00966     
00967     AEDisposeDesc (&event); 
00968     
00969     disposehandle (hresult);
00970     
00971     return (false);
00972     } /*frontEditGlossary*/
00973 
00974 
00975 boolean frontGlossaryReference (bigstring name, bigstring errorstring, Handle *hresult) {
00976     
00977     AppleEvent event;
00978     
00979     *hresult = nil;
00980     
00981     if (!newevent (refglossarytoken, &event))
00982         return (false);
00983         
00984     IACglobals.event = &event;
00985     
00986     if (!IACpushstringparam (name, 'prm1'))
00987         goto error;
00988     
00989     if (!callcompiledscript (&event, typeChar, errorstring, hresult))
00990         return (false);
00991         
00992     return (true);
00993     
00994     error:
00995     
00996     AEDisposeDesc (&event); 
00997     
00998     disposehandle (*hresult);
00999     
01000     return (false);
01001     } /*frontGlossaryReference*/
01002 
01003 
01004 boolean frontEditObject (bigstring celladdress, bigstring errorstring) {
01005     
01006     AppleEvent event;
01007     Handle hresult = nil;
01008     
01009     if (!newevent (editobjecttoken, &event))
01010         return (false);
01011         
01012     IACglobals.event = &event;
01013     
01014     if (!IACpushstringparam (celladdress, 'prm1'))
01015         goto error;
01016     
01017     if (!callcompiledscript (&event, typeChar, errorstring, &hresult))
01018         return (false);
01019         
01020     disposehandle (hresult);
01021     
01022     return (true);
01023     
01024     error:
01025     
01026     AEDisposeDesc (&event); 
01027     
01028     disposehandle (hresult);
01029     
01030     return (false);
01031     } /*frontEditObject*/
01032 
01033 #endif
01034 
01035 

Generated on Wed May 31 18:19:49 2006 for frontierkernel 10.1.10a by  doxygen 1.4.6