~ubuntu-branches/ubuntu/karmic/kdepim/karmic-backports

« back to all changes in this revision

Viewing changes to akonadi/xml/akonadi2xml.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Christian Mangold
  • Date: 2009-07-10 06:34:50 UTC
  • mfrom: (1.1.40 upstream)
  • Revision ID: james.westby@ubuntu.com-20090710063450-neojgew2fh0n3y0u
Tags: 4:4.2.96-0ubuntu1
* New upstream release
* Bump kde build-deps to 4.2.96

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
    Copyright (c) 2009 Volker Krause <vkrause@kde.org>
3
 
 
4
 
    This library is free software; you can redistribute it and/or modify it
5
 
    under the terms of the GNU Library General Public License as published by
6
 
    the Free Software Foundation; either version 2 of the License, or (at your
7
 
    option) any later version.
8
 
 
9
 
    This library is distributed in the hope that it will be useful, but WITHOUT
10
 
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
 
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
12
 
    License for more details.
13
 
 
14
 
    You should have received a copy of the GNU Library General Public License
15
 
    along with this library; see the file COPYING.LIB.  If not, write to the
16
 
    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17
 
    02110-1301, USA.
18
 
*/
19
 
 
20
 
#include "xmlwritejob.h"
21
 
 
22
 
#include <akonadi/collection.h>
23
 
#include <akonadi/private/collectionpathresolver_p.h>
24
 
 
25
 
#include <KAboutData>
26
 
#include <KApplication>
27
 
#include <KCmdLineArgs>
28
 
#include <KDebug>
29
 
 
30
 
using namespace Akonadi;
31
 
 
32
 
int main( int argc, char *argv[] )
33
 
{
34
 
  KAboutData aboutdata( "akonadi2xml", 0,
35
 
                        ki18n( "Akonadi To XML converter" ),
36
 
                        "1.0",
37
 
                        ki18n( "Converts a Akonadi collection subtree into a XML file." ),
38
 
                        KAboutData::License_GPL,
39
 
                        ki18n( "(c) 2009 Volker Krause <vkrause@kde.org>" ) );
40
 
 
41
 
  KCmdLineArgs::init( argc, argv, &aboutdata );
42
 
  KCmdLineOptions options;
43
 
  options.add( "c" ).add( "collection <root>", ki18n( "Root collection id or path" ) );
44
 
  options.add( "o" ).add( "output <file>", ki18n( "Output file" ) );
45
 
  KCmdLineArgs::addCmdLineOptions( options );
46
 
 
47
 
  KApplication app;
48
 
  const KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
49
 
 
50
 
  Collection root;
51
 
  if ( args->isSet( "collection" ) ) {
52
 
    const QString path = args->getOption( "collection" );
53
 
    CollectionPathResolver resolver( path );
54
 
    if ( !resolver.exec() ) {
55
 
      kError() << resolver.errorString();
56
 
      return -1;
57
 
    }
58
 
    root = Collection( resolver.collection() );
59
 
  } else
60
 
    return -1;
61
 
 
62
 
  XmlWriteJob writer( root, args->getOption( "output" ) );
63
 
  if ( !writer.exec() ) {
64
 
    kError() << writer.exec();
65
 
    return -1;
66
 
  }
67
 
}