~ubuntu-branches/ubuntu/breezy/kdemultimedia/breezy

« back to all changes in this revision

Viewing changes to libkcddb/test/asynccddblookuptest.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2005-03-24 04:48:58 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050324044858-8ff88o9jxej6ii3d
Tags: 4:3.4.0-0ubuntu3
Add kubuntu_02_hide_arts_menu_entries.diff to hide artsbuilder and artscontrol k-menu entries

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <kdebug.h>
 
2
#include <kapplication.h>
 
3
#include <kcmdlineargs.h>
 
4
 
 
5
#include "asynccddblookuptest.h"
 
6
 
 
7
#include "libkcddb/cache.h"
 
8
#include "libkcddb/lookup.h"
 
9
 
 
10
AsyncCDDBLookupTest::AsyncCDDBLookupTest()
 
11
  : QObject()
 
12
{
 
13
  using namespace KCDDB;
 
14
 
 
15
  client_ = new Client;
 
16
  client_->config().setHostname("freedb.freedb.org");
 
17
  client_->config().setPort(8880);
 
18
  client_->config().setCachePolicy(Cache::Ignore);
 
19
  client_->config().setLookupTransport(Lookup::CDDBP);
 
20
  client_->setBlockingMode( false );
 
21
 
 
22
  connect
 
23
    (
 
24
      client_,
 
25
      SIGNAL(finished(CDDB::Result)),
 
26
      SLOT(slotFinished(CDDB::Result))
 
27
    );
 
28
 
 
29
  TrackOffsetList list;
 
30
 
 
31
  // a1107d0a - Kruder & Dorfmeister - The K&D Sessions - Disc One.
 
32
  list
 
33
    << 150      // First track start.
 
34
    << 29462
 
35
    << 66983
 
36
    << 96785
 
37
    << 135628
 
38
    << 168676
 
39
    << 194147
 
40
    << 222158
 
41
    << 247076
 
42
    << 278203   // Last track start.
 
43
    << 10       // Disc start.
 
44
    << 316732;  // Disc end.
 
45
 
 
46
  client_->lookup(list);
 
47
}
 
48
 
 
49
AsyncCDDBLookupTest::~AsyncCDDBLookupTest()
 
50
{
 
51
  delete client_;
 
52
}
 
53
 
 
54
  void
 
55
AsyncCDDBLookupTest::slotFinished(CDDB::Result r)
 
56
{
 
57
  kdDebug() << "AsyncCDDBLookupTest::slotResult: Got " << KCDDB::CDDB::resultToString(r) << endl;
 
58
 
 
59
  CDInfoList l = client_->lookupResponse();
 
60
 
 
61
  kdDebug() << "AsyncCDDBLookupTest::slotResult: Item count: " <<  l.count() << endl;
 
62
 
 
63
  for (CDInfoList::ConstIterator it(l.begin()); it != l.end(); ++it)
 
64
  {
 
65
    CDInfo i(*it);
 
66
 
 
67
    kdDebug() << "Disc artist: `" << i.artist << "'" << endl;
 
68
    kdDebug() << "Disc title: `" << i.title << "'" << endl;
 
69
    kdDebug() << "Disc revision: `" << i.revision << "'" << endl;
 
70
  }
 
71
 
 
72
  if (!l.isEmpty())
 
73
  {
 
74
    kdDebug() << "---------------------------------------" << endl;
 
75
    kdDebug() << "Showing first item" << endl;
 
76
 
 
77
    CDInfo i(l.first());
 
78
 
 
79
    kdDebug() << "Disc artist: `" << i.artist << "'" << endl;
 
80
    kdDebug() << "Disc title: `" << i.title << "'" << endl;
 
81
    kdDebug() << "Disc genre: `" << i.genre << "'" << endl;
 
82
    kdDebug() << "Disc year: `" << i.year << "'" << endl;
 
83
    kdDebug() << "Disc length: `" << i.length << "'" << endl;
 
84
    kdDebug() << "Disc id: `" << i.id << "'" << endl;
 
85
    kdDebug() << "Tracks........" << endl;
 
86
 
 
87
    for (TrackInfoList::ConstIterator it(i.trackInfoList.begin()); it != i.trackInfoList.end(); ++it)
 
88
    {
 
89
      kdDebug() << "  Track: `" << (*it).title << "'" << endl;
 
90
    }
 
91
    kdDebug() << "---------------------------------------" << endl;
 
92
  }
 
93
 
 
94
  CDInfo i(client_->bestLookupResponse());
 
95
 
 
96
  kdDebug() << "Best CDInfo had title: " << i.title << endl;
 
97
  kdDebug() << "and revision: " << i.revision << endl;
 
98
 
 
99
  kapp->quit();
 
100
}
 
101
 
 
102
int main(int argc, char ** argv)
 
103
{
 
104
  KCmdLineArgs::init(argc, argv, "libkcddb_test", "", "", "");
 
105
 
 
106
  KApplication app(false /* No styles */, false /* No GUI */);
 
107
 
 
108
  AsyncCDDBLookupTest test;
 
109
 
 
110
  return app.exec();
 
111
}
 
112
 
 
113
#include "asynccddblookuptest.moc"