Exemplo n.º 1
0
static int
resolve_disc (cddb_disc_t* disc, char *disc_list)
{
    trace("cda: resolve_disc\n");

    cddb_conn_t *conn = new_cddb_connection();
    if (!conn) {
        return 0;
    }

    cddb_disc_t *temp_disc = cddb_disc_clone(disc);
    cddb_disc_t *query_disc = disc;

    cddb_cache_disable(conn);
    const int matches = cddb_query(conn, query_disc);

    cddb_cache_enable(conn);
    size_t discs_read = 0;
    disc_list[0] = '\0';
    for (int i = 0; i < matches; i++) {
        if (cddb_read(conn, query_disc) && discs_read < MAX_CDDB_DISCS) {
            discs_read++;
            char temp_string[CDDB_CATEGORY_SIZE + CDDB_DISCID_SIZE + 1];
            sprintf(temp_string, ",%s/%08x", cddb_disc_get_category_str(query_disc), cddb_disc_get_discid(query_disc));
            strcat(disc_list, temp_string);
            query_disc = temp_disc;
        }
        cddb_query_next(conn, query_disc);
    }

    cddb_disc_destroy(temp_disc);
    cddb_destroy(conn);

    return discs_read;
}
Exemplo n.º 2
0
    CddbConnection(cddb_disc_t *d) : disc(0) {
        connection = cddb_new();
        if (connection) {
            cddb_cache_disable(connection);
            cddb_set_server_name(connection, Settings::self()->cddbHost().toLatin1().constData());
            cddb_set_server_port(connection, Settings::self()->cddbPort());
            disc=cddb_disc_clone(d);
#ifdef ENABLE_KDE_SUPPORT
            QString proxy=KProtocolManager::proxyFor("http");
            if (!proxy.isEmpty()) {
                QUrl url(proxy);
                cddb_set_http_proxy_server_name(connection, url.host().toLatin1().constData());
                cddb_set_http_proxy_server_port(connection, url.port());
                cddb_http_proxy_enable(connection);
            }
#else
            QUrl url;
            url.setHost(Settings::self()->cddbHost());
            url.setPort(Settings::self()->cddbPort());
            QList<QNetworkProxy> proxies=NetworkProxyFactory::self()->queryProxy(QNetworkProxyQuery(url));

            foreach (const QNetworkProxy &p, proxies) {
                if (QNetworkProxy::HttpProxy==p.type() && 0!=p.port()) {
                    cddb_set_http_proxy_server_name(connection, p.hostName().toLatin1().constData());
                    cddb_set_http_proxy_server_port(connection, p.port());
                    cddb_http_proxy_enable(connection);
                    break;
                }
            }
#endif
        }
    }
Exemplo n.º 3
0
    CddbConnection(cddb_disc_t *d) : disc(0) {
        connection = cddb_new();
        if (connection) {
            cddb_cache_disable(connection);
            cddb_set_server_name(connection, Settings::self()->cddbHost().toLatin1().constData());
            cddb_set_server_port(connection, Settings::self()->cddbPort());
            disc=cddb_disc_clone(d);
            QUrl url;
            url.setHost(Settings::self()->cddbHost());
            url.setPort(Settings::self()->cddbPort());
            QList<QNetworkProxy> proxies=NetworkProxyFactory::self()->queryProxy(QNetworkProxyQuery(url));

            foreach (const QNetworkProxy &p, proxies) {
                if (QNetworkProxy::HttpProxy==p.type() && 0!=p.port()) {
                    cddb_set_http_proxy_server_name(connection, p.hostName().toLatin1().constData());
                    cddb_set_http_proxy_server_port(connection, p.port());
                    cddb_http_proxy_enable(connection);
                    break;
                }
            }
        }
    }
Exemplo n.º 4
0
static void 
print_cddb_info(CdIo_t *p_cdio, track_t i_tracks, track_t i_first_track) {
  int i, matches;
  
  cddb_conn_t *conn =  cddb_new();
  cddb_disc_t *disc = NULL;

  if (!conn) {
    report(stderr,  "%s: unable to initialize libcddb\n", program_name);
    goto cddb_destroy;
  }

  if (NULL == opts.cddb_email) 
    cddb_set_email_address(conn, "me@home");
  else 
    cddb_set_email_address(conn, opts.cddb_email);

  if (NULL == opts.cddb_server) 
    cddb_set_server_name(conn, "freedb.freedb.org");
  else 
    cddb_set_server_name(conn, opts.cddb_server);

  if (opts.cddb_timeout >= 0) 
    cddb_set_timeout(conn, opts.cddb_timeout);

  cddb_set_server_port(conn, opts.cddb_port);

  if (opts.cddb_http) 
    cddb_http_enable(conn);
  else 
    cddb_http_disable(conn);

  if (NULL != opts.cddb_cachedir) 
    cddb_cache_set_dir(conn, opts.cddb_cachedir);
    
  if (opts.cddb_disable_cache) 
    cddb_cache_disable(conn);
    
  disc = cddb_disc_new();
  if (!disc) {
    report(stderr, "%s: unable to create CDDB disc structure", program_name);
    goto cddb_destroy;
  }
  for(i = 0; i < i_tracks; i++) {
    cddb_track_t *t = cddb_track_new(); 
    t->frame_offset = cdio_get_track_lba(p_cdio, i+i_first_track);
    cddb_disc_add_track(disc, t);
  }
    
  disc->length = 
    cdio_get_track_lba(p_cdio, CDIO_CDROM_LEADOUT_TRACK) 
    / CDIO_CD_FRAMES_PER_SEC;

  if (!cddb_disc_calc_discid(disc)) {
    report(stderr, "%s: libcddb calc discid failed.\n", 
	    program_name);
    goto cddb_destroy;
  }

  matches = cddb_query(conn, disc);

  if (-1 == matches) 
  {
    sprintf(temp_msg, "%s: %s\n", program_name, cddb_error_str(cddb_errno(conn)));
	report(stdout, temp_msg);
  }
  else {
    sprintf(temp_msg, "%s: Found %d matches in CDDB\n", program_name, matches);
	report(stdout, temp_msg);
    for (i=1; i<=matches; i++) {
      cddb_read(conn, disc);
      cddb_disc_print(disc);
      cddb_query_next(conn, disc);
    }
  }
  
  cddb_disc_destroy(disc);
  cddb_destroy:
  cddb_destroy(conn);
}