WebGadget Problem

Linux specific forum
Perkin
Enthusiast
Enthusiast
Posts: 504
Joined: Thu Jul 03, 2008 10:13 pm
Location: Kent, UK

WebGadget Problem

Post by Perkin »

I'm trying to get some of my old code to work on linux (xubuntu 10.4)

Is there any workaround to get this working in linux, so the page loads fully/properly.
(works perfectly well in Windows and url works fine in full Firefox browser.)

May need to be in UK! (which I am)

Code: Select all

url.s="http://www.bbc.co.uk/iplayer/console/bbc_radio_two"
OpenWindow(0,400,50,420,720,"BBC Radio 2", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget)
WebGadget(1,0,0,420,720,url)
Repeat
  evn = WaitWindowEvent()
Until evn = #PB_Event_CloseWindow
Comes up with an error page - phone not supported
%101010 = $2A = 42
User avatar
idle
Always Here
Always Here
Posts: 6026
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: WebGadget Problem

Post by idle »

I got the same error
maybe it's a java or cookie problem or maybe it's just the header passed to the page by the browser
so perhaps you can spoof the header and download the page locally and open it from file.

using firefox is fine form NZ, Jool Holand show is on at the moment!
Windows 11, Manjaro, Raspberry Pi OS
Image
Perkin
Enthusiast
Enthusiast
Posts: 504
Joined: Thu Jul 03, 2008 10:13 pm
Location: Kent, UK

Re: WebGadget Problem

Post by Perkin »

idle wrote:maybe it's just the header passed to the page by the browser
so perhaps you can spoof the header and download the page locally and open it from file.
That's what I don't get how to do. Any hints of how to do?

The page streams audio so I don't think dl'ing and opening will be possible.

Thanks.
%101010 = $2A = 42
User avatar
idle
Always Here
Always Here
Posts: 6026
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: WebGadget Problem

Post by idle »

Try this to get the source, save it to file then open it in the webgadget
then try to alter the user-agent: at line 32 adding the browser type
(I'm just assuming that's what the problem is, I really don't know)


Code: Select all

Global gServerID
Global gBusy

Procedure.s GetURL(mUrl.s)
 
  Protected Header.s, *Buffer = AllocateMemory(1200), recString.s,mDoc.s,mServer.s,Timeout.i,pos,pos1,lRet.i,i.i,DataLength.i,TotalRec.i,tdata.s,rlen.i,chunked.i
   
  i=FindString(mUrl,"/",1)
  If i
    mDoc = Right(mUrl,Len(mUrl)-i)
    mServer = Left(mUrl,i-1)
  Else
    ProcedureReturn ""
  EndIf
   
   
  If gbusy = 0
     gServerID = OpenNetworkConnection(mServer,80)
     
           
      If Not gServerID
        MessageRequester("Network Problem","Can't establish connection, please check that you're online")
       
      EndIf
  EndIf
     
  Timeout = ElapsedMilliseconds() + 10000
       
  If gServerID
       
    Header = "GET /"+ mDoc + " HTTP/1.1"+#CRLF$ 
    Header + "User-Agent: Mozilla/5.0 (Linux;en-GB; rv:1.8.0.11) Gecko/20070312 Firefox/1.5.0.11" + #CRLF$ ;you can  change the header to spoof the browser  "User-Agent:  
    Header + "Host: "+ mServer + #CRLF$+#CRLF$
       
      SendNetworkData(gServerID,@Header,Len(Header))
     
      Repeat
        Delay(2)
      Until NetworkClientEvent(gServerID) = #PB_NetworkEvent_Data And ElapsedMilliseconds() < Timeout
     
      If ElapsedMilliseconds() < Timeout 
         DataLength = ReceiveNetworkData(gServerID,*Buffer,1200)
         totalRec + DataLength
         recString + PeekS(*Buffer,DataLength)
         pos = FindString(UCase(recString),UCase("Content-Length"),1)
         If pos
            pos1 = FindString(UCase(recString),#CRLF$,pos+2)
            tdata.s = Mid(recString,pos,pos1-pos)
            pos = FindString(tdata,":",1)
            rlen = Val(Right(tdata,Len(tdata)-(pos+1)) )
           
            Debug "content len " + Str(rlen) 
         ElseIf FindString(UCase(recString),UCase("Transfer-Encoding: chunked"),1) 
            rlen = $7FFFFFFF
            chunked = 1
         EndIf   
         ;Debug recString
         Repeat
           DataLength = ReceiveNetworkData(gServerID,*Buffer,1200)
           totalRec + DataLength
           Debug Datalength
           If DataLength
              recString + PeekS(*Buffer,DataLength)
           EndIf
           Delay(2)
           If chunked
             If FindString(recString, #CRLF$ + "0" + #CRLF$,1)
               DataLength = 0   
             EndIf
           EndIf   
         Until totalRec >= rlen Or DataLength = 0   
         Debug Str(totalRec) + " " + Str(datalength) 
      EndIf     
      CloseNetworkConnection(gServerID)
 
  EndIf 
 
  FreeMemory(*Buffer)
  gbusy = 0
 
  ProcedureReturn recString
   
EndProcedure

InitNetwork()

OpenWindow(#PB_Any,0,0,800,600,"event window",#PB_Window_ScreenCentered | #PB_Window_SystemMenu)
 
StringGadget(0,5,5,240,20,"www.bbc.co.uk/iplayer/console/bbc_radio_two ") 
ButtonGadget(1,5,25,60,20,"Get")
WebGadget(2,5,45,790,560,"")
;EditorGadget(2,5,45,790,560)

Repeat

ev = WaitWindowEvent()

If ev = #PB_Event_Gadget
    evg = EventGadget()
    If evg = 1
      SetGadgetText(2,"")
      murl.s = GetGadgetText(0)
      doc.s = geturl(murl)
      If doc <> ""
        OpenFile(0,"/tmp/bbc2.html")
        WriteString(0,doc)
        CloseFile(0)
        SetGadgetText(2,"file:///tmp/bbc2.html")
        
      EndIf   
    EndIf       
EndIf

Until ev = #PB_Event3D_CloseWindow 
Windows 11, Manjaro, Raspberry Pi OS
Image
Perkin
Enthusiast
Enthusiast
Posts: 504
Joined: Thu Jul 03, 2008 10:13 pm
Location: Kent, UK

Re: WebGadget Problem

Post by Perkin »

Thanks. Yes, that loads the page, but as you said, doesn't bring up the audio (which is the main reason for code).

I'm getting two debugger WARNINGs from line 96 (ev = WaitWindowEvent()) which could be the reason

GLib GObject (CRITICAL): g_object_unref : assertion `G_IS_OBJECT (object)' failed

MESSAGE: console message: http://static.bbc.co.uk/frameworks/requ ... /requirejs @1: Error: require.js load timeout for modules: pal/flagpoles

Any more suggestions.

Such a pain, when the Windows version just works, it's a headache to sort out - especially when it's beyond my ability -- Thats why I love the Forum :D
%101010 = $2A = 42
User avatar
idle
Always Here
Always Here
Posts: 6026
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: WebGadget Problem

Post by idle »

Don't know, maybe it hasn't downloaded a jscript if there are any relative links in the source they won't get resolved
as it would be looking in the tmp dir. If thats the case you'll have to work out what the absolute path is and do a search
and replace before saving the file like this maybe

Code: Select all

        pos=1
        repeat  
          pos = FindString(doc,Chr(32)+#DOUBLEQUOTE$+"/",pos)
          If pos 
             InsertString(doc,"http://www.bbc.co.uk/WhatEverPathMayBe/",pos)
          EndIf   
       until pos =0   
or download the jscripts into the tmp dir
Windows 11, Manjaro, Raspberry Pi OS
Image
Perkin
Enthusiast
Enthusiast
Posts: 504
Joined: Thu Jul 03, 2008 10:13 pm
Location: Kent, UK

Re: WebGadget Problem

Post by Perkin »

Still no joy.

Looks like I'll just have to open that in ff and leave open.

I'll also do a bug report, for the WebGadget - as it's not being perceived as a 'full' browser
%101010 = $2A = 42
User avatar
idle
Always Here
Always Here
Posts: 6026
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: WebGadget Problem

Post by idle »

I'm not sure what the problem is but yes it's probably missing an extension
Windows 11, Manjaro, Raspberry Pi OS
Image
Perkin
Enthusiast
Enthusiast
Posts: 504
Joined: Thu Jul 03, 2008 10:13 pm
Location: Kent, UK

Re: WebGadget Problem

Post by Perkin »

Idle, thanks for your input.
%101010 = $2A = 42
User avatar
idle
Always Here
Always Here
Posts: 6026
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: WebGadget Problem

Post by idle »

your welcome, I wasn't much help though!
Windows 11, Manjaro, Raspberry Pi OS
Image
Ramihyn_
Enthusiast
Enthusiast
Posts: 314
Joined: Fri Feb 24, 2006 9:40 am

Re: WebGadget Problem

Post by Ramihyn_ »

If you really want to know whats "missing", you could fire up wireshark and watch what is being loaded in the windows version and what is loaded with the linux version.
User avatar
idle
Always Here
Always Here
Posts: 6026
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: WebGadget Problem

Post by idle »

yes that could help
while it sends errors to stdout so they appear in the debugger, they not really saying what the problem is.
well it is but it's not telling Perkin if its a problem with the browser missing some feature.
I just thought that the webgadget might not have support for swf audio streams.
flash on linux isn't that flash!
Windows 11, Manjaro, Raspberry Pi OS
Image
Post Reply