KVIrc  4.9.2
DeveloperAPIs
Service.h
Go to the documentation of this file.
1 //=============================================================================
2 //
3 // File : Service.h
4 // Creation date : Fri Aug 08 18:00:00 2008 GMT by Fabio Bas
5 //
6 // This file is part of the KVIrc IRC client distribution
7 // Copyright (C) 2008 Fabio Bas (ctrlaltca at gmail dot com)
8 //
9 // This program is FREE software. You can redistribute it and/or
10 // modify it under the terms of the GNU General Public License
11 // as published by the Free Software Foundation; either version 2
12 // of the License, or (at your option) any later version.
13 //
14 // This program is distributed in the HOPE that it will be USEFUL,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 // See the GNU General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with this program. If not, write to the Free Software Foundation,
21 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 //
23 // Original Copyright follows:
24 //=============================================================================
25 
26 /***************************************************************************
27  Service.h - description
28  -------------------
29  begin : Sun Jul 24 2005
30  copyright : (C) 2005 by Diederik van der Boor
31  email : vdboor --at-- codingdomain.com
32  ***************************************************************************/
33 
34 #ifndef UPNP_CONTROLPOINT_H
35 #define UPNP_CONTROLPOINT_H
36 
37 #include <QObject>
38 #include <QDomNode>
39 #include <QMap>
40 #include <QString>
41 
42 namespace UPnP
43 {
44 
45  // A datablock to make the exchange
46  // of service information easier
48  {
49  QString hostname;
50  int port;
51  QString scpdUrl;
52  QString controlUrl;
53  QString serviceId;
54  QString serviceType;
55  };
56 
68  class Service : public QObject
69  {
70  Q_OBJECT
71 
72  public: // public methods
73  // The constructor for the root service
74  Service(const QString & hostname, int port, const QString & informationUrl);
75  // The constructor for action services
76  Service(const ServiceParameters & params);
77  // The destructor
78  virtual ~Service();
79 
80  // Get the number of pending requests
81  int getPendingRequests() const;
82 
83  protected: // Protected methods
84  // Makes a UPnP action request
85  int callAction(const QString & actionName, const QString & prefix);
86  // Makes a UPnP action request
87  int callAction(const QString & actionName, const QMap<QString, QString> & arguments, const QString & prefix);
88  // Makes a UPnP service request
89  int callInformationUrl();
90 
91  // The control point received an action failure indication
92  virtual void gotActionErrorResponse(const QDomNode & response);
93  // The control point received a response to callAction()
94  virtual void gotActionResponse(const QString & responseType, const QMap<QString, QString> & resultValues);
95  // The control point received a response to callInformationUrl()
96  virtual void gotInformationResponse(const QDomNode & response);
97 
98  private slots:
99  // The QHttp object retrieved data.
100  void slotRequestFinished();
101 
102  private:
103  // Makes a UPnP action request (keeps pointers from the external interface)
104  int callActionInternal(const QString & actionName, const QMap<QString, QString> * arguments, const QString & prefix);
105 
106  private:
107  // The URL to control the service
108  QString m_szControlUrl;
109  // The URL to request service information
111  // The number of pending queries/actions
113  // The ID of the service
114  QString m_szServiceId;
115  // The Type of the service
117  // The xml prefix used by the router
119  // hostname
120  QString m_szHostname;
121  //port
122  int m_iPort;
123 
124  signals:
125  // Called when a query completed
126  void queryFinished(bool error);
127  };
128 }
129 
130 #endif
Service(const QString &hostname, int port, const QString &informationUrl)
Definition: Service.cpp:52
virtual ~Service()
Definition: Service.cpp:67
int m_iPendingRequests
Definition: Service.h:112
QString m_szInformationUrl
Definition: Service.h:110
int port
Definition: Service.h:50
int m_iPort
Definition: Service.h:122
void slotRequestFinished()
Definition: Service.cpp:209
virtual void gotInformationResponse(const QDomNode &response)
Definition: Service.cpp:202
virtual void gotActionResponse(const QString &responseType, const QMap< QString, QString > &resultValues)
Definition: Service.cpp:196
Definition: Service.h:68
void queryFinished(bool error)
QString serviceType
Definition: Service.h:54
Definition: Service.h:47
virtual void gotActionErrorResponse(const QDomNode &response)
Definition: Service.cpp:187
QString m_szServiceId
Definition: Service.h:114
int getPendingRequests() const
Definition: Service.cpp:181
QString controlUrl
Definition: Service.h:52
QString scpdUrl
Definition: Service.h:51
int callInformationUrl()
Definition: Service.cpp:159
QString m_szHostname
Definition: Service.h:120
QString serviceId
Definition: Service.h:53
int callAction(const QString &actionName, const QString &prefix)
Definition: Service.cpp:74
QString m_szServiceType
Definition: Service.h:116
int callActionInternal(const QString &actionName, const QMap< QString, QString > *arguments, const QString &prefix)
Definition: Service.cpp:86
QString m_szControlUrl
Definition: Service.h:108
QString m_szBaseXmlPrefix
Definition: Service.h:118
QString hostname
Definition: Service.h:49
QString hostname()
Definition: KviRuntimeInfo.cpp:720