719
703
"JobResultAvailable",\
721
705
SLOT(CatchallLocalJobResultAvailableSignalsHandler(QDBusMessage)))) {
723
706
qDebug("Failed to connect slot for JobResultAvailable events");
726
709
// to get only the *jobs* that are designated by the whitelist.
727
m_desired_job_list = GenerateDesiredJobList(m_job_list);
710
m_desired_job_list = GenerateDesiredJobList();
729
712
// This is just the list of all provider jobs marked "local"
730
m_local_job_list = GetLocalJobs();
732
// desired local jobs are the Union of all local jobs and the desired jobs
733
m_desired_local_job_list = JobTreeNode::FilteredJobs(m_local_job_list, \
713
m_local_job_list = GetLocalJobs(m_desired_job_list);
736
715
// Now I update the desired job list.
737
716
QStringList errors = UpdateDesiredJobList(m_session, \
738
m_desired_local_job_list);
739
718
if (errors.count() != 0) {
740
719
qDebug("UpdateDesiredJobList generated errors:");
1044
1024
const QString &flags, \
1045
1025
const QString &running_job_name, \
1046
1026
const QString &title, \
1047
const QByteArray& app_blob)
1027
const QByteArray& app_blob, \
1028
const QString &app_id)
1049
1030
qDebug() << "GuiEngine::SetSessionStateMetadata() \n" \
1050
1031
<< " " << session.path() \
1051
1032
<< "\nflags : " << flags \
1052
1033
<< "\nrunning_job_name: " << running_job_name \
1053
1034
<< "\ntitle : " << title \
1054
<< "\napp_blob : " << app_blob;
1035
<< "\napp_blob : " << app_blob \
1036
<< "\napp_id : " << app_id;
1056
1038
QMap<QString,QVariant> metadata;
1255
1238
return session;
1258
QList<QDBusObjectPath> GuiEngine::GetLocalJobs(void)
1241
QList<QDBusObjectPath> GuiEngine::GetLocalJobs(const QList<QDBusObjectPath> &job_list)
1260
1243
QList<QDBusObjectPath> generator_jobs;
1262
QList<PBTreeNode*> jobnodes = GetJobNodes();
1264
QList<PBTreeNode*>::const_iterator iter = jobnodes.begin();
1266
while(iter != jobnodes.end()) {
1268
PBTreeNode* node = *iter;
1270
QList<PBObjectInterface*> interfaces = node->interfaces;
1272
// Now find the plainbox interface
1273
for (int i=0; i< interfaces.count(); i++) {
1274
if (interfaces.at(i)->interface.compare(CheckBoxJobDefinition1) == 0) {
1276
// Now we need to find the plugin property
1279
variant = interfaces.at(i)->properties.find("plugin").value();
1281
if (variant.isValid() && variant.canConvert(QMetaType::QString)) {
1282
if (variant.toString().compare("local") == 0) {
1284
// now append this to the list of jobs for CreateSession()
1285
generator_jobs.append(node->object_path);
1245
QListIterator<QDBusObjectPath> jobs(job_list);
1246
while (jobs.hasNext()) {
1247
QDBusObjectPath job = jobs.next();
1248
QDBusInterface job_iface(PBBusName, \
1250
CheckBoxJobDefinition1, \
1251
QDBusConnection::sessionBus());
1252
if (!job_iface.isValid()) {
1253
throw std::runtime_error("Could not connect to com.canonical.certification.CheckBox.JobDefinition1 interface");
1255
if (job_iface.property("plugin").toString() == "local") {
1256
generator_jobs.append(job);
1257
qDebug() << job.path();
1294
1261
return generator_jobs;
1684
QList<QDBusObjectPath> GuiEngine::GenerateDesiredJobList(QList<QDBusObjectPath> job_list)
1651
QList<QDBusObjectPath> GuiEngine::GenerateDesiredJobList()
1686
1653
QList<QDBusObjectPath> desired_job_list;
1688
// Iterate through each whitelist, and check if it Designates each job
1655
QDBusInterface iface(PBBusName, \
1658
QDBusConnection::sessionBus());
1659
if (!iface.isValid()) {
1660
qDebug("Could not connect to \
1661
com.canonical.certification.PlainBox.Service1 interface");
1662
return desired_job_list;
1665
QList<QDBusObjectPath> whitelists;
1689
1666
QMap<QDBusObjectPath, bool>::iterator iter = whitelist.begin();
1690
while(iter != whitelist.end()) {
1692
// Try it if we have selected this whitelist
1667
while (iter != whitelist.end()) {
1693
1668
if (iter.value()) {
1694
QDBusObjectPath white = iter.key();
1697
for(int i=0; i < job_list.count(); i++) {
1699
QDBusObjectPath job = job_list.at(i);
1701
// Does the whitelist designate this job?
1702
bool ok = WhiteListDesignates(white,job);
1704
// If ANY whitelist wants this job, we say yes
1706
if (!desired_job_list.contains(job)) {
1707
desired_job_list.append(job);
1669
whitelists.append(iter.key());
1674
QDBusReply<opath_array_t> reply = \
1675
iface.call("SelectJobs", \
1676
QVariant::fromValue<opath_array_t>(whitelists));
1678
if (reply.isValid()) {
1679
desired_job_list = reply.value();
1681
qDebug("Failed to CreateSession()");
1717
1683
return desired_job_list;
2085
QString GuiEngine::SendDataViaTransport(const QDBusObjectPath session, \
2086
const QString &transport, \
2087
const QString &url, \
2088
const QString &option_list, \
2089
const QString &data)
2091
QDBusInterface iface(PBBusName, \
2094
QDBusConnection::sessionBus());
2095
if (!iface.isValid()) {
2096
qDebug() << "Could not connect to " << PBInterfaceName;
2097
return QString("Could not connect to " + PBInterfaceName);
2100
QDBusReply<QString> reply = \
2101
iface.call("SendDataViaTransport", \
2102
QVariant::fromValue<QString>(session.path()), \
2103
QVariant::fromValue<QString>(transport), \
2104
QVariant::fromValue<QString>(url), \
2105
QVariant::fromValue<QString>(option_list), \
2106
QVariant::fromValue<QString>(data));
2107
if (!reply.isValid()) {
2108
qDebug() << "Error: " << reply.error();
2109
return QString("Error: " + reply.error().message());
2114
const QString GuiEngine::SendSubmissionViaCertificationTransport( \
2115
const QString &submission_path,
2116
const QString &secure_id,
2117
const bool submit_to_hexr)
2119
QDBusInterface iface(PBBusName, \
2122
QDBusConnection::sessionBus());
2123
if (!iface.isValid()) {
2124
qDebug() << "Could not connect to " << PBInterfaceName;
2125
return QString("Could not connect to " + PBInterfaceName);
2129
QDBusReply<QStringList> reply = iface.call("GetAllTransports");
2130
if (!reply.isValid()) {
2131
qDebug() << "Error: " << reply.error();
2132
return QString("Error: " + reply.error().message());
2134
if (!reply.value().contains("certification")) {
2135
return QString("'certification' is not a supported transport");
2138
// Read submission file
2139
QFile submissionFile(submission_path);
2140
QByteArray submissionData;
2141
if (submissionFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
2142
submissionData = submissionFile.readAll();
2143
submissionFile.close();
2146
qDebug() << "Could not read " << submission_path;
2147
return QString("Could not read " + submission_path);
2150
QStringList options;
2151
options << QString("secure_id=" + secure_id);
2152
options << QString("submit_to_hexr=" + QString::number(submit_to_hexr));
2154
return SendDataViaTransport(m_session, "certification", \
2155
"https://certification.canonical.com/submissions/submit/", \
2156
options.join(','), \
2160
const QString GuiEngine::SendSubmissionViaLaunchpadTransport( \
2161
const QString &submission_path,
2162
const QString &email)
2164
QDBusInterface iface(PBBusName, \
2167
QDBusConnection::sessionBus());
2168
if (!iface.isValid()) {
2169
qDebug() << "Could not connect to " << PBInterfaceName;
2170
return QString("Could not connect to " + PBInterfaceName);
2174
QDBusReply<QStringList> reply = iface.call("GetAllTransports");
2175
if (!reply.isValid()) {
2176
qDebug() << "Error: " << reply.error();
2177
return QString("Error: " + reply.error().message());
2179
if (!reply.value().contains("launchpad")) {
2180
return QString("'launchpad' is not a supported transport");
2183
// Read submission file
2184
QFile submissionFile(submission_path);
2185
QByteArray submissionData;
2186
if (submissionFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
2187
submissionData = submissionFile.readAll();
2188
submissionFile.close();
2191
qDebug() << "Could not read " << submission_path;
2192
return QString("Could not read " + submission_path);
2195
QStringList options;
2196
options << QString("field.emailaddress=" + email);
2198
return SendDataViaTransport(m_session, "launchpad", \
2199
"https://launchpad.net/+hwdb/+submit", \
2200
options.join(','), \
2119
2204
void GuiEngine::CatchallIOLogGeneratedSignalsHandler(QDBusMessage /*msg*/)
2121
2206
/* TODO - This could be used for updating a live display of the IO Log