30 #include <QtXml/qdom.h>
31 #include <QtCore/QMutableStringListIterator>
36 :
QObject(parent), m_provider(provider)
38 m_soap =
new Soap(
this);
39 connect(m_soap, SIGNAL(signalResult(QDomNode,
int)), SLOT(slotResult(QDomNode,
int)));
40 connect(m_soap, SIGNAL(
signalError()), SLOT(slotError()));
54 m_endpoint = endpoint;
60 QDomElement info = doc.createElement(
"ns:GHNSInfo");
63 m_soap->
call(info, m_endpoint.
url());
69 QDomElement info = doc.createElement(
"ns:GHNSCategories");
70 m_soap->
call(info, m_endpoint.
url());
77 QDomElement entries = doc.createElement(
"ns:GHNSList");
78 QDomElement ecategory = doc.createElement(
"category");
79 QDomText t = doc.createTextNode(category);
80 ecategory.appendChild(t);
81 entries.appendChild(ecategory);
82 if (!feed.isEmpty()) {
83 QDomElement efeed = doc.createElement(
"feed");
84 QDomText t2 = doc.createTextNode(feed);
85 efeed.appendChild(t2);
86 entries.appendChild(efeed);
88 int jobid = m_soap->
call(entries, m_endpoint.
url());
96 QDomElement comments = doc.createElement(
"ns:GHNSComments");
97 QDomElement eid = doc.createElement(
"id");
98 QDomText t = doc.createTextNode(QString::number(
id));
100 comments.appendChild(eid);
101 m_soap->
call(comments, m_endpoint.
url());
107 QDomElement changes = doc.createElement(
"ns:GHNSChanges");
108 QDomElement eid = doc.createElement(
"id");
109 QDomText t = doc.createTextNode(QString::number(
id));
111 changes.appendChild(eid);
112 m_soap->
call(changes, m_endpoint.
url());
118 QDomElement history = doc.createElement(
"ns:GHNSHistory");
119 QDomElement eid = doc.createElement(
"id");
120 QDomText t = doc.createTextNode(QString::number(
id));
122 history.appendChild(eid);
123 m_soap->
call(history, m_endpoint.
url());
129 QDomElement removal = doc.createElement(
"ns:GHNSRemoval");
130 QDomElement eid = doc.createElement(
"id");
131 QDomText t = doc.createTextNode(QString::number(
id));
133 removal.appendChild(eid);
134 m_soap->
call(removal, m_endpoint.
url());
140 QDomElement subscription = doc.createElement(
"ns:GHNSSubscription");
141 QDomElement eid = doc.createElement(
"id");
142 QDomText t = doc.createTextNode(QString::number(
id));
144 subscription.appendChild(eid);
145 QDomElement esubscribe = doc.createElement(
"subscribe");
146 QDomText t2 = doc.createTextNode((subscribe ?
"true" :
"false"));
147 esubscribe.appendChild(t2);
148 subscription.appendChild(esubscribe);
149 m_soap->
call(subscription, m_endpoint.
url());
156 QDomElement ecomment = doc.createElement(
"ns:GHNSComment");
157 QDomElement eid = doc.createElement(
"id");
158 QDomText tid = doc.createTextNode(QString::number(
id));
159 eid.appendChild(tid);
160 ecomment.appendChild(eid);
161 QDomElement ecommenttext = doc.createElement(
"comment");
162 QDomText tcomment = doc.createTextNode(comment);
163 ecommenttext.appendChild(tcomment);
164 ecomment.appendChild(ecommenttext);
165 m_soap->
call(ecomment, m_endpoint.
url());
171 QDomElement erating = doc.createElement(
"ns:GHNSRating");
172 QDomElement eid = doc.createElement(
"id");
173 QDomText tid = doc.createTextNode(QString::number(
id));
174 eid.appendChild(tid);
175 erating.appendChild(eid);
176 QDomElement eratingtext = doc.createElement(
"rating");
177 QDomText trating = doc.createTextNode(QString::number(rating));
178 eratingtext.appendChild(trating);
179 erating.appendChild(eratingtext);
180 m_soap->
call(erating, m_endpoint.
url());
183 void Dxs::slotError()
188 void Dxs::slotResult(QDomNode node,
int jobid)
193 if (m_soap->
localname(node) ==
"Fault") {
199 if (m_soap->
localname(node) ==
"GHNSInfoResponse") {
205 }
else if (m_soap->
localname(node) ==
"GHNSCategoriesResponse") {
209 for (
int i = 0; i < catlist.count(); i++) {
212 QDomNode node = catlist.at(i).toElement();
213 QString categoryname = m_soap->
xpath(node,
"/category");
216 QString description = m_soap->
xpath(node,
"/description");
218 category->
setId(categoryname);
223 categories << category;
227 }
else if (m_soap->
localname(node) ==
"GHNSListResponse") {
230 Feed * thisFeed = m_jobfeeds.value(jobid);
231 QDomNode entriesNode = node.firstChild();
236 for (
int i = 0; i < entrylist.count(); i++) {
237 QDomElement element = entrylist.at(i).toElement();
238 element.setTagName(
"stuff");
248 }
else if (m_soap->
localname(node) ==
"GHNSCommentsResponse") {
252 for (
int i = 0; i < comlist.count(); i++) {
253 comments << comlist.at(i).toElement().text();
257 }
else if (m_soap->
localname(node) ==
"GHNSChangesResponse") {
261 for (
int i = 0; i < changelist.count(); i++) {
262 QDomNode node = changelist.at(i);
268 changes << changelog;
273 }
else if (m_soap->
localname(node) ==
"GHNSHistoryResponse") {
277 for (
int i = 0; i < entrylist.count(); i++) {
278 entries << entrylist.at(i).toElement().text();
282 }
else if (m_soap->
localname(node) ==
"GHNSRemovalResponse") {
284 }
else if (m_soap->
localname(node) ==
"GHNSSubscriptionResponse") {
286 }
else if (m_soap->
localname(node) ==
"GHNSCommentResponse") {
288 }
else if (m_soap->
localname(node) ==
"GHNSRatingResponse") {
void signalHistory(QStringList entries)
void call_comments(int id)
void call_rating(int id, int rating)
Change the rating.
void call_entries(QString category, QString feed)
void call_changes(int id)
QList< QDomNode > directChildNodes(const QDomNode &node, const QString &name)
void call_comment(int id, QString comment)
QString xpath(const QDomNode &node, const QString &expr)
Find the text element to a xpath like expression.
KNewStuff data entry container.
void setDescription(const KTranslatable &type)
Sets the category description.
void signalCategories(QList< KNS::Category * > categories)
void signalComments(QStringList comments)
const char * name(StandardAction id)
void setId(const QString &id)
Sets the unique id for this category.
void signalComment(bool success)
void signalRating(bool success)
Feed * downloadUrlFeed(const QString &feedtype) const
Feed to retrieve for the given feed type.
QString localname(const QDomNode &node)
Name of the QDomElement for node without the namespace.
void call_subscription(int id, bool subscribe)
void setName(const KTranslatable &name)
Sets the name for this category.
void addEntry(Entry *entry)
Adds an association to an entry.
void signalInfo(QString provider, QString server, QString version)
void call_history(int id)
void setIcon(const KUrl &icon)
Sets the icon.
void call_removal(int id)
Dxs(QObject *parent, KNS::Provider *provider)
KNewStuff transport layer.
void signalRemoval(bool success)
void signalChanges(QStringList comments)
void signalSubscription(bool success)
int call(const QDomElement &element, const QString &endpoint)
Send to the server - uses either soap or tree.
QString url(AdjustPathOption trailing=LeaveTrailingSlash) const
void setEndpoint(KUrl endpoint)
Parser and dumper for KNewStuff data entries.
void signalEntries(KNS::Entry::List entries, Feed *feed)
KNewStuff provider container.