~ubuntu-branches/ubuntu/trusty/baloo/trusty

« back to all changes in this revision

Viewing changes to .pc/upstream_git/0028-FileIndexingJobTest-Test-when-multiple-files-fail-to.patch/src/file/autotest/fileindexingjob/extractor.cpp

  • Committer: Package Import Robot
  • Author(s): Harald Sitter
  • Date: 2014-04-07 12:35:02 UTC
  • Revision ID: package-import@ubuntu.com-20140407123502-96r3nm663m4cm8dz
Tags: 4:4.12.97-0ubuntu2
Blanket import fixes between 4.12.97 and current git KDE/4.13 in
debian/patches/upstream_git/

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of the KDE Baloo Project
 
3
 * Copyright (C) 2014  Vishesh Handa <me@vhanda.in>
 
4
 *
 
5
 * This library is free software; you can redistribute it and/or
 
6
 * modify it under the terms of the GNU Lesser General Public
 
7
 * License as published by the Free Software Foundation; either
 
8
 * version 2.1 of the License, or (at your option) version 3, or any
 
9
 * later version accepted by the membership of KDE e.V. (or its
 
10
 * successor approved by the membership of KDE e.V.), which shall
 
11
 * act as a proxy defined in Section 6 of version 3 of the license.
 
12
 *
 
13
 * This library is distributed in the hope that it will be useful,
 
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
16
 * Lesser General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU Lesser General Public
 
19
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 
20
 *
 
21
 */
 
22
 
 
23
#include <KAboutData>
 
24
#include <KCmdLineArgs>
 
25
#include <KLocale>
 
26
#include <KComponentData>
 
27
 
 
28
#include <QApplication>
 
29
#include <QTextStream>
 
30
#include <QDebug>
 
31
 
 
32
#include <signal.h>
 
33
#include <iostream>
 
34
 
 
35
int main(int argc, char* argv[])
 
36
{
 
37
    KAboutData aboutData("baloo_file_extractor_dummy", 0, KLocalizedString(),
 
38
                         "0.1", KLocalizedString());
 
39
 
 
40
    KCmdLineArgs::init(argc, argv, &aboutData);
 
41
 
 
42
    KCmdLineOptions options;
 
43
    options.add("+[url]", KLocalizedString());
 
44
 
 
45
    KCmdLineArgs::addCmdLineOptions(options);
 
46
    const KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
 
47
 
 
48
    int argCount = args->count();
 
49
    if (argCount == 0) {
 
50
        QTextStream err(stderr);
 
51
        err << "Must input url/id of the file to be indexed";
 
52
 
 
53
        return 1;
 
54
    }
 
55
 
 
56
    KComponentData data(aboutData, KComponentData::RegisterAsMainComponent);
 
57
 
 
58
    QByteArray arr = qgetenv("BALOO_EXTRACTOR_FAIL_FILE");
 
59
    if (arr.isEmpty()) {
 
60
        return 0;
 
61
    }
 
62
 
 
63
    QString failFile = QString::fromUtf8(arr);
 
64
 
 
65
    for (int i = 0; i < args->count(); i++) {
 
66
        QString fid = args->arg(i);
 
67
        if (fid == failFile) {
 
68
            // kill oneself
 
69
            raise(SIGKILL);
 
70
            return -1;
 
71
        }
 
72
    }
 
73
 
 
74
    return 0;
 
75
}