notify.c

Go to the documentation of this file.
00001 
00002 /*  $Id: notify.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 "memory.h"
00032 #include "strings.h"
00033 #include "lang.h"
00034 #include "shell.h"
00035 #include "process.h"
00036 #include "notify.h"
00037 #include "dialogs.h"
00038 #include "versions.h"
00039 
00040 
00041 
00042 typedef struct tyiconfamily {
00043     
00044     Handle hicl1, hicl4, hicl8, hmskl;
00045     
00046     Handle hics1, hics4, hics8, hmsks;
00047     
00048     long unknown1, unknown2;
00049     } tyiconfamily, **hdliconfamily;
00050 
00051 
00052 boolean notifyuser (bigstring bsmessage) {
00053     
00054     /*
00055     use the Notification Manager to ask the user to bring our app to the front.
00056     
00057     note that we must allocate the record in the heap because multi-threading 
00058     makes stack addresses non-persistent.
00059     
00060     1/18/93 dmb: langbackgroundtask now takes flresting parameter; don't set global
00061     
00062     6/9/93 dmb: don't ignore the result of the background callbacks
00063     
00064     2.1b5 dmb: if we're in the main thread, need to do same as if yield is disabled.
00065 
00066     7.0d6 PBS: In Pike, the header of the dialog should not read UserLand Frontier,
00067     it should be UserLand [Whatever]. At this writing, [Whatever] is still undefined,
00068     so we'll go with Whatever for the moment.
00069     */
00070     
00071 #ifdef MACVERSION
00072 
00073     NMRecPtr pb;
00074     tyiconfamily icons;
00075     OSErr errcode;
00076     boolean fl = true;
00077 
00078     #define systemevents (osMask | updateMask | activMask | highLevelEventMask)
00079 
00080     #if TARGET_API_MAC_CARBON == 1
00081     
00082         {
00083         
00084             SInt16 itemhit = 0;
00085             OSErr err = noErr;
00086             
00087             err = StandardAlert (kAlertNoteAlert, bsmessage, nil, nil, &itemhit);
00088     
00089             return (err == noErr);
00090         }
00091     
00092     #endif
00093     
00094     pb = (NMRecPtr) NewPtrClear (longsizeof (NMRec));
00095     
00096     if (pb == nil)
00097         return (false);
00098     /*
00099     clearbytes (&pb, longsizeof (pb));
00100     */
00101     
00102     (*pb).qType = nmType;
00103     
00104     (*pb).nmMark = 1;
00105     
00106     clearbytes (&icons, longsizeof (icons));
00107     
00108     icons.hics1 = GetResource ('ics#', 128);
00109     
00110     icons.hics4 = GetResource ('ics4', 128);
00111     
00112     icons.hics8 = GetResource ('ics8', 128);
00113     
00114     newfilledhandle (&icons, longsizeof (tyiconfamily), &(*pb).nmIcon);
00115     
00116     (*pb).nmSound = (Handle) -1;
00117     
00118     if (isemptystring (bsmessage))
00119         (*pb).nmStr = nil;
00120     
00121     else {
00122         (*pb).nmStr = (StringPtr) NewPtr (stringsize (bsmessage));
00123         
00124         copystring (bsmessage, (*pb).nmStr);
00125         }
00126     
00127     (*pb).nmResp = nil;
00128     
00129     errcode = NMInstall (pb);
00130     
00131     if (errcode == noErr) {
00132         
00133         while (!shellisactive ()) {
00134             
00135             if (flscriptrunning) {
00136                 
00137                 if (fldisableyield || inmainthread ())
00138                     fl = langpartialeventloop (systemevents);
00139                 else
00140                     fl = langbackgroundtask (true); /*let main thread field events*/
00141                 }
00142             else
00143                 fl = shellpartialeventloop (systemevents);
00144             
00145             if (!fl)
00146                 break;
00147             }
00148         
00149         NMRemove (pb);
00150         }
00151     
00152     disposehandle ((*pb).nmIcon);
00153     
00154     if ((*pb).nmStr != nil)
00155         DisposePtr ((Ptr) (*pb).nmStr);
00156     
00157     DisposePtr ((Ptr) pb);
00158 
00159     return (fl && (errcode == noErr));
00160 #endif
00161 
00162 #ifdef WIN95VERSION
00163     char s [256];
00164     short itemnumber;
00165 
00166     copyptocstring (bsmessage, s);
00167 
00168     releasethreadglobals ();
00169 
00170 //#ifdef PIKE
00171 //
00172 //  /*7.0d8 PBS: name change to Radio UserLand*/
00173 //
00174 //  itemnumber = MessageBox (hwndMDIClient, s, "Radio UserLand", MB_OK | MB_ICONINFORMATION | MB_APPLMODAL);
00175 //
00176 //#else
00177 
00178 /* 9.1b3 JES: APPNAME macro is defined in versions.h for both Radio and Frontier -- use instead of hard-coded string */
00179 itemnumber = MessageBox (hwndMDIClient, s, APPNAME, MB_OK | MB_ICONINFORMATION | MB_APPLMODAL);
00180 
00181 //#endif
00182 
00183     grabthreadglobals ();
00184     
00185     return (itemnumber == IDOK);
00186 #endif
00187     } /*notifyuser*/
00188 
00189 
00190 
00191 
00192 
00193 

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