<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ClearChain &#187; OpenSource</title>
	<atom:link href="http://www.clearchain.com/blog/categories/computers/opensource/feed" rel="self" type="application/rss+xml" />
	<link>http://www.clearchain.com/blog</link>
	<description>-= Daily Happenings =-</description>
	<lastBuildDate>Wed, 05 Oct 2011 23:02:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>libdc1394_video_set_mode doesn&#8217;t change the mode &#8211; A solution!</title>
		<link>http://www.clearchain.com/blog/posts/libdc1394_video_set_mode-doesnt-change-the-mode-a-solution</link>
		<comments>http://www.clearchain.com/blog/posts/libdc1394_video_set_mode-doesnt-change-the-mode-a-solution#comments</comments>
		<pubDate>Fri, 06 May 2011 03:29:06 +0000</pubDate>
		<dc:creator>Benjamin Close</dc:creator>
				<category><![CDATA[OpenSource]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[1394]]></category>
		<category><![CDATA[broken]]></category>
		<category><![CDATA[crash]]></category>
		<category><![CDATA[different resolution]]></category>
		<category><![CDATA[firewire]]></category>
		<category><![CDATA[ieee1394]]></category>
		<category><![CDATA[libdc1394]]></category>
		<category><![CDATA[libdc1394_video_set_mode]]></category>
		<category><![CDATA[mode not set]]></category>
		<category><![CDATA[video mode problem]]></category>

		<guid isPermaLink="false">http://www.clearchain.com/blog/?p=991</guid>
		<description><![CDATA[<a href="http://www.clearchain.com/blog/posts/libdc1394_video_set_mode-doesnt-change-the-mode-a-solution"><img align="left" hspace="5" width="150" height="150" src="http://www.clearchain.com/blog/wp-content/plugins/thumbnail-for-excerpts/tfe_no_thumb.png" class="alignleft wp-post-image tfe" alt="" title="" /></a>This article details a reason libdc1394_video_set_mode/libdc1394_video_set_framerate  may not work. Whilst working on an application that makes use of a 1394a/firewire camera I found a strange bug/feature with libdc1394. The problem was dc1394 was being used to the mode of the camera to 800&#215;600 resolution. However, when querying the frame size after dequeuing the frame, the<a href="http://www.clearchain.com/blog/posts/libdc1394_video_set_mode-doesnt-change-the-mode-a-solution"> <font size=-2>[..more..]</font></a>]]></description>
			<content:encoded><![CDATA[<p><em>This article details a reason libdc1394_video_set_mode/libdc1394_video_set_framerate  may not work.</em></p>
<p>Whilst working on an application that makes use of a 1394a/firewire  camera I found a strange bug/feature with <a href="http://damien.douxchamps.net/ieee1394/libdc1394/">libdc1394</a>. The problem was  dc1394 was being used to the mode of the camera to 800&#215;600 resolution.  However, when querying the frame size after dequeuing the frame, the  size was only 640&#215;480. Ie: See the below snippits:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">..
<span style="color: #202020;">dc1394error_t</span> result <span style="color: #339933;">=</span> dc1394_video_set_mode<span style="color: #009900;">&#40;</span> this<span style="color: #339933;">-&gt;</span>camera<span style="color: #339933;">,</span> DC1394_VIDEO_MODE_800x600_RGB8<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> result <span style="color: #339933;">!=</span> DC1394_SUCCESS <span style="color: #009900;">&#41;</span>
exit<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
....
<span style="color: #202020;">dc1394video_frame_t</span> <span style="color: #339933;">*</span>frame<span style="color: #339933;">=</span>NULL<span style="color: #339933;">;</span>
dc1394error_t result<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// capture one frame</span>
result <span style="color: #339933;">=</span> dc1394_capture_dequeue<span style="color: #009900;">&#40;</span> this<span style="color: #339933;">-&gt;</span>camera<span style="color: #339933;">,</span> DC1394_CAPTURE_POLICY_WAIT<span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>frame <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> result <span style="color: #339933;">!=</span> DC1394_SUCCESS <span style="color: #009900;">&#41;</span>
exit<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Allocate image memory if required</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> this<span style="color: #339933;">-&gt;</span>lastFrame.<span style="color: #202020;">image</span> <span style="color: #339933;">==</span> NULL <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
memcpy<span style="color: #009900;">&#40;</span>this<span style="color: #339933;">-&gt;</span>lastFrame<span style="color: #339933;">,</span>frame<span style="color: #339933;">,</span> <span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span>dc1394video_frame_t<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
this<span style="color: #339933;">-&gt;</span>lastFrame.<span style="color: #202020;">image</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">uint8_t</span> <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>malloc<span style="color: #009900;">&#40;</span>frame<span style="color: #339933;">-&gt;</span>total_bytes <span style="color: #339933;">*</span> <span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">uint8_t</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
..</pre></div></div>

<p>At this point total_bytes was 921600 which works out to be 640x480x3 (RGB);</p>
<p>I was stumped. I asked for one mode and got another back. All with no errors what so ever from libdc1394.</p>
<p>After over an hour of debugging, google searching and more,  I eventually found the reason.  The comment that ended up in the code explains the cause:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Shutdown any isotransports that are setup for the camera.</span>
<span style="color: #666666; font-style: italic;">// It turns out that libDC1394 will quite happily let you set modes,</span>
<span style="color: #666666; font-style: italic;">// framerates, etc but if there is an iso stream running none of them</span>
<span style="color: #666666; font-style: italic;">// will actually take affect. Hence you can set a 800x600 res and get</span>
<span style="color: #666666; font-style: italic;">// back 640x480 video frame - really nice libdc1394. It could at least</span>
<span style="color: #666666; font-style: italic;">// indicate there was a active stream when setting the mode!</span>
<span style="color: #666666; font-style: italic;">// Anyway to deal with this we force the camera to stop capturing</span>
<span style="color: #666666; font-style: italic;">// before we change the settings, if the camera was capturing prior to</span>
<span style="color: #666666; font-style: italic;">// setConfiguration being called, we restart the capture</span></pre></div></div>

<p>So the solution is to make sure the iso transmission stream has been shutdown. this can be achieved using:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">dc1394_video_set_transmission<span style="color: #009900;">&#40;</span> this<span style="color: #339933;">-&gt;</span>camera<span style="color: #339933;">,</span> DC1394_OFF <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
dc1394_capture_stop<span style="color: #009900;">&#40;</span> this<span style="color: #339933;">-&gt;</span>camera <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>An easy fix but certainly an annoying setup. I&#8217;ve not tested it but I&#8217;m guessing many of the other functions:</p>
<ul>
<li>dc1394_video_set_framerate</li>
<li>dc1394_video_set_iso_speed</li>
<li>dc1394_feature_set_mode</li>
<li>dc1394_video_set_one_shot</li>
</ul>
<p>are also affected.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.clearchain.com/blog/posts/libdc1394_video_set_mode-doesnt-change-the-mode-a-solution/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Solving the Apache SSL error &#8220;Oops, no RSA or DSA server certificate found for &#8216;www.somedomain.com:0&#8242;?!&#8221;</title>
		<link>http://www.clearchain.com/blog/posts/solving-the-apache-ssl-error-oops-no-rsa-or-dsa-server-certificate-found-for-www-somedomain-com0</link>
		<comments>http://www.clearchain.com/blog/posts/solving-the-apache-ssl-error-oops-no-rsa-or-dsa-server-certificate-found-for-www-somedomain-com0#comments</comments>
		<pubDate>Fri, 21 Jan 2011 01:17:29 +0000</pubDate>
		<dc:creator>Benjamin Close</dc:creator>
				<category><![CDATA[OpenSource]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[certificate]]></category>
		<category><![CDATA[crash]]></category>
		<category><![CDATA[httpd]]></category>
		<category><![CDATA[openssl]]></category>
		<category><![CDATA[ssl]]></category>
		<category><![CDATA[startup]]></category>
		<category><![CDATA[webserver]]></category>
		<category><![CDATA[www]]></category>

		<guid isPermaLink="false">http://www.clearchain.com/blog/?p=877</guid>
		<description><![CDATA[<a href="http://www.clearchain.com/blog/posts/solving-the-apache-ssl-error-oops-no-rsa-or-dsa-server-certificate-found-for-www-somedomain-com0"><img align="left" hspace="5" width="150" src="http://www.clearchain.com/blog/images//2011/01/ssl-logo.gif" class="alignleft wp-post-image tfe" alt="" title="ssl-logo" /></a>Recently a colleague of mine came to me with a problem he was having with SSL certificates and the web server Apache 2.2. Put simply Apache (httpd) would not start. It was an unusual situation as this server had been running flawlessly for almost 2 years and it was only a recent power outage that<a href="http://www.clearchain.com/blog/posts/solving-the-apache-ssl-error-oops-no-rsa-or-dsa-server-certificate-found-for-www-somedomain-com0"> <font size=-2>[..more..]</font></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.clearchain.com/blog/images//2011/01/ssl-logo.gif"><img class="alignleft size-full wp-image-883" title="ssl-logo" src="http://www.clearchain.com/blog/images//2011/01/ssl-logo.gif" alt="" width="100" height="50" /></a>Recently a colleague of mine came to me with a problem he was having with SSL certificates and the <a href="http://httpd.apache.org/">web server Apache 2.2</a>. Put simply Apache (httpd) would not start. It was an unusual situation as this server had been running flawlessly for almost 2 years and it was only a recent power outage that had caused the error to occur. Running<em> apachectl configtest</em> revealed no problems with the setup but when running <em>apachectl start</em>, whilst there was no errors reported on the command line, apache would instantly die/crash. Checking the log files we found:</p>
<pre><strong>[Thu Jan 20 14:15:16 2011] [error] Oops, no RSA or DSA server certificate found for 'www.somedomain.com:0'?!</strong></pre>
<p>Whilst <em>somedomain.com</em> isn&#8217;t the official domain name reported (I can&#8217;t reveal the client), this error was being printed for every SSL host except the default SSL host. Ironically the default SSL host was simply a redirect to one of the others. A quick check and indeed the problem lied with the SSL hosts &#8211; we removed every ssl host and the webserver would start fine &#8211; obviously without any ssl.</p>
<p>My colleague and I were  perplexed. He&#8217;d tried a quite few things to fix this all without luck. A so call Server Admin told him it was due to not using ip based virtual hosts for ssl, he claimed you can&#8217;t use Name Base Virtual hosts with SSL. No doubt this was obtained from a <a href="http://mail-archives.apache.org/mod_mbox/httpd-users/200512.mbox/%3C8C29B2F93BAE9047A906EF6D6F9C5D43FE00B5@exchange2k301.gaia.fr%3E">quick google search for the error.</a> The problems is you <em><span style="text-decoration: underline;">can</span></em> run NamedBasedVirtual hosts with SSL on port 443 provided you have a wildcard SSL certificate. A wild is required for NamedBaseVirtual hosts as the SSL connection is established first before the headers are sent. A wildcard will allow any subdomain to use the SSL connection then apache will see the host header and respond with the appropriate vhost. If on only have a single certificate this does not work and you&#8217;ll need a separate IP per certificate.</p>
<p>Anyway, we began trying to debug the issue. First we checked the certificate files were at the specified locations &#8211; they were. Next we checked the certificates were actually valid. You can use the <a href="http://www.openssl.org/">openssl</a> command below to do this:</p>
<pre><strong>openssl x509 -noout -text -in <em>YOURCERTIFICATE.crt</em></strong></pre>
<p>The certificate, key, and certificate authority (CA) were all valid and in date.<br />
Next we tried putting each Vhost in to the config one by one to see if one host had errors over another. Turns out it didn&#8217;t matter what order each host was in the config file or which ssl hosts were included, they all had issues &#8211; except for the default ssl vhost.</p>
<p>At this point we were a little lost. So we decided to go back to basics and work out what the error really meant. We search to see what apache module the error came from. A simple grep later we&#8217;d narrowed down the error to mod_ssl. A search of the mod_ssl source code found the following instance of the message:</p>
<pre># grep Oops *
ssl_engine_init.c:                         "Init: Oops, you want to request client "
ssl_engine_init.c:                "<strong>Oops, no RSA or DSA server certificate found</strong> "
ssl_engine_init.c:                "Oops, no RSA or DSA server private key found?!");
ssl_engine_io.c:                    (argp != NULL ? "(BIO dump follows)" : "(Oops, no memory buffer?)"));</pre>
<p>Looking in <em>ssl_engine_init.c </em>we found the error came from the following function</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">static</span> <span style="color: #993333;">void</span> ssl_init_server_certs<span style="color: #009900;">&#40;</span>server_rec <span style="color: #339933;">*</span>s<span style="color: #339933;">,</span>
                                  apr_pool_t <span style="color: #339933;">*</span>p<span style="color: #339933;">,</span>
                                  apr_pool_t <span style="color: #339933;">*</span>ptemp<span style="color: #339933;">,</span>
                                  modssl_ctx_t <span style="color: #339933;">*</span>mctx<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #993333;">const</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>rsa_id<span style="color: #339933;">,</span> <span style="color: #339933;">*</span>dsa_id<span style="color: #339933;">;</span>
    <span style="color: #993333;">const</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>vhost_id <span style="color: #339933;">=</span> mctx<span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>sc<span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>vhost_id<span style="color: #339933;">;</span>
    <span style="color: #993333;">int</span> i<span style="color: #339933;">;</span>
    <span style="color: #993333;">int</span> have_rsa<span style="color: #339933;">,</span> have_dsa<span style="color: #339933;">;</span>
&nbsp;
    rsa_id <span style="color: #339933;">=</span> ssl_asn1_table_keyfmt<span style="color: #009900;">&#40;</span>ptemp<span style="color: #339933;">,</span> vhost_id<span style="color: #339933;">,</span> SSL_AIDX_RSA<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    dsa_id <span style="color: #339933;">=</span> ssl_asn1_table_keyfmt<span style="color: #009900;">&#40;</span>ptemp<span style="color: #339933;">,</span> vhost_id<span style="color: #339933;">,</span> SSL_AIDX_DSA<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #339933;">&lt;</span>em<span style="color: #339933;">&gt;</span>have_rsa<span style="color: #339933;">&lt;/</span>em<span style="color: #339933;">&gt;</span> <span style="color: #339933;">=</span> ssl_server_import_cert<span style="color: #009900;">&#40;</span>s<span style="color: #339933;">,</span> mctx<span style="color: #339933;">,</span> rsa_id<span style="color: #339933;">,</span> SSL_AIDX_RSA<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #339933;">&lt;</span>em<span style="color: #339933;">&gt;</span>have_dsa<span style="color: #339933;">&lt;/</span>em<span style="color: #339933;">&gt;</span> <span style="color: #339933;">=</span> ssl_server_import_cert<span style="color: #009900;">&#40;</span>s<span style="color: #339933;">,</span> mctx<span style="color: #339933;">,</span> dsa_id<span style="color: #339933;">,</span> SSL_AIDX_DSA<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span>have_rsa <span style="color: #339933;">||</span> have_dsa<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        ap_log_error<span style="color: #009900;">&#40;</span>APLOG_MARK<span style="color: #339933;">,</span> APLOG_ERR<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> s<span style="color: #339933;">,</span>
                <span style="color: #339933;">&lt;</span>strong<span style="color: #339933;">&gt;</span><span style="color: #ff0000;">&quot;Oops, no RSA or DSA server certificate found &quot;</span>
                <span style="color: #ff0000;">&quot;for&lt;/strong&gt; '%s:%d'?!&quot;</span><span style="color: #339933;">,</span> s<span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>server_hostname<span style="color: #339933;">,</span> s<span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>port<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        ssl_die<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> SSL_AIDX_MAX<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>         ssl_check_public_cert<span style="color: #009900;">&#40;</span>s<span style="color: #339933;">,</span> ptemp<span style="color: #339933;">,</span> mctx<span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>pks<span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>certs<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    have_rsa <span style="color: #339933;">=</span> ssl_server_import_key<span style="color: #009900;">&#40;</span>s<span style="color: #339933;">,</span> mctx<span style="color: #339933;">,</span> rsa_id<span style="color: #339933;">,</span> SSL_AIDX_RSA<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    have_dsa <span style="color: #339933;">=</span> ssl_server_import_key<span style="color: #009900;">&#40;</span>s<span style="color: #339933;">,</span> mctx<span style="color: #339933;">,</span> dsa_id<span style="color: #339933;">,</span> SSL_AIDX_DSA<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span>have_rsa <span style="color: #339933;">||</span> have_dsa<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        ap_log_error<span style="color: #009900;">&#40;</span>APLOG_MARK<span style="color: #339933;">,</span> APLOG_ERR<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> s<span style="color: #339933;">,</span>
                <span style="color: #ff0000;">&quot;Oops, no RSA or DSA server private key found?!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        ssl_die<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Hence  the error was caused by the certificates not being able to be imported. Once again we checked paths to make sure the certificates/keys were correct. Alas they were. So we began to wonder why the certificates couldn&#8217;t be found. We&#8217;d specified the correct files, confirmed they were correct. It occurred to me that perhaps the openSSL context had not been setup correctly. But why not? I took a look at the default SSL vhost which did work and noticed a single line that were not in any of the other ssl vhosts.</p>
<pre>SSLEngine on</pre>
<p>The comment above this line read:</p>
<pre>#   SSL Engine Switch:
#   Enable/Disable SSL for this virtual host.</pre>
<p>I added &#8220;<em>SSLEngine On&#8221;</em> to the other ssl vhosts and it worked! So it turns out you can have an vhost setup on port 443 without SSL hence for each vhost you want SSL working in you must add the above line. My colleague was extremely thankful &#8211; why it happened in the  first place, we still don&#8217;t know. We suspect previously the option may have been enabled globally. However the fix allows apache to run again and works after a clean shutdown and startup.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.clearchain.com/blog/posts/solving-the-apache-ssl-error-oops-no-rsa-or-dsa-server-certificate-found-for-www-somedomain-com0/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>VNC Connects Then Hangs</title>
		<link>http://www.clearchain.com/blog/posts/vnc-connects-then-hangs</link>
		<comments>http://www.clearchain.com/blog/posts/vnc-connects-then-hangs#comments</comments>
		<pubDate>Thu, 06 Aug 2009 06:26:36 +0000</pubDate>
		<dc:creator>Benjamin Close</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[OpenSource]]></category>
		<category><![CDATA[UniSA]]></category>
		<category><![CDATA[connection hangs]]></category>
		<category><![CDATA[freezes]]></category>
		<category><![CDATA[no image]]></category>
		<category><![CDATA[onhold]]></category>
		<category><![CDATA[vnc]]></category>

		<guid isPermaLink="false">http://www.clearchain.com/blog/?p=537</guid>
		<description><![CDATA[<a href="http://www.clearchain.com/blog/posts/vnc-connects-then-hangs"><img align="left" hspace="5" width="150" height="150" src="http://www.clearchain.com/blog/wp-content/plugins/thumbnail-for-excerpts/tfe_no_thumb.png" class="alignleft wp-post-image tfe" alt="" title="" /></a>Working out that VNC can put a client ONHOLD, making it look like the server has frozen]]></description>
			<content:encoded><![CDATA[<p>The other day I was working with a few colleges using VNC. We came across an issue with our VNC setup. We could connect a VNC client (be it tightvnc, vncviewer, vinagre or x4vnclient) to our vnc server but never see anything on the screen. It was if the server was freezing or hanging.  This left us wondering why. Initially we thought we had broken something in the VNC server &#8211; after all we had made code modifications. However the solution turned out to be a very simple fix.</p>
<p>You see the VNC protocol has the ability to place a client ONHOLD. During this state the clients events are not transmitted and the server sends back no images. This is what was happening to us. Normally the VNCServer will place the client on hold during a connection, asking the user to accept/reject the client. However we had been playing around with configuration files and set the prompt to disabled &#8211; we wanted automatic connection, with no prompt. Hence the VNCServer was placing the client on hold, noticed prompts were disabled and because authentication had not been established, sat there twiddling it&#8217;s thumbs.</p>
<p>A simple configuration file fix and everything was working again. Ironically at the same time we also discovered that modifying files by had in ~/.gconf/* doesn&#8217;t do anything as there&#8217;s a daemon that holds the configuration and it periodically writes to ~/.gconf/* overwriting any changes you might have made &#8211; hence we used gconftool2.</p>
<p><strong>The Fix? </strong></p>
<p>To allow gnome to prompt the user for authentication. Hence a dialog would show up and the authorisation could take place.</p>
<pre dir="ltr">gconftool-2 -s -t bool /desktop/gnome/remote_access/prompt_enabled true
</pre>
<p>You can also find this same setting in gconf-editor if you want a gui way to update it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.clearchain.com/blog/posts/vnc-connects-then-hangs/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Xinput 1 -&gt; XInput 2 conversion guide</title>
		<link>http://www.clearchain.com/blog/posts/xinput-1-xinput-2-conversion-guide</link>
		<comments>http://www.clearchain.com/blog/posts/xinput-1-xinput-2-conversion-guide#comments</comments>
		<pubDate>Thu, 30 Jul 2009 01:30:14 +0000</pubDate>
		<dc:creator>Benjamin Close</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[FreeDesktop]]></category>
		<category><![CDATA[OpenSource]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[examples]]></category>
		<category><![CDATA[gtk+]]></category>
		<category><![CDATA[MPX]]></category>
		<category><![CDATA[protocol]]></category>
		<category><![CDATA[toolkit]]></category>
		<category><![CDATA[XI1]]></category>
		<category><![CDATA[XI2]]></category>
		<category><![CDATA[XInput 1.5]]></category>
		<category><![CDATA[XInput1]]></category>
		<category><![CDATA[Xinput2]]></category>

		<guid isPermaLink="false">http://www.clearchain.com/blog/?p=415</guid>
		<description><![CDATA[<a href="http://www.clearchain.com/blog/posts/xinput-1-xinput-2-conversion-guide"><img align="left" hspace="5" width="150" height="150" src="http://www.clearchain.com/blog/wp-content/plugins/thumbnail-for-excerpts/tfe_no_thumb.png" class="alignleft wp-post-image tfe" alt="" title="" /></a>Details about the API changes between Xinput 1(XI1) and XInput 2 (XI2)]]></description>
			<content:encoded><![CDATA[<p>Recently I was tasked with porting <a href="http://www.gtk.org/">GTK+</a> to support Xinput 2 (XI2), and whilst the port isn&#8217;t finished I quickly discovered just how big the conversion was. This page is designed to help someone who is familiar with XInput 1 switch to XInput 2 &#8211; it&#8217;s certainly is by no means a complete guide and anyone reading this should also take a look at the various <a href="http://who-t.blogspot.com/">Input2 recipies published.</a></p>
<p>XI2 is the first major rewrite of the <a href="http://www.x.org/wiki/XInputSpec">XInput specification</a> in years and with it comes a lot of enhanced functionality, but also a <a href="http://cgit.freedesktop.org/xorg/lib/libXi/tree/man">new API</a>. The API was deliberately designed not to be backward compatible. Why? To prevent both XI1 and XI2 features to be intermingled. XI2 brings with it a new device model and a new input model. Both of these are incompatible with XI1. The decision to break the API was not a light one by <a href="http://who-t.blogspot.com/">Peter Hutterer</a>, the main XI2 developer.  Supporting XI1 would have ment future changes to XI2 would be impossible &#8211; there&#8217;s only so far you can push an out dated protocol and api. The added complexity of trying to maintain 2 code paths was also determined to be too high. XI2 is more than just a api/abi change. It literally change the entire input subsystem of the <a href="http://www.x.org">Xorg</a> Xserver. XI2 supports:</p>
<ul>
<li>Mulitple Independent Master Devices  (MPX)</li>
<li>Subpixel Accuracy for input devices</li>
<li>Support for 32bit key codes</li>
<li>.. lots more See: <a href="http://fedoraproject.org/wiki/Features/XI2">http://fedoraproject.org/wiki/Features/XI2</a> for full details</li>
</ul>
<p>With that in mind, the new XI2 API often leaves someone who&#8217;s been working with the XI1 wondering what the equivilant XI2 API call is.  Most functions have an equivilant in XI2 function though the usage has more often than not, changed dramatically. Below is some examples of how to convert XI1 code to XI2 compatible code and a list of <strong>some</strong> of the changes which have occurred. If you find something missing, please add to the comments.</p>
<h2>Change Overview</h2>
<p>The biggest change that any XI1 developer will notice is the <em><strong>XDevice *</strong></em> type has vanished. All XI2 devices make use of the <em><strong>XID</strong></em> type instead. Under the hoods, in the Xserver and XDevice really equates back to an XID anyway now. The next biggest change XI1 developers will notice is the entire XInput2 API has had shifted namespaces. All XInput2 functions, types, etc are now prefixed with XI (ie XIEventMask). This was designed to force segregation of XI1 -&gt; XI2 code.</p>
<p>The header file you include has also changed. Instead of:</p>
<pre>#include &lt;X11/extensions/XInput.h&gt;</pre>
<p>It&#8217;s now:</p>
<pre>#include &lt;X11/extensions/XInput<span style="text-decoration: underline;"><strong>2</strong></span>.h&gt;</pre>
<h2>Notable Changes</h2>
<ul>
<li>Proximity events are no longer supported, these are now reported as regular events on another axis (ie think of a pressure axis)</li>
<li>Events are  longer use device classes, instead all events are type XIEvent (a type of XEvent). Hence there is no need to pass around an array of integer classes anymore when registering for events, instead a single XIEventMask will do what is needed. The macros XISetMask and XIGetMask help with using the mask.</li>
</ul>
<p>There&#8217;s also been a lot of changes to structures, functions, types and how they are used.</p>
<h2>Event Changes</h2>
<table border="1">
<tbody>
<tr>
<th>XI1 Event</th>
<th>XI2 Event</th>
<th>Notes</th>
</tr>
<tr>
<td>XDeviceKeyEvent,  XDeviceKeyPressedEvent, XDeviceKeyReleasedEvent, XDeviceButtonEvent,  XDeviceButtonPressedEvent,  XDeviceButtonReleasedEvent ,XDeviceMotionEvent</td>
<td>XIDeviceEvent</td>
<td>The various events are now incorporated into the one event type. XIDeviceEvent-&gt;evtype indicates the subtype of event. Ie XIMotion is a motion event for that device.</td>
</tr>
<tr>
<td>XProximityNotifyEvent, XProximityInEvent, XProximityOutEvent</td>
<td>XIDeviceEvent (See Note)</td>
<td>Proximity Events have been replaced with device events. Proximity is represented as a value in the valuator on one of the axes</td>
</tr>
</tbody>
</table>
<h2>Structure/Type Changes</h2>
<table border="1">
<tbody>
<tr>
<th>XI1 Structure/Type</th>
<th>XI2 Structure/Type</th>
<th>Notes</th>
</tr>
<tr>
<td>XDeviceState</td>
<td>XIDeviceInfo</td>
<td>XIDeviceInfo also contains  a name and classes</td>
</tr>
<tr>
<td>XAnyClassPtr</td>
<td>XIAnyClassInfo *</td>
<td></td>
</tr>
<tr>
<td>XValuatorInfo</td>
<td>XIValuatorClassInfo</td>
<td></td>
</tr>
<tr>
<td>XInputClass</td>
<td>XIAnyClassInfo</td>
<td></td>
</tr>
<tr>
<td>XEventClass</td>
<td>XIEventMask</td>
<td>Used for selecting events to be monitored.<br />
One mask is used per device.  Standard usage is:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">XIEventMask mask<span style="color: #339933;">;</span>
mask.<span style="color: #202020;">deviceid</span><span style="color: #339933;">=</span><span style="color: #666666; font-style: italic;">//some device or XIAllDevices for all devices&amp;lt;</span>
mask.<span style="color: #202020;">mask_len</span><span style="color: #339933;">=</span><span style="color: #0000dd;">2</span><span style="color: #339933;">;</span>
mask.<span style="color: #202020;">mask</span><span style="color: #339933;">=</span>calloc<span style="color: #009900;">&#40;</span>mask.<span style="color: #202020;">mask_len</span><span style="color: #339933;">,</span> <span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
XISetMask<span style="color: #009900;">&#40;</span>mask.<span style="color: #202020;">mask</span><span style="color: #339933;">,</span> XI_ButtonPress<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
..
<span style="color: #202020;">XISelectEvents</span><span style="color: #009900;">&#40;</span>display<span style="color: #339933;">,</span> win<span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>mask<span style="color: #339933;">,</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span></pre></div></div>

</td>
</tr>
<tr>
<td>XExtensionVersion</td>
<td>Struct Removed</td>
<td>XIQueryVersion should be used instead</td>
</tr>
<tr>
<td>XDeviceKeyEvent, XDeviceKeyPressedEvent, XDeviceKeyReleasedEvent, XDeviceButtonEvent, XDeviceButtonPressedEvent, XDeviceButtonReleasedEvent,</td>
<td>Structs Removed</td>
<td>XIDeviceEvents are now used instead</td>
</tr>
<tr>
<td>XDeviceFocusChangeEvnet, XDeviceFocusInEvent, XDeviceFocusOutEvent</td>
<td>Structs Removed</td>
<td>XIDeviceEvents are now used</td>
</tr>
<tr>
<td>XProximityNotifyEvent, XProximityInEvent, XProximityOutEvent</td>
<td>Structs Removed</td>
<td>XIDeviceEvents are now used</td>
</tr>
</tbody>
</table>
<h2>Function/Macro Changes</h2>
<table border="1">
<tbody>
<tr>
<th>XI1 Function</th>
<th>XI2 Function</th>
<th>Notes</th>
</tr>
<tr>
<td>XFreeDeviceList</td>
<td>XIFreeDeviceInfo</td>
<td></td>
</tr>
<tr>
<td>XDefineDeviceCursor</td>
<td>XIDefineCursor</td>
<td></td>
</tr>
<tr>
<td>DeviceButton1Motion</p>
<p>DeviceButton2Motion</p>
<p>&#8230;</td>
<td>(No Equivelant)</td>
<td></td>
</tr>
<tr>
<td>XWarpPointer</p>
<p>XWarpDevicePointer</td>
<td>XIWarpPointer</td>
<td>XIWarpPointer makes use of the device id like XWarpDevicePointer (XI1.5).   XWarpPointer is considered obsolete as it has no concept of a device</td>
</tr>
<tr>
<td>XQueryDeviceState</td>
<td>XIQueryDevice</td>
<td>Return type is XIDeviceInfo *, can be called with deviceid = XIAllDevices to query all devices hence the ndevices return</td>
</tr>
<tr>
<td>XFreeDeviceState</td>
<td>XIFreeDeviceInfo</td>
<td></td>
</tr>
<tr>
<td>DeviceGrabButton</td>
<td>XIGrabButton</td>
<td></td>
</tr>
<tr>
<td>XSelectExtensionEvent</td>
<td>XISelectEvents</td>
<td>Instead of a list of classes now a list of XIEventMask is used, one mask per device. XSelectExtensionEvent is still used for other extension events not related to XInput2</td>
</tr>
<tr>
<td>XGetExtensionVersion</td>
<td>XIQueryVersion</td>
<td>If only XI1 is present this will be returned vi the major/minor numbers (ie major = 1)</td>
</tr>
</tbody>
</table>
<h2>Examples</h2>
<p>Below are some examples of how to use some of the new XI2 functions.</p>
<h3>Event Processing &#8211; Registering For Events</h3>
<p>A simple indication how to register for events (XI2 greatly simplifies this)</p>
<ul>
<li><strong>XInput 1 (Taken from: <a href="http://cgit.freedesktop.org/xorg/app/xinput/tree/src/test.c">http://cgit.freedesktop.org/xorg/app/xinput/tree/src/test.c)</a> </strong></li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">static</span> <span style="color: #993333;">int</span>           motion_type <span style="color: #339933;">=</span> INVALID_EVENT_TYPE<span style="color: #339933;">;</span>
<span style="color: #993333;">static</span> <span style="color: #993333;">int</span>           button_press_type <span style="color: #339933;">=</span> INVALID_EVENT_TYPE<span style="color: #339933;">;</span>
<span style="color: #993333;">static</span> <span style="color: #993333;">int</span>           button_release_type <span style="color: #339933;">=</span> INVALID_EVENT_TYPE<span style="color: #339933;">;</span>
<span style="color: #993333;">static</span> <span style="color: #993333;">int</span>           key_press_type <span style="color: #339933;">=</span> INVALID_EVENT_TYPE<span style="color: #339933;">;</span>
<span style="color: #993333;">static</span> <span style="color: #993333;">int</span>           key_release_type <span style="color: #339933;">=</span> INVALID_EVENT_TYPE<span style="color: #339933;">;</span>
<span style="color: #993333;">static</span> <span style="color: #993333;">int</span>           proximity_in_type <span style="color: #339933;">=</span> INVALID_EVENT_TYPE<span style="color: #339933;">;</span>
<span style="color: #993333;">static</span> <span style="color: #993333;">int</span>           proximity_out_type <span style="color: #339933;">=</span> INVALID_EVENT_TYPE<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">static</span> <span style="color: #993333;">int</span> register_event<span style="color: #009900;">&#40;</span>Display <span style="color: #339933;">*</span>dpy<span style="color: #339933;">,</span> XDeviceInfo <span style="color: #339933;">*</span>info<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    XEventClass         event_list<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">7</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #993333;">int</span>                 i<span style="color: #339933;">;</span>
    XDevice             <span style="color: #339933;">*</span>device<span style="color: #339933;">;</span>
    XInputClassInfo     <span style="color: #339933;">*</span>ip<span style="color: #339933;">;</span>
&nbsp;
    device <span style="color: #339933;">=</span> XOpenDevice<span style="color: #009900;">&#40;</span>dpy<span style="color: #339933;">,</span> info<span style="color: #339933;">-&gt;</span>id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Check for open error</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>device<span style="color: #339933;">-&gt;</span>num_classes <span style="color: #339933;">&gt;</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>ip <span style="color: #339933;">=</span> device<span style="color: #339933;">-&gt;</span>classes<span style="color: #339933;">,</span> i<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>info<span style="color: #339933;">-&gt;</span>num_classes<span style="color: #339933;">;</span> ip<span style="color: #339933;">++,</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">switch</span> <span style="color: #009900;">&#40;</span>ip<span style="color: #339933;">-&gt;</span>input_class<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">case</span> ButtonClass<span style="color: #339933;">:</span>
                DeviceButtonPress<span style="color: #009900;">&#40;</span>device<span style="color: #339933;">,</span> button_press_type<span style="color: #339933;">,</span> event_list<span style="color: #009900;">&#91;</span>number<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> number<span style="color: #339933;">++;</span>
                DeviceButtonRelease<span style="color: #009900;">&#40;</span>device<span style="color: #339933;">,</span> button_release_type<span style="color: #339933;">,</span> event_list<span style="color: #009900;">&#91;</span>number<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> number<span style="color: #339933;">++;</span>
                <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #b1b100;">case</span> ValuatorClass<span style="color: #339933;">:</span>
                DeviceMotionNotify<span style="color: #009900;">&#40;</span>device<span style="color: #339933;">,</span> motion_type<span style="color: #339933;">,</span> event_list<span style="color: #009900;">&#91;</span>number<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> number<span style="color: #339933;">++;</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>handle_proximity<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    ProximityIn<span style="color: #009900;">&#40;</span>device<span style="color: #339933;">,</span> proximity_in_type<span style="color: #339933;">,</span> event_list<span style="color: #009900;">&#91;</span>number<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> number<span style="color: #339933;">++;</span>
                    ProximityOut<span style="color: #009900;">&#40;</span>device<span style="color: #339933;">,</span> proximity_out_type<span style="color: #339933;">,</span> event_list<span style="color: #009900;">&#91;</span>number<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> number<span style="color: #339933;">++;</span>
                <span style="color: #009900;">&#125;</span>
                <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #b1b100;">default</span><span style="color: #339933;">:</span>
                fprintf<span style="color: #009900;">&#40;</span>stderr<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;unknown class<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>XSelectExtensionEvent<span style="color: #009900;">&#40;</span>dpy<span style="color: #339933;">,</span> root_win<span style="color: #339933;">,</span> event_list<span style="color: #339933;">,</span> number<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            fprintf<span style="color: #009900;">&#40;</span>stderr<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;error selecting extended events<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span></pre></div></div>

<ul>
<li><strong>XInput 2:<br />
(Taken from: <a href="http://who-t.blogspot.com/2009/05/xi2-recipes-part-1.html">http://who-t.blogspot.com/2009/05/xi2-recipes-part-1.html</a>)<br />
</strong></li>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">XIEventMask eventmask<span style="color: #339933;">;</span>
<span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> mask<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> <span style="color: #0000dd;">0</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/* the actual mask */</span>
&nbsp;
eventmask.<span style="color: #202020;">deviceid</span> <span style="color: #339933;">=</span> <span style="color: #0000dd;">2</span><span style="color: #339933;">;</span>
eventmask.<span style="color: #202020;">mask_len</span> <span style="color: #339933;">=</span> <span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span>mask<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/* always in bytes */</span>
eventmask.<span style="color: #202020;">mask</span> <span style="color: #339933;">=</span> mask<span style="color: #339933;">;</span>
<span style="color: #808080; font-style: italic;">/* now set the mask */</span>
XISetMask<span style="color: #009900;">&#40;</span>mask<span style="color: #339933;">,</span> XI_ButtonPress<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
XISetMask<span style="color: #009900;">&#40;</span>mask<span style="color: #339933;">,</span> XI_Motion<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
XISetMask<span style="color: #009900;">&#40;</span>mask<span style="color: #339933;">,</span> XI_KeyPress<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* select on the window */</span>
XISelectEvents<span style="color: #009900;">&#40;</span>display<span style="color: #339933;">,</span> window<span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>eventmask<span style="color: #339933;">,</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</ul>
<h3>Event Processing &#8211; Listening/Processing Events</h3>
<p>A simple indication how to get events from XI1 and XI2</p>
<ul>
<li><strong>XInput 1: </strong>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//setup via other means</span>
<span style="color: #993333;">int</span> motion_type<span style="color: #339933;">,</span> button_press_type<span style="color: #339933;">,</span>button_release_type<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">void</span> doEvents<span style="color: #009900;">&#40;</span>Display    <span style="color: #339933;">*</span>dpy<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
&nbsp;
 XEvent        Event<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        XNextEvent<span style="color: #009900;">&#40;</span>dpy<span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>Event<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>Event.<span style="color: #202020;">type</span> <span style="color: #339933;">==</span> motion_type<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            XDeviceMotionEvent <span style="color: #339933;">*</span>motion <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>XDeviceMotionEvent <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>Event<span style="color: #339933;">;</span>
            ...
&nbsp;
        <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>Event.<span style="color: #202020;">type</span> <span style="color: #339933;">==</span> button_press_type<span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span>
                   <span style="color: #009900;">&#40;</span>Event.<span style="color: #202020;">type</span> <span style="color: #339933;">==</span> button_release_type<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                      XDeviceButtonEvent <span style="color: #339933;">*</span>button <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>XDeviceButtonEvent <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>Event<span style="color: #339933;">;</span>
&nbsp;
            ...
        <span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>Event.<span style="color: #202020;">type</span><span style="color: #339933;">=</span> .... <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            ...
     <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

</li>
<li><strong>XInput 2 </strong><strong> </strong>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//Somewhere else...</span>
&nbsp;
<span style="color: #993333;">int</span> xi_opcode<span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>XQueryExtension<span style="color: #009900;">&#40;</span>display<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;XInputExtension&quot;</span><span style="color: #339933;">,&amp;</span>xi_opcode<span style="color: #339933;">,&amp;</span>event<span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>error<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;X Input extension not available.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">return</span> EXIT_FAILURE<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong> </strong></p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">void</span> doEvents <span style="color: #009900;">&#40;</span>Display <span style="color: #339933;">*</span>dpy <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        XEvent        ev<span style="color: #339933;">;</span>
        XGenericEventCookie <span style="color: #339933;">*</span>cookie <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>ev.<span style="color: #202020;">xcookie</span><span style="color: #339933;">;</span>
        XNextEvent<span style="color: #009900;">&#40;</span>dpy<span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>ev<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>XGetEventData<span style="color: #009900;">&#40;</span>dpy<span style="color: #339933;">,</span> cookie<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> cookie<span style="color: #339933;">-&gt;</span>type <span style="color: #339933;">==</span> GenericEvent
            <span style="color: #339933;">&amp;&amp;</span> cookie<span style="color: #339933;">-&gt;</span>extension<span style="color: #339933;">==</span>xi_opcode<span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            XIDeviceEvent <span style="color: #339933;">*</span>event <span style="color: #339933;">=</span> cookie<span style="color: #339933;">-&gt;</span>data<span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;EVENT type %d<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> event<span style="color: #339933;">-&gt;</span>evtype<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">switch</span> <span style="color: #009900;">&#40;</span>event<span style="color: #339933;">-&gt;</span>evtype<span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
                <span style="color: #666666; font-style: italic;">//</span>
                <span style="color: #666666; font-style: italic;">// In all below event&gt;deviceid contains the id of the device</span>
                <span style="color: #666666; font-style: italic;">//</span>
                <span style="color: #b1b100;">case</span> XI_DeviceChanged<span style="color: #339933;">:</span>
                    XIDeviceChangedEvent <span style="color: #339933;">*</span>dc <span style="color: #339933;">=</span> cookie<span style="color: #339933;">-&gt;</span>data<span style="color: #339933;">;</span>
                    ...
                    <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">case</span> XI_HierarchyChanged<span style="color: #339933;">:</span>
                    XIHierarchyEvent <span style="color: #339933;">*</span>he <span style="color: #339933;">=</span> cookie<span style="color: #339933;">-&gt;</span>data<span style="color: #339933;">;</span>
                    ...
                    <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">case</span> XI_RawEvent<span style="color: #339933;">:</span>
                    XIRawEvent <span style="color: #339933;">*</span>re <span style="color: #339933;">=</span> cookie<span style="color: #339933;">-&gt;</span>data<span style="color: #339933;">;</span>
                    ...
                    <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">case</span> XI_FocusIn<span style="color: #339933;">:</span>
                <span style="color: #b1b100;">case</span> XI_Enter<span style="color: #339933;">:</span>
                    XIEnterEvent <span style="color: #339933;">*</span>ee <span style="color: #339933;">=</span> cookie<span style="color: #339933;">-&gt;</span>data<span style="color: #339933;">;</span>
                    ...
                    <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">case</span> XI_FocusOut<span style="color: #339933;">:</span>
                <span style="color: #b1b100;">case</span> XI_Leave<span style="color: #339933;">:</span>
                    XILeaveEvent <span style="color: #339933;">*</span>le <span style="color: #339933;">=</span> cookie<span style="color: #339933;">-&gt;</span>data<span style="color: #339933;">;</span>
                    ...
                    <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">case</span> XI_PropertyEvent<span style="color: #339933;">:</span>
                    XIPropertyEvent <span style="color: #339933;">*</span>pe <span style="color: #339933;">=</span> cookie<span style="color: #339933;">-&gt;</span>data<span style="color: #339933;">;</span>
                    ...
                    <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">case</span> XI_Motion<span style="color: #339933;">:</span>
                <span style="color: #b1b100;">case</span> XI_ButtonPress<span style="color: #339933;">:</span>
                <span style="color: #b1b100;">case</span> XI_ButtonRelease<span style="color: #339933;">:</span>
                <span style="color: #b1b100;">case</span> XI_KeyPress<span style="color: #339933;">:</span>
                <span style="color: #b1b100;">case</span> XI_KeyRelease<span style="color: #339933;">:</span>
                    <span style="color: #666666; font-style: italic;">// do something with event (XIDeviceEvent contains data)</span>
                    <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
     <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span></pre></div></div>

</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.clearchain.com/blog/posts/xinput-1-xinput-2-conversion-guide/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Caldav calendar &amp; icalserver</title>
		<link>http://www.clearchain.com/blog/posts/caldav-calendar-icalserver</link>
		<comments>http://www.clearchain.com/blog/posts/caldav-calendar-icalserver#comments</comments>
		<pubDate>Wed, 24 Jun 2009 07:00:47 +0000</pubDate>
		<dc:creator>Benjamin Close</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[OpenSource]]></category>
		<category><![CDATA[caldav]]></category>
		<category><![CDATA[calendar]]></category>
		<category><![CDATA[frontend]]></category>
		<category><![CDATA[ical]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[web gui]]></category>

		<guid isPermaLink="false">http://www.clearchain.com/blog/?p=445</guid>
		<description><![CDATA[<a href="http://www.clearchain.com/blog/posts/caldav-calendar-icalserver"><img align="left" hspace="5" width="150" src="http://www.local-guru.net/img/guru/calendar_sc.png" class="alignleft wp-post-image tfe" alt="" title="Web Calendar" /></a>For quite a while now I&#8217;ve been using Apple&#8217;s ICal server on FreeBSD and Sunbird/Lightning as a front end to the calendar. However, one thing that has always annoyed me was the lack of a web frontend to my calendars. Well today after searching on a completely different topic I found a javascript front end<a href="http://www.clearchain.com/blog/posts/caldav-calendar-icalserver"> <font size=-2>[..more..]</font></a>]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft" title="Web Calendar" src="http://www.local-guru.net/img/guru/calendar_sc.png" alt="" width="307" height="211" /></p>
<p>For quite a while now I&#8217;ve been using <a href="http://trac.calendarserver.org/">Apple&#8217;s ICal server</a> on <a href="http://www.freebsd.org">FreeBSD</a> and <a href="http://www.mozilla.org/projects/calendar">Sunbird/Lightning</a> as a front end to the calendar. However, one thing that has always annoyed me was the lack of a web frontend to my calendars.</p>
<p>Well today after searching on a completely different topic I found a <a href="http://www.local-guru.net/blog/2009/03/29/javascript-caldav-frontend">javascript front end to caldav</a>. After only a few minutes setup I had the frontend up and running. Sadly however, It didn&#8217;t play happy with ICalServer. A little debugging of the caldav REPORT request and I had it querying correctly.</p>
<p>Now there was valid data populating the table&#8230; or was it. Looking a little closer there were bugs with the reoccurring events and also with the lastMonday function. <a href="http://clearchain.com/~benjsc/downloads/patches/20090329-javascript-caldav-Frontend.patch">A quick fix</a> (after 20mins finding them) and now the calendar works great!</p>
<p>Best thing about it is I can now have a public caldav calendar which everyone can view whilst being able to update thing directly on my own writable version of the caldav calendar.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.clearchain.com/blog/posts/caldav-calendar-icalserver/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>samba ADS nightmares</title>
		<link>http://www.clearchain.com/blog/posts/samba-ads-nightmares</link>
		<comments>http://www.clearchain.com/blog/posts/samba-ads-nightmares#comments</comments>
		<pubDate>Mon, 02 Feb 2009 02:35:03 +0000</pubDate>
		<dc:creator>Benjamin Close</dc:creator>
				<category><![CDATA[OpenSource]]></category>
		<category><![CDATA[UniSA]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[ad]]></category>
		<category><![CDATA[domain]]></category>
		<category><![CDATA[net ads]]></category>
		<category><![CDATA[samba]]></category>

		<guid isPermaLink="false">http://www.clearchain.com/blog/?p=225</guid>
		<description><![CDATA[<a href="http://www.clearchain.com/blog/posts/samba-ads-nightmares"><img align="left" hspace="5" width="150" height="150" src="http://www.clearchain.com/blog/wp-content/plugins/thumbnail-for-excerpts/tfe_no_thumb.png" class="alignleft wp-post-image tfe" alt="" title="" /></a>Recently Ben and I have been trying to get a FreeBSD box to join an Active Directory domain. The domain controller was running Windows Server 2008. After a *lot* of stuffing around to get this working we finally found the solution to our problem &#8211; the version of samba. You see the problem we were<a href="http://www.clearchain.com/blog/posts/samba-ads-nightmares"> <font size=-2>[..more..]</font></a>]]></description>
			<content:encoded><![CDATA[<p>Recently Ben and I have been trying to get a FreeBSD box to join an Active Directory domain. The domain controller was running Windows Server 2008. After a *lot* of stuffing around to get this working we finally found the solution to our problem &#8211; the version of samba.<br />
You see the problem we were facing was:</p>
<pre># net ads join -U cis-closebs
cis-closebs's password:
Failed to join domain: Improperly formed account name</pre>
<p>Now we checked the logs, checked kerberos, samba, but could not get this working. The debug logs showed something but nothing really useful:</p>
<pre># net ads join -U cis-closebs
cis-closebs's password:
Failed to join domain: Improperly formed account name
# net ads join -d 3 -U cis-closebs
[2009/02/02 12:55:26, 3] param/loadparm.c:lp_load(5031)
  lp_load: refreshing parameters
[2009/02/02 12:55:26, 3] param/loadparm.c:init_globals(1430)
  Initialising global parameters
[2009/02/02 12:55:26, 3] param/params.c:pm_process(572)
  params.c:pm_process() - Processing configuration file "/usr/local/etc/smb.conf"
[2009/02/02 12:55:26, 3] param/loadparm.c:do_section(3770)
  Processing section "[global]"
[2009/02/02 12:55:26, 2] lib/interface.c:add_interface(81)
  added interface ip=130.220.236.62 bcast=130.220.237.255 nmask=255.255.254.0
[2009/02/02 12:55:26, 3] libsmb/namequery.c:get_dc_list(1489)
  get_dc_list: preferred server list: "130.220.64.77, uninet.unisa.edu.au, *"
[2009/02/02 12:55:26, 3] libads/ldap.c:ads_connect(394)
  Connected to LDAP server 130.220.64.77
[2009/02/02 12:55:26, 3] libsmb/namequery.c:get_dc_list(1489)
  get_dc_list: preferred server list: "130.220.64.77, uninet.unisa.edu.au, *"
[2009/02/02 12:55:26, 3] libsmb/namequery.c:get_dc_list(1489)
  get_dc_list: preferred server list: "130.220.64.77, uninet.unisa.edu.au, *"
cis-closebs's password:
[2009/02/02 12:55:27, 3] libsmb/namequery.c:get_dc_list(1489)
  get_dc_list: preferred server list: "130.220.64.77, uninet.unisa.edu.au, *"
[2009/02/02 12:55:27, 3] libads/ldap.c:ads_connect(394)
  Connected to LDAP server 130.220.64.77
[2009/02/02 12:55:27, 3] libads/sasl.c:ads_sasl_spnego_bind(213)
  ads_sasl_spnego_bind: got OID=1 2 840 48018 1 2 2
[2009/02/02 12:55:27, 3] libads/sasl.c:ads_sasl_spnego_bind(213)
  ads_sasl_spnego_bind: got OID=1 2 840 113554 1 2 2
[2009/02/02 12:55:27, 3] libads/sasl.c:ads_sasl_spnego_bind(213)
  ads_sasl_spnego_bind: got OID=1 2 840 113554 1 2 2 3
[2009/02/02 12:55:27, 3] libads/sasl.c:ads_sasl_spnego_bind(213)
  ads_sasl_spnego_bind: got OID=1 3 6 1 4 1 311 2 2 10
[2009/02/02 12:55:27, 3] libads/sasl.c:ads_sasl_spnego_bind(222)
  ads_sasl_spnego_bind: got server principal name = not_defined_in_RFC4178@please_ignore
[2009/02/02 12:55:27, 3] libsmb/clikrb5.c:ads_krb5_mk_req(593)
  ads_krb5_mk_req: krb5_cc_get_principal failed (No such file or directory)
[2009/02/02 12:55:27, 1] libsmb/clikrb5.c:ads_krb5_mk_req(602)
  ads_krb5_mk_req: krb5_get_credentials failed for not_defined_in_RFC4178@please_ignore (Server not found in Kerberos database)
[2009/02/02 12:55:27, 1] utils/net_ads.c:net_ads_join(1470)
  error on ads_startup: Server not found in Kerberos database
Failed to join domain: Improperly formed account name
[2009/02/02 12:55:27, 2] utils/net.c:main(1036)
  return code = -1</pre>
<p>Turns out that it was the version of samba we were using. Version 3.0.28 had issues with joining a Windows Server 2008 Active Directory domain. This was fixed in Samba 3.0.28a and as can be seen with the <a href="http://www.freebsd.org/cgi/cvsweb.cgi/ports/net/samba3/Makefile">FreeBSD ports commit</a>:</p>
<table border="1">
<tbody>
<tr>
<td>
<p style="padding-left: 60px; ">Revision <strong>1.169</strong>: <a class="download-link" href="http://www.freebsd.org/cgi/cvsweb.cgi/~checkout~/ports/net/samba3/Makefile?rev=1.169;content-type=text%2Fplain">download</a> - view: <a class="display-link" href="http://www.freebsd.org/cgi/cvsweb.cgi/ports/net/samba3/Makefile?rev=1.169;content-type=text%2Fplain">text</a>, <a class="display-link" href="http://www.freebsd.org/cgi/cvsweb.cgi/ports/net/samba3/Makefile?rev=1.169;content-type=text%2Fx-cvsweb-markup">markup</a>, <a href="http://www.freebsd.org/cgi/cvsweb.cgi/ports/net/samba3/Makefile?annotate=1.169">annotated</a> - <a href="http://www.freebsd.org/cgi/cvsweb.cgi/ports/net/samba3/Makefile?r1=1.169#rev1.169">select for diffs</a><br />
<em>Thu May 1 16:32:53 2008 UTC</em> (9 months ago) by <em>timur</em><br />
Branches: <a href="http://www.freebsd.org/cgi/cvsweb.cgi/ports/net/samba3/Makefile?only_with_tag=MAIN">MAIN</a><br />
Diff to: previous 1.168: <a href="http://www.freebsd.org/cgi/cvsweb.cgi/ports/net/samba3/Makefile.diff?r1=1.168;r2=1.169">preferred</a>, <a href="http://www.freebsd.org/cgi/cvsweb.cgi/ports/net/samba3/Makefile.diff?r1=1.168;r2=1.169;f=h">colored</a><br />
Changes since revision 1.168: +2 -2 lines</p>
<pre class="log">Update port to the 3.0.28a revision.

Major changes:

  o Failure to join Windows 2008 domains
  o Windows Vista (including SP1 RC) interop issues

Approved by:	shaun (mentor, implicit)</pre>
</td>
</tr>
</tbody>
</table>
<p>So if you find yourself hunting around chasing something that surely should work.. consider upgrading samba!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.clearchain.com/blog/posts/samba-ads-nightmares/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding Multiple Mice Support to FLTK using MPX</title>
		<link>http://www.clearchain.com/blog/posts/adding-multiple-mice-support-to-fltk-using-mpx</link>
		<comments>http://www.clearchain.com/blog/posts/adding-multiple-mice-support-to-fltk-using-mpx#comments</comments>
		<pubDate>Tue, 25 Nov 2008 06:53:07 +0000</pubDate>
		<dc:creator>Benjamin Close</dc:creator>
				<category><![CDATA[OpenSource]]></category>
		<category><![CDATA[UniSA]]></category>
		<category><![CDATA[fltk]]></category>
		<category><![CDATA[MPX]]></category>
		<category><![CDATA[multiple mice]]></category>
		<category><![CDATA[toolkit]]></category>
		<category><![CDATA[win32]]></category>

		<guid isPermaLink="false">http://www.clearchain.com/blog/?p=146</guid>
		<description><![CDATA[<a href="http://www.clearchain.com/blog/posts/adding-multiple-mice-support-to-fltk-using-mpx"><img align="left" hspace="5" width="150" height="150" src="http://www.clearchain.com/blog/wp-content/plugins/thumbnail-for-excerpts/tfe_no_thumb.png" class="alignleft wp-post-image tfe" alt="" title="" /></a>Details about adding multiple mice support to the FLTK toolkit]]></description>
			<content:encoded><![CDATA[<p>For a while now I&#8217;ve been working on modifying <a href="http://fltk.org">FLTK</a> to support multiple Mice. We need this functionality for applications we are working on. FLTK was chosen for a number of reasons. </p>
<ol>
<li>It&#8217;s light weight</li>
<li>It&#8217;s cross platform</li>
<li>It was already in use by the applications being extended.</li>
</ol>
<div>However, FLTK didn&#8217;t support multiple mice out the box. Multiple Mice support exists both under Win32 via the RAWINPUT api and under <a href="http://www.x.org">Xorg</a> via <a href="http://wearables.unisa.edu.au/mpx">MPX</a>.</div>
<div>Though support in the various toolkits is still lacking. Not surprizing considering how recent MPX/RAWINPUT is.</div>
<p><span id="more-146"></span></p>
<div>MPX was the natural choice for the first implementation of multiple choice in a toolkit. </div>
<div>MPX is built into the windowing system hence focus, grabs and cursor rending is all semi transparently delt with where as RAWINPUT has you doing most the work yourself.</div>
<div>Hence I set about modifying FLTK to support Multiple Mice using MPX.</div>
<div>Results so far have been quite good. Due to FLTK internally doing most of it&#8217;s own component hit testing, having to deal with a window per component wasn&#8217;t needed. Instead a simple API extending the existing toolkit has been created.</div>
<div>The patch implementing this API and the relevant glue to use it is available at: <a href="http://wcl.ml.unisa.edu.au/~closebs/downloads/fltk-1.3-mpx.patch">http://wcl.ml.unisa.edu.au/~closebs/downloads/fltk-1.3-mpx.patch</a></div>
<div>This patch against the current 1.3 SVN (rev 6524) development branch and provides the following API extensions:</div>
<div>Creation of FL/Fl_Mouse.H which defines two important types:</div>
<div><strong><span style="text-decoration: underline;">Types:</span></strong></div>
<div>
<ul>
<li>FL_MouseID <span style="white-space:pre"> </span>- A type indicating the id of a mouse</li>
<li>FL_Mouse  <span style="white-space:pre"> </span>- A type that records information about a mouse (ie x, y, button state, etc)</li>
</ul>
<div><span style="text-decoration: underline;"><strong>Functions/Variables</strong></span></div>
</div>
<div>New functions/variarables in FL/Fl.H</div>
<div>
<ul>
<li>FL::e_mouse_id       <span style="white-space:pre"> </span>- The id of the last mouse to cause an event</li>
<li>FL::e_last_mouseid <span style="white-space:pre"> </span>- The id of the last mouse in the system</li>
<li>Fl::grab(Fl_MouseID)- Put a grab on a specific mouse</li>
<li>Fl::get_last_mouseid- Return the ID of the last mouse know to the toolkit</li>
<li>Fl::create_mouse()<span style="white-space:pre"> </span>- Register a new mouse with the toolkit</li>
<li>Fl::event_mouse_id()- Return the id of the mouse that caused the last event</li>
</ul>
<div>There has also been a number of changes to existing functions but all in a way which should be API compatible &#8211; sadly not ABI compatible.</div>
</div>
<div>These changes basically support passing in mouse id&#8217;s or storage of grabs/focus per mouse, etc.</div>
<div>There&#8217;s also been a test application created: test/multiplemice</div>
<div>This application, whilst very simple shows an example use of the MULTIPLE_MICE functionality. In it you can use two mice to drag two FLTK widgets around at the same time. </div>
<h2>I want to try</h2>
<p>If you want to give the FLTK changes a shot it&#8217;s fairly simple all you have to do is:</p>
<p> </p>
<ul>
<li>Build a version of Xorg with MPX support (see <a href="http://wearables.unisa.edu.au/mpx">http://wearables.unisa.edu.au/mpx</a>) for details.</li>
<li>Build a version of xinput with MPX support
<ul>
<li>This will allow you to create multiple mice via<br />
xinput create-master mymouse<br />
xinput list &#8211;short       # Take note of one of the mouse id&#8217;s, lets call it x and mymouse id y <br />
xinput reattach  x y</li>
</ul>
</li>
<li>Grab the latest version of the 1.3 branch of FLTK from SVN (<a href="http://fltk.org/svn.php">http://fltk.org/svn.php)</a></li>
<li>Apply the patch at <a href="http://wcl.ml.unisa.edu.au/~closebs/downloads/fltk-1.3-mpx.patch">http://wcl.ml.unisa.edu.au/~closebs/downloads/fltk-1.3-mpx.patch</a>
<ul>
<li>patch -p0 &lt; fltk-1.3-mpx.patch</li>
</ul>
</li>
<li>Configure with multiple mice support: ./configure &#8211;enable-multiplemice</li>
<li>Build the toolkit: make</li>
<li>Test the multiple mice application: test/multiplemice</li>
</ul>
<p> </p>
<h2>Future</h2>
<p>Win32 support is currently under way with large chunks being already done. Though the lack of native cursor rendering under Win32 is causing greif. Other patches not far around the corner are a custom cursor patch, which allows a custom cursor per mouse as well as the ability to capture input events from the toolkit and inject input events into the toolkit &#8211; great for distributed event reconstruction.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.clearchain.com/blog/posts/adding-multiple-mice-support-to-fltk-using-mpx/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>jhbuild just won&#8217;t build! (aka Include path madness)</title>
		<link>http://www.clearchain.com/blog/posts/jhbuild-just-wont-build-aka-include-path-madness</link>
		<comments>http://www.clearchain.com/blog/posts/jhbuild-just-wont-build-aka-include-path-madness#comments</comments>
		<pubDate>Mon, 17 Nov 2008 23:42:04 +0000</pubDate>
		<dc:creator>Benjamin Close</dc:creator>
				<category><![CDATA[FreeDesktop]]></category>
		<category><![CDATA[OpenSource]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[UniSA]]></category>
		<category><![CDATA[C_INCLUDE_PATH]]></category>
		<category><![CDATA[gcc]]></category>
		<category><![CDATA[jhbuild]]></category>
		<category><![CDATA[search paths]]></category>

		<guid isPermaLink="false">http://www.clearchain.com/blog/?p=137</guid>
		<description><![CDATA[<a href="http://www.clearchain.com/blog/posts/jhbuild-just-wont-build-aka-include-path-madness"><img align="left" hspace="5" width="150" height="150" src="http://www.clearchain.com/blog/wp-content/plugins/thumbnail-for-excerpts/tfe_no_thumb.png" class="alignleft wp-post-image tfe" alt="" title="" /></a>I&#8217;ve been recently trying to work out why jhbuild fails to build xorg on my FreeBSD box. Traditionally I compile to /usr/local/ however after wanting to experiment with MPX I&#8217;ve set things up so that I compile to /usr/local/MPX Sadly this kept breaking in xorg/lib/libX11 with the error: xcb_io.c: In function 'require_socket': xcb_io.c:35: warning: implicit declaration<a href="http://www.clearchain.com/blog/posts/jhbuild-just-wont-build-aka-include-path-madness"> <font size=-2>[..more..]</font></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been recently trying to work out why jhbuild fails to build xorg on my FreeBSD box. Traditionally I compile to <em>/usr/local/</em> however after wanting to experiment with MPX I&#8217;ve set things up so that I compile to <em>/usr/local/MPX</em></p>
<p>Sadly this kept breaking in xorg/lib/libX11 with the error:</p>
<p><span id="more-137"></span></p>
<pre style="padding-left: 30px; ">xcb_io.c: In function 'require_socket':
xcb_io.c:35: warning: implicit declaration of function 'xcb_take_socket'
xcb_io.c:35: warning: nested extern declaration of 'xcb_take_socket'
xcb_io.c: In function 'process_responses':
xcb_io.c:188: error: 'GenericEvent' undeclared (first use in this function)
xcb_io.c:188: error: (Each undeclared identifier is reported only once
xcb_io.c:188: error: for each function it appears in.)
xcb_io.c:189: error: 'xcb_ge_event_t' undeclared (first use in this function)
xcb_io.c:189: error: expected expression before ')' token
xcb_io.c:193: error: expected expression before ')' token
xcb_io.c: In function '_XSend':
xcb_io.c:332: warning: implicit declaration of function 'xcb_writev'
xcb_io.c:332: warning: nested extern declaration of 'xcb_writev'</pre>
<p> </p>
<p>For the life of me I couldn&#8217;t make sense of it. GenericEvent is defined in xcb/xcb.h and checking the preprocessor output xcb.h was being included. Likewise the lack of xcb_ge_event_t was baffling me as it was certain in xcb/xcb.h. It wasn&#8217;t till I looked a little closer that I realised that the wrong xcb.h was being used. Turns out that /<em>usr/local/include/xcb/xcb.h</em> was being used however I wanted <em>/usr/local/MPX/include/xcb/xcb.h</em> to be used. Hence I tried adding <em>-I/usr/local/MPX</em> to CFLAGS with no success and also tried setting <em>CC=&#8221;gcc -I/usr/local/MPX&#8221;</em> also with no success. It just didn&#8217;t make sense!</p>
<p>Looking at the gcc line, <em>/u</em><em>sr/local/MPX</em> should have been used first. It wasn&#8217;t until I finally check the preprocessor what it thought the system paths were did it all make sense.</p>
<p>The output from cpp is below:</p>
<pre style="padding-left: 30px; "><span style="font-family: 'Lucida Grande'; line-height: 19px; white-space: normal; ">U</span>sing built-in specs.
Target: amd64-undermydesk-freebsd
Configured with: FreeBSD/amd64 system compiler
Thread model: posix
gcc version 4.2.1 20070719  [FreeBSD]
 /usr/libexec/cc1 -E -quiet -v -I. -I../include/X11 -I../include -I../include/X11
-I../include -I../include/X11 -I../src/xcms -I../src/xkb -I../src/xlibi18n -I/usr/local/include 
-D_LONGLONG -DHAVE_CONFIG_H -D_BSD_SOURCE -DHAS_FCHOWN -DHAS_STICKY_DIR_BIT -D_THREAD_SAFE -D_BSD_SOURCE
-DX11_t -DTRANS_CLIENT -isystem /usr/local/MPX/include xcb_io.c -o xcb_io.lo -Wall -Wpointer-arith
-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -fno-strict-aliasing -fworking-directory -O0</pre>
<pre style="padding-left: 30px; ">ignoring duplicate directory "/usr/local/MPX/include"
ignoring duplicate directory "/usr/include"
ignoring duplicate directory "../include/X11"
ignoring duplicate directory "../include"
ignoring duplicate directory "../include/X11"
#include "..." search starts here:
#include &lt;...&gt; search starts here:
 .
 ../include/X11
 ../include
 ../src/xcms
 ../src/xkb
 ../src/xlibi18n
 /usr/local/include
 /usr/local/MPX/include
 /usr/include
End of search list.</pre>
<p>It turns out that jhbuild sets the environment variable <em>C_INCLUDE_PATH, </em>in this case to <em>/usr/local/MPX/include</em>. This variable adds a library to the system search path. Whilst it prepends to the system search path,  -I<em> </em>options prepend the system search path, hence with one -I option being <em>/usr/local/include</em>, we get the ordering incorrect and the wrong header is used.  </p>
<p>So now it was up to working out why <em>/usr/local/include</em> was needed. Searching config.log it turns out the bigfontproto was needed by libX11, pkg_config was searching for it and finding it not in <em>/usr/local/MPX/lib/share/pkg_config</em> but in <em>/usr/local/lib/share/pkg_config</em>. The reason for this is bigfontproto wasn&#8217;t listed as a dependancy in the xorg.modules file used by jhbuild (avaliable at:<a href="http://cgit.freedesktop.org/xorg/util/modular/tree/xorg.modules">http://cgit.freedesktop.org/xorg/util/modular/tree/xorg.modules</a>). Because of this bigfont proto wasn&#8217;t being built by <a href="http://www.jamesh.id.au/software/jhbuild/">jhbuild</a>. Hence the only bigfontproto that existed on the box was the default system bigfont proto which WAS located under /usr/local/include. </p>
<p>The fix was simple. List xf86bigfontproto as a dependency in xorg.modules and all was good. bigfontproto is now pulled in as a dependency and hence gets built before libX11. pkg_config now correctly finds bigfontproto in /<em>usr/local/MPX/lib/share/pkg_config</em> hence doesn&#8217;t need to fallback to the system version so <em>-I/usr/local/include</em> doesn&#8217;t get added to the gcc line. Hence the compiler uses <em>/usr/local/MPX/include/xcb/xcb.h </em>rather than the one in <em>/usr/local/include/xcb/xcb.h</em> and the compiler errors vanish.</p>
<p>So now things are building and I&#8217;m off for a coffee!<br />
(xorg.modules has also been correctly updated so some other poor person doesn&#8217;t have the same issues).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.clearchain.com/blog/posts/jhbuild-just-wont-build-aka-include-path-madness/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Setting up Sendmail with TLS &amp; Auth support under FreeBSD</title>
		<link>http://www.clearchain.com/blog/posts/setting-up-sendmail-with-tls-auth-support-under-freebsd</link>
		<comments>http://www.clearchain.com/blog/posts/setting-up-sendmail-with-tls-auth-support-under-freebsd#comments</comments>
		<pubDate>Thu, 13 Nov 2008 13:53:39 +0000</pubDate>
		<dc:creator>Benjamin Close</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[OpenSource]]></category>
		<category><![CDATA[mta]]></category>
		<category><![CDATA[sasl]]></category>
		<category><![CDATA[sendmail]]></category>
		<category><![CDATA[smtp auth]]></category>
		<category><![CDATA[smtps]]></category>

		<guid isPermaLink="false">http://www.clearchain.com/blog/?p=110</guid>
		<description><![CDATA[<a href="http://www.clearchain.com/blog/posts/setting-up-sendmail-with-tls-auth-support-under-freebsd"><img align="left" hspace="5" width="150" height="150" src="http://www.clearchain.com/blog/wp-content/plugins/thumbnail-for-excerpts/tfe_no_thumb.png" class="alignleft wp-post-image tfe" alt="" title="" /></a>In order to setup a secure mail transport agent (MTA) that helps eliminate some spam and also allows roaming client support, some sort of authentication mechanisim must be added when setting up a MTA. In my case I&#8217;m using FreeBSD 4.9 with sendmail as my MTA. Setting Up Sendmail The first step in setting up<a href="http://www.clearchain.com/blog/posts/setting-up-sendmail-with-tls-auth-support-under-freebsd"> <font size=-2>[..more..]</font></a>]]></description>
			<content:encoded><![CDATA[<p>In order to setup a secure mail transport agent (MTA) that helps eliminate some spam and also allows roaming client support, some sort of authentication mechanisim must be added when setting up a MTA. In my case I&#8217;m using FreeBSD 4.9 with sendmail as my MTA. Setting Up Sendmail</p>
<p><span id="more-110"></span></p>
<p>The first step in setting up TLS/Auth support is to install the required additional libraries. For SSL support (required by TLS) the following ports must be installed:</p>
<ul>
<li> security/cyrus-sasl</li>
<li> security/cyrus-sasl-saslauthd//</li>
</ul>
<p>These must be installed before sendmail is recompiled.</p>
<p>Sendmail in FreeBSD by default is not compiled with TLS/Auth support. In order to allow it to work with these features it must be recompiled. This is actually quite simple as long as the FreeBSD machine has the FreeBSD source collection (aka /usr/src). First you need to edit ///etc/make.conf// (//cp /etc/defaults/make.conf// if it doesn&#8217;t already exist. Edit the file so the following lines exist/are uncommented.</p>
<pre>  # with SASLv2:
  SENDMAIL_CFLAGS=-I/usr/local/include -DSASL=2
  SENDMAIL_LDFLAGS=-L/usr/local/lib
  SENDMAIL_LDADD=-lsasl2</pre>
<p>Next you need to recompile sendmail. Due to the way sendmail exists in the ports collections you must compile some of the libraries first. The following lines show the procedure for recompiling the libraries and sendmail.</p>
<ol>
<li> Compile the smutil library</li>
</ol>
<pre>  cd /usr/src/lib/libsmutil
  make clean
  make obj
  make</pre>
<ol>
<li> Compile the smlibrary</li>
</ol>
<pre>  cd /usr/src/lib/libsm
  make clean
  make obj
  make</pre>
<ol>
<li> Compile Sendmail</li>
</ol>
<pre>  cd /usr/src/usr.sbin/sendmail
  make clean
  make obj
  make
  make install</pre>
<p>At this point sendmail with TLS/Auth support is installed. Now sendmail must be configured to work with these features. Setting Up TLS Support</p>
<p>TLS stands for Transport Layer Security. It&#8217;s a bit like SSL (Socket Layer Security) in that it provides encryption between two points. The difference is that TLS provides it only in the data, SSL provides encryption of the headers as well.</p>
<p>Using TLS is a good idea. It provides encyrption for authentication purposes and also Trusted mail headers. Ie A Mail server can create a TLS connection between itself and another TLS server and this is reported in the mail headers and the mail headers are thus deemed &#8216;accurate&#8217;.</p>
<p>To setup TLS support you need to first generate a public/private key pair for use with the mail server. This is outside the scope of this document. Then you need to setup sendmail with the following options:</p>
<pre>  define(`CERT_DIR', `MAIL_SETTINGS_DIR`'certs')
  define(`confCACERT_PATH', `CERT_DIR')
  define(`confCACERT', `CERT_DIR/CAcert.pem')
  define(`confSERVER_CERT', `CERT_DIR/MYcert.pem')
  define(`confSERVER_KEY', `CERT_DIR/MYkey.pem')
  define(`confCLIENT_CERT', `CERT_DIR/cert.pem')
  define(`confCLIENT_KEY', `CERT_DIR/MYkey.pem')</pre>
<p>You must set both the client and the server key so that incomming mail can be encrypted and so that outgoing mail can be encrypted.</p>
<p>Once you have set this up, restart sendmail and test it (See below) Setting Up Auth Support</p>
<p>In order to use authentication support you must first add a few options to the sendmail configuration file. Authentication is used to allow relaying from domains that are not listed as relay domains provided authentication exists. Ie: as long as the authentication is successful, then the mail server is affectivly an open relay on that connection. This is great for roaming laptop users who want to send mail but are often in a different domain or on dialup.</p>
<p>To set this up add the following to your //sendmail.mc// file:</p>
<pre>  define(`confAUTH_MECHANISMS',`GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN')
  TRUST_AUTH_MECH(`GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN');</pre>
<p>This tells sendmail to support the listed authentication methods. There is also a &#8216;PLAIN&#8217; option but this should be avoided as the password is sent in plain text. Even of TLS/SSL this is not a good idea.</p>
<p>With that option in place you now have to tell sendmail what it is allowed to relay based on authentication. To allow relays to anywhere provided authentication works add the following to the access file.</p>
<pre>  From: * OK
  To: * RELAY</pre>
<p>Make sure that you rebuild the access database (run make) then restart sendmail and authentication should be enabled so test it! Extra Sendmail Configuration Options</p>
<p>It is possible and highly recommended that sendmail be setup to force TLS for authentication purposes. Otherwise sendmail will quite happily accept plain text passwords across an unencrypted data stream. This is just a big security problem. Hence adding the following line to sendmail forces the use to use TLS/SSL before authentication is possible:</p>
<pre>  define(`confAUTH_OPTIONS',`p,y')</pre>
<p><a name="Testing_it_all"></a></p>
<h5><span class="editsection"> </span> <span class="mw-headline">Testing it all </span></h5>
<p>After everything has been setup, it is extreemly important to test that the results are as expected. There are a number of tests you will want to run. These include the following: Test Test Implementation TLS Test</p>
<p>The following shows a telnet to the mail server, type the text in bold and look for the result in italics/bold</p>
<pre>  $ telnet localhost 25
  220 mail.example.net ESMTP Sendmail 8.11.1/8.11.1; Sat, 19 May 2001 08:04:04 -0400
  EHLO localhost
  250-mail.example.net Hello IDENT:jose@[127.0.0.1], pleased to meet you
  250-ENHANCEDSTATUSCODES
  250-EXPN
  250-VERB
  250-8BITMIME
  250-SIZE
  250-DSN
  250-ONEX
  250-ETRN
  250-XUSR
  250-STARTTLS
  250-DELIVERBY
  250 HELP
  Auth Test</pre>
<p>The following shows a telnet to the mail server, type the text in bold and look for the result in italics/bold</p>
<pre>  $ telnet localhost 25
  220 mail.example.net ESMTP Sendmail 8.11.1/8.11.1; Sat, 19 May 2001 08:04:04 -0400
  EHLO localhost
  250-mail.example.net Hello IDENT:jose@[127.0.0.1], pleased to meet you
  250-ENHANCEDSTATUSCODES
  250-EXPN
  250-VERB
  250-8BITMIME
  250-SIZE
  250-DSN
  250-ONEX
  250-ETRN
  250-AUTH DIGEST-MD5 CRAM-MD5
  250-XUSR
  250-STARTTLS
  250-DELIVERBY
  250 HELP</pre>
<p>You might find that the authentication methods supported don&#8217;t match what you selected. This is due to various libraries not supporting those methods of authentication.</p>
<p><a name="Open_Relay_Test"></a></p>
<h4><span class="editsection"> </span><span class="mw-headline"> Open Relay Test </span></h4>
<p><a class="external free" title="http://www.relaycheck.com" rel="nofollow" href="http://www.relaycheck.com/">http://www.relaycheck.com</a> telnet relay-test.mail-abuse.org Authentication Test On the system it should work Off the system it should require authentication</p>
<pre>  telnet server 25
  helo server
  mail from: user@server
  rcpt to: someotheruser@someotherserver</pre>
<p>This should complain about relaying being denied without authorisation if not on the local machine</p>
<p><a name="Authentication_Test"></a></p>
<h4><span class="editsection"> </span> <span class="mw-headline">Authentication Test </span></h4>
<p>With SSL &amp; Authentications Enabled You should be able to email anywhere.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.clearchain.com/blog/posts/setting-up-sendmail-with-tls-auth-support-under-freebsd/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>LDAPAddressBook</title>
		<link>http://www.clearchain.com/blog/posts/ldapaddressbook</link>
		<comments>http://www.clearchain.com/blog/posts/ldapaddressbook#comments</comments>
		<pubDate>Thu, 13 Nov 2008 13:45:41 +0000</pubDate>
		<dc:creator>Benjamin Close</dc:creator>
				<category><![CDATA[OpenSource]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://www.clearchain.com/blog/?p=108</guid>
		<description><![CDATA[<a href="http://www.clearchain.com/blog/posts/ldapaddressbook"><img align="left" hspace="5" width="150" src="http://www.clearchain.com/blog/images//2008/11/LDAPAB_stage_1-150x150.png" class="alignleft wp-post-image tfe" alt="LDAPAB_stage_1" title="LDAPAB_stage_1" /></a>LDAP is a great protocol. It allows multiple clients to obtain data about virtually anything that you can think of. The LDAPAddressBook project is a project to determine a LDAP Schema that works in the following clients: Mozilla Thunderbird Windows Address Book OS X Address Book Squirrel Mail In fact any client that supports LDAP.<a href="http://www.clearchain.com/blog/posts/ldapaddressbook"> <font size=-2>[..more..]</font></a>]]></description>
			<content:encoded><![CDATA[<p>LDAP is a great protocol. It allows multiple clients to obtain data about virtually anything that you can think of. The LDAPAddressBook project is a project to determine a LDAP Schema that works in the following clients:</p>
<ul>
<li> Mozilla Thunderbird</li>
<li> Windows Address Book</li>
<li> OS X Address Book</li>
<li> Squirrel Mail</li>
</ul>
<p>In fact any client that supports LDAP.</p>
<p><span id="more-108"></span></p>
<p>By determining this schema, ClearChain can finally have a &#8216;go anywhere&#8217; addressbook.</p>
<p><script type="text/javascript">// <![CDATA[
  if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); }
// ]]&gt;</script></p>
<h2><span class="editsection"> </span> <span class="mw-headline">Conceptual Layout </span></h2>
<h3><span class="editsection"> </span><span class="mw-headline">Stage 1</span></h3>
<p><a href="http://www.clearchain.com/blog/images//2008/11/LDAPAB_stage_1.png"><img class="aligncenter size-thumbnail wp-image-628" title="LDAPAB_stage_1" src="http://www.clearchain.com/blog/images//2008/11/LDAPAB_stage_1-150x150.png" alt="LDAPAB_stage_1" width="150" height="150" /></a></p>
<p>The idea is that everything is stored in a database. Databases are great for storing and manipulating information. Currently we use a MySQL database. Data is extracted from the database in xml format. This is actually ridiculously easy. MySQL (on the command line at least) supports output formats of xml. On the command line when connecting to the database you just throw in a &#8211;xml flag, for example:</p>
<pre>mysql --xml -u frank -p</pre>
<p>Then when you get any text back from any queries you run the results will be wrapped in xml. Even commands such as:</p>
<pre>mysql&gt; show databases;</pre>
<p>will return results marked up with xml, for example:</p>
<pre>&lt;?xml version="1.0"?&gt;

&lt;resultset statement="show databases;"&gt;
  &lt;row&gt;
        &lt;field name="Database"&gt;information_schema&lt;/field&gt;
  &lt;/row&gt;

  &lt;row&gt;
        &lt;field name="Database"&gt;addressbook&lt;/field&gt;
  &lt;/row&gt;

  &lt;row&gt;
        &lt;field name="Database"&gt;budget&lt;/field&gt;
  &lt;/row&gt;

  &lt;row&gt;
        &lt;field name="Database"&gt;dinner&lt;/field&gt;
  &lt;/row&gt;

  &lt;row&gt;
        &lt;field name="Database"&gt;mysql&lt;/field&gt;
  &lt;/row&gt;

  &lt;row&gt;
        &lt;field name="Database"&gt;wiki_thesis&lt;/field&gt;
  &lt;/row&gt;
&lt;/resultset&gt;</pre>
<p>This is awesome because it means that we can easily convert the xml into any format that we want in particular an LDAP schema that Thunderbird understands, an LDAP schema that Outlook understands, but also just as easily HTML, XHTML, plain text&#8230; you name it the xml can be converted to it simply with an xml transformation.</p>
<p>In the case of an LDAP server once the XML has been converted to the appropriate format existing LDAP data is blown away and then replaced by the new schema.</p>
<p><strong>NOTE:</strong> Through php the mysql calls do not support fetch results in xml format, except via an extension. For this reason I wrote a simple method that wraps the mysql like xml around the data set returned via the usual query call.</p>
<h3><span class="editsection"> </span><span class="mw-headline">Stage 2</span></h3>
<p><a href="http://www.clearchain.com/blog/images//2008/11/LDAPAB_stage_2.png"><img class="aligncenter size-thumbnail wp-image-629" title="LDAPAB_stage_2" src="http://www.clearchain.com/blog/images//2008/11/LDAPAB_stage_2-150x150.png" alt="LDAPAB_stage_2" width="150" height="150" /></a></p>
<p>The second stage of this project is to provide the various email clients and addressbooks with the ability to add and modify contacts in the database. This is more of a pipe dream at the moment, but should be relatively straight forward with an email client such as Thunderbird.</p>
<h2><span class="editsection"> </span><span class="mw-headline"> LDAP Schema </span></h2>
<p>This section details the various fields used by different applications for the address book. I&#8217;ve tried to map the fields to the official ldap schemas that exist. A full list that are supported by thunderbird is available at:  <a class="external free" title="http://www.mozilla.org/projects/thunderbird/specs/ldap.html" rel="nofollow" href="http://www.mozilla.org/projects/thunderbird/specs/ldap.html">http://www.mozilla.org/projects/thunderbird/specs/ldap.html</a></p>
<p>There is however a lot of undocumented mozilla/thunderbird specific attributes. <a href="http://www.pro-linux.de/t_office/mozilla_op20.schema">http://www.pro-linux.de/t_office/mozilla_op20.schema</a></p>
<p>Documents a complete mozilla schema but is yet to be tested</p>
<table style="border: 1px solid #aaaaaa; margin: 1em 1em 1em 0pt; background: #f9f9f9 none repeat scroll 0% 0%; border-collapse: collapse;" border="2" cellspacing="0" cellpadding="4">
<tbody>
<tr>
<th> LDAP Schema</th>
<th> Field</th>
<th> Thunderbird</th>
<th> Outlook Express</th>
</tr>
<tr>
<td>inetOrgPerson</td>
<td>givenName</td>
<td>Firstname</td>
<td></td>
</tr>
<tr>
<td>person</td>
<td>sn</td>
<td>Lastname</td>
<td></td>
</tr>
<tr>
<td>inetOrgPerson</td>
<td>displayName</td>
<td>Display</td>
<td></td>
</tr>
<tr>
<td>mozillaAbPersonObsolete</td>
<td>mozillaNickname</td>
<td>Nickname</td>
<td></td>
</tr>
<tr>
<td>inetOrgPerson</td>
<td>mail</td>
<td>Email</td>
<td></td>
</tr>
<tr>
<td>mozillaAbPersonObsolete</td>
<td>mozillaSecondEmail</td>
<td>Additional Email</td>
<td></td>
</tr>
<tr>
<td>mozillaAbPersonObsolete</td>
<td>mozillaUseHtmlMail</td>
<td>Prefers to receive message formated as</td>
<td></td>
</tr>
<tr>
<td></td>
<td>-</td>
<td>Screen Name</td>
<td></td>
</tr>
<tr>
<td>2.5.4.20(M)</td>
<td>telephoneNumber</td>
<td>Work (Phone)</td>
<td></td>
</tr>
<tr>
<td>inetOrgPerson</td>
<td>homePhone</td>
<td>Home (Phone)</td>
<td></td>
</tr>
<tr>
<td>2.5.4.23</td>
<td>faximileTelephoneNumber</td>
<td>Fax</td>
<td></td>
</tr>
<tr>
<td>inetOrgPerson</td>
<td>pager</td>
<td>Pager</td>
<td></td>
</tr>
<tr>
<td>inetOrgPerson</td>
<td>mobile</td>
<td>Mobile</td>
<td></td>
</tr>
<tr>
<td></td>
<td>-</td>
<td>Address (Ln1 HM)</td>
<td></td>
</tr>
<tr>
<td>mozillaAbPersonObsolete</td>
<td>mozillaHomePostalAddress2</td>
<td>Address (Ln2 HM)</td>
<td></td>
</tr>
<tr>
<td>mozillaAbPersonObsolete</td>
<td>mozillaHomeLocalityName</td>
<td>City (HM)</td>
<td></td>
</tr>
<tr>
<td>mozillaAbPersonObsolete</td>
<td>mozillaHomeState</td>
<td>State/Provice(HM)</td>
<td></td>
</tr>
<tr>
<td>mozillaAbPersonObsolete</td>
<td>mozillaHomePostalCode</td>
<td>Zip/Postal Code(HM)</td>
<td></td>
</tr>
<tr>
<td>mozillaAbPersonObsolete</td>
<td>mozillaHomeCountryName</td>
<td>Country(HM)</td>
<td></td>
</tr>
<tr>
<td>mozillaAbPersonObsolete</td>
<td>mozillaHomeUrl</td>
<td>Web Page(HM)</td>
<td></td>
</tr>
<tr>
<td>organizationPerson</td>
<td>title</td>
<td>Title (Wk)</td>
<td></td>
</tr>
<tr>
<td>inetOrgPerson</td>
<td>departmentNumber</td>
<td>Department (WK)</td>
<td></td>
</tr>
<tr>
<td>2.5.4.10</td>
<td>o</td>
<td>Organization(Wk)</td>
<td></td>
</tr>
<tr>
<td>2.5.4.18</td>
<td>postOfficeBox</td>
<td>Address (Ln1 Wk)</td>
<td></td>
</tr>
<tr>
<td>mozillaAbPersonObsolete</td>
<td>mozillaPostalAddress2</td>
<td>Address (Ln2 Wk)</td>
<td></td>
</tr>
<tr>
<td>2.5.4.7</td>
<td>l</td>
<td>City (Wk)</td>
<td></td>
</tr>
<tr>
<td>2.5.4.8</td>
<td>st</td>
<td>State/Provice(Wk)</td>
<td></td>
</tr>
<tr>
<td>2.5.4.17</td>
<td>postalCode</td>
<td>Zip/Postal Code(Wk)</td>
<td></td>
</tr>
<tr>
<td></td>
<td>-</td>
<td>Country (Wk)</td>
<td></td>
</tr>
<tr>
<td>mozillaAbPersonObsolete</td>
<td>mozillaWorkUrl</td>
<td>Web Page (Wk)</td>
<td></td>
</tr>
<tr>
<td>mozillaAbPersonObsolete</td>
<td>mozillaCustom1</td>
<td>Custom 1</td>
<td></td>
</tr>
<tr>
<td>mozillaAbPersonObsolete</td>
<td>mozillaCustom2</td>
<td>Custom 2</td>
<td></td>
</tr>
<tr>
<td>mozillaAbPersonObsolete</td>
<td>mozillaCustom3</td>
<td>Custom 3</td>
<td></td>
</tr>
<tr>
<td>mozillaAbPersonObsolete</td>
<td>mozillaCustom4</td>
<td>Custom 4</td>
<td></td>
</tr>
<tr>
<td></td>
<td>-</td>
<td>Custom 5</td>
<td></td>
</tr>
<tr>
<td>2.5.4.13</td>
<td>description</td>
<td>Notes</td>
<td></td>
</tr>
</tbody>
</table>
<h2><span class="editsection"> </span><span class="mw-headline"> OpenLdap </span></h2>
<p>In order to use create a schema for openldap that works for at least Thunderbird, download the schema linked above then make sure you have the following lines in your slapd.conf</p>
<pre>include         /usr/local/etc/openldap/schema/core.schema

# Add additional schema
include                 /usr/local/etc/openldap/schema/cosine.schema
include                 /usr/local/etc/openldap/schema/inetorgperson.schema
include                 /usr/local/etc/openldap/schema/mozilla_op20.schema</pre>
<h1><span class="editsection"> </span><span class="mw-headline">Contributors</span></h1>
<p><a class="external text" title="http://wcl.ml.unisa.edu.au/~staffora/index.php/Aaron_Stafford" rel="nofollow" href="http://www.hog3d.net/aaron.html">Aaron Stafford</a> has written a substantial amount of code for this project, including:</p>
<ul>
<li>HTML front end which communicates with the the database over PHP</li>
<li>XSL transformation that converts XML extracted from the database into the openldap ready text</li>
</ul>
<h2><span class="editsection"> </span><span class="mw-headline">Code Access</span></h2>
<p>Access to the code is currently restricted, but hopefully this will become a public upon request. If you are interested in seeing this project become public please drop us a line.</p>
<pre>git clone username@git.clearchain.com:/export/git/projects/ldapab</pre>
<p>On the mac you have to specify where you want it checked out to so use:</p>
<pre>git clone username@git.clearchain.com:/export/git/projects/ldapab ldapab</pre>
<p>If you are on a mac. It might be the case that you need to do this on any platform. I haven&#8217;t tested it anywhere else though.</p>
<h1><span class="editsection"> </span><span class="mw-headline">External Links</span></h1>
<p><a class="external free" title="http://www.plaxo.com/" rel="nofollow" href="http://www.plaxo.com/">http://www.plaxo.com/</a> &#8211; Plaxo is an interesting application. It lets you sync a whole bunch of different address books and calendar information from different application and online accounts. I have not used this but it appears to be a near perfect solution if you are prepared to hand over your usernames and passwords to another company. ldapab is designed to be managed by the person looking after their own contacts, not having someone else manage it for you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.clearchain.com/blog/posts/ldapaddressbook/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

