~ubuntu-branches/ubuntu/precise/kbibtex/precise

« back to all changes in this revision

Viewing changes to src/z3950connection.h

  • Committer: Package Import Robot
  • Author(s): Michael Hanke
  • Date: 2011-07-18 09:29:48 UTC
  • mfrom: (1.1.6) (2.1.5 sid)
  • Revision ID: package-import@ubuntu.com-20110718092948-ksxjmg7kdfamolmg
Tags: 0.3-1
* First upstream release for KDE4 (Closes: #634255). A number of search
  engines are still missing, in comparison to the 0.2 series.
* Bumped Standards-Version to 3.9.2, no changes necessary.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
    copyright            : (C) 2005-2006 by Robby Stephenson
3
 
    email                : robby@periapsis.org
4
 
 ***************************************************************************/
5
 
 
6
 
/***************************************************************************
7
 
 *                                                                         *
8
 
 *   This file has been modified to match the requirements of KBibTeX.     *
9
 
 *   In case of problems or bugs arising from this implementation, please  *
10
 
 *   contact the KBibTeX team first.                                       *
11
 
 *                             Thomas Fischer <fischer@unix-ag.uni-kl.de>  *
12
 
 *                                                                         *
13
 
 ***************************************************************************/
14
 
 
15
 
/***************************************************************************
16
 
 *                                                                         *
17
 
 *   This program is free software; you can redistribute it and/or modify  *
18
 
 *   it under the terms of version 2 of the GNU General Public License as  *
19
 
 *   published by the Free Software Foundation;                            *
20
 
 *                                                                         *
21
 
 ***************************************************************************/
22
 
 
23
 
#ifndef KBIBTEX_Z3950CONNECTION_H
24
 
#define KBIBTEX_Z3950CONNECTION_H
25
 
 
26
 
#include <qthread.h>
27
 
#include <qevent.h>
28
 
#include <qdeepcopy.h>
29
 
 
30
 
#include <ksharedptr.h>
31
 
 
32
 
namespace KBibTeX {
33
 
class Z3950ResultFound : public QCustomEvent {
34
 
public:
35
 
  Z3950ResultFound(const QString& s);
36
 
  ~Z3950ResultFound();
37
 
  const QString& result() const { return m_result; }
38
 
 
39
 
  static int uid() { return User + 11111; }
40
 
 
41
 
private:
42
 
  QString m_result;
43
 
};
44
 
 
45
 
class Z3950ConnectionDone : public QCustomEvent {
46
 
public:
47
 
  Z3950ConnectionDone(bool more) : QCustomEvent(uid()), m_type(-1), m_hasMore(more) {}
48
 
  Z3950ConnectionDone(bool more, const QString& s, int t) : QCustomEvent(uid()), m_msg(QDeepCopy<QString>(s)), m_type(t), m_hasMore(more) {}
49
 
 
50
 
  const QString& message() const { return m_msg; }
51
 
  int messageType() const { return m_type; }
52
 
  bool hasMoreResults() const { return m_hasMore; }
53
 
 
54
 
  static int uid() { return User + 22222; }
55
 
 
56
 
private:
57
 
  QString m_msg;
58
 
  int m_type;
59
 
  bool m_hasMore;
60
 
};
61
 
 
62
 
class Z3950SyntaxChange : public QCustomEvent {
63
 
public:
64
 
  Z3950SyntaxChange(const QString& s) : QCustomEvent(uid()), m_syntax(QDeepCopy<QString>(s)) {}
65
 
  const QString& syntax() const { return m_syntax; }
66
 
 
67
 
  static int uid() { return User + 33333; }
68
 
 
69
 
private:
70
 
  QString m_syntax;
71
 
};
72
 
 
73
 
/**
74
 
 * @author Robby Stephenson
75
 
 */
76
 
class Z3950Connection : public QThread {
77
 
public:
78
 
  Z3950Connection(QObject* fetcher,
79
 
                  const QString& host,
80
 
                  uint port,
81
 
                  const QString& dbname,
82
 
                  const QString& sourceCharSet,
83
 
                  const QString& syntax,
84
 
                  const QString& esn);
85
 
  ~Z3950Connection();
86
 
 
87
 
  void reset();
88
 
  void setQuery(const QString& query, unsigned int numHits);
89
 
  void setUserPassword(const QString& user, const QString& pword);
90
 
  void run();
91
 
 
92
 
  void abort() { m_aborted = true; }
93
 
 
94
 
private:
95
 
  static QCString iconvRun(const QCString& text, const QString& fromCharSet, const QString& toCharSet);
96
 
  static QString toXML(const QCString& marc, const QString& fromCharSet);
97
 
 
98
 
  bool makeConnection();
99
 
  void done();
100
 
  void done(const QString& message, int type);
101
 
  QCString toCString(const QString& text);
102
 
  QString toString(const QCString& text);
103
 
  void checkPendingEvents();
104
 
 
105
 
  class Private;
106
 
  Private* d;
107
 
 
108
 
  bool m_connected;
109
 
  bool m_aborted;
110
 
 
111
 
  QObject* m_fetcher;
112
 
  QString m_host;
113
 
  uint m_port;
114
 
  QString m_dbname;
115
 
  QString m_user;
116
 
  QString m_password;
117
 
  QString m_sourceCharSet;
118
 
  QString m_syntax;
119
 
  QString m_pqn;
120
 
  QString m_esn;
121
 
  size_t m_start;
122
 
  size_t m_limit;
123
 
  bool m_hasMore;
124
 
 
125
 
  friend class Z3950ResultFound;
126
 
  static int resultsLeft;
127
 
};
128
 
 
129
 
} // end namespace
130
 
 
131
 
#endif