/* ----------------------------------------------------------------------------- This source file is part of OpenSpace3D For the latest info, see http://www.openspace3d.com Copyright (c) 2012 I-maginer This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA, or go to http://www.gnu.org/copyleft/lesser.txt ----------------------------------------------------------------------------- */ fun deleteOb(inst)= clearHttpRequest; clearHttpCookies; 0;; fun cbGetContent(url, data, p) = let p -> [inst url] in if (data != nil) then ( SendPluginEvent inst "Response" data nil; 0; ) else ( addLogMessage strcatn "Call Url PlugIT : "::url::" failed or empty response!"::nil; 0; ); 0;; fun cbIsConnected(testurl, p, rc) = if (rc == 1) then // Active Internet Connection detected let p -> [inst url urlparams] in ( if (urlparams != nil) && (strcmp (strtrim urlparams) "") then postUrl url urlparams mkfun3 @cbGetContent [inst url] else getUrl url nil mkfun3 @cbGetContent [inst url]; 0; ) // No Active Internet Connection detected else ( addLogMessage "Call Url PlugIT : no internet connection found!"; 0; );; fun cbCall(inst, from, action, param, reply, p)= let p -> [url urlparams] in let if param == nil then _DMSreadParam param urlparams else param -> urlparams in // replace $0, $1.. and %var% let _DMSreadParam param url -> url in checkInternetConnection nil @cbIsConnected [inst url urlparams]; 0;; fun newOb(inst)= let (getPluginInstanceParam inst "url") -> url in let (getPluginInstanceParam inst "params") -> params in ( PluginRegisterAction inst "Call" mkfun6 @cbCall [url params]; setPluginInstanceCbDel inst @deleteOb; ); 0;; fun IniPlug(file)= PlugRegister @newOb nil; setPluginEditor @dynamicedit; 0;;