/* ----------------------------------------------------------------------------- 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 ----------------------------------------------------------------------------- */ typeof inetDl = ObjCURL;; fun deleteOb(inst, p)= let p -> [inst url litems pos utf8 req] in killHttpRequest req; 0;; fun cbNextItem(inst, from, action, param, reply, p)= let p -> [inst url litems pos utf8 req] in let sizelist litems -> size in let nth_list litems pos -> itemmark in let if (pos + 1) >= size then 0 else pos + 1 -> npos in ( let XMLgetData (XMLgetMarkByValueFromMark itemmark "title") -> title in let XMLgetData (XMLgetMarkByValueFromMark itemmark "link") -> link in let XMLgetData (XMLgetMarkByValueFromMark itemmark "description") -> desc in ( SendPluginEvent inst "Title" (if utf8 then (utf8tostr title) else title) nil; SendPluginEvent inst "Link" (if utf8 then (utf8tostr link) else link) nil; SendPluginEvent inst "Description" (if utf8 then (utf8tostr desc) else desc) nil; ); if (pos + 1) < size then nil else SendPluginEvent inst "End" nil nil; mutate p <- [_ _ _ npos _ _]; ); 0;; fun cbPreviousItem(inst, from, action, param, reply, p)= let p -> [inst url litems pos utf8 req] in let sizelist litems -> size in let nth_list litems pos -> itemmark in let if (pos - 1) < 0 then (size-1) else pos - 1 -> npos in ( let XMLgetData (XMLgetMarkByValueFromMark itemmark "title") -> title in let XMLgetData (XMLgetMarkByValueFromMark itemmark "link") -> link in let XMLgetData (XMLgetMarkByValueFromMark itemmark "description") -> desc in ( SendPluginEvent inst "Title" (if utf8 then (utf8tostr title) else title) nil; SendPluginEvent inst "Link" (if utf8 then (utf8tostr link) else link) nil; SendPluginEvent inst "Description" (if utf8 then (utf8tostr desc) else desc) nil; ); if (pos - 1) >= 0 then nil else SendPluginEvent inst "End" nil nil; mutate p <- [_ _ _ npos _ _]; ); 0;; fun cbGetContent(url, cont, p) = let p -> [inst url litems pos utf8 req] in let XMLloadString cont -> xmlrss in let XMLgetMarkByValue xmlrss "rss" -> rssmark in let XMLgetMarkByValueFromMark rssmark "channel" -> chanmark in let XMLgetMarksByValueFromMarkSons chanmark "item" -> litems in if litems == nil then nil else ( mutate p <- [_ _ litems 0 (if (strfindi "iso-8859-1" xmlrss.XMLtype 0) != nil then 0 else 1) nil]; SendPluginEvent inst "Loaded" nil nil; ); 0;; fun cbIsConnected(testurl, p, rc) = let p -> [inst url litems pos utf8 req] in if (rc == 1) then // Active Internet Connection detected ( mutate p <- [_ _ _ _ _ (getUrl url nil mkfun3 @cbGetContent p)]; 0; ) // No Active Internet Connection detected else 0;; fun cbSetUrl(inst, from, action, param, reply, p)= if !(strIsUrl param) then nil else let p -> [inst url litems pos utf8 req] in ( killHttpRequest req; mutate p <- [_ param nil 0 _ _]; checkInternetConnection nil @cbIsConnected p; ); 0;; fun cbReload(inst, from, action, param, reply, p)= let p -> [inst url litems pos utf8 req] in ( killHttpRequest req; mutate p <- [_ _ nil 0 _ nil]; checkInternetConnection nil @cbIsConnected p; ); 0;; fun newOb(inst)= let (getPluginInstanceParam inst "url") -> url in let [inst url nil (-1) 0 nil] -> p in ( PluginRegisterAction inst "Reload" mkfun6 @cbReload p; PluginRegisterAction inst "Set url" mkfun6 @cbSetUrl p; PluginRegisterAction inst "Previous item" mkfun6 @cbPreviousItem p; PluginRegisterAction inst "Next item" mkfun6 @cbNextItem p; setPluginInstanceCbDel inst mkfun2 @deleteOb p; cbSetUrl inst nil nil url nil p; ); 0;; fun IniPlug(file)= PlugRegister @newOb nil; setPluginEditor @dynamicedit; 0;;