1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
<?xml version="1.0"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
]>
<refentry id="serviceaddedcb">
<refmeta>
<refentrytitle>Service Added Callback</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>Libdmapsharing</refmiscinfo>
</refmeta>
<refnamediv>
<refname>Service Added Callback</refname>
<refpurpose>
Defining a Service Added Callback
</refpurpose>
</refnamediv>
<refsect1>
<title>Service Added Callback</title>
<para>
The "service-added" callback typically creates DmapDb and
DmapRecordFactory objects, and then passes these objects to
dmap_connection_new. A subsequent call to the dmap_connection_start
method causes this connection object to interact with the DAAP share in order to
populate the client's DmapDb.
</para>
<para>
The following is a simple "service-added" callback which creates a DAAP connection:
</para>
<screen>
static void
service_added_cb(DmapMdnsBrowser *browser, DmapMdnsBrowserService *service, gpointer user_data)
DmapDb *db;
DmapRecordFactory *factory;
DmapConnection *conn;
db = DMAP_DB(my_dmap_db_new());
factory = DMAP_RECORD_FACTORY(my_dmap_av_record_factory_new());
conn = DMAP_CONNECTION(dmap_av_connection_new(service->name, service->host, service->port, db, factory));
g_signal_connect(conn, "authenticate", G_CALLBACK(authenticate_cb), NULL, NULL);
g_signal_connect(conn, "error", G_CALLBACK(error_cb), NULL, NULL);
dmap_connection_start(conn, (DmapConnectionFunc) connected_cb, db);
}
</screen>
</refsect1>
</refentry>
|