<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>The Homeless Badger</title>
	<atom:link href="http://cbadger.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://cbadger.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Wed, 29 Sep 2010 19:06:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='cbadger.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>The Homeless Badger</title>
		<link>http://cbadger.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://cbadger.wordpress.com/osd.xml" title="The Homeless Badger" />
	<atom:link rel='hub' href='http://cbadger.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Proxying Transmission Web interface with nginx</title>
		<link>http://cbadger.wordpress.com/2010/09/29/proxying-transmission-web-interface-with-nginx/</link>
		<comments>http://cbadger.wordpress.com/2010/09/29/proxying-transmission-web-interface-with-nginx/#comments</comments>
		<pubDate>Wed, 29 Sep 2010 19:05:23 +0000</pubDate>
		<dc:creator>youx</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Server administration]]></category>

		<guid isPermaLink="false">http://hugo.coding-badger.net/?p=52</guid>
		<description><![CDATA[0. Why do this? Easy for me : I use a PCH box as my torrent client. It&#8217;s really nice, but it cannot : Use IPv6 (I don&#8217;t want to forward ports when it can be avoided) Protect the Transmission web interface with a password On the other hand My macbook is always on (though [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cbadger.wordpress.com&amp;blog=7424986&amp;post=52&amp;subd=cbadger&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>0. Why do this?</h2>
<p>Easy for me : I use a <a href="http://www.popcornhour.com/">PCH</a> box as my torrent client.</p>
<p>It&#8217;s really nice, but it cannot :</p>
<ul>
<li>Use IPv6 (I don&#8217;t want to forward ports when it can be avoided)</li>
<li>Protect the <a href="http://www.transmissionbt.com/">Transmission</a> web interface with a password</li>
</ul>
<p>On the other hand</p>
<ul>
<li>My macbook is always on (though I&#8217;ll replace this with a Guruplug&#8230; if I ever receive the one I ordered)</li>
<li>I want to access the torrent administration interface when I&#8217;m not at home</li>
<li>I wanted to tinker with nginx <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </li>
</ul>
<h2>1. The easy solution</h2>
<pre>server {
    listen       :8080;
    server_name  bt.coding-badger.net;
    location / {
        proxy_pass  http://192.168.0.2:9091/;
    }
}</pre>
<p>Ok. We&#8217;re done. Redirect all requests to bt.coding-badger.net:8080 to the popcorn hour box on transmission&#8217;s port. KTHXBYE</p>
<h2>2. Less subdirectories, moar fun!</h2>
<p>Wait, of course we aren&#8217;t. It would be no fun at all. I don&#8217;t really like to have to access this page through /transmission/web/. We&#8217;re already on a special vhost, so I want my bt page at the root!</p>
<pre>server {
        listen       :8080;
        server_name  bt.coding-badger.net;
	location /transmission {
    	    proxy_pass	http://192.168.0.2:9091/transmission;
	}
	location / {
    	    proxy_pass	http://192.168.0.2:9091/transmission/web/;
	}
}</pre>
<p>What happens there? First you have to know what transmission does :</p>
<ul>
<li>&#8220;/&#8221; requests are redirected to &#8220;/transmission/web&#8221; with a 301 Error page</li>
<li>/transmission/web/ contains javascript, css, pages, etc&#8230;</li>
<li>/transmission/upload is used to upload a torrent</li>
<li>/transmission/rpc is used to update the window</li>
</ul>
<p>What we do is redirect all requests that hit / to /transmission/web/ on the transmission server (that way we can be on the / page and transmission will think we&#8217;re on /transmission/web and not attempt to redirect), and redirect all other /transmission/* requests to /transmission/*</p>
<p>You can tweak this to your liking, but you have to remember :</p>
<p>NEVER. EVER hit the &#8220;/&#8221; on the transmission web interface with your proxy, because it will redirect the browser to /transmission/web. You could probably handle this with a &#8220;proxy_redirect&#8221; command in the nginx configuration, but it&#8217;s a bit tricky to get right.</p>
<h2>3. IPv6</h2>
<p>On OSX, I use <a href="http://github.com/mxcl/homebrew">brew</a> as the package manager for OSX. Unfortunately, it does not compile nginx with ipv6 support by default!</p>
<pre>$ brew edit nginx</pre>
<p>Go to the install function, and add &#8211;enable-ipv6 to the args array</p>
<pre>$ brew install nginx</pre>
<p>On debian, it should be compiled with ipv6 by default. You can check by running</p>
<pre>$ nginx -V
<div id="_mcePaste">nginx version: nginx/0.7.67</div>
<div id="_mcePaste">TLS SNI support enabled</div>
<div id="_mcePaste">configure arguments: --prefix=/usr/local/Cellar/nginx/0.7.67 --with-http_ssl_module --with-pcre --conf-path=/usr/local/etc/nginx/nginx.conf --pid-path=/usr/local/var/run/nginx.pid --lock-path=/usr/local/var/nginx/nginx.lock --with-ipv6</div>

nginx version: nginx/0.7.67TLS SNI support enabledconfigure arguments: --prefix=/usr/local/Cellar/nginx/0.7.67 --with-http_ssl_module --with-pcre --conf-path=/usr/local/etc/nginx/nginx.conf --pid-path=/usr/local/var/run/nginx.pid --lock-path=/usr/local/var/nginx/nginx.lock --with-ipv6</pre>
<p>If you&#8217;ve got &#8211;enable-ipv6 you&#8217;re all good!</p>
<p>Then we have to update the &#8220;listen&#8221; configuration of the server to tell it to use IPv4 and IPv6</p>
<pre>server {
        listen       [::]:8080; # this enables ipv6
        server_name  bt.coding-badger.net;
        location /transmission {
                proxy_pass      http://192.168.0.2:9091/transmission;
        }
        location / {
                proxy_pass      http://192.168.0.2:9091/transmission/web/;
        }
}</pre>
<h2>4. Authentication</h2>
<p>We don&#8217;t want our transmission client to be accessed by anyone! nginx can provide authentication through htpasswd files</p>
<pre>$ sudo htpasswd -c /usr/local/etc/nginx/nginx.passwd &lt;username&gt;</pre>
<p>Enter the password you wish, then setup nginx to request a password :</p>
<pre>server {
        listen       [::]:8080;
        server_name  bt.coding-badger.net;
        location /transmission {
                proxy_pass      http://192.168.0.2:9091/transmission;
        }
        location / {
                proxy_pass      http://192.168.0.2:9091/transmission/web/;
        }
        auth_basic            "Restricted";
        auth_basic_user_file  /usr/local/etc/nginx/nginx.passwd;
}</pre>
<p>Of course, if you are not using brew, you may want to use more &#8220;traditionnal&#8221; places for the passwd file, (like /etc/nginx instead of /usr/local/etc/nginx&#8230; use the same directory as your nginx config file)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cbadger.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cbadger.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cbadger.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cbadger.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cbadger.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cbadger.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cbadger.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cbadger.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cbadger.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cbadger.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cbadger.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cbadger.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cbadger.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cbadger.wordpress.com/52/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cbadger.wordpress.com&amp;blog=7424986&amp;post=52&amp;subd=cbadger&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cbadger.wordpress.com/2010/09/29/proxying-transmission-web-interface-with-nginx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f4e79b2cadb048394986aea6ed7c61e8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">youx</media:title>
		</media:content>
	</item>
		<item>
		<title>Edje Messages vs Signals</title>
		<link>http://cbadger.wordpress.com/2010/05/18/edje-messages-vs-signals/</link>
		<comments>http://cbadger.wordpress.com/2010/05/18/edje-messages-vs-signals/#comments</comments>
		<pubDate>Tue, 18 May 2010 20:35:01 +0000</pubDate>
		<dc:creator>youx</dc:creator>
				<category><![CDATA[Edje]]></category>
		<category><![CDATA[EFL]]></category>

		<guid isPermaLink="false">http://hugo.coding-badger.net/?p=35</guid>
		<description><![CDATA[We saw in the previous Edje post how to send Signals down the Edje elements. We&#8217;re now going to see another way of communicating between the application and the Edje theme : Messages. 1. Difference between Messages and Signals That was my first question when I discovered Messages : &#8220;what is this stuff for, since [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cbadger.wordpress.com&amp;blog=7424986&amp;post=35&amp;subd=cbadger&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>We saw in the previous Edje post how to send Signals down the Edje elements. We&#8217;re now going to see another way of communicating between the application and the Edje theme : Messages.</p>
<h2>1. Difference between Messages and Signals</h2>
<p>That was my first question when I discovered Messages : &#8220;what is this stuff for, since we have signals?&#8221;</p>
<p>The answer is :<br />
Signals allow you to send some discrete (punctual) information. It fits really well in an &#8220;action&#8221; type communication &#8220;do this&#8221;, &#8220;hey this event happened&#8221;, &#8230;</p>
<p>Now what if you want, for example, to send data (which could be anything, like a bunch of strings, &#8230;), to the theme, or the other way? This doesn&#8217;t really fit in the signal+source mold. This is where messages come in handy.</p>
<p>For a concrete example, you could see the existing E &#8220;alarm&#8221; widget. (I will try to find the URL when I have time)</p>
<h2>2. Structure of a message</h2>
<p>Three things define a message :<br />
- its Type<br />
- its ID<br />
- its data</p>
<p>The first one is obvious and tells the type of data contained. In C the existing types are defined by EDJE_MESSAGE_* (see Edje.h), and in Embryo as Edje_Type:MSG_*<br />
The second one is an integer that allows you to know what is the function of the message. Use whatever you want, put the defined values in some header shared between your code and your edc files.<br />
The last one is the data.</p>
<p>Now, about the data, you have a few defined types :<br />
<em>Edje_Message_String</em> is just one string<br />
<em>Edje_Message_Int</em> is just one int (ok, that was easy)<br />
<em>Edje_Message_Float</em> oh well you guessed it&#8230;<br />
<em>Edje_Message_String_Set</em> more interesting, a variable number of strings (in an array), the number of strings is a <em>count</em> field in the struct.<br />
<em>Edje_Message_Float_Set</em> and <em>Edje_Message_Int_Set</em>, same as the previous one but with floats and strings<br />
<em>Edje_Message_String_Int</em>, <em>Edje_Message_String_Float</em>, a string with an integer (or a float), could be used as a key =&gt; value pair for example<br />
<em>Edje_Message_String_Int_Set</em>, <em>Edje_Message_String_Int_Set</em>, a string and an array of integers/floats (with the additional <em>count</em> field).</p>
<p>Note that the set is defined in the struct as an int[1], float[1], or char *[1]. This means you have to allocate your structure to a size bigger depending on the number of elements.</p>
<pre><code>
/* allocate a struct for 4 integers */
Edje_Message_String_Int_Set *msg = malloc(sizeof(Edje_Message_String_Int_Set + (4 - 1) * sizeof(int));
/* allocate a struct for 10 string pointers */
Edje_Message_String_Set *msg2 = malloc(sizeof(Edje_Message_String_Set + (10 - 1) * sizeof(char *));</code></pre>
<h2>3. Sending a message from Edje to the application</h2>
<h3>3.1 Binding a message callback</h3>
<pre><code>#define MSG_ID_GET_TIME 0
#define MSG_ID_GET_FLOAT AND STR 1

/* your callback */
void message_cb(void *data, Evas_Object *obj, Edje_Message_Type type, int id, void *msg)
{
    if (id == MSG_ID_GET_TIME &amp;&amp; type == EDJE_MESSAGE_INT_SET) {
        /* check the right number of integers */
        if (msg-&gt;count != 3)
            return;
        int seconds, minutes, hours;
        hours = msg-&gt;val[0];
        minutes = msg-&gt;val[1];
        seconds = msg-&gt;val[2];
        /* do whatever processing you want with your values */
        ...
    } else if (id == MSG_ID_GET_FLOAT_AND_STR &amp;&amp; type == EDJE_MESSAGE_STRING_FLOAT) {
        float f;
        char *str;
        f = msg-&gt;val;
        str = msg-&gt;str;
        /* processing again */
        ...
    }
}

int main()
{
    /* initialization and all */
    ...
    edje_object_message_handler_set(my_edje_object, &amp;message_cb, NULL);
    ...
    /* more stuff after that, you could set the handler at anytime you want anyway */
}</code></pre>
<h3>3.2 Sending the message using Embryo</h3>
<p>This probably has to be defined in the &#8220;top&#8221; group loaded as an Evas, I don&#8217;t know what would happen otherwise.</p>
<pre><code>group {
    programs {
        program {
            name: "my_program";
            signal: "whatever";
            source: "same";
            script {
                send_message(MSG_INT_SET, MSG_ID_GET_TIME, 5, 10, 3);
                send_message(MSG_STRING_FLOAT, MSG_ID_GET_FLOAT_AND_STR, 5.2, "hello world");
            }
        }
    }
}</code></pre>
<h2>4. Sending a message from the application to Edje</h2>
<p>Now, if you would want to do it the other way</p>
<h3>4.1 Create an embryo callback in the skin</h3>
<p><code> </code></p>
<pre><code>group {
    name: "mygroup";
    script {
        /* this function is automatically bound
          * you may have noticed we don't pass a structure but a variable
          * number of arguments */
        public message(Message_Type:type, int id, ...) {
            if (type == MSG_INT_SET &amp;&amp; id == MSG_ID_GET_TIME) {
                /* look in the embryo doc if you need to count the arguments
                  * the "count" variable is not provided in the arguments */
                int sec = getarg(2);
                int min = getarg(3);
                int hour = getarg(4);
                /* do whatever you want in embryo with it */
            } else if (type == MSG_STRING_FLOAT &amp;&amp; id == MSG_ID_GET_FLOAT_AND_STR) {
                float f = getfarg(2); /* get a float */
                new str[128];
                getsarg(3, str, 128);
                /* do whatever you want in embryo with it */
            }
        }
    }
}</code></pre>
<h3>4.2 Sending the message in the code</h3>
<pre><code>/* allocate a struct for 3 integers */
Edje_Message_Int_Set *msg = malloc(sizeof(Edje_Message_Int_Set + (3 - 1) * sizeof(int));
msg-&gt;val[0] = 10;
msg-&gt;val[1] = 42;
msg-&gt;val[2] = 31;
edje_object_send_message(my_edje, EDJE_MESSAGE_INT_SET, MSG_ID_GET_TIME, msg);
/* allocate a struct for string &amp; float */
Edje_Message_String_Float *msg2 = malloc(sizeof(Edje_Message_String_Float);
msg2-&gt;str = "I can haz cheezburger";
msg2-&gt;val = 0.7777;
edje_object_message_send(my_edje, EDJE_MESSAGE_STRING_FLOAT, MSG_ID_GET_FLOAT_AND_STR, msg2);</code></pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cbadger.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cbadger.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cbadger.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cbadger.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cbadger.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cbadger.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cbadger.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cbadger.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cbadger.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cbadger.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cbadger.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cbadger.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cbadger.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cbadger.wordpress.com/35/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cbadger.wordpress.com&amp;blog=7424986&amp;post=35&amp;subd=cbadger&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cbadger.wordpress.com/2010/05/18/edje-messages-vs-signals/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f4e79b2cadb048394986aea6ed7c61e8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">youx</media:title>
		</media:content>
	</item>
		<item>
		<title>Migrating a domain name from 1and1</title>
		<link>http://cbadger.wordpress.com/2010/04/23/migrating-a-domain-name-from-1and1/</link>
		<comments>http://cbadger.wordpress.com/2010/04/23/migrating-a-domain-name-from-1and1/#comments</comments>
		<pubDate>Fri, 23 Apr 2010 20:36:37 +0000</pubDate>
		<dc:creator>youx</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Server administration]]></category>

		<guid isPermaLink="false">http://cbadger.wordpress.com/?p=32</guid>
		<description><![CDATA[I thought I would share this information, since the steps you have to follow are completely not obvious at all : 1. Allow the migration of your account - log in to your account - select your domain name - set it to an &#8220;unlocked&#8221; state 2. Cancel your contract Now, this feels completely idiotic, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cbadger.wordpress.com&amp;blog=7424986&amp;post=32&amp;subd=cbadger&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I thought I would share this information, since the steps you have to follow are completely not obvious at all :</p>
<h3>1. Allow the migration of your account</h3>
<p>- log in to your account<br />
- select your domain name<br />
- set it to an &#8220;unlocked&#8221; state</p>
<h3>2. Cancel your contract</h3>
<p>Now, <em>this</em> feels completely idiotic, but to migrate your domain name, you have to follow the same workflow as a cancellation. And it&#8217;s called at every step a cancellation. Maybe <em>1and1</em> wants people to fear losing their domain name when they try to migrate, so they&#8217;ll just keep their contract with them?</p>
<p>- go to cancel.1and1.com (or contrat.1and1.fr if you use the french version)<br />
- log in<br />
- cancel your domain or pack. You will have to answer to a &#8220;customer satisfaction&#8221; poll<br />
- at the end, just before confirming, you will have the ability to choose :<br />
1. when to apply this action (10 days, 10 days + 1 month, 10 days + 2 months) &#8211; just pick whatever fits you<br />
2. what you want to do. <strong>THIS IS THE IMPORTANT PART</strong>, choose the option to migrate your domain to another provider.<br />
3. when to cancel &#8211; right now or wait the end of the contract. You don&#8217;t care about that since the migration option will replace it with As Soon As Possible.</p>
<p>Now, you&#8217;re going to get a code, <strong>keep it</strong> since it will be necessary to migrate.</p>
<p>You will now have to validate your cancellation to 1and1 by email.</p>
<h3>3. Register with your new provider</h3>
<p>- Follow the steps. You will be asked for the migration code you received when cancelling. This is used to ensure someone isn&#8217;t trying to steal your domain name.<br />
-  your new provider will also probably ask for an email confirmation using the email in the <em>whois<br />
<span style="font-style:normal;">- now you just have to wait <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </span></em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cbadger.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cbadger.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cbadger.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cbadger.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cbadger.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cbadger.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cbadger.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cbadger.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cbadger.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cbadger.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cbadger.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cbadger.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cbadger.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cbadger.wordpress.com/32/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cbadger.wordpress.com&amp;blog=7424986&amp;post=32&amp;subd=cbadger&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cbadger.wordpress.com/2010/04/23/migrating-a-domain-name-from-1and1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f4e79b2cadb048394986aea6ed7c61e8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">youx</media:title>
		</media:content>
	</item>
		<item>
		<title>Edje Signals, Callbacks and propagation.</title>
		<link>http://cbadger.wordpress.com/2010/04/16/edje-signals-callbacks-and-propagation/</link>
		<comments>http://cbadger.wordpress.com/2010/04/16/edje-signals-callbacks-and-propagation/#comments</comments>
		<pubDate>Fri, 16 Apr 2010 17:20:49 +0000</pubDate>
		<dc:creator>youx</dc:creator>
				<category><![CDATA[Edje]]></category>
		<category><![CDATA[EFL]]></category>

		<guid isPermaLink="false">http://cbadger.wordpress.com/?p=8</guid>
		<description><![CDATA[An overview of Edje signals and callbacks, including how to propagate those signals down a group...<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cbadger.wordpress.com&amp;blog=7424986&amp;post=8&amp;subd=cbadger&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As you may already know, interaction with an edje file is down mostly with signals.</p>
<p>You can set up a group with a part and some signal to detect when the part has been clicked</p>
<pre><code>group {
  name: "my_group"
  parts {
    part {
      name: "button";
      type: RECT;
      description {
        state: "default" 0.0;
        color: 255 0 0 255;
        min: 50 50;
      }
    }
  }
  programs {
    program {
      signal: "mouse,up,*";
      source: "button";
      action: SIGNAL_EMIT "button_clicked" "";
    }
  }
}</code></pre>
<p>When the red rectangle is clicked, it will emit a signal {&#8220;button_clicked&#8221;, &#8220;&#8221;}</p>
<p>Imagine you want to do something in your program when the button is clicked. You have to add a callback for this :</p>
<pre><code>{
  Evas_Object *evas_obj = edje_object_add(evas);
  edje_object_file_set(evas_obj, "my_theme.edj", "my_group");
  /* needed evas resize/move/show */
  evas_object_resize(evas_obj, 800, 480);
  evas_object_move(evas_obj, 0, 0);
  evas_object_show(evas_obj);

  /* add a callback */
  edje_object_signal_callback_add(evas_obj, "button_clicked", "", &amp;my_callback, NULL);
  /*  simulate a mouse signal on the button to see if it works */
  edje_object_signal_emit(evas_obj, "mouse,up,acme", "button");
}
...
void my_callback(void *data, Evas_Object *o, const char *emission, const char *source)
{
  if (strcmp(emission, "button_clicked") == 0 &amp;&amp; strcmp(source, "") == 0) {
    /* do something */
  }
}
</code></pre>
<p>As you may notice, there are 4 arguments to the callback :<br />
- <em>data</em>, corresponds to the last field of callback_add. You can pass whatever you want to it, but be sure to have it allocated on the heap. You don&#8217;t know when the callback will be launched, so if you specify a pointer to a variable that was allocated in the function stack, you&#8217;re going to have some problems.<br />
- <em>evas_object</em> will be the object that emitted a signal (will correspond to <em>evas_obj</em> here)<br />
- <em>emission</em> and <em>source</em> correspond to the signal and the source. You can use the same callback for many signals and dispatch however you want after that.</p>
<p>This is basic stuff you will see in any tutorial, and may lead you to get a bad habit : allocating an Evas_Object for each group of your theme and integrating those in the code.<br />
The ideal goal in an edje application is to have as little code as possible, and move the logic to the edje. That way, you can make a completely different interface (including the way it works, not just graphics) for the same program.<br />
Instead of loading each group in an Evas_Object and use evas to show, hide, move, resize all the elements, juste do one big group with subparts.</p>
<pre><code>group {
  name: "main";
  parts {
    part {
      name: "instance_of_my_group1";
      type: GROUP;
      source: "my_group";
      description {
        state: "default" 0.0;
      }
    }
    part {
      name: "instance_of_my_group2";
      type: GROUP;
      source: "my_group";
      description {
        state: "default" 0.0;
      }
    }
  }
}</code></pre>
<p>What this does is create two instances of the same group, loaded into the &#8220;main&#8221; group. You only need to instantiate main (<em>edje_object_add</em> and <em>edje_object_file_set</em>) to create those two buttons.<br />
Your next question will be : but if I don&#8217;t have an <em>Evas_Object</em> of the group, how do I emit signals to them, how do I add callbacks?</p>
<p>Signal. Propagation.</p>
<pre><code>{
  Evas_Object *main_obj = edje_object_add(evas);
  edje_object_file_set(main_obj, "my_theme.edj", "main");
  /* needed evas resize/move/show */
  evas_object_resize(evas_obj, 800, 480);
  evas_object_move(evas_obj, 0, 0);
  evas_object_show(evas_obj);

  edje_object_signal_callback_add(main_obj, ""button_clicked", "instance_of_my_group1:", &amp;my_callback, NULL);
  /*  simulate a mouse signal on the button to see if it works */
  edje_object_signal_emit(evas_obj, "instance_of_my_group1:mouse,up,acme", "button");
}
...
void my_callback(void *data, Evas_Object *o, const char *emission,  const char *source)
{
  if (strcmp(emission, "button_clicked") == 0 &amp;&amp;  strcmp(source, "instance_of_my_group1:") == 0) {
    /* do something */
  }
}</code></pre>
<p>Understand this important thing :</p>
<p>If you want to <strong>emit</strong> a signal to a subgroup of an edje object, you have to <strong>prefix the signal</strong> with the subgroup instance name.<br />
<em> { &#8220;mysubgroup:signal&#8221;, &#8220;source&#8221; }</em></p>
<p>If you want to <strong>add a callback</strong> to a signal emitted by a subgroup of an edje object, you have to <strong>prefix the source</strong> with the subgroup instance name.<br />
<em> { &#8220;signal&#8221;, &#8220;mysubgroup:source&#8221; }</em></p>
<p>Edje will take care to dispatch those signals automagically. This works with an infinite number of group levels. You could emit <em>{&#8220;group:subgroup:subsubgroup:signal&#8221;, &#8220;source&#8221;}</em>.</p>
<p>Now, if you have elements put in a table, or a box, you cannot (at least for now, but it would be a good addition to edje) send signals or get signals from the sub-elements. No &#8220;<em>mybox[4]:signal</em>&#8221; &#8230; for now.</p>
<p>Edit (18/05/2010) :</p>
<p>When you send a signal from the object (<strong><em>if</em></strong> the item was inserted in Edje in the <em>box.items{}</em>), I think the object name is skipped, as if the table itself had sent the signal.</p>
<p>I&#8217;ve submitted a patch that would allow someone to send signals to box elements by using this syntax :<br />
<em> {&#8220;boxpartname:idx:signal&#8221;, &#8220;source&#8221;}</em> where idx is the index of the element you want to send the signal too, let&#8217;s hope it gets accepted.</p>
<p>Edit (20/05/2010) :</p>
<p>Add the evas_object_resize/move/show when initializing the edje object.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cbadger.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cbadger.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cbadger.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cbadger.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cbadger.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cbadger.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cbadger.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cbadger.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cbadger.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cbadger.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cbadger.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cbadger.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cbadger.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cbadger.wordpress.com/8/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cbadger.wordpress.com&amp;blog=7424986&amp;post=8&amp;subd=cbadger&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cbadger.wordpress.com/2010/04/16/edje-signals-callbacks-and-propagation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f4e79b2cadb048394986aea6ed7c61e8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">youx</media:title>
		</media:content>
	</item>
		<item>
		<title>Frist Post (haha)</title>
		<link>http://cbadger.wordpress.com/2010/04/15/frist-post-haha/</link>
		<comments>http://cbadger.wordpress.com/2010/04/15/frist-post-haha/#comments</comments>
		<pubDate>Thu, 15 Apr 2010 12:10:57 +0000</pubDate>
		<dc:creator>youx</dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://cbadger.wordpress.com/?p=6</guid>
		<description><![CDATA[Ok, so this is the first test post. I&#8217;m going to use this website for some personal rant, and also to post some coding examples (especially on the EFL &#8211; Enlightenment Foundation Library I&#8217;m working with) This will replace the old hugo.coding-badger.net which died a fiery death (disk controller of the server died&#8230; meh)<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cbadger.wordpress.com&amp;blog=7424986&amp;post=6&amp;subd=cbadger&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Ok, so this is the first test post.</p>
<p>I&#8217;m going to use this website for some personal rant, and also to post some coding examples (especially on the EFL &#8211; Enlightenment Foundation Library I&#8217;m working with)</p>
<p>This will replace the old hugo.coding-badger.net which died a fiery death (disk controller of the server died&#8230; meh)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cbadger.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cbadger.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cbadger.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cbadger.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cbadger.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cbadger.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cbadger.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cbadger.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cbadger.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cbadger.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cbadger.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cbadger.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cbadger.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cbadger.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cbadger.wordpress.com&amp;blog=7424986&amp;post=6&amp;subd=cbadger&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cbadger.wordpress.com/2010/04/15/frist-post-haha/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f4e79b2cadb048394986aea6ed7c61e8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">youx</media:title>
		</media:content>
	</item>
	</channel>
</rss>
