htmlcontrol.c

Go to the documentation of this file.
00001 
00002 /*  $Id: htmlcontrol.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 #define NEEDMOREWIN 1
00032 
00033 #include "standard.h"
00034 
00035 #include "htmlcontrol.h"
00036 
00037 #include "WinLand.h"
00038 #include "dialogs.h"
00039 #include "file.h"
00040 #include "font.h"
00041 #include "kb.h"
00042 #include "menu.h"
00043 #include "mouse.h"
00044 #include "quickdraw.h"
00045 #include "scrap.h"
00046 #include "strings.h"
00047 #include "frontierwindows.h"
00048 #include "cancoon.h"
00049 #include "cancooninternal.h"
00050 #include "shell.h"
00051 #include "shellprivate.h"
00052 #include "shellmenu.h"
00053 #include "lang.h"
00054 #include "wininet.h"
00055 
00056 extern HWND hwndHTMLControl;
00057 
00058 #if (FRONTIERWEB==1)
00059 tywebappInfo gwebappInfo = {false, NULL};
00060 
00061 HANDLE webappStartup () {
00062 
00063     gwebappInfo.flactive = false;
00064 
00065     gwebappInfo.hwebappModule = LoadLibrary ("WEBAPPDLL.DLL");
00066     
00067     if (gwebappInfo.hwebappModule == NULL)
00068         gwebappInfo.hwebappModule = LoadLibrary ("DLLS\\WEBAPPDLL.DLL");
00069         
00070     if (gwebappInfo.hwebappModule == NULL)
00071         gwebappInfo.hwebappModule = LoadLibrary ("..\\DLLS\\WEBAPPDLL.DLL");
00072 
00073     if (gwebappInfo.hwebappModule != NULL) {
00074         gwebappInfo.webappSetup = (tywebappSetup) GetProcAddress (gwebappInfo.hwebappModule, "webappSetup");
00075         gwebappInfo.webappWndProc = (tywebappWndProc) GetProcAddress (gwebappInfo.hwebappModule, "webappWndProc");
00076         gwebappInfo.webappBack = (tywebappNoParam) GetProcAddress (gwebappInfo.hwebappModule, "webappBack");
00077         gwebappInfo.webappForward = (tywebappNoParam) GetProcAddress (gwebappInfo.hwebappModule, "webappForward");
00078         gwebappInfo.webappHome = (tywebappNoParam) GetProcAddress (gwebappInfo.hwebappModule, "webappHome");
00079         gwebappInfo.webappStop = (tywebappNoParam) GetProcAddress (gwebappInfo.hwebappModule, "webappStop");
00080         gwebappInfo.webappRefresh = (tywebappNoParam) GetProcAddress (gwebappInfo.hwebappModule, "webappRefresh");
00081         gwebappInfo.webappNavigate = (tywebappNavigate) GetProcAddress (gwebappInfo.hwebappModule, "webappNavigate");
00082         gwebappInfo.webappVersion = (tywebappVersion) GetProcAddress (gwebappInfo.hwebappModule, "webappVersion");
00083         gwebappInfo.webappIsOffline = (tywebappIsOffline) GetProcAddress (gwebappInfo.hwebappModule, "webappIsOffline");
00084         gwebappInfo.webappSetOffline = (tywebappSetOffline) GetProcAddress (gwebappInfo.hwebappModule, "webappSetOffline");
00085         }
00086 
00087     return (gwebappInfo.hwebappModule);
00088     } /*webappStartup*/
00089 
00090 boolean webappShutdown () {
00091 //  if ((gwebappInfo.webappSetup != NULL) && (gwebappInfo.webappWndProc != NULL))
00092 //      (*(gcomServerInfo.comclear)) ();
00093 
00094     if (gwebappInfo.hwebappModule != NULL)
00095         FreeLibrary (gwebappInfo.hwebappModule);
00096 
00097     gwebappInfo.webappSetup = NULL;
00098     gwebappInfo.webappWndProc = NULL;
00099     gwebappInfo.hwebappModule = NULL;
00100     return (TRUE);
00101     } /*webappShutdown*/
00102 
00103 long doweb (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
00104 //  long MDI;
00105 
00106 //  MDI = GetWindowLong(hwndMDIClient, GWL_USERDATA);
00107 
00108 //  if ((MDI != 0L) && (MDI == GetWindowLong(hwnd, GWL_USERDATA)))
00109         if (htmlcontrolactive())
00110             return ((*(gwebappInfo.webappWndProc))(hwnd, msg, wParam, lParam));
00111     return (1);
00112 }
00113 
00114 #endif
00115 
00116 void htmlcontrolback () {
00117     #if (FRONTIERWEB==1)
00118         if (gwebappInfo.webappBack == NULL)
00119             return;
00120 
00121         //(*(gwebappInfo.webappBack))();
00122 
00123         releasethreadglobals ();
00124 
00125         SendMessage (hwndHTMLControl, WM_USER+500, 0, 0);
00126 
00127         grabthreadglobals ();
00128     #endif
00129     }
00130 
00131 boolean htmlcontrolsetoffline (boolean floffline) {
00132 
00133     #if (FRONTIERWEB==1)
00134 
00135         /*releasethreadglobals ();
00136 
00137         SendMessage (hwndHTMLControl, WM_USER+501, floffline, 0);
00138 
00139         grabthreadglobals ();*/
00140 
00141     INTERNET_CONNECTED_INFO ci;
00142 
00143     memset(&ci, 0, sizeof(ci));
00144     if(floffline) {
00145         ci.dwConnectedState = INTERNET_STATE_DISCONNECTED_BY_USER;
00146         ci.dwFlags = ISO_FORCE_DISCONNECTED;
00147     } else {
00148         ci.dwConnectedState = INTERNET_STATE_CONNECTED;
00149     }
00150 
00151     InternetSetOption(NULL, INTERNET_OPTION_CONNECTED_STATE, &ci, sizeof(ci));
00152 
00153     #endif
00154 
00155     return (true);
00156     }
00157 
00158     
00159 void htmlcontrolforward () {
00160     #if (FRONTIERWEB==1)
00161         if (gwebappInfo.webappForward == NULL)
00162             return;
00163 
00164         (*(gwebappInfo.webappForward))();
00165     #endif
00166     }
00167 
00168 void htmlcontrolrefresh () {
00169     #if (FRONTIERWEB==1)
00170         if (gwebappInfo.webappRefresh == NULL)
00171             return;
00172 
00173         (*(gwebappInfo.webappRefresh))();
00174     #endif
00175     }
00176 
00177 void htmlcontrolhome () {
00178     #if (FRONTIERWEB==1)
00179         if (gwebappInfo.webappHome == NULL)
00180             return;
00181 
00182         (*(gwebappInfo.webappHome))();
00183     #endif
00184     }
00185 
00186 void htmlcontrolstop () {
00187     #if (FRONTIERWEB==1)
00188         if (gwebappInfo.webappStop == NULL)
00189             return;
00190 
00191         (*(gwebappInfo.webappStop))();
00192     #endif
00193     }
00194 
00195 void htmlcontrolnavigate (Handle htext) {
00196     #if (FRONTIERWEB==1)
00197         unsigned long len;
00198         char buff[2048];
00199 
00200         if (gwebappInfo.webappNavigate == NULL)
00201             return;
00202 
00203         len = gethandlesize (htext);
00204 
00205         memmove (buff, *htext, len);
00206 
00207         buff[len] = 0;
00208 
00209         releasethreadglobalsnopriority();
00210 
00211         (*(gwebappInfo.webappNavigate))(buff);
00212 
00213         grabthreadglobalsnopriority();
00214     #endif
00215     }
00216 
00217 boolean htmlcontrolversion (unsigned short * majorVersion, unsigned short * minorVersion) {
00218     #if (FRONTIERWEB==1)
00219 
00220         unsigned long version;
00221 
00222         if (gwebappInfo.webappVersion != NULL)
00223             version = (*(gwebappInfo.webappVersion))();
00224         else
00225             version = 0L;
00226 
00227         *majorVersion = HIWORD(version);
00228         *minorVersion = LOWORD(version);
00229         return (true);
00230 
00231     #else
00232 
00233         *majorVersion = 0;
00234         *minorVersion = 0;
00235         return (false);
00236 
00237     #endif
00238     }
00239 
00240 boolean htmlcontrolpresent () {
00241     #if (FRONTIERWEB==1)
00242 
00243         if (gwebappInfo.hwebappModule != NULL)
00244             return (true);
00245         else
00246             return (false);
00247 
00248     #else
00249 
00250         return (false);
00251 
00252     #endif
00253     }
00254 
00255 boolean htmlcontrolactive () {
00256     #if (FRONTIERWEB==1)
00257 
00258         return (gwebappInfo.flactive);
00259 
00260     #else
00261 
00262         return (false);
00263 
00264     #endif
00265     }
00266 
00267 boolean htmlcontrolisoffline (boolean * fl) {
00268 
00269     #if (FRONTIERWEB==1)
00270 
00271 
00272     DWORD   dwState = 0, dwSize = sizeof(DWORD);
00273     BOOL    fRet = FALSE;
00274 
00275     if(InternetQueryOption(NULL, INTERNET_OPTION_CONNECTED_STATE, &dwState,
00276         &dwSize))
00277     {
00278         if(dwState & INTERNET_STATE_DISCONNECTED_BY_USER)
00279             fRet = TRUE;
00280     }
00281 
00282     *fl = fRet;
00283 
00284     return (true);
00285 
00286 
00287     /*  short bl;
00288 
00289         if (gwebappInfo.webappIsOffline == NULL)
00290             return (false);
00291 
00292         if ((*(gwebappInfo.webappIsOffline))(&bl)) {
00293             *fl = bl;
00294             return (true);
00295             }
00296         else {
00297             return (false);
00298             }*/
00299     #else
00300         return (false);
00301     #endif*/
00302     }
00303 
00304 boolean htmlcontrolsetofflinehandler (boolean  fl) {
00305     #if (FRONTIERWEB==1)
00306         short bl;
00307         boolean floffline = false;
00308 
00309         if (gwebappInfo.webappSetOffline == NULL)
00310             return (false);
00311 
00312         bl = fl;
00313         releasethreadglobals ();
00314 
00315         floffline = (*(gwebappInfo.webappSetOffline)) (bl);
00316         
00317         grabthreadglobals ();
00318 
00319         return (floffline);
00320 
00321     #else
00322         return (false);
00323     #endif
00324     }
00325 
00326 
00327 long CALLBACK htmlControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
00328     
00329 #if (FRONTIERWEB==1)
00330     
00331     doweb (hwnd, msg, wParam, lParam);
00332 
00333 
00334     if (msg == WM_USER+500)
00335         (*(gwebappInfo).webappBack) ();
00336 
00337     if (msg == WM_USER+501)
00338         htmlcontrolsetofflinehandler (wParam);
00339 
00340     switch (msg) {
00341         case WM_WINDOWPOSCHANGING:
00342             {
00343             WINDOWPOS * wp;
00344 
00345             if (hwndMDIClient != NULL) {
00346 
00347                 wp = (WINDOWPOS *) lParam;
00348 
00349                 wp->flags |= SWP_NOZORDER;
00350                 
00351                 }
00352             break;
00353             }
00354         }
00355 #endif
00356 
00357     return (DefMDIChildProc (hwnd, msg, wParam, lParam));
00358     }

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