greghaynes / kdelicious

A Konqueror del.icio.us plugin

laurent Montel (author)
Thu Apr 09 00:12:54 -0700 2009
greghaynes (committer)
Thu Apr 09 00:12:54 -0700 2009
kdelicious / postrequest.cpp
100644 55 lines (49 sloc) 1.321 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "postrequest.h"
 
#include <QXmlAttributes>
 
namespace QtLicious
{
 
PostRequest::PostRequest( const QUrl &path,
const QString &description,
const QString &url,
const QString &notes,
QList<QString> tags,
bool shared,
bool replace,
QObject *parent )
: Request( path, parent )
{
QUrl newPath;
QList<QPair<QString, QString> > arglist;
arglist.append( QPair<QString, QString>( "url", url ) );
arglist.append( QPair<QString, QString>( "description", description ) );
if( !notes.isEmpty() )
arglist.append( QPair<QString, QString>( "extended", notes ) );
QString tag, tagarg;
if( tags.size() > 0 )
{
foreach( tag, tags )
tagarg.append( tag + " " );
}
if( !shared )
arglist.append( QPair<QString, QString>( "shared", "no" ) );
if( !replace )
arglist.append( QPair<QString, QString>( "replace", "no" ) );
arglist.append( QPair<QString, QString>( "tags", tagarg ) );
newPath.setPath( path.toString() );
newPath.setQueryItems( arglist );
setPath( newPath );
}
 
bool PostRequest::startElement( const QString &namespaceURI,
const QString &localName,
const QString &qName,
const QXmlAttributes &attr )
{
Q_UNUSED(namespaceURI);
Q_UNUSED(qName)
if( localName == "result" && attr.value( "code" ) == "something went wrong" )
{
emit( failed( SomethingWentWrong ) );
}
return true;
}
 
}