cancoonverbs.c

Go to the documentation of this file.
00001 
00002 /*  $Id: cancoonverbs.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 "resources.h"
00032 #include "lang.h"
00033 #include "langexternal.h"
00034 #include "tablestructure.h"
00035 #include "cancoon.h"
00036 #include "cancooninternal.h"
00037 #include "kernelverbdefs.h"
00038 #include "about.h"
00039 
00040 
00041 
00042 
00043 #define cancoonerrorlist 268 
00044 #define notimplementederror 3
00045 
00046 
00047 typedef enum tycancoontoken { 
00048     
00049     showflagfunc,
00050     
00051     hideflagfunc,
00052     
00053     showpopupfunc,
00054     
00055     hidepopupfunc,
00056     
00057     showbuttonsfunc,
00058     
00059     hidebuttonsfunc,
00060 
00061     showserverstatsfunc,
00062     
00063     /*
00064     setmsgfunc,
00065     */
00066     
00067     ctcancoonverbs
00068     } tycancoontoken;
00069 
00070 
00071 
00072 static boolean ccshowhideverb (hdltreenode hparam1, boolean flshow, boolean flshowing, callback toggleroutine, tyvaluerecord *vreturned) {
00073     
00074     /*
00075     set vreturned to false if the state of the flag is not changed.  otherwise, 
00076     call the toggle routine and return true.
00077     
00078     1/30/92 dmb: fixed typo; when toggling, set vreturned to true, not false!
00079     
00080     5.6.97 dmb: can no longer assume that the "root" window is cancoon. globals 
00081     are now set in ccfunctionvalue
00082     */
00083     
00084     if (!langcheckparamcount (hparam1, 0)) /*shouldn't have any parameters*/
00085         return (false);
00086     
00087     if (flshowing != flshow) { /*changing*/
00088     
00089     //  shellpushfrontrootglobals ();
00090         
00091         (*toggleroutine) ();
00092         
00093     //  shellpopglobals ();
00094         
00095         (*vreturned).data.flvalue = true;
00096         }
00097     
00098     return (true);
00099     } /*ccshowhideverb*/
00100 
00101 
00102 static boolean ccshowflagverb (hdltreenode hparam1, boolean flshow, tyvaluerecord *vreturned) {
00103     
00104     /*
00105     set vreturned to false if the state of the flag is not changed.
00106     */
00107     
00108     return (ccshowhideverb (hparam1, flshow, !(**cancoonglobals).flflagdisabled, (callback) &cctoggleflag, vreturned));
00109     } /*ccshowflagverb*/
00110 
00111 
00112 static boolean ccshowpopupverb (hdltreenode hparam1, boolean flshow, tyvaluerecord *vreturned) {
00113     
00114     /*
00115     set vreturned to false if the state of the popup is not changed.
00116     */
00117     
00118     return (ccshowhideverb (hparam1, flshow, !(**cancoonglobals).flpopupdisabled, (callback) &cctoggleagentspopup, vreturned));
00119     } /*ccshowpopupverb*/
00120 
00121 
00122 static boolean ccshowbuttonsverb (hdltreenode hparam1, boolean flshow, tyvaluerecord *vreturned) {
00123     
00124     /*
00125     set vreturned to false if the state of the buttons is not changed.
00126     */
00127     
00128     return (ccshowhideverb (hparam1, flshow, (**cancoonglobals).flbigwindow, (callback) &ccflipflag, vreturned));
00129     } /*ccshowbuttonsverb*/
00130 
00131 
00132 static boolean ccmsgverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
00133     
00134     bigstring bsmsg;
00135     
00136     flnextparamislast = true;
00137     
00138     if (!getstringvalue (hparam1, 1, bsmsg))
00139         return (false);
00140     
00141     if (shellwindow != nil)
00142         shellpushrootglobals (shellwindow);
00143     else
00144         shellpushfrontrootglobals ();
00145     
00146     ccmsg (bsmsg, !processisoneshot (true));
00147     
00148     shellpopglobals ();
00149     
00150     return (setbooleanvalue (true, vreturned));
00151     } /*ccmsgverb*/
00152 
00153 
00154 static boolean ccfunctionvalue (short token, hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
00155     
00156     /*
00157     8/23/91 dmb: don't push front globals around entire switch, since that 
00158     would disable background processes while the parameter to "msg" is 
00159     evaluated.
00160     
00161     8/25/92 dmb: commented-out setmsgfunc -- redundant & undocumented
00162     */
00163     
00164     register tyvaluerecord *v = vreturned;
00165     register boolean fl = false;
00166     register short errornum = 0;
00167     
00168     setbooleanvalue (false, v); /*by default, cancoon functions return false*/
00169     
00170     #ifdef version42orgreater
00171         // can no longer assume that the "root" window is cancoon
00172         if (!shellfindwindow (idcancoonconfig, &cancoonwindow, &cancoonwindowinfo, (Handle *) &cancoondata))
00173             return (true);
00174         
00175         shellpushglobals (cancoonwindow);
00176     #endif
00177 
00178     switch (token) {
00179         
00180         case showflagfunc:
00181             fl = ccshowflagverb (hparam1, true, v);
00182             
00183             break;
00184         
00185         case hideflagfunc:
00186             fl = ccshowflagverb (hparam1, false, v);
00187             
00188             break;
00189         
00190         case showpopupfunc:
00191             fl = ccshowpopupverb (hparam1, true, v);
00192             
00193             break;
00194         
00195         case hidepopupfunc:
00196             fl = ccshowpopupverb (hparam1, false, v);
00197             
00198             break;
00199         
00200         case showbuttonsfunc:
00201             fl = ccshowbuttonsverb (hparam1, true, v);
00202             
00203             break;
00204         
00205         case hidebuttonsfunc:
00206             fl = ccshowbuttonsverb (hparam1, false, v);
00207             
00208             break;
00209         
00210         case showserverstatsfunc: {
00211             boolean flset;
00212             
00213             flnextparamislast = true;
00214 
00215             if (!getbooleanvalue (hparam1, 1, &flset))
00216                 break;
00217                                                 
00218             aboutsetstatsflag (flset);
00219                         
00220             fl = setbooleanvalue (true, v);
00221             }
00222             
00223             break;
00224         
00225         /*
00226         case setmsgfunc:
00227             fl = ccmsgverb (hparam1, v);
00228             
00229             break;
00230         */
00231         
00232         default:
00233             fl = false;
00234             
00235             errornum = notimplementederror;
00236             
00237             break;
00238         } /*switch*/
00239     
00240     #ifdef version42orgreater
00241         shellpopglobals ();
00242     #endif
00243 
00244     if (fl)
00245         return (true);
00246     
00247     if (errornum != 0) /*get error string*/
00248         getstringlist (cancoonerrorlist, errornum, bserror);
00249     
00250     return (false);
00251     } /*ccfunctionvalue*/
00252 
00253 
00254 boolean ccinitverbs (void) {
00255     
00256     langcallbacks.msgverbcallback = &ccmsgverb;
00257     
00258     return (loadfunctionprocessor (idcancoonverbs, &ccfunctionvalue));
00259     } /*ccinitverbs*/
00260 
00261 
00262 
00263 

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