1 /*
2  * This file is part of the KDE Akonadi Search Project
3  * SPDX-FileCopyrightText: 2013 Vishesh Handa <me@vhanda.in>
4  *
5  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6  *
7  */
8 
9 #include "../contactcompleter.h"
10 
11 #include <QCoreApplication>
12 #include <QDebug>
13 #include <QElapsedTimer>
14 #include <QTimer>
15 #include <iostream>
16 
17 #include <Akonadi/ItemFetchJob>
18 #include <Akonadi/ItemFetchScope>
19 
20 #include <KMime/Message>
21 
22 using namespace Akonadi::Search::PIM;
23 
24 class App : public QCoreApplication
25 {
26     Q_OBJECT
27 public:
28     App(int &argc, char **argv, int flags = ApplicationFlags);
29 
30     QString m_query;
31 
32 private Q_SLOTS:
33     void main();
34 };
35 
main(int argc,char ** argv)36 int main(int argc, char **argv)
37 {
38     App app(argc, argv);
39 
40     if (argc != 2) {
41         qWarning() << "Proper args required";
42         exit(0);
43     }
44     app.m_query = QString::fromUtf8(argv[1]);
45 
46     return app.exec();
47 }
48 
App(int & argc,char ** argv,int flags)49 App::App(int &argc, char **argv, int flags)
50     : QCoreApplication(argc, argv, flags)
51 {
52     QTimer::singleShot(0, this, &App::main);
53 }
54 
main()55 void App::main()
56 {
57     ContactCompleter com(m_query, 100);
58 
59     QElapsedTimer timer;
60     timer.start();
61 
62     const QStringList emails = com.complete();
63     for (const QString &em : std::as_const(emails)) {
64         std::cout << em.toUtf8().data() << std::endl;
65     }
66 
67     qDebug() << timer.elapsed();
68     quit();
69 }
70 
71 #include "contactcompletiontest.moc"
72