<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, Sans-Serif;font-size:16px"><div id="yui_3_16_0_1_1416952330017_23002" dir="ltr"><span id="yui_3_16_0_1_1416952330017_23007">In the avahi-client C-API there is the concept of a Service Browser and a Record Browser. Service Browser sounds like what you are using now:</span></div><div id="yui_3_16_0_1_1416952330017_23002" dir="ltr"><span><br></span></div><table class="" style="font-family: 'Lucida Grande', Verdana, Geneva, Arial, sans-serif; font-size: 13px; line-height: 1.3; white-space: nowrap; font-weight: bold; margin-left: 6px;" id="yui_3_16_0_1_1416952330017_23468"><tbody class="" style="" id="yui_3_16_0_1_1416952330017_23467"><tr class="" style="" id="yui_3_16_0_1_1416952330017_24401"><td class="" style="margin-left: 6px;" id="yui_3_16_0_1_1416952330017_24400"><a class="" href="http://avahi.org/download/doxygen/lookup_8h.html#ade1392a93ff4d0407c1735374bc0ff7b" style="color: rgb(70, 101, 162); text-decoration: none;">AvahiServiceBrowser</a>* <a class="" href="http://avahi.org/download/doxygen/lookup_8h.html#a52d55a5156a7943012d03e6700880d2b" style="color: rgb(70, 101, 162); text-decoration: none;" id="yui_3_16_0_1_1416952330017_24399">avahi_service_browser_new</a></td><td class="" style="" id="yui_3_16_0_1_1416952330017_25226">(</td><td class="" style="" id="yui_3_16_0_1_1416952330017_24864"><a class="" href="http://avahi.org/download/doxygen/client_8h.html#a3d65e9ea7182c44fa8df04a72f1a56bb" style="color: rgb(70, 101, 162); text-decoration: none;" id="yui_3_16_0_1_1416952330017_24863">AvahiClient</a> * </td><td class="" style="color: rgb(96, 32, 32);" id="yui_3_16_0_1_1416952330017_25227">client,</td></tr><tr class="" style="" id="yui_3_16_0_1_1416952330017_23728"><td class="" style="text-align: right;" id="yui_3_16_0_1_1416952330017_24402"></td><td class="" style=""></td><td class="" style="" id="yui_3_16_0_1_1416952330017_24861"><a class="" href="http://avahi.org/download/doxygen/address_8h.html#a2fda397a8f430cb537e37bbca0afb535" style="color: rgb(70, 101, 162); text-decoration: none;" id="yui_3_16_0_1_1416952330017_24862">AvahiIfIndex</a> </td><td class="" style="color: rgb(96, 32, 32);" id="yui_3_16_0_1_1416952330017_23727">interface,</td></tr><tr class="" style="" id="yui_3_16_0_1_1416952330017_24404"><td class="" style="text-align: right;" id="yui_3_16_0_1_1416952330017_24403"></td><td class="" style=""></td><td class="" style="" id="yui_3_16_0_1_1416952330017_24859"><a class="" href="http://avahi.org/download/doxygen/address_8h.html#a5342ada86ff1566a7fc6e855b3d46c3d" style="color: rgb(70, 101, 162); text-decoration: none;" id="yui_3_16_0_1_1416952330017_24860">AvahiProtocol</a> </td><td class="" style="color: rgb(96, 32, 32);" id="yui_3_16_0_1_1416952330017_25228">protocol,</td></tr><tr class="" style="" id="yui_3_16_0_1_1416952330017_23730"><td class="" style="text-align: right;" id="yui_3_16_0_1_1416952330017_24405"></td><td class="" style=""></td><td class="" style="" id="yui_3_16_0_1_1416952330017_23729">const char * </td><td class="" style="color: rgb(96, 32, 32);" id="yui_3_16_0_1_1416952330017_23739">type,</td></tr><tr class="" style="" id="yui_3_16_0_1_1416952330017_23736"><td class="" style="text-align: right;" id="yui_3_16_0_1_1416952330017_23735"></td><td class="" style=""></td><td class="" style="" id="yui_3_16_0_1_1416952330017_23737">const char * </td><td class="" style="color: rgb(96, 32, 32);" id="yui_3_16_0_1_1416952330017_23738">domain,</td></tr><tr class="" style="" id="yui_3_16_0_1_1416952330017_23732"><td class="" style="text-align: right;" id="yui_3_16_0_1_1416952330017_23734"></td><td class="" style="" id="yui_3_16_0_1_1416952330017_23740"></td><td class="" style="" id="yui_3_16_0_1_1416952330017_23731"><a class="" href="http://avahi.org/download/doxygen/defs_8h.html#afa669747c3ff55190d86673dff960e50" style="color: rgb(70, 101, 162); text-decoration: none;" id="yui_3_16_0_1_1416952330017_24480">AvahiLookupFlags</a> </td><td class="" style="color: rgb(96, 32, 32);" id="yui_3_16_0_1_1416952330017_24853">flags,</td></tr><tr class="" style="" id="yui_3_16_0_1_1416952330017_23475"><td class="" style="text-align: right;" id="yui_3_16_0_1_1416952330017_23733"></td><td class="" style=""></td><td class="" style="" id="yui_3_16_0_1_1416952330017_23741"><a class="" href="http://avahi.org/download/doxygen/lookup_8h.html#a666e712e840c612ba24d9e41673a94df" style="color: rgb(70, 101, 162); text-decoration: none;" id="yui_3_16_0_1_1416952330017_23742">AvahiServiceBrowserCallback</a> </td><td class="" style="color: rgb(96, 32, 32);" id="yui_3_16_0_1_1416952330017_23474">callback,</td></tr><tr class="" style="" id="yui_3_16_0_1_1416952330017_23466"><td class="" style="text-align: right;" id="yui_3_16_0_1_1416952330017_23465"></td><td class="" style="" id="yui_3_16_0_1_1416952330017_24406"></td><td class="" style="" id="yui_3_16_0_1_1416952330017_23472">void * </td><td class="" style="color: rgb(96, 32, 32);" id="yui_3_16_0_1_1416952330017_23473">userdata </td></tr><tr class="" style="" id="yui_3_16_0_1_1416952330017_23470"><td style="color: rgb(37, 53, 85); line-height: 16.8999996185303px; background-color: rgb(226, 232, 242);" class="" id="yui_3_16_0_1_1416952330017_23469"></td><td style="color: rgb(37, 53, 85); line-height: 16.8999996185303px; background-color: rgb(226, 232, 242);" class="" id="yui_3_16_0_1_1416952330017_23471">)</td></tr></tbody></table><div id="yui_3_16_0_1_1416952330017_23002" dir="ltr"><span><br></span></div><div id="yui_3_16_0_1_1416952330017_23002" dir="ltr"><span id="yui_3_16_0_1_1416952330017_24069">The type being for example _http._tcp. Whereas a Record Browser looks like this:</span></div><div id="yui_3_16_0_1_1416952330017_23002" dir="ltr"><span><br></span></div><table class="" style="font-family: 'Lucida Grande', Verdana, Geneva, Arial, sans-serif; font-size: 13px; line-height: 1.3; white-space: nowrap; font-weight: bold; margin-left: 6px;" id="yui_3_16_0_1_1416952330017_24471"><tbody class="" style="" id="yui_3_16_0_1_1416952330017_24470"><tr class="" style="" id="yui_3_16_0_1_1416952330017_24482"><td class="" style="margin-left: 6px;" id="yui_3_16_0_1_1416952330017_25224"><a class="" href="http://avahi.org/download/doxygen/lookup_8h.html#ad0a38359b6c52d4272acd831410186f2" style="color: rgb(70, 101, 162); text-decoration: none;">AvahiRecordBrowser</a>* <a class="" href="http://avahi.org/download/doxygen/lookup_8h.html#a21ac2275126fb9e5eaaae8afe3b75532" style="color: rgb(70, 101, 162); text-decoration: none;" id="yui_3_16_0_1_1416952330017_25223">avahi_record_browser_new</a></td><td class="" style="">(</td><td class="" style="" id="yui_3_16_0_1_1416952330017_24481"><a class="" href="http://avahi.org/download/doxygen/client_8h.html#a3d65e9ea7182c44fa8df04a72f1a56bb" style="color: rgb(70, 101, 162); text-decoration: none;">AvahiClient</a> * </td><td class="" style="color: rgb(96, 32, 32);" id="yui_3_16_0_1_1416952330017_24865">client,</td></tr><tr class="" style="" id="yui_3_16_0_1_1416952330017_24484"><td class="" style="text-align: right;" id="yui_3_16_0_1_1416952330017_25232"></td><td class="" style=""></td><td class="" style="" id="yui_3_16_0_1_1416952330017_24883"><a class="" href="http://avahi.org/download/doxygen/address_8h.html#a2fda397a8f430cb537e37bbca0afb535" style="color: rgb(70, 101, 162); text-decoration: none;" id="yui_3_16_0_1_1416952330017_25221">AvahiIfIndex</a> </td><td class="" style="color: rgb(96, 32, 32);" id="yui_3_16_0_1_1416952330017_24483">interface,</td></tr><tr class="" style="" id="yui_3_16_0_1_1416952330017_24479"><td class="" style="text-align: right;" id="yui_3_16_0_1_1416952330017_25225"></td><td class="" style="" id="yui_3_16_0_1_1416952330017_25231"></td><td class="" style="" id="yui_3_16_0_1_1416952330017_24478"><a class="" href="http://avahi.org/download/doxygen/address_8h.html#a5342ada86ff1566a7fc6e855b3d46c3d" style="color: rgb(70, 101, 162); text-decoration: none;" id="yui_3_16_0_1_1416952330017_24477">AvahiProtocol</a> </td><td class="" style="color: rgb(96, 32, 32);" id="yui_3_16_0_1_1416952330017_25230">protocol,</td></tr><tr class="" style="" id="yui_3_16_0_1_1416952330017_24486"><td class="" style="text-align: right;" id="yui_3_16_0_1_1416952330017_25222"></td><td class="" style=""></td><td class="" style="" id="yui_3_16_0_1_1416952330017_24882">const char * </td><td class="" style="color: rgb(96, 32, 32);" id="yui_3_16_0_1_1416952330017_24485">name,</td></tr><tr class="" style="" id="yui_3_16_0_1_1416952330017_24867"><td class="" style="text-align: right;" id="yui_3_16_0_1_1416952330017_24880"></td><td class="" style=""></td><td class="" style="" id="yui_3_16_0_1_1416952330017_24868">uint16_t </td><td class="" style="color: rgb(96, 32, 32);" id="yui_3_16_0_1_1416952330017_24866">clazz,</td></tr><tr class="" style="" id="yui_3_16_0_1_1416952330017_24469"><td class="" style="text-align: right;" id="yui_3_16_0_1_1416952330017_24879"></td><td class="" style=""></td><td class="" style="" id="yui_3_16_0_1_1416952330017_24468">uint16_t </td><td class="" style="color: rgb(96, 32, 32);" id="yui_3_16_0_1_1416952330017_25220">type,</td></tr><tr class="" style="" id="yui_3_16_0_1_1416952330017_24870"><td class="" style="text-align: right;" id="yui_3_16_0_1_1416952330017_24871"></td><td class="" style="" id="yui_3_16_0_1_1416952330017_24869"></td><td class="" style="" id="yui_3_16_0_1_1416952330017_24878"><a class="" href="http://avahi.org/download/doxygen/defs_8h.html#afa669747c3ff55190d86673dff960e50" style="color: rgb(70, 101, 162); text-decoration: none;" id="yui_3_16_0_1_1416952330017_24877">AvahiLookupFlags</a> </td><td class="" style="color: rgb(96, 32, 32);" id="yui_3_16_0_1_1416952330017_25229">flags,</td></tr><tr class="" style="" id="yui_3_16_0_1_1416952330017_24476"><td class="" style="text-align: right;" id="yui_3_16_0_1_1416952330017_24872"></td><td class="" style="" id="yui_3_16_0_1_1416952330017_25573"></td><td class="" style="" id="yui_3_16_0_1_1416952330017_24475"><a class="" href="http://avahi.org/download/doxygen/lookup_8h.html#a867a24784f27539ed34291e0db8b51b8" style="color: rgb(70, 101, 162); text-decoration: none;" id="yui_3_16_0_1_1416952330017_24474">AvahiRecordBrowserCallback</a> </td><td class="" style="color: rgb(96, 32, 32);" id="yui_3_16_0_1_1416952330017_24858">callback,</td></tr><tr class="" style="" id="yui_3_16_0_1_1416952330017_24473"><td class="" style="text-align: right;" id="yui_3_16_0_1_1416952330017_24873"></td><td class="" style="" id="yui_3_16_0_1_1416952330017_25571"></td><td class="" style="" id="yui_3_16_0_1_1416952330017_24472">void * </td><td class="" style="color: rgb(96, 32, 32);" id="yui_3_16_0_1_1416952330017_25572">userdata </td></tr><tr class="" style="" id="yui_3_16_0_1_1416952330017_24875"><td style="color: rgb(37, 53, 85); line-height: 16.8999996185303px; background-color: rgb(226, 232, 242);" class="" id="yui_3_16_0_1_1416952330017_24874"></td><td style="color: rgb(37, 53, 85); line-height: 16.8999996185303px; background-color: rgb(226, 232, 242);" class="" id="yui_3_16_0_1_1416952330017_24884">)</td></tr></tbody></table><div id="yui_3_16_0_1_1416952330017_23002" dir="ltr"><span><br></span></div><div id="yui_3_16_0_1_1416952330017_23002" dir="ltr"><span id="yui_3_16_0_1_1416952330017_24876">I wonder if that is a more generic mDNS browser? Unfortunately the parameters, and what a "record" is, is not explained in the online documentation. I'll have a look in the source to see if I can find out more.</span></div><div id="yui_3_16_0_1_1416952330017_23002" dir="ltr"><span><br></span></div><div id="yui_3_16_0_1_1416952330017_23002" dir="ltr"><span>Regards,</span></div><div id="yui_3_16_0_1_1416952330017_23002" dir="ltr"><span id="yui_3_16_0_1_1416952330017_25912">Jonathan</span></div> <div class="qtdSeparateBR"><br><br></div><div class="yahoo_quoted" style="display: block;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, Sans-Serif; font-size: 16px;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, Sans-Serif; font-size: 16px;"> <div dir="ltr"> <font size="2" face="Arial"> On Tuesday, 25 November 2014, 13:17, Michael Jones <avahi@jonesmz.com> wrote:<br> </font> </div>  <br><br> <div class="y_msg_container"><div id="yiv1239290909"><div dir="ltr"><br><div class="yiv1239290909gmail_extra"><div class="yiv1239290909gmail_quote"><blockquote class="yiv1239290909gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex;"><br>
Hi Michael,<br>
I'm looking at your ZConfBrowserWidget and I see that it needs a service type. Technically I believe from what I've been reading the mDNS host announcements are different to an DNS-SD service, although they are both announced in a similar way.Is there a "service type" that catches the mDNS hostname announcements?<br>
Regards,<br>
Jonathan<br>
<br>
     On Friday, 21 November 2014, 15:08, Jonathan Fitt <<a rel="nofollow" ymailto="mailto:jonfitt@yahoo.com" target="_blank" href="mailto:jonfitt@yahoo.com">jonfitt@yahoo.com</a>> wrote:<br>
<br>
<br>
 Thanks! I'll give that a go and let you know how it goes. <br>
Jonathan<br>
On Nov 21, 2014, at 1:25 PM, Michael Jones <<a rel="nofollow" ymailto="mailto:avahi@jonesmz.com" target="_blank" href="mailto:avahi@jonesmz.com">avahi@jonesmz.com</a>> wrote:<br>
<br>
<br>
<br>
<br>
Hello,I am looking for a way for a Linux machine to tell when I return home. My idea is that my iPhone will always do an mDNS announcement when it joins my home wifi. So I'm looking for a way to watch for mDNS announcements and perform and action if the right one is seen. Obviously the avahi-daemon is watching these all the time and updating its cache, so I was thinking that there might be a good place to start. However the only command line way I can see to get to the avahi-daemon cache is to send a SIGUSR1 to get it to dump to /var/log/syslog. Then I can look at the timestamp to determine the last time it registered and compare with now. That seems quite ugly though, and I don't like the idea of continually dumping to syslog.<br>
So is there a way to make it more event driven with the avahi-daemon? I think from looking at the D-Bus API that might be the way to go?If it is the right approach, I would appreciate it if someone knew of a related chunk of source that I could use as a starting point.<br>
Thanks!Jonathan<br>
<br>
<br>
<br>
Write a small program that uses the Avahi API. A very high level wrapper for the Avahi API is: <a rel="nofollow" target="_blank" href="https://github.com/johanneshilden/qtzeroconf">https://github.com/johanneshilden/qtzeroconf</a><br>
<br>
Using that, you can detect your phone joining your home network in under 10 lines of code.<br>
Create the service browser object<br>
Connect that new object to a qt slot that'll respond to the new service joining your network, Tell the service browser object which services to listen for.<br>
<br>
>From there, you can do whatever you want with the information. Perhaps you would want to send some kind of DBus signal to let other programs know.<br>
<br>
I'm afraid I haven't investigated the DBus API, so I'm not certain I can give you any advice in that direction, but I have written apps using the high level Qt API that I linked above, and I've never had any trouble with it.<br>
<br>
--Michael Jone</blockquote><div><br><br></div><div>Hi Jonathan <br><br><br></div><div>That's a good question. I actually don't know. The qtzeroconf library isn't actually mine, originally. I made a lot of modifications to it (Here: <a rel="nofollow" target="_blank" href="https://github.com/jonesmz/qtzeroconf">https://github.com/jonesmz/qtzeroconf</a>) that take advantage of Qt5 and C++11, but those changes aren't compatible with older versions of Qt, so I didn't want to recommend it to you.<br><br>If you feel like poking around at the Avahi C API and can demonstrate how to get mDNS host announcements out of the Avahi C api, I'd be willing to add support for that to my version of the qtzeroconf library (though, it'll still not be compatible with Qt4 or older versions of C++, so you might end up needing to backport the changes to the original authors github project.)<br><br></div><div>If you want to work just with what the current qtzeroconf library can do, you can just make your phone advertise an avahi service. Perhaps give the protocol name something like "_phone._tcp" or something. <br><br></div><div>Another thing to keep in mind, I don't know whether Avahi will automatically detect your phone on the local network unless your phone's operating system automatically sends that announcement. As far as I know, Android doesn't do that. I don't know about the other phone OS's.<br><br></div><div>Best of luck, and let me know if you want to investigate the host announcement support in qtzeroconf.<br><br></div><div>--Michael Jones<br></div></div></div></div></div><br>_______________________________________________<br>avahi mailing list<br><a ymailto="mailto:avahi@lists.freedesktop.org" href="mailto:avahi@lists.freedesktop.org">avahi@lists.freedesktop.org</a><br><a href="http://lists.freedesktop.org/mailman/listinfo/avahi" target="_blank">http://lists.freedesktop.org/mailman/listinfo/avahi</a><br><br><br></div>  </div> </div>  </div> </div></body></html>