Service Added CallbackService Added Callback — Defining a Service Added Callback |
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.
The following is a simple "service-added" callback which creates a DAAP connection:
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); }