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

« back to all changes in this revision

Viewing changes to akonadi/itemserializer.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:
22
22
#include "item.h"
23
23
#include "itemserializerplugin.h"
24
24
#include "typepluginloader_p.h"
 
25
#include "servermanager.h"
 
26
#include <akonadi/private/xdgbasedirs_p.h>
25
27
 
26
28
// Qt
27
29
#include <QtCore/QBuffer>
28
30
#include <QtCore/QFile>
29
31
#include <QtCore/QIODevice>
30
32
#include <QtCore/QString>
 
33
#include <QtCore/QDir>
31
34
 
32
35
#include <string>
33
36
 
81
84
void ItemSerializer::deserialize( Item& item, const QByteArray& label, const QByteArray& data, int version, bool external )
82
85
{
83
86
  if ( external ) {
84
 
    QFile file( QString::fromUtf8(data) );
 
87
    QString path;
 
88
    QString fileName = QString::fromUtf8( data );
 
89
    QFileInfo fi( fileName );
 
90
    if ( !fi.isAbsolute() ) {
 
91
      QString fullRelPath = QLatin1String( "akonadi" );
 
92
      if ( Akonadi::ServerManager::hasInstanceIdentifier() ) {
 
93
        fullRelPath += QDir::separator() + QLatin1String( "instance" ) + QDir::separator() + Akonadi::ServerManager::instanceIdentifier();
 
94
      }
 
95
      fullRelPath += QDir::separator() + QLatin1String( "file_db_data" );
 
96
      fileName = XdgBaseDirs::saveDir( "data", fullRelPath ) + QDir::separator() + fileName;
 
97
    }
 
98
 
 
99
    QFile file( fileName );
85
100
    if ( file.open( QIODevice::ReadOnly ) ) {
86
101
      deserialize( item, label, file, version );
87
102
      file.close();
 
103
    } else {
 
104
      kWarning() << "Failed to open external payload:" << fileName << file.errorString();
88
105
    }
89
106
  } else {
90
107
    QBuffer buffer;
206
223
  return Item();
207
224
}
208
225
 
 
226
void ItemSerializer::overridePluginLookup( QObject *p )
 
227
{
 
228
  TypePluginLoader::overridePluginLookup(p);
 
229
}
 
230
 
209
231
}