66
66
QList<QVariant> args( d->defaultArgs( blogId() ) );
67
67
args << QVariant( number );
68
68
d->mXmlRpcClient->call(
69
"metaWeblog.getRecentPosts", args,
69
QLatin1String("metaWeblog.getRecentPosts"), args,
70
70
this, SLOT(slotListRecentPosts(QList<QVariant>,QVariant)),
71
71
this, SLOT(slotError(int,QString,QVariant)),
72
72
QVariant( number ) );
348
347
QStringList categories = post->categories();
349
348
for ( int j = 0; j < categories.count(); j++ ) {
350
349
for ( int k = 0; k < mCategoriesList.count(); k++ ) {
351
if ( mCategoriesList[k]["name"] == categories[j] ) {
352
kDebug() << "Matched category with name: " << categories[ j ] << " and id: " << mCategoriesList[ k ][ "categoryId" ];
350
if ( mCategoriesList[k][QLatin1String("name")] == categories[j] ) {
351
kDebug() << "Matched category with name: " << categories[ j ] << " and id: " << mCategoriesList[ k ][ QLatin1String("categoryId") ];
353
352
QMap<QString,QVariant> category;
354
353
//the first in the QStringList of post->categories()
355
354
// is the primary category
356
category["categoryId"] = mCategoriesList[k]["categoryId"].toInt();
355
category[QLatin1String("categoryId")] = mCategoriesList[k][QLatin1String("categoryId")].toInt();
357
356
catList << QVariant( category );
466
465
QStringList mapkeys = postInfo.keys();
467
kDebug() << endl << "Keys:" << mapkeys.join( ", " );
466
kDebug() << endl << "Keys:" << mapkeys.join( QLatin1String(", ") );
468
467
kDebug() << endl;
471
KDateTime( postInfo["dateCreated"].toDateTime(), KDateTime::UTC );
470
KDateTime( postInfo[QLatin1String("dateCreated")].toDateTime(), KDateTime::UTC );
472
471
if ( dt.isValid() && !dt.isNull() ) {
473
472
post->setCreationDateTime( dt.toLocalZone() );
477
KDateTime( postInfo["lastModified"].toDateTime(), KDateTime::UTC );
476
KDateTime( postInfo[QLatin1String("lastModified")].toDateTime(), KDateTime::UTC );
478
477
if ( dt.isValid() && !dt.isNull() ) {
479
478
post->setModificationDateTime( dt.toLocalZone() );
482
post->setPostId( postInfo["postid"].toString().isEmpty() ? postInfo["postId"].toString() :
483
postInfo["postid"].toString() );
481
post->setPostId( postInfo[QLatin1String("postid")].toString().isEmpty() ? postInfo[QLatin1String("postId")].toString() :
482
postInfo[QLatin1String("postid")].toString() );
485
QString title( postInfo["title"].toString() );
486
QString description( postInfo["description"].toString() );
487
QStringList categoryIdList = postInfo["categories"].toStringList();
484
QString title( postInfo[QLatin1String("title")].toString() );
485
QString description( postInfo[QLatin1String("description")].toString() );
486
QStringList categoryIdList = postInfo[QLatin1String("categories")].toStringList();
488
487
QStringList categories;
489
488
// since the metaweblog definition is ambigious, we try different
490
489
// category mappings
491
490
for ( int i = 0; i < categoryIdList.count(); i++ ) {
492
491
for ( int k = 0; k < mCategoriesList.count(); k++ ) {
493
if ( mCategoriesList[ k ][ "name" ] == categoryIdList[ i ] ) {
494
categories << mCategoriesList[ k ][ "name" ];
495
} else if ( mCategoriesList[ k ][ "categoryId" ] == categoryIdList[ i ]) {
496
categories << mCategoriesList[ k ][ "name" ];
492
if ( mCategoriesList[ k ][ QLatin1String("name") ] == categoryIdList[ i ] ) {
493
categories << mCategoriesList[ k ][ QLatin1String("name") ];
494
} else if ( mCategoriesList[ k ][ QLatin1String("categoryId") ] == categoryIdList[ i ]) {
495
categories << mCategoriesList[ k ][ QLatin1String("name") ];
501
500
//TODO 2 new keys are:
502
501
// String mt_convert_breaks, the value for the convert_breaks field
503
post->setSlug( postInfo["wp_slug"].toString() );
504
post->setAdditionalContent( postInfo["mt_text_more"].toString() );
502
post->setSlug( postInfo[QLatin1String("wp_slug")].toString() );
503
post->setAdditionalContent( postInfo[QLatin1String("mt_text_more")].toString() );
505
504
post->setTitle( title );
506
505
post->setContent( description );
507
post->setCommentAllowed( (bool)postInfo["mt_allow_comments"].toInt() );
508
post->setTrackBackAllowed( (bool)postInfo["mt_allow_pings"].toInt() );
509
post->setSummary( postInfo["mt_excerpt"].toString() );
510
post->setTags( postInfo["mt_keywords"].toStringList() );
511
post->setLink( postInfo["link"].toString() );
512
post->setPermaLink( postInfo["permaLink"].toString() );
513
QString postStatus = postInfo["post_status"].toString();
514
if ( postStatus != "publish" &&
506
post->setCommentAllowed( (bool)postInfo[QLatin1String("mt_allow_comments")].toInt() );
507
post->setTrackBackAllowed( (bool)postInfo[QLatin1String("mt_allow_pings")].toInt() );
508
post->setSummary( postInfo[QLatin1String("mt_excerpt")].toString() );
509
post->setTags( postInfo[QLatin1String("mt_keywords")].toStringList() );
510
post->setLink( postInfo[QLatin1String("link")].toString() );
511
post->setPermaLink( postInfo[QLatin1String("permaLink")].toString() );
512
QString postStatus = postInfo[QLatin1String("post_status")].toString();
513
if ( postStatus != QLatin1String("publish") &&
515
514
!postStatus.isEmpty() ) {
517
516
* Maybe this field wasn't set by server! so, on that situation, we will assume it as non-Private,
550
549
QMap<QString,QString> tping;
551
550
kDebug() << "MIDDLE:" << ( *it ).typeName();
552
551
const QMap<QString, QVariant> trackBackInfo = ( *it ).toMap();
553
tping[ "title" ] = trackBackInfo[ "pingTitle"].toString();
554
tping[ "url" ] = trackBackInfo[ "pingURL"].toString();
555
tping[ "ip" ] = trackBackInfo[ "pingIP"].toString();
552
tping[ QLatin1String("title") ] = trackBackInfo[ QLatin1String("pingTitle")].toString();
553
tping[ QLatin1String("url") ] = trackBackInfo[ QLatin1String("pingURL")].toString();
554
tping[ QLatin1String("ip") ] = trackBackInfo[ QLatin1String("pingIP")].toString();
556
555
trackBackList << tping;
558
557
kDebug() << "Emitting listedTrackBackPings()";
570
569
QMap<QString, QVariant> map;
571
map["categories"] = post.categories();
572
map["description"] = post.content();
570
map[QLatin1String("categories")] = post.categories();
571
map[QLatin1String("description")] = post.content();
573
572
if ( !post.additionalContent().isEmpty() ) {
574
map["mt_text_more"] = post.additionalContent();
573
map[QLatin1String("mt_text_more")] = post.additionalContent();
576
map["title"] = post.title();
577
map["dateCreated"] = post.creationDateTime().dateTime().toUTC();
578
map["mt_allow_comments"] = (int)post.isCommentAllowed();
579
map["mt_allow_pings"] = (int)post.isTrackBackAllowed();
580
map["mt_excerpt"] = post.summary();
581
map["mt_keywords"] = post.tags().join( "," );
575
map[QLatin1String("title")] = post.title();
576
map[QLatin1String("dateCreated")] = post.creationDateTime().dateTime().toUTC();
577
map[QLatin1String("mt_allow_comments")] = (int)post.isCommentAllowed();
578
map[QLatin1String("mt_allow_pings")] = (int)post.isTrackBackAllowed();
579
map[QLatin1String("mt_excerpt")] = post.summary();
580
map[QLatin1String("mt_keywords")] = post.tags().join( QLatin1String(",") );
582
581
//map["mt_tb_ping_urls"] check for that, i think this should only be done on the server.
584
583
*args << QVariant( !post.isPrivate() );