claycallbacks.c

Go to the documentation of this file.
00001 
00002 /*  $Id: claycallbacks.c 1254 2006-04-12 20:27:14Z sethdill $    */
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 "cursor.h"
00032 #include "dialogs.h"
00033 #include "error.h"
00034 #include "file.h"
00035 #include "fileloop.h"
00036 #include "kb.h"
00037 #include "memory.h"
00038 #include "ops.h"
00039 #include "strings.h"
00040 #include "opinternal.h"
00041 #include "claybrowserstruc.h"
00042 #include "claybrowserexpand.h"
00043 #include "claycallbacks.h"
00044 #if odbbrowser
00045 #include "lang.h"
00046 #include "langinternal.h"
00047 #include "langexternal.h"
00048 #include "tableverbs.h"
00049 #include "tableinternal.h"
00050 #include "tablestructure.h"
00051 #endif
00052 
00053 
00054 
00055 #if filebrowser
00056 
00057 boolean claymakespec (tybrowservol vnum, tybrowserdir dirid, bigstring fname, tybrowserspec *pfs) {
00058 
00059     return (filemakespec (vnum, dirid, fname, pfs));
00060     } /*claymakespec*/
00061 
00062 #endif
00063 
00064 #if odbbrowser
00065 
00066 boolean claymakespec (tybrowservol vnum, tybrowserdir dirid, bigstring fname, tybrowserspec *pfs) {
00067 
00068     (*pfs).vRefNum = vnum;
00069     
00070     (*pfs).parID = dirid;
00071     
00072     copystring (fname, (*pfs).name);
00073     
00074     return (dirid != 0L);
00075     } /*claymakespec*/
00076 
00077 #endif
00078 
00079 
00080 #if odbbrowser
00081 
00082 boolean claylookupvalue (const tybrowserspec *fs, tyvaluerecord *val, hdlhashnode * hnode) {
00083 
00084     return (hashtablelookup ((*fs).parID, (*fs).name, val, hnode));
00085     } /*claylookupvalue*/
00086 
00087     
00088 boolean claycopyfile (const tybrowserspec *fsource, const tybrowserspec *fdest) {
00089     
00090     /*
00091     5.1b21 dmb: push/pop databases
00092     
00093     5.1.4 dmb: hook, trap errors
00094     */
00095 
00096     tyvaluerecord val;
00097     boolean fl;
00098     Handle hpacked;
00099     hdldatabaserecord hdatabase;
00100     langerrormessagecallback savecallback;
00101     ptrvoid saverefcon;
00102     bigstring bspackerror;
00103     hdlhashnode hnode;
00104     
00105     fl = claylookupvalue (fsource, &val, &hnode);
00106     
00107     if (!fl)
00108         return (true); /*not fatal error; false is returned to caller*/
00109     
00110     if (!flscriptrunning)
00111         langhookerrors ();
00112     
00113     langtraperrors (bspackerror, &savecallback, &saverefcon);
00114     
00115     hdatabase = (*fsource).vRefNum;
00116 
00117     if (hdatabase)
00118         dbpushdatabase (hdatabase);
00119     
00120     fl = langpackvalue (val, &hpacked, hnode);
00121     
00122     if (hdatabase)
00123         dbpopdatabase ();
00124 
00125     if (!fl) /*error packing -- probably out of memory*/
00126         goto exit;
00127     
00128     hdatabase = (*fdest).vRefNum;
00129     
00130     if (hdatabase)
00131         dbpushdatabase (hdatabase);
00132     
00133     fl = langunpackvalue (hpacked, &val);
00134     
00135     if (hdatabase)
00136         dbpopdatabase ();
00137 
00138     disposehandle (hpacked);
00139     
00140     opstartinternalchange ();
00141     
00142     if (fl) {
00143         
00144         fl = hashtableassign ((*fdest).parID, (*fdest).name, val);
00145         
00146         if (!fl)
00147             disposevaluerecord (val, true);
00148         }
00149     
00150     opendinternalchange ();
00151     
00152 exit:
00153     
00154     languntraperrors (savecallback, saverefcon, !fl);
00155     
00156     if (!flscriptrunning)
00157         langunhookerrors ();
00158     
00159     if (!fl)
00160         shellerrormessage (bspackerror);
00161     
00162     return (fl);
00163     } /*claycopyfile*/
00164 
00165 
00166 boolean claycreatefile (const tybrowserspec *fs) {
00167     
00168     tyvaluerecord val;
00169     boolean fl;
00170     
00171     initvalue (&val, novaluetype);
00172     
00173     opstartinternalchange ();
00174     
00175     fl = hashtableassign ((*fs).parID, (*fs).name, val);
00176     
00177     opendinternalchange ();
00178     
00179     return (fl);
00180     } /*claycreatefile*/
00181 
00182 
00183 boolean claydeletefile (const tybrowserspec *fs) {
00184     
00185     boolean fl;
00186     
00187     opstartinternalchange ();
00188     
00189     fl = hashtabledelete ((*fs).parID, (ptrstring) (*fs).name);
00190     
00191     opendinternalchange ();
00192     
00193     return (fl);
00194     } /*claydeletefile*/
00195 
00196 
00197 boolean claymovefile (const tybrowserspec *fs, const tybrowserspec *fsto) {
00198     
00199     tyvaluerecord val;
00200     hdlhashtable hdest;
00201     boolean fl;
00202     hdlhashnode hnode;
00203     
00204     if (!claygetdirid (fsto, &hdest)) {
00205         
00206         langerrormessage (BIGSTRING ("\x1b" "destination must be a table"));
00207         
00208         return (false);
00209         }
00210     
00211     opstartinternalchange ();
00212     
00213     pushhashtable ((*fs).parID);
00214     
00215     fl = hashlookup ((*fs).name, &val, &hnode);
00216     
00217     if (fl) {
00218         
00219     //  if ((*fs).parID == agentstable)
00220         
00221         hashdelete ((*fs).name, false, false); /*don't toss the value*/
00222         }
00223         
00224     
00225     pophashtable ();
00226     
00227     if (fl) {
00228         
00229         fl = hashtableassign (hdest, (*fs).name, val);
00230         
00231         /*
00232         if (fl && (hdest == agentstable) {
00233             
00234             hashtablelookupnode (hdest, (*fs).name, &hnode);
00235             
00236             scriptinstallagent (hnode);
00237             }
00238         */
00239         }
00240 
00241     opendinternalchange ();
00242     
00243     return (true);
00244 
00245     } /*claymovefile*/
00246 
00247 #endif
00248 
00249 #if filebrowswer
00250 
00251 static boolean filedeletevisit (bigstring bsitem, tyfileinfo *info, long refcon) {
00252     
00253     tybrowserspec fs;
00254     
00255 //  if (stringlength (fs.name) == 0) /*defensive driving -- if you turn this off -- it could delete C source code in the program you're testing*/
00256 //      return (false);
00257     
00258     claymakespec ((*info).vnum, (*info).dirid, bsitem, &fs);
00259     
00260     return (filedelete (&fs));
00261     } /*filedeletevisit*/
00262 
00263 
00264 boolean clayemptyfilefolder (tybrowserspec *fsfolder) {
00265     
00266     return (folderloop (fsfolder, true, &filedeletevisit, 0));
00267     } /*clayemptyfilefolder*/
00268 
00269 #endif
00270 
00271 #if odbbrowser
00272 
00273 boolean clayemptyfilefolder (tybrowserspec *fsfolder) {
00274 
00275     return (emptyhashtable ((*fsfolder).parID, true) > 0);
00276     } /*clayemptyfilefolder*/
00277 
00278 
00279 #endif
00280 
00281 
00282 #if filebrowser
00283 
00284 boolean claygetdirid (const tybrowserspec * fsfolder, tybrowserdir *dirid) {
00285     
00286     CInfoPBRec pb;
00287 
00288     if (!getmacfileinfo (fsfolder, &pb))
00289         return (false);
00290         
00291     *dirid = pb.dirInfo.ioDrDirID; 
00292     
00293     return (true);
00294     } /*claygetdirid*/
00295 
00296 #endif
00297 
00298 #if odbbrowser
00299 
00300 static boolean claygetfolder (const tybrowserspec * fsfolder, tybrowserdir *dirid, boolean flinmemory) {
00301     
00302     tyvaluerecord val;
00303     hdlhashnode hnode;
00304     
00305     if ((*fsfolder).parID == nil) {
00306         
00307         assert (equalstrings ((*fsfolder).name, nameroottable));
00308         
00309         *dirid = roottable;
00310         
00311         goto tagandexit;
00312         }
00313     
00314     if (isemptystring ((*fsfolder).name)) {
00315         
00316         *dirid = (*fsfolder).parID;
00317         
00318         goto tagandexit;
00319         }
00320     
00321     if (!claylookupvalue (fsfolder, &val, &hnode))
00322         return (false);
00323     
00324     if (flinmemory) {
00325         
00326         hdlexternalvariable hv = (hdlexternalvariable) val.data.externalvalue;
00327         
00328         if (!(**hv).flinmemory)
00329             return (false);
00330         }
00331     
00332     if (!tablevaltotable (val, dirid, hnode))
00333         return (false);
00334     
00335 tagandexit:
00336     
00337 //  (***dirid).flmayaffectdisplay = true; // let tablesymbol calls know we may care
00338     
00339     return (true);
00340     } /*claygetfolder*/
00341 
00342 
00343 boolean claygetdirid (const tybrowserspec * fsfolder, tybrowserdir *dirid) {
00344     
00345     return (claygetfolder (fsfolder, dirid, false));
00346     } /*claygetdirid*/
00347 
00348 
00349 boolean claygetinmemorydirid (const tybrowserspec * fsfolder, tybrowserdir *dirid) {
00350     
00351     return (claygetfolder (fsfolder, dirid, true));
00352     } /*claygetinmemorydirid*/
00353 
00354 #endif
00355 
00356 
00357 #if filebrowser
00358 
00359 static boolean filegetprefsspec (bigstring fname, tybrowserspec *fsprefs) {
00360     
00361     short vnum;
00362     long dirid;
00363     OSErr ec;
00364     
00365     ec = FindFolder (kOnSystemDisk, kPreferencesFolderType, kCreateFolder, &vnum, &dirid);
00366     
00367     if (oserror (ec)) 
00368         return (false);
00369     
00370     claymakespec (vnum, dirid, fname, fsprefs);
00371     
00372     return (true);
00373     } /*filegetprefsspec*/
00374 
00375 #endif
00376 
00377 #if 0 //odbbrowser
00378 
00379 static boolean xxxfilegetprefsspec (bigstring fname, tybrowserspec *fsprefs) {
00380     
00381     tybrowservol vnum;
00382     tybrowserdir dirid;
00383     
00384     vnum = databasedata;    // we really should use a different record, not an fsspec
00385     
00386     dirid = internaltable;
00387     
00388     claymakespec (vnum, dirid, fname, fsprefs);
00389     
00390     return (true);
00391     } /*filegetprefsspec*/
00392 
00393 #endif
00394 
00395 
00396 #if filebrowser
00397 
00398 static boolean filecreatefolder (const tybrowserspec * fsfolder) {
00399     
00400     OSErr ec;
00401     long folderid;
00402     
00403     ec = FSpDirCreate (fsfolder, smSystemScript, &folderid);
00404     
00405     return (true);
00406     } /*filecreatefolder*/
00407 
00408 #endif
00409 
00410 #if odbbrowser
00411 
00412 static boolean filecreatefolder (tybrowserspec * fsfolder) {
00413     
00414     tybrowserdir folderid;
00415     
00416     return (tablenewsystemtable ((*fsfolder).parID, (*fsfolder).name, (tybrowserdir *) &folderid));
00417     } /*filecreatefolder*/
00418 
00419 #endif
00420 
00421 boolean claygetsubitemspec (tybrowserspec *fsfolder, bigstring fname, tybrowserspec *fssubitem) {
00422     
00423     /*
00424     dmb 9/20/93: must return false if claymakespec returns false
00425     */
00426     
00427     tybrowserdir dirid;
00428     
00429     if (!claygetdirid (fsfolder, &dirid))
00430         return (false);
00431     
00432     return (claymakespec ((*fsfolder).vRefNum, dirid, fname, fssubitem));
00433     } /*claygetsubitemspec*/
00434 
00435 
00436 boolean claygetspecialfolder (void *foldername, boolean flcreate, tybrowserspec *fsspecialfolder) {
00437 
00438     /*
00439     a bottleneck for finding special Clay Basket folders. it actually works
00440     for files too -- it's used to locate the preferences file.
00441     
00442     if flcreate is true, and the folder doesn't exist, we create it.
00443     
00444     DW 3/12/95: Add another level, the Clay Basket folder is contained within
00445     the UserLand folder.
00446     */
00447     
00448     #if filebrowser
00449         tybrowserspec fsuserland, fsfolder;
00450         
00451         if (!filegetprefsspec (BIGSTRING ("\x08" "UserLand"), &fsuserland)) 
00452             return (false);
00453             
00454         if (!clayfileexists (&fsuserland, &flfolder)) {
00455             
00456             if (!filecreatefolder (&fsuserland))
00457                 return (false);
00458             }
00459         
00460         if (!claygetsubitemspec (&fsuserland, BIGSTRING ("\x12" "Clay Basket Folder"), &fsfolder))
00461             return (false);
00462             
00463         if (!clayfileexists (&fsfolder, &flfolder)) { 
00464         
00465             if (!filecreatefolder (&fsfolder))
00466                 return (false);
00467             }
00468         
00469         if (!claygetsubitemspec (&fsfolder, foldername, fsspecialfolder))
00470             return (false);
00471     #endif
00472 
00473     #if odbbrowser
00474         static hdlhashtable hclaybaskettable = nil;
00475         
00476         if (hclaybaskettable == nil) { // first time called
00477             
00478             if (!newhashtable (&hclaybaskettable))
00479                 return (false);
00480             }
00481 
00482         claymakespec (nil, hclaybaskettable, foldername, fsspecialfolder);
00483     #endif
00484     
00485     if (!flcreate)
00486         return (true);
00487         
00488     if (!clayfileexists (fsspecialfolder, &flfolder)) /*doesn't exist*/
00489         return (filecreatefolder (fsspecialfolder));
00490         
00491     return (true);
00492     } /*claygetspecialfolder*/
00493 
00494 #if filebrowser
00495     
00496 void fileinfotobrowserinfo (tyfileinfo *fileinfo, tybrowserinfo *browserinfo) {
00497     
00498     (*browserinfo).flfolder = (*fileinfo).flfolder;
00499     
00500     (*browserinfo).flvolume = (*fileinfo).flvolume;
00501     
00502     (*browserinfo).fllocked = (*fileinfo).fllocked;
00503     
00504     (*browserinfo).flhardwarelock = (*fileinfo).flhardwarelock;
00505     
00506     (*browserinfo).flremotevolume = (*fileinfo).flremotevolume;
00507     
00508     (*browserinfo).flstationery = (*fileinfo).flstationery;
00509     
00510     (*browserinfo).flalias = (*fileinfo).flalias;
00511     
00512     (*browserinfo).flejectable = (*fileinfo).flejectable;
00513     
00514     (*browserinfo).flnamelocked = (*fileinfo).flnamelocked;
00515     
00516     (*browserinfo).flcustomicon = (*fileinfo).flcustomicon;
00517     
00518     (*browserinfo).filetype = (*fileinfo).filetype;
00519     
00520     (*browserinfo).filecreator = (*fileinfo).filecreator;
00521 
00522     (*browserinfo).timecreated = (*fileinfo).timecreated;
00523     
00524     (*browserinfo).timemodified = (*fileinfo).timemodified;
00525     
00526     (*browserinfo).vnum = (*fileinfo).vnum;
00527     
00528     (*browserinfo).dirid = (*fileinfo).dirid;
00529     
00530     (*browserinfo).suffixnum = (*fileinfo).suffixnum; // dmb 5.0b9 - was: 0;
00531     
00532     (*browserinfo).ixlabel = (*fileinfo).ixlabel;
00533     
00534     (*browserinfo).folderview = (*fileinfo).folderview;
00535     
00536     if ((*browserinfo).flfolder) 
00537         (*browserinfo).filesize = (*fileinfo).ctfiles;
00538     else
00539         (*browserinfo).filesize = (*fileinfo).sizedatafork + (*fileinfo).sizeresourcefork;
00540     } /*fileinfotobrowserinfo*/
00541     
00542 #endif
00543 
00544 
00545 #if filebrowser
00546 
00547 
00548 typedef struct tycallbackinfo {
00549     
00550     tyclayfileloopcallback callback;
00551     
00552     long refcon;
00553     } tycallbackinfo;
00554 
00555 
00556 static boolean clayfolderexpandvisit (bigstring bsitem, tyfileinfo *info, long refcon) {
00557     
00558     tycallbackinfo *cb = (tycallbackinfo *) refcon;
00559     tybrowserinfo browserinfo;
00560     
00561     if ((*info).flinvisible && (!clayprefs.showinvisibles)) /*invisible file/folder, don't show it*/
00562         return (true);
00563     
00564     fileinfotobrowserinfo (info, &browserinfo);
00565     
00566     return ((*(*cb).callback) (bsitem, &browserinfo, (*cb).refcon));
00567     } /*clayfolderexpandvisit*/
00568 
00569 boolean clayfolderloop (const tybrowserspec *pfs, boolean flreverse, tyclayfileloopcallback filecallback, long refcon) {
00570 
00571     tycallbackinfo callbackinfo;
00572     
00573     callbackinfo.callback = filecallback;
00574     callbackinfo.refcon = refcon;
00575     
00576     return (folderloop (pfs, flreverse, clayfolderexpandvisit, (long) &callbackinfo));
00577     } /*clayfolderloop*/
00578 
00579 #endif
00580 
00581 
00582 #if odbbrowser
00583 
00584 typedef struct tycallbackinfo {
00585     
00586     hdldatabaserecord hdatabase;
00587     
00588     hdlhashtable hparenttable;
00589     
00590     tyclayfileloopcallback callback;
00591     
00592     long refcon;
00593     } tycallbackinfo;
00594 
00595 
00596 static boolean clayfolderloopvisit (bigstring bsname, hdlhashnode hnode, tyvaluerecord val, ptrvoid refcon) {
00597 #pragma unused(hnode, val)
00598 
00599     /*
00600     5.0a3 dmb: set flmayaffectdisplay for the parent table
00601 
00602     5.0a17 dmb: no, let clayfolderloop do it, once, even if table is empty
00603     */
00604     
00605     tybrowserspec fs;
00606     tybrowserinfo info;
00607     tycallbackinfo *cbinfo = (tycallbackinfo *) refcon;
00608     
00609     fs.vRefNum = (*cbinfo).hdatabase;
00610     
00611     fs.parID = (*cbinfo).hparenttable;
00612     
00613     copystring (bsname, fs.name);
00614     
00615     claygetfileinfo (&fs, &info);
00616     
00617     return (!(*(*cbinfo).callback) (bsname, &info, (*cbinfo).refcon));
00618     } /*clayfolderloopvisit*/
00619 
00620 
00621 boolean clayfolderloop (const tybrowserspec *pfs, boolean flreverse, tyclayfileloopcallback filecallback, long refcon) {
00622 #pragma unused(flreverse)
00623 
00624     /*
00625     5.0.2b21 dmb: set hdatafield according to pfs; no more databasedata refs
00626     */
00627 
00628     hdlhashtable htable;
00629     tycallbackinfo fileloopcallbackinfo;
00630     
00631     if (!claygetdirid (pfs, &htable))
00632         return (false);
00633     
00634     (**htable).flmayaffectdisplay = true;
00635     
00636     fileloopcallbackinfo.hdatabase = (*pfs).vRefNum;
00637     
00638     fileloopcallbackinfo.hparenttable = htable;
00639     
00640     fileloopcallbackinfo.callback = filecallback;
00641     
00642     fileloopcallbackinfo.refcon = refcon;
00643     
00644     return (!hashsortedinversesearch (htable, clayfolderloopvisit, &fileloopcallbackinfo));
00645     } /*clayfolderloop*/
00646 
00647 #endif
00648 
00649 
00650 boolean claygetfileinfo (const tybrowserspec *fs, tybrowserinfo *info) {
00651     
00652     /*
00653     5.0a3 dmb: side effect: set flmayaffectdisplay flags
00654     */
00655     
00656 #if filebrowser
00657     
00658     tyfileinfo fileinfo;
00659     
00660     if (!filegetinfo (fs, &fileinfo))
00661         return (false);
00662     
00663     fileinfotobrowserinfo (&fileinfo, info);
00664     
00665     return (true);
00666     
00667 #endif
00668 
00669 #if odbbrowser
00670 
00671     tyvaluerecord val;
00672     hdlexternalvariable hv;
00673     hdlhashtable ht;
00674     hdlhashnode hnode;
00675     long ct;
00676     
00677     clearbytes (info, sizeof (tybrowserinfo));
00678     
00679     if ((*fs).parID == nil) { // a root
00680     
00681         (*info).flfolder = true;
00682         
00683         hashcountitems (roottable, &ct);
00684         
00685         (*info).filesize = ct;
00686         }
00687     else {
00688         if (claylookupvalue (fs, &val, &hnode)) {
00689             
00690             if (val.valuetype == externalvaluetype) {
00691                 
00692                 hv = (hdlexternalvariable) val.data.externalvalue;
00693                 
00694                 (**hv).flmayaffectdisplay = true;
00695                 
00696                 if (istablevariable (hv)) {
00697                     
00698                     (*info).flfolder = true;
00699                     
00700                     (*info).filesize = 1; // can expand; don't care about actual #
00701                     
00702                     if ((**hv).flinmemory) {
00703                         
00704                         if (langexternalvaltotable (val, &ht, hnode))
00705                             (**ht).flmayaffectdisplay = true;
00706                         }
00707                     }
00708                 }
00709             
00710     //      langgetvalsize (val, &(*info).filesize);
00711             }
00712         }
00713     
00714     /*      *** replace fields with odb-specific info
00715     (*fs).filetype = (*fileinfo).filetype;
00716     
00717     (*fs).filecreator = (*fileinfo).filecreator;
00718 
00719     (*fs).timecreated = (*fileinfo).timecreated;
00720     
00721     (*fs).timemodified = (*fileinfo).timemodified;
00722     */
00723     
00724     (*info).vnum = (*fs).vRefNum;
00725     
00726     (*info).dirid = (*fs).parID;
00727     
00728     (*info).suffixnum = /*(*fileinfo).suffixnum*/ 0;
00729     
00730     /*
00731     (*fs).ixlabel = (*fileinfo).ixlabel;
00732     
00733     (*fs).folderview = (*fileinfo).folderview;
00734     
00735     if ((*fs).flfolder) 
00736         (*fs).filesize = (*fileinfo).ctfiles;
00737     else
00738         (*fs).filesize = (*fileinfo).sizedatafork + (*fileinfo).sizeresourcefork;
00739     */
00740     
00741     return (true);
00742     
00743 #endif
00744     } /*claygetfileinfo*/
00745 
00746 
00747 boolean claygetfilename (const tybrowserspec *pfs, bigstring name) {
00748     
00749 #if filebrowser
00750     
00751     return (filegetfilename (pfs, name));
00752     
00753 #endif
00754 
00755 #if odbbrowser
00756     
00757     copystring ((*pfs).name, name);
00758     
00759     return (true);
00760     
00761 #endif
00762     } /*claygetfilename*/
00763     
00764     
00765 boolean clayrenamefile (tybrowserspec *fs, hdlheadrecord headnode) {
00766     
00767     /*
00768     6.2b16 AR. tablesetitemname now takes a headnode param instead of a bigstring
00769     */
00770     
00771 #if filebrowser
00772     
00773     bigstring bsnew;
00774     
00775     opgetheadstring (headnode, bsnew);
00776     
00777     return (renamefile (fs, bsnew));
00778     
00779 #endif
00780 
00781 #if odbbrowser
00782     
00783     boolean fl;
00784     
00785     opstartinternalchange ();
00786     
00787     fl = tablesetitemname ((*fs).parID, (*fs).name, headnode, true);
00788     
00789     opendinternalchange ();
00790     
00791     return (fl);
00792 #endif  
00793     } /*clayrenamefile*/
00794 
00795 
00796 #if filebrowser
00797 
00798 static boolean expanddiskvisit (bigstring bsitem, tyfileinfo *info, long refcon) {
00799     
00800     /*
00801     dmb 9/24/93: need this layer between the diskloop and browserexpandvisit 
00802     to completely fill out the info record. most clients of diskloop don't 
00803     care about the fields that can only be set from the root directory, but 
00804     we do.
00805     */
00806     
00807     tybrowserspec fsdiskroot;
00808     
00809     if (filemakespec ((*info).vnum, (*info).dirid, bsitem, &fsdiskroot)) {
00810         
00811         if (filegetinfo (&fsdiskroot, info)) {
00812             
00813             tybrowserinfo browserinfo;
00814             
00815             fileinfotobrowserinfo (info, &browserinfo);
00816             
00817             browserexpandvisit (bsitem, &browserinfo, refcon);
00818             }
00819         }
00820     
00821     return (true);
00822     } /*expanddiskvisit*/
00823 
00824 #endif
00825 
00826 #if 0
00827 
00828 static boolean xxxclayinitializeoutline (void) {
00829 
00830 
00831     #if filebrowser
00832         tyexpandinfo expandinfo;    
00833         expandinfo.hparent = nil; /*special case, see browserfindinsertionpoint*/
00834         
00835         expandinfo.ctlevels = 1;
00836         
00837         expandinfo.flsettmpbits = false;
00838     
00839         return (diskloop (&expanddiskvisit, (long) &expandinfo));
00840     #endif
00841     
00842     #if odbbrowser
00843         tybrowserspec fsroot;
00844         tybrowserinfo browserinfo;
00845         tyexpandinfo expandinfo;    
00846         expandinfo.hparent = nil; /*special case, see browserfindinsertionpoint*/
00847         
00848         expandinfo.ctlevels = 1;
00849         
00850         expandinfo.flsettmpbits = false;
00851     
00852         fsroot.vRefNum = databasedata;
00853         
00854         /*
00855         fsroot.parID = roottable;
00856         
00857         setemptystring (fsroot.name);
00858         */
00859         
00860         fsroot.parID = nil;
00861         
00862         copystring (nameroottable, fsroot.name);
00863         
00864         claygetfileinfo (&fsroot, &browserinfo);
00865         
00866         return (clayfolderloop (&fsroot, false, browserexpandvisit, (long) &expandinfo));
00867         
00868     #endif
00869     } /*clayinitializeoutline*/
00870 
00871 #endif
00872 
00873 
00874 #if filebrowser
00875 
00876 static void pushadjective (bigstring adjective, bigstring bs) {
00877     
00878     bigstring adj;
00879     
00880     copystring (adjective, adj); /*we might modify it*/
00881     
00882     if (stringlength (bs) > 0) {
00883     
00884         pushstring (BIGSTRING ("\x01" " "), bs);
00885         
00886         alllower (adj);
00887         }
00888         
00889     pushstring (adj, bs);
00890     } /*pushadjective*/
00891     
00892 
00893 static void claygetfilekindstring (const tybrowserinfo *info, bigstring bs) {
00894     
00895 //  FSSpec appspec;
00896     
00897     if ((*info).flvolume) {
00898         
00899         setstringlength (bs, 0);
00900     
00901         if ((*info).flejectable)
00902             pushadjective (BIGSTRING ("\x09" "Removable"), bs);
00903             
00904         if ((*info).flhardwarelock)
00905             pushadjective (BIGSTRING ("\x09" "Read-only"), bs);
00906             
00907         if ((*info).flremotevolume)
00908             pushadjective (BIGSTRING ("\x06" "Shared"), bs);
00909         
00910         if (stringlength (bs) > 0)
00911             pushstring (BIGSTRING ("\x05" " disk"), bs);
00912         else
00913             copystring (BIGSTRING ("\x04" "Disk"), bs);
00914         
00915         return;
00916         }
00917     
00918     if ((*info).flfolder) {
00919         
00920         copystring (BIGSTRING ("\x06" "Folder"), bs);
00921         
00922         return;
00923         }
00924     
00925     if ((*info).flalias) {
00926         
00927         copystring (BIGSTRING ("\x05" "Alias"), bs);
00928         
00929         return;
00930         }
00931         
00932     switch ((*info).filecreator) {
00933         
00934         case 'DMGR': case 'ERIK':
00935             copystring (BIGSTRING ("\x14" "Desktop Manager file"), bs);
00936         
00937             return;
00938 
00939         case 'MACS':
00940             copystring (BIGSTRING ("\x0f" "System Software"), bs);
00941             
00942             return;
00943         } /*switch*/
00944         
00945     switch ((*info).filetype) {
00946         
00947         case 'APPL':
00948             copystring (BIGSTRING ("\x13" "Application program"), bs);
00949         
00950             return;
00951             
00952         case 'cdev':
00953             copystring (BIGSTRING ("\x0d" "Control Panel"), bs);
00954         
00955             return;
00956             
00957         case 'INIT': case 'appe': case 'fext': case 'adev':
00958             copystring (BIGSTRING ("\x10" "System Extension"), bs);
00959         
00960             return;
00961         
00962         case 'thng': 
00963             copystring (BIGSTRING ("\x10" "System Component"), bs);
00964         
00965             return;
00966             
00967         case 'PRER': case 'PRES':
00968             copystring (BIGSTRING ("\x11" "Chooser Extension"), bs);
00969         
00970             return;
00971             
00972         case 'FFIL':
00973             copystring (BIGSTRING ("\x0d" "Font Suitcase"), bs);
00974             
00975             return;
00976             
00977         case 'dbgr':
00978             copystring (BIGSTRING ("\x08" "Debugger"), bs);
00979             
00980             return;
00981             
00982         case 'dfil':
00983             copystring (BIGSTRING ("\x0e" "Desk Accessory"), bs);
00984             
00985             return;
00986         } /*switch*/
00987 #if 0   
00988     if (clayfindapp ((*info).filecreator, &appspec, (*info).vnum)) {
00989         
00990         if (stringlength (appspec.name) > 0) {
00991         
00992             copystring (appspec.name, bs);
00993     
00994             pushstring (BIGSTRING ("\x09" " document"), bs);
00995         
00996             return;
00997             }
00998         }
00999     else { /*DW 9/14/93 -- add it to the cache -- avoid future delays*/
01000         
01001         addapptocache ((*info).filecreator, nil);
01002         }
01003 #endif
01004     
01005     copystring (BIGSTRING ("\x08" "document"), bs);
01006     } /*claygetfilekindstring*/
01007     
01008 
01009 static void claygetfatsizestring (const tybrowserinfo *browserinfo, bigstring bs) {
01010     
01011     setstringlength (bs, 0);
01012     
01013     if ((*browserinfo).flvolume) { 
01014         
01015         tybrowserspec fs;
01016         tyfileinfo fileinfo;
01017         
01018         if (!claymakespec ((*browserinfo).vnum, 0, "\0", &fs))
01019             return;
01020     
01021         if (!filegetinfo (&fs, &fileinfo))
01022             return;
01023 
01024         numbertostring (fileinfo.cttotalbytes, bs);
01025         
01026         return;             
01027         }
01028         
01029     if ((*browserinfo).flfolder) {
01030         
01031         short ctfiles = (*browserinfo).filesize;
01032         
01033         numbertostring (ctfiles, bs);
01034         
01035         pushstring (BIGSTRING ("\x05" " item"), bs);
01036         
01037         if (ctfiles != 1)
01038             pushstring (BIGSTRING ("\x01" "s"), bs);
01039     
01040         return;
01041         }
01042         
01043     numbertostring ((*browserinfo).filesize, bs);
01044     } /*claygetfatsizestring*/
01045 
01046 
01047 #endif
01048 
01049 boolean browsertextchanged (hdlheadrecord hnode, bigstring origname) {
01050     
01051     /*
01052     dmb 9/24/93: don't call browserloadnode on hnode itself. renaming a 
01053     file doesn't change its mod date, so it shouldn't need reloading. if 
01054     something else has changed, say because something SpaceSaver took some 
01055     other action in response to the rename, reloading the node isn't 
01056     thorough enough. it will just prevent the idle loop from picking up 
01057     the change.
01058     
01059     5.0d18 dmb: don't resort node based on text change
01060 
01061     5.0b18 dmb: don't check line length here, with bogus message. it will 
01062     be checked by rename file
01063     
01064     6.2b16 AR: clayrenamefile now takes a hdlheadrecord instead of a bigstring
01065     */
01066     
01067     tybrowserspec fs;
01068     bigstring newname;
01069     tybrowserinfo info;
01070     
01071     claygetfilespec (hnode, &fs);
01072     
01073     if (!browsergetrefcon (hnode, &info)) // it's a new node
01074         return (browserlineinserted (hnode));
01075     
01076     opgetheadstring (hnode, newname);
01077     
01078     /*
01079     if (!browserchecklinelength (stringlength (newname), newname))
01080         return (false);
01081     */
01082 
01083     if (!info.flvolume) 
01084         copystring (origname, fs.name);
01085     
01086     if (!clayrenamefile (&fs, hnode))
01087         return (false);
01088     
01089     (**hnode).tmpbit2 = false; //user gave it a name, no longer temp
01090     
01091     langexternalpleasesave (fs.parID, newname); // 5.1.4
01092     
01093 //  if (clayprefs.addonnamechange)
01094 //      addnodetohistorymenu (hnode);
01095     
01096     if (false) 
01097         browserinsertagain (hnode);
01098     
01099     browserloadnode ((**hnode).headlinkleft); /*mod date changed*/
01100     
01101     return (true);
01102     } /*browsertextchanged*/
01103 
01104 

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