<div dir="ltr">Thanks James.<div><br></div><div>In other news, I have tried add a simple web server,</div><div>but apparently I couldn't make run webkit and the webserver together,</div><div>even using threads.</div><div>
<br></div><div>Gonzalo</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Sep 19, 2013 at 7:46 PM, James Cameron <span dir="ltr"><<a href="mailto:quozl@laptop.org" target="_blank">quozl@laptop.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I just love sockets.<br>
<br>
But that seems wrong to me; to open a socket to get a port number and<br>
then shut it down. Presumably later code would open another socket<br>
and bind it to the port?<br>
<br>
If you truly need to do it that way, there's one more thing to add<br>
before the call to bind():<br>
<br>
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)<br>
<br>
This is so that the same port number can be re-used shortly<br>
afterwards. Otherwise the later code would see an address in use<br>
error.<br>
<div class="HOEnZb"><div class="h5"><br>
On Thu, Sep 19, 2013 at 08:56:31AM -0300, Gonzalo Odiard wrote:<br>
> A free port can be get using:<br>
><br>
> # Get a free socket<br>
> sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)<br>
> sock.bind(('', 0))<br>
> sock.listen(socket.SOMAXCONN)<br>
> _ipaddr, self.port = sock.getsockname()<br>
> sock.shutdown(socket.SHUT_RDWR)<br>
> logging.error('Using port %d', self.port)<br>
><br>
> Should be good use 0.0.0.0 as ip instead of localhost, to avoid [1]<br>
> To serve the files python already have HTTPServer.<br>
><br>
> Gonzalo<br>
><br>
> [1] <a href="http://dev.laptop.org/ticket/12479" target="_blank">http://dev.laptop.org/ticket/12479</a> <br>
><br>
><br>
> On Wed, Sep 18, 2013 at 9:39 PM, Daniel Narvaez <<a href="mailto:dwnarvaez@gmail.com">dwnarvaez@gmail.com</a>> wrote:<br>
><br>
> Just a directory. It needs to be one server per activity though, so that<br>
> the different port gives us a different origin.<br>
><br>
><br>
> On 18 September 2013 23:32, Gonzalo Odiard <<a href="mailto:gonzalo@laptop.org">gonzalo@laptop.org</a>> wrote:<br>
><br>
> Ok. Thanks.<br>
> The web server need have something special or just serve a directory is<br>
> enough? <br>
><br>
> Gonzalo<br>
><br>
><br>
> On Wed, Sep 18, 2013 at 6:22 PM, Daniel Narvaez <<a href="mailto:dwnarvaez@gmail.com">dwnarvaez@gmail.com</a>><br>
> wrote:<br>
><br>
> Well, there are several html features which depend on each activity<br>
> having their own origin, for example local storage.<br>
><br>
><br>
> On Wednesday, 18 September 2013, Gonzalo Odiard wrote:<br>
><br>
> No, why is needed use a local web server instead of<br>
> the use of the proposed solution (use '<br>
> enable-file-access-from-file-uris' )<br>
><br>
> Gonzalo<br>
><br>
><br>
> On Wed, Sep 18, 2013 at 6:06 PM, Daniel Narvaez <<br>
> <a href="mailto:dwnarvaez@gmail.com">dwnarvaez@gmail.com</a>> wrote:<br>
><br>
> You mean why the http server would be a problem?<br>
><br>
><br>
> On Wednesday, 18 September 2013, Gonzalo Odiard wrote:<br>
><br>
> This is for the potential security risk of opening<br>
> files outside of the activity directory,<br>
> or because can be a problem with different activities<br>
> running at the same time<br>
> or multiple instances of the same activity?<br>
><br>
> Gonzalo<br>
><br>
><br>
> On Wed, Sep 18, 2013 at 5:46 PM, Daniel Narvaez <<br>
> <a href="mailto:dwnarvaez@gmail.com">dwnarvaez@gmail.com</a>> wrote:<br>
><br>
> You could put an http server in the activity...<br>
> Sucks but I'm not sure there is a better way :/<br>
><br>
><br>
> On Wednesday, 18 September 2013, Manuel Quiñones<br>
> wrote:<br>
><br>
> I finally got web activities working on XO-4,<br>
> in the AU build<br>
> published yesterday [1] . I did it by<br>
> modifying webactivities.py to<br>
> use WebKitGTK1 instead of v2. The changes are:<br>
><br>
> <a href="https://github.com/manuq/sugar-toolkit-gtk3-1/" target="_blank">https://github.com/manuq/sugar-toolkit-gtk3-1/</a><br>
> compare/webacts-webkit1<br>
><br>
> I tried it with Gears Activity v3, and is<br>
> working. It stores the data<br>
> and the metadata. So it is communicating with<br>
> the shell just fine.<br>
><br>
> The touchscreen is not responding very well, at<br>
> least in this<br>
> activity. I can tap buttons, but I can barely<br>
> drag to move a gear or<br>
> to draw one. The dragging seems to be<br>
> cancelled in the middle of the<br>
> action. Mouse input works fine.<br>
><br>
> Also as expected, the icons look small in the<br>
> XO screen because I need<br>
> to adapt the theme. But that is an easy one,<br>
> just changing the<br>
> CEL_SIZE variable in the LESS file to create<br>
> another CSS for the XO<br>
> screen DPI, and adding a CSS media query<br>
> selector to the HTML. I'll<br>
> provide a patch to sugar-web-template and will<br>
> update my web<br>
> activities.<br>
><br>
> The inspector is not working, it does not<br>
> display. It shoud display<br>
> by Ctrl+Shift+I or by right-click -> "Inspect<br>
> element". There is no<br>
> error in the logs and the API is there [2], but<br>
> nothing is happening.<br>
> Surprisingly, JavaScript console logs go to the<br>
> activity log. We are<br>
> missing that in master.<br>
><br>
> I managed to keep the activity:// scheme that<br>
> we need for the<br>
> same-origin policy, but I still had to add the<br>
> setting<br>
> 'enable-file-access-from-file-uris' to<br>
> workaround the cross-site<br>
> requests. I can't find a way to register the<br>
> URI scheme in WK1, so I<br>
> added a big FIXME.<br>
><br>
> [1] <a href="http://build.laptop.org.au/xo/os/sugar-100/" target="_blank">http://build.laptop.org.au/xo/os/sugar-100/</a><br>
> build-21/<br>
> [2] <a href="http://webkitgtk.org/reference/webkitgtk/" target="_blank">http://webkitgtk.org/reference/webkitgtk/</a><br>
> stable/WebKitWebInspector.html<br>
><br>
><br>
> --<br>
> .. manuq ..<br>
> _______________________________________________<br>
> Sugar-devel mailing list<br>
> <a href="mailto:Sugar-devel@lists.sugarlabs.org">Sugar-devel@lists.sugarlabs.org</a><br>
> <a href="http://lists.sugarlabs.org/listinfo/sugar-devel" target="_blank">http://lists.sugarlabs.org/listinfo/sugar-devel</a><br>
><br>
><br>
><br>
> --<br>
> Daniel Narvaez<br>
><br>
><br>
> _______________________________________________<br>
> Sugar-devel mailing list<br>
> <a href="mailto:Sugar-devel@lists.sugarlabs.org">Sugar-devel@lists.sugarlabs.org</a><br>
> <a href="http://lists.sugarlabs.org/listinfo/sugar-devel" target="_blank">http://lists.sugarlabs.org/listinfo/sugar-devel</a><br>
><br>
><br>
><br>
><br>
><br>
><br>
> --<br>
> Daniel Narvaez<br>
><br>
><br>
><br>
><br>
><br>
><br>
> --<br>
> Daniel Narvaez<br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
> --<br>
> Daniel Narvaez<br>
><br>
><br>
<br>
> _______________________________________________<br>
> Sugar-devel mailing list<br>
> <a href="mailto:Sugar-devel@lists.sugarlabs.org">Sugar-devel@lists.sugarlabs.org</a><br>
> <a href="http://lists.sugarlabs.org/listinfo/sugar-devel" target="_blank">http://lists.sugarlabs.org/listinfo/sugar-devel</a><br>
<br>
<br>
--<br>
</div></div><span class="HOEnZb"><font color="#888888">James Cameron<br>
<a href="http://quozl.linux.org.au/" target="_blank">http://quozl.linux.org.au/</a><br>
</font></span></blockquote></div><br></div>