~ubuntu-branches/ubuntu/trusty/kdepimlibs/trusty

« back to all changes in this revision

Viewing changes to kblog/movabletype.cpp

  • Committer: Package Import Robot
  • Author(s): Rohan Garg, Rohan Garg, Philip Muškovac
  • Date: 2013-11-23 17:36:44 UTC
  • mfrom: (1.1.102)
  • Revision ID: package-import@ubuntu.com-20131123173644-p5ow94192ezsny8g
Tags: 4:4.11.80-0ubuntu1
[ Rohan Garg ]
* New upstream beta release
  - Bump akonadi requirement to 1.10.45
  - Update install files
  - Update symbols

[ Philip Muškovac ]
* kdepimlibs-dev/-dbg breaks/replaces kdepim-runtime/-dbg (<< 4:4.11.80)

Show diffs side-by-side

added added

removed removed

Lines of Context:
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 ) );
81
81
  unsigned int i = d->mCallCounter++;
82
82
  d->mCallMap[ i ] = post;
83
83
  d->mXmlRpcClient->call(
84
 
    "mt.getTrackbackPings", args,
 
84
    QLatin1String("mt.getTrackbackPings"), args,
85
85
    this, SLOT(slotListTrackbackPings(QList<QVariant>,QVariant)),
86
86
    this, SLOT(slotError(int,QString,QVariant)),
87
87
    QVariant( i ) );
215
215
  mFetchPostCache.clear();
216
216
}
217
217
 
218
 
 
219
218
MovableTypePrivate::MovableTypePrivate()
220
219
{
221
220
  kDebug();
251
250
    serverID = result[0].toString();
252
251
  }
253
252
  if ( result[0].type() == QVariant::Int ) {
254
 
    serverID = QString( "%1" ).arg( result[0].toInt() );
 
253
    serverID = QString::fromLatin1( "%1" ).arg( result[0].toInt() );
255
254
  }
256
255
  post->setPostId( serverID );
257
256
  if ( mSilentCreationList.contains(  post ) )
292
291
    unsigned int i= mCallCounter++;
293
292
    mCallMap[ i ] = post;
294
293
    mXmlRpcClient->call(
295
 
      "mt.getPostCategories", args,
 
294
      QLatin1String("mt.getPostCategories"), args,
296
295
      q, SLOT(slotGetPostCategories(QList<QVariant>,QVariant)),
297
296
      q, SLOT(slotError(int,QString,QVariant)),
298
297
      QVariant( i ) );
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 );
358
357
         break;
359
358
       }
365
364
  args << QVariant( catList );
366
365
 
367
366
  mXmlRpcClient->call(
368
 
    "mt.setPostCategories", args,
 
367
    QLatin1String("mt.setPostCategories"), args,
369
368
    q, SLOT(slotSetPostCategories(QList<QVariant>,QVariant)),
370
369
    q, SLOT(slotError(int,QString,QVariant)),
371
370
    QVariant( i ) );
393
392
    QList<QVariant>::ConstIterator it = categoryList.constBegin();
394
393
    QList<QVariant>::ConstIterator end = categoryList.constEnd();
395
394
    for ( ; it != end; it++ ) {
396
 
      newCatList << ( *it ).toMap()[ "categoryName" ].toString();
 
395
      newCatList << ( *it ).toMap()[ QLatin1String("categoryName") ].toString();
397
396
    }
398
397
    kDebug() << "categories list: " << newCatList;
399
398
    post->setCategories( newCatList );
464
463
    return false;
465
464
  }
466
465
  QStringList mapkeys = postInfo.keys();
467
 
  kDebug() << endl << "Keys:" << mapkeys.join( ", " );
 
466
  kDebug() << endl << "Keys:" << mapkeys.join( QLatin1String(", ") );
468
467
  kDebug() << endl;
469
468
 
470
469
  KDateTime dt =
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() );
474
473
  }
475
474
 
476
475
  dt =
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() );
480
479
  }
481
480
 
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() );
484
483
 
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") ];
497
496
      }
498
497
    }
499
498
  }
500
499
 
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() ) {
516
515
    /**
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;
557
556
  }
558
557
  kDebug() << "Emitting listedTrackBackPings()";
568
567
    return false;
569
568
  }
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();
575
574
  }
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.
583
582
  *args << map;
584
583
  *args << QVariant( !post.isPrivate() );