<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Fbreader on Random notes from mg</title>
    <link>https://mg.pov.lt/blog/tags/fbreader.html</link>
    <description>Recent content in Fbreader on Random notes from mg</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <managingEditor>marius@gedmin.as (Marius Gedminas)</managingEditor>
    <webMaster>marius@gedmin.as (Marius Gedminas)</webMaster>
    <copyright>Copyright © 2004–2020 Marius Gedminas</copyright>
    <lastBuildDate>Fri, 29 Jul 2011 03:16:38 +0300</lastBuildDate>
    <atom:link href="https://mg.pov.lt/blog/tags/fbreader/index.xml" rel="self" type="application/rss+xml" />
    
    <item>
      <title>Porting FBReader to Meego 1.2 Harmattan</title>
      <link>https://mg.pov.lt/blog/harmattan-fbreader.html</link>
      <pubDate>Fri, 29 Jul 2011 03:16:38 +0300</pubDate>
      <author>marius@gedmin.as (Marius Gedminas)</author>
      <guid>https://mg.pov.lt/blog/harmattan-fbreader.html</guid>
      <description>
&lt;p&gt;&lt;a href=&#34;http://wiki.meego.com/User:Fiferboy&#34;&gt;Andrew Olmsted&lt;/a&gt; built
the first &lt;a href=&#34;http://www.fbreader.org&#34;&gt;FBReader&lt;/a&gt; packages for Harmattan, after &lt;a
href=&#34;https://mg.pov.lt/fiferboy-fbreader-harmattan.patch&#34;&gt;tweaking the build
system&lt;/a&gt; a bit.  The desktop version of FBReader already used Qt 4, and
ran almost unmodified, but with some bugs (&lt;a
href=&#34;http://pastie.org/2238548&#34;&gt;segfault&lt;/a&gt; on task switch) and ugly
UI.&lt;/p&gt;

&lt;p&gt;I started with the Ubuntu packages for FBReader, since they used a more
sane build system for .debs (compared to upstream&#39;s &lt;a
href=&#34;https://github.com/geometer/FBReader/blob/master/build_packages.sh&#34;&gt;funky
shell script&lt;/a&gt;).  Some tweaks were needed to make it build in Scratchbox:
since GTK+ and Hildon libraries aren&#39;t available on Harmattan, I had to disable
the building of -gtk and -maemo versions of libzlui.  I also got to learn
a new tool &amp;mdash; &lt;a href=&#34;http://wiki.debian.org/UsingQuilt&#34;&gt;quilt&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Fixing the &lt;a href=&#34;http://pastie.org/2281152&#34;&gt;segfault&lt;/a&gt; took a couple of days of &lt;a
href=&#34;http://pastie.org/2281247&#34;&gt;debugging&lt;/a&gt;, studying the &lt;a
href=&#34;https://github.com/geometer/FBReader/blob/master/zlibrary/ui/src/qt4/view/ZLQtViewWidget.cpp#L97&#34;&gt;source&lt;/a&gt;
&lt;a href=&#34;https://github.com/geometer/FBReader/blob/master/zlibrary/ui/src/qt4/view/ZLQtPaintContext.cpp#L47&#34;&gt;code&lt;/a&gt;
of both FBReader and Qt itself, and asking for help on IRC.  Turns out
FBReader was holding an active QPainter instance for too long, and its backing
pixmap got destroyed (or, rather, converted from an OpenGL texture to a plain
X11 pixmap) during a task switch, causing the crash.  I&#39;m probably describing
this wrong BTW, but, in any case, adding QPainter::begin() and QPainter::end()
calls in the paintEvent handler fixed the segfault.&lt;/p&gt;

&lt;p&gt;Next, a small tweak in the .desktop file to make FBReader a single-instance
application: change &lt;tt&gt;Exec=FBReader&lt;/tt&gt; to &lt;tt&gt;Exec=single-instance
  /usr/bin/FBReader&lt;/tt&gt; (I&#39;m paraphrasing slightly).&lt;/p&gt;

&lt;p&gt;Then, a more ambitious goal: making FBReader intercept volume keys and
use them for scrolling.  Google gave me a &lt;a
href=&#34;http://www.developer.nokia.com/Community/Discussion/showthread.php?226283-Grab-Volume-Keys-on-Harmattan&#34;&gt;pointer&lt;/a&gt;
to &lt;a href=&#34;http://apidocs.meego.com/1.2/qmsystem/classMeeGo_1_1QmKeys.html&#34;&gt;QmKeys&lt;/a&gt;, which was the
wrong API to use here, but gave me a lead to qmkeyd2, which appears to be an
&lt;a href=&#34;https://www.meego.gitorious.org/meego-middleware/qmsystem/blobs/5edeec3815de0a2cb81e305e504f072460efe30d/keyd/qmkeyd.cpp&#34;&gt;open
source&lt;/a&gt; daemon, which gave me a lead to sysuid, another &lt;a
href=&#34;https://meego.gitorious.org/meegotouch/meegotouch-systemui/blobs/master/src/extensions/volume/volumebarlogic.cpp&#34;&gt;open
source&lt;/a&gt; daemon, which in turn gave me a lead to &lt;a
href=&#34;http://harmattan-dev.nokia.com/unstable/beta/api_refs/showdoc.php?pkn=libresourceqt&amp;wb=daily-docs&amp;url=Li94bWwvZGFpbHktZG9jcy9saWJyZXNvdXJjZXF0&#34;&gt;libresourceqt&lt;/a&gt;,
and that was the right API at last.&lt;/p&gt;

&lt;p&gt;Volume keys generate regular key events for XF86AudioRaiseVolume and
XF86AudioLowerVolume, but they&#39;re also intercepted by qmkeyd2, which tells
all subscribers (and sysuid is one) about them.  Which subscriber gets to
react is determined by the resource policy framework.  So what I needed to do
in FBReader was acquire the ScaleButtonResource when FBReader starts up or gets
focus, and release it when FBReader quits or goes into background.  That
also required some IRC help until I discovered &lt;a
href=&#34;http://doc.qt.nokia.com/latest/qobject.html#installEventFilter&#34;&gt;installEventFilter()&lt;/a&gt;
and the &lt;a
href=&#34;http://doc.qt.nokia.com/latest/qevent.html#Type-enum&#34;&gt;ApplicationActivate/ApplicationDeactivate&lt;/a&gt;
events. And &lt;a
href=&#34;http://doc.qt.nokia.com/latest/qcoreapplication.html#instance&#34;&gt;QApplication::instance()&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The various tools available in the developer firmware were invaluable:
openssh, gdb, valgrind, strace, xev, xprop, lsof, netstat.  Also, I would not
have achieved my second goal without being able to look at the sources of Meego
system components (qmkeyd, sysuid).  Yay open source!&lt;/p&gt;

&lt;p&gt;Here are &lt;a
href=&#34;https://mg.pov.lt/fbreader-0.12.10dfsg-1ubuntu2mg9-harmattan.patch&#34;&gt;my
changes to the source code&lt;/a&gt;.  You can find my modified &lt;a href=&#34;https://mg.pov.lt/770/dists/harmattan/experimental/source/fbreader_0.12.10dfsg-1ubuntu2mg9.diff.gz&#34;&gt;Debian packaging
files&lt;/a&gt;, as well as &lt;strong&gt;prebuilt binary packages&lt;/strong&gt; (with full
debug info, for gdb goodness), in my &lt;a
href=&#34;https://mg.pov.lt/770/&#34;&gt;experimental harmattan apt repository&lt;/a&gt;.
The UI is still ugly and non-native, but it doesn&#39;t matter much in fullscreen
mode &lt;tt&gt;:)&lt;/tt&gt; .&lt;/p&gt;

&lt;p&gt;Note to self: when next building fbreader, make sure the 2 megabyte
&lt;tt&gt;tags&lt;/tt&gt; file doesn&#39;t end up in the &lt;tt&gt;.diff.gz&lt;/tt&gt;.  And speaking of crud
in source packages, the &lt;a
href=&#34;https://mg.pov.lt/770/dists/harmattan/user/binary-armel/vim_7.3.260-1_armel.deb&#34;&gt;vim
package&lt;/a&gt; I built for Harmattan the other day contains the entire 50 meg
&lt;tt&gt;.hg&lt;/tt&gt; in the &lt;tt&gt;.orig.tar.gz&lt;/tt&gt;.  I need to figure out how to
tell dh_make to omit it.&lt;/p&gt;

</description>
    </item>
    
    <item>
      <title>Serving ePub files to Android 1.6</title>
      <link>https://mg.pov.lt/blog/android-fbreader-epub-problem.html</link>
      <pubDate>Fri, 23 Jul 2010 02:23:38 +0300</pubDate>
      <author>marius@gedmin.as (Marius Gedminas)</author>
      <guid>https://mg.pov.lt/blog/android-fbreader-epub-problem.html</guid>
      <description>
&lt;p&gt; If you click on an ePub download link in the Android browser and get back
an error saying &#34;Cannot download. The content type is not supported on the
device&#34;, then make sure the web server is setting the Content-Type header to
&#34;application/epub+zip&#34; and not &#34;application/octet-stream&#34;.  When you do this,
Android will launch FBReaderJ automatically (provided that you have it
installed, of course).&lt;/p&gt;
</description>
    </item>
    
  </channel>
</rss>
