summaryrefslogtreecommitdiffstats
path: root/libkcddb/test/synccddblookuptest.cpp
blob: 511ea571612a7064446ec3c9e23e66f04b4a7126 (plain)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include <kapplication.h>
#include <kcmdlineargs.h>
#include <kdebug.h>

#include "libkcddb/client.h"
#include "libkcddb/cache.h"
#include "libkcddb/lookup.h"


  int
main(int argc, char ** argv)
{
  TDECmdLineArgs::init(argc, argv, "libkcddb_test", "", "", "");

  TDEApplication app(false /* No styles */, false /* No GUI */);

  using namespace KCDDB;

  Client c;
  c.config().setHostname("freedb.freedb.org");
  c.config().setPort(8880);
  c.config().setCachePolicy(Cache::Ignore);
  c.config().setLookupTransport(Lookup::CDDBP);

  TrackOffsetList list;

  // a1107d0a - Kruder & Dorfmeister - The K&D Sessions - Disc One.
//  list
//    << 150      // First track start.
//    << 29462
//    << 66983
//    << 96785
//    << 135628
//    << 168676
//    << 194147
//    << 222158
//    << 247076
//    << 278203   // Last track start.
//    << 10       // Disc start.
//    << 316732;  // Disc end.
  list
    << 150
    << 106965
    << 127220
    << 151925
    << 176085
    << 5
    << 234500;

  kdDebug() << "Stuff to send to server:" << endl;

  kdDebug()
    << CDDB::trackOffsetListToId(list)
    << " "
    //<< trackOffsetListToString(list)
    << endl;

  CDDB::Result r = c.lookup(list);

  kdDebug() << "Client::lookup gave : " << CDDB::resultToString(r) << endl;

  CDInfoList response = c.lookupResponse();

  kdDebug() << "Client::lookup returned : " << response.count() << " entries"
    << endl;

  CDInfoList::ConstIterator it;

  for (it = response.begin(); it != response.end(); ++it)
  {
    CDInfo i(*it);

    kdDebug() << "Disc title: " << i.title << endl;
    kdDebug() << "Total tracks: " << i.trackInfoList.count() << endl;
    kdDebug() << "Disc revision: `" << i.revision << "'" << endl;
  }

  CDInfo i( c.bestLookupResponse() );

  kdDebug() << "Best CDInfo had title: " << i.title << endl;
  kdDebug() << "and revision: " << i.revision << endl;

  return 0;
}