1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
/*
* Copyright (C) 2014 Canonical Ltd
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authored by Kyle Nitzsche <kyle.nitzsche@canonical.com>
*
*/
#include "manager.h"
#include "types.h"
#include "textevent.h"
#include "texteventattachment.h"
#include <QStringList>
#include <QString>
#include <QDebug>
#include <QCoreApplication>
using namespace History;
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
QStringList args = QCoreApplication::arguments();
if (args.size() == 1) {
qDebug() << "Usage: maketextevents accountId";
return 1;
}
//TODO let the user pass numbers as args so they can corrspond to
//the user's contacts
QString number0 = "1234567890";
QString number1 = "01234456789";
QString number2 = "0987654321";
QString number;
int idx = 0;
QDateTime datetime = QDateTime::currentDateTime();
int control = 0;
while (idx < 50) {
idx ++;
if (control == 0) {
qDebug() << "=== control is 0";
number = number0;
control++;
} else if (control == 1) {
qDebug() << "=== control is 1";
number = number1;
control++;
} else {
qDebug() << "=== control is else";
control = 0;
number = number2;
datetime = datetime.addDays(-1);
}
const QString accountId = args.at(1);
Thread thread = Manager::instance()->threadForParticipants(accountId,
EventTypeText,
QStringList() << number,
MatchCaseSensitive,
true);
const QString threadId = thread.threadId();
const QString eventId = QString::number(QDateTime::currentMSecsSinceEpoch());
const QString sender = number;
TextEvent ev(accountId,
threadId,
eventId,
sender,
datetime,
true,
QString::fromStdString("the text message"),
MessageTypeText,
MessageStatusUnknown,
datetime,
QString::fromStdString("the subject"));
QList<Event> events;
events.append(ev);
Manager::instance()->writeEvents(events);
}
}
|