~ubuntu-branches/ubuntu/karmic/tellico/karmic

« back to all changes in this revision

Viewing changes to src/fetch/z3950connection.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Richard A. Johnson
  • Date: 2007-11-19 14:19:44 UTC
  • mfrom: (0.1.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20071119141944-xu98vod9nmcef62w
Tags: 1.2.14-0ubuntu1
* New upstream release (LP: #150710)
* Remaining Ubuntu changes:
  - debian/control: build-dep on kdepim-dev
  - debian/control: drop versioned python from tellico-data build-dep
  - debian/control: adhere to DebianMaintainerField
* debian/rules: changed dh_iconcache to dh_icon

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#include <klocale.h>
33
33
 
34
34
#include <qfile.h>
35
 
#include <qeventloop.h>
36
35
 
37
36
namespace {
38
37
  static const size_t Z3950_DEFAULT_MAX_RECORDS = 20;
39
38
}
40
39
 
 
40
using Tellico::Fetch::Z3950ResultFound;
41
41
using Tellico::Fetch::Z3950Connection;
42
42
 
 
43
Z3950ResultFound::Z3950ResultFound(const QString& s) : QCustomEvent(uid())
 
44
    , m_result(QDeepCopy<QString>(s)) {
 
45
  ++Z3950Connection::resultsLeft;
 
46
}
 
47
 
 
48
Z3950ResultFound::~Z3950ResultFound() {
 
49
  --Z3950Connection::resultsLeft;
 
50
}
 
51
 
43
52
class Z3950Connection::Private {
44
53
public:
45
54
  Private() {}
54
63
#endif
55
64
};
56
65
 
 
66
int Z3950Connection::resultsLeft = 0;
 
67
 
57
68
// since the character set goes into a yaz api call
58
69
// I'm paranoid about user insertions, so just grab 64
59
70
// characters at most
104
115
//  myDebug() << "Z3950Connection::run() - " << m_fetcher->source() << endl;
105
116
  m_aborted = false;
106
117
  m_hasMore = false;
 
118
  resultsLeft = 0;
107
119
#if HAVE_YAZ
108
120
 
109
121
  if(!makeConnection()) {
358
370
}
359
371
 
360
372
void Z3950Connection::checkPendingEvents() {
361
 
  // I do not want the Done event to happen while Result events are still pending
362
 
  int maxEventsLeft = 3; // no infinite loops!
363
 
  while(kapp->hasPendingEvents() && maxEventsLeft--) {
364
 
    kapp->eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
 
373
  // if there's still some pending result events, go ahead and just wait 1 second
 
374
  if(resultsLeft > 0) {
 
375
    sleep(1);
365
376
  }
366
377
}
367
378
 
413
424
    myDebug() << "Z3950Connection::iconvRun() - can't decode buffer" << endl;
414
425
    return text_;
415
426
  }
 
427
  // bug in yaz, need to flush buffer to catch last character
 
428
  yaz_iconv(cd, 0, 0, &result, &outlen);
416
429
 
417
430
  // length is pointer difference
418
431
  size_t len = result - result0;