Example #1
0
//! [1]
void NfcReceiver::receivedInvokeTarget(const bb::system::InvokeRequest& request)
{
    // The data contains our NDEF message
    const QByteArray data = request.data();

    // Create out NDEF message
    const QtMobilitySubset::QNdefMessage ndefMessage = QtMobilitySubset::QNdefMessage::fromByteArray(data);

    // Fill the model with the single records
    m_messageRecords->clear();

    for (int i = 0; i < ndefMessage.size(); ++i) {
        const QtMobilitySubset::QNdefRecord record = ndefMessage.at(i);

        QVariantMap entry;
        entry["tnfType"] = record.typeNameFormat();
        entry["recordType"] = QString::fromLatin1(record.type());
        entry["payload"] = QString::fromLatin1(record.payload());
        entry["hexPayload"] = QString::fromLatin1(record.payload().toHex());

        m_messageRecords->append(entry);
    }

    emit messageReceived();
}
void MainMenu::receivedInvokeRequest(const bb::system::InvokeRequest& request) {

    QByteArray data = request.data();
    QtMobilitySubset::QNdefMessage ndefMessage = QtMobilitySubset::QNdefMessage::fromByteArray(data);

    emit launchReader(QString("Tag read event detected"));

    handleNdefRequest(ndefMessage);
}
void ApplicationUI::onInvoked(const bb::system::InvokeRequest& invokeRequest) {

	if(invokeRequest.action() == "bb.action.SEARCH.EXTENDED") {
		// Begin searching in app
		_root->setProperty("searchString", QString(invokeRequest.data()));
	} else {
		// some other invocation..
	}
}
void ApplicationUI::onInvoked(const bb::system::InvokeRequest &request)
{
    qDebug() << "XXXX Received invoke=" << request.action();

    if (request.action().compare(WAKEME_INVOKE_ACTION_STARTAPP) == 0) {

        qDebug() << "XXXX Application Started started via Invoke with data: " << request.data().data() << endl;

        JsonDataAccess jda;
        QVariant parsedPayload = jda.loadFromBuffer(request.data());
        if (!jda.hasError()) {
            handleBeaconEvent(parsedPayload.toMap());
        } else {
            qWarning() << "XXXX ApplicationUI::onInvoked() - JSON parse error" << request.data() << endl;
        }

    } else {
        qWarning() << "XXXX received invocation request we don't handle:" << request.action() << endl;
    }
}
Example #5
0
void TranslationInterface::onInvoked(const bb::system::InvokeRequest &request)
{
    if (request.mimeType() != "text/plain")
        return;

    setSourceText(QString::fromUtf8(request.data()));

#ifdef WITH_ANALYTICS
    if (m_privacyLevel == NoPrivacy) {
        QVariantMap props;
        fillTranslationProperties(props);
        m_analytics->trackEvent("Invoked", props, true);
    }
#endif

    retranslate();
}
Example #6
0
void MainMenu::receivedInvokeRequest(const bb::system::InvokeRequest& request) {

	qDebug() << "XXXX invoked by iF: " << request.target() << " MIME=" << request.mimeType() << " ACTION=" << request.action() << " URI=" << request.uri();
	QByteArray data = request.data();
	qDebug() << "XXXX got data";
	if (request.mimeType().compare("application/vnd.rim.nfc.ndef") == 0)
	{
		qDebug("XXXX launched because an NFC tag has been presented");
		emit launchEventLog();
		_nfcManager = NfcManager::getInstance();
		_nfcManager->handleTagReadInvocation(data);
	}
	else {
		if (request.mimeType().compare("application/vnd.bb.nfc_transaction") == 0) {
			qDebug("XXXX launched because an NFC card emulation transaction event has been notified by an applet in the secure element");
			QString json = QString(data);
			qDebug() << "XXXX " << json;
			_systemDialog->setBody(json);
			_systemDialog->show();
		}
	}
}
Example #7
0
//! [2]
void xandosdroid::onInvoked(const bb::system::InvokeRequest& request) {
    if (request.action().compare("bb.action.START") == 0) {
        qDebug() << "XandOsDroid : start requested";
        // once the headless is started, communicate back to ui that its ready to play
        connectToServer();
    } else if (request.action().compare("bb.action.STOP") == 0) {
        qDebug() << "XandOsDroid: stop request";
        // terminate headless droid
        terminateDroid();
    } else if (request.action().compare("bb.action.CHOICE") == 0) {
        int choice = QString(request.data()).toInt();
        qDebug() << "XandOsDroid: received user choice: " << choice;
        // mark the user selection in the grid matrix and update the
        // game matrix state
        select(choice, 1);
        // verify there are still moves available
        if (availableChoices().isEmpty()) {
            qDebug() << "XandOsDroid: game over!";
            terminateDroid();
        }
        // Check whether you have any two in a row sequences
        int nextM = nextMove(-2);
        // If no, than block the user based on his possible selections for
        // a consecutive sequence
        if (-1 == nextM) {
            nextM = nextMove(1);
        }
        qDebug() << "XandOsDroid: droid selection: " << nextM;
        // send your next selection to the UI.
        sendSelection(nextM);

    } else {
        qDebug() << "XandOsDroid : unknown service request "
                << request.action();
    }
}
void HeadlessHubIntegration::onInvoked(const bb::system::InvokeRequest& request)
{
    qDebug() << "HeadlessHubIntegration: onInvoked: HeadlessHubIntegration was invoked";

    // Sometimes this method gets invoked before the constructor initializes fully so the following code should handle this scenario.
    initialize();

	if(request.action().compare("bb.action.system.STARTED") == 0) {
		qDebug() << "HeadlessHubIntegration: onInvoked: HeadlessHubIntegration : auto started";
	} else if(request.action().compare("bb.action.START") == 0) {
		qDebug() << "HeadlessHubIntegration: onInvoked: HeadlessHubIntegration : start";
	} else if(request.action().compare("bb.action.STOP") == 0) {
		qDebug() << "HeadlessHubIntegration: onInvoked: HeadlessHubIntegration : stop";
		//_app->quit();
		_app->requestExit();

    } else if(request.action().compare("bb.action.MARKREAD") == 0) {
        qDebug() << "HeadlessHubIntegration: onInvoked: mark read" << request.data();
        JsonDataAccess jda;

        QVariantMap objectMap = (jda.loadFromBuffer(request.data())).toMap();
        QVariantMap attributesMap = objectMap["attributes"].toMap();

        markHubItemRead(attributesMap);

    } else if(request.action().compare("bb.action.MARKUNREAD") == 0) {
        qDebug() << "HeadlessHubIntegration: onInvoked: mark unread" << request.data();
        JsonDataAccess jda;

        QVariantMap objectMap = (jda.loadFromBuffer(request.data())).toMap();
        QVariantMap attributesMap = objectMap["attributes"].toMap();

        markHubItemUnread(attributesMap);

    } else if(request.action().compare("bb.action.MARKPRIORREAD") == 0) {
        JsonDataAccess jda;

        qint64 timestamp = (jda.loadFromBuffer(request.data())).toLongLong();
        QDateTime date = QDateTime::fromMSecsSinceEpoch(timestamp);

        qDebug() << "HeadlessHubIntegration: onInvoked: mark prior read : " << timestamp << " : " << request.data();

        _testAccount->markHubItemsReadBefore(_testAccount->categoryId(), timestamp);

    } else if(request.action().compare("bb.action.DELETE") == 0) {
        qDebug() << "HeadlessHubIntegration: onInvoked: HeadlessHubIntegration : delete" << request.data();
        JsonDataAccess jda;

        QVariantMap objectMap = (jda.loadFromBuffer(request.data())).toMap();
        QVariantMap attributesMap = objectMap["attributes"].toMap();

        removeHubItem(attributesMap);

    } else if(request.action().compare("bb.action.DELETEPRIOR") == 0) {
        JsonDataAccess jda;

        qint64 timestamp = (jda.loadFromBuffer(request.data())).toLongLong();
        QDateTime date = QDateTime::fromMSecsSinceEpoch(timestamp);

        qDebug() << "HeadlessHubIntegration: onInvoked: mark prior delete : " << timestamp << " : " << request.data();

        _testAccount->removeHubItemsBefore(_testAccount->categoryId(), timestamp);

    } else if(request.action().compare("bb.action.PUSH") == 0) {
        qDebug() << "HeadlessHubIntegration: onInvoked: HeadlessHubIntegration : push";
        QByteArray message = _pushManager->getPayload(request);
        processNewMessage(message);
    } else {
        qDebug() << "HeadlessHubIntegration: onInvoked: unknown service request " << request.action() << " : " << request.data();
    }
}
Example #9
0
void ApplicationUI::onInvoked(const bb::system::InvokeRequest& request) {
    qDebug() << "invoke!" << request.action();

    if(request.action().compare("bb.action.VIEW") == 0 || request.action().compare("bb.action.OPEN") == 0) {
//         qDebug() << "HubIntegration: onInvoked: view item: " << request.data();

         JsonDataAccess jda;

         QVariantMap objectMap = (jda.loadFromBuffer(request.data())).toMap();
         QVariantMap itemMap = objectMap["attributes"].toMap();


         QVariantList items = m_Settings.value("hub/items").toList();

         QString urlToOpen;
         for(int index = 0; index < items.size(); index++) {
             QVariantMap item = items.at(index).toMap();
             QString sourceId = item["messageid"].toString();

              if (item["sourceId"].toString() == itemMap["messageid"].toString() ||
                  item["sourceId"].toString() == itemMap["sourceId"].toString()) {

                  qDebug() << "FOUD!";
                  urlToOpen = item["url"].toString();

                  break;
              }
         }

         qDebug() << "URL TO OPEN: " << urlToOpen;

         QmlDocument *qml = QmlDocument::create("asset:///StartupCardThread.qml")
                                                          .parent(this);

         m_root = qml->createRootObject<NavigationPane>();
         qml->setContextProperty("_app", this);
         m_app->setScene(m_root);

         QObject *thread = m_root->findChild<QObject*>("pageThread");
         if(thread != NULL) {
             thread->setProperty("urlPage", urlToOpen);

             bb::device::DisplayInfo display;
             QDeclarativePropertyMap* displayDimensions = new QDeclarativePropertyMap;
             displayDimensions->insert( "width", QVariant( display.pixelSize().width() ) );
             displayDimensions->insert( "height", QVariant( display.pixelSize().height() ) );
             qml->setContextProperty( "DisplayInfo", displayDimensions );
         } else
             qDebug() << "pageThread variable is not found in the qml document :(";


         InvokeRequest request;
         request.setTarget("com.amonchakai.HFR10Service");
         request.setAction("bb.action.MARKREAD");
         request.setMimeType("hub/item");
         request.setUri(QUrl("pim:"));

         QByteArray bytes;
         jda.saveToBuffer(objectMap, &bytes);
         request.setData(bytes);

         m_InvokeManager->invoke(request);

    }

    if(request.action().compare("bb.action.COMPOSE") == 0) {
        QmlDocument *qml = QmlDocument::create("asset:///StartupCardCompose.qml")
                                                                  .parent(this);

        m_root = qml->createRootObject<NavigationPane>();
        qml->setContextProperty("_app", this);

        m_app->setScene(m_root);

        QString directory = QDir::homePath() + QLatin1String("/HFRBlackData");
        if (!QFile::exists(directory)) {
            return;
        }

        QFile file(directory + "/UserID.txt");

        QString userName;
        if (file.open(QIODevice::ReadOnly)) {
            QDataStream stream(&file);
            stream >> userName;

            file.close();
        }
void HeadlessApplication::onInvoked(const bb::system::InvokeRequest& request) {
    qDebug() << "invoke Headless!" << request.action();
    initializeHub();

    if(request.action().compare("bb.action.system.STARTED") == 0) {
            qDebug() << "HeadlessHubIntegration: onInvoked: HeadlessHubIntegration : auto started";
        } else if(request.action().compare("bb.action.START") == 0) {
            qDebug() << "HeadlessHubIntegration: onInvoked: HeadlessHubIntegration : start";
            resynchHub();
        } else if(request.action().compare("bb.action.DELETE.ACCOUNT") == 0) {
            qDebug() << "HeadlessHubIntegration: onInvoked: DELETE ACCOUNT CALLED";
            m_Hub->remove();

        } else if(request.action().compare("bb.action.system.TIMER_FIRED") == 0) {
            qDebug() << "HeadlessHubIntegration: onInvoked: bb.action.system.TIMER_FIRED";
            resynchHub();

        } else if(request.action().compare("bb.action.STOP") == 0) {
            qDebug() << "HeadlessHubIntegration: onInvoked: HeadlessHubIntegration : stop";
            m_app->requestExit();

        } else if(request.action().compare("bb.action.MARKREAD") == 0) {
            //qDebug() << "HeadlessHubIntegration: onInvoked: mark read" << request.data();
            bb::data::JsonDataAccess jda;

            QVariantMap objectMap = (jda.loadFromBuffer(request.data())).toMap();
            QVariantMap attributesMap = objectMap["attributes"].toMap();

            {

                markHubItemRead(attributesMap);
            }


        } else if(request.action().compare("bb.action.MARKUNREAD") == 0) {
            //qDebug() << "HeadlessHubIntegration: onInvoked: mark unread" << request.data();
            bb::data::JsonDataAccess jda;

            QVariantMap objectMap = (jda.loadFromBuffer(request.data())).toMap();
            QVariantMap attributesMap = objectMap["attributes"].toMap();

            {
                markHubItemUnread(attributesMap);
            }

        } else if(request.action().compare("bb.action.MARKPRIORREAD") == 0) {
            bb::data::JsonDataAccess jda;

            qint64 timestamp = (jda.loadFromBuffer(request.data())).toLongLong();

            QVariantList hubItems = m_Hub->items();
            for(int i = 0 ; i < hubItems.size() ; ++i) {
                QVariantMap item = hubItems.at(i).toMap();

                if(item["timestamp"].toLongLong() < timestamp) {

                    markHubItemRead(item);
                }
            }


        } else if(request.action().compare("bb.action.DELETE") == 0) {
            // qDebug() << "HeadlessHubIntegration: onInvoked: HeadlessHubIntegration : delete" << request.data();
            bb::data::JsonDataAccess jda;

            QVariantMap objectMap = (jda.loadFromBuffer(request.data())).toMap();
            QVariantMap attributesMap = objectMap["attributes"].toMap();

            {
                removeHubItem(attributesMap);
            }

        } else if(request.action().compare("bb.action.DELETEPRIOR") == 0) {
            bb::data::JsonDataAccess jda;

            qint64 timestamp = (jda.loadFromBuffer(request.data())).toLongLong();
            QVariantList hubItems = m_Hub->items();
            for(int i = 0 ; i < hubItems.size() ; ++i) {
                QVariantMap item = hubItems.at(i).toMap();

                if(item["timestamp"].toLongLong() < timestamp) {
                    removeHubItem(item);
                }
            }


            qDebug() << "HeadlessHubIntegration: onInvoked: mark prior delete : " << timestamp << " : " << request.data();

        } else {
            qDebug() << "HeadlessHubIntegration: onInvoked: unknown service request " << request.action() << " : " << request.data();
        }

}
Example #11
0
void Card::on_invoked(const bb::system::InvokeRequest& request)
{
    qDebug() << "==== Card::onInvoked() START ====";

    emit load_configuration();

    QVariantMap metadata    = request.metadata();
    QString source          = request.source().installId() + " - " + request.source().groupId();
    QString listId          = QString::number(request.listId());
    QString action          = request.action();
    QString target          = request.target();
    QString uri             = request.uri().toString();
    QString data            = QString::fromUtf8(request.data());

    qDebug() << "==== Card::onInvoked(): action: " << action << data << ", uri: " << uri;

    if(action == "bb.action.VIEW")
    {
        JsonDataAccess jda;
        QVariantMap objectMap   = (jda.loadFromBuffer(data)).toMap();
        QVariantMap itemMap     = objectMap["attributes"].toMap();
        QString messageID1      = itemMap["messageid"].toString();
        QString sourceID1       = itemMap["sourceId"].toString();

        QString itemsFromJSON   = Utilities::get_string_from_file("data/hub_items.json");

        QVariantList itemsFromJSONList = jda.loadFromBuffer(itemsFromJSON).toList();

        qDebug() << "**** Card::onInvoked: itemsFromJSONList: " << itemsFromJSONList.size() << ", sourceId1: " << sourceID1 << ", messageID1: " << messageID1;

        for(int index = 0; index < itemsFromJSONList.size(); index++)
        {
            QVariantMap attributes    = itemsFromJSONList.at(index).toMap();
            QString pageName          = attributes["thePage"].toString();
            QString theData           = attributes["theData"].toString();
            QString sourceID2         = attributes["sourceId"].toString();

            qDebug() << "**** Card::onInvoked: thePage" << pageName << ", theData: " << theData << ", sourceId2: " << sourceID2;

            if (sourceID2 == messageID1 || sourceID2 == sourceID1)
            {
                InvokeRequest request2;
                request2.setTarget("com.nemory.Insta10HeadlessService");
                request2.setAction("bb.action.MARKREAD");
                request2.setMimeType("hub/item");
                request2.setUri(QUrl("pim:"));

                QByteArray bytes;
                jda.saveToBuffer(objectMap, &bytes);
                request2.setData(bytes);

                InvokeTargetReply *reply = _invoke_manager->invoke(request2);

                if (!reply)
                {
                    qDebug() << "**** FAILED Card::onInvoked: " << reply->errorCode();
                    reply->deleteLater();
                }

                QmlDocument *pageDocument  = QmlDocument::create("asset:///pages/" + pageName).parent(this);
                _page = pageDocument->createRootObject<Page>();
                _page->setProperty("is_card", true);
                //_page->setActionBarVisibility((getSetting("backButton", "false") == "false") ? ChromeVisibility::Hidden : ChromeVisibility::Default);
                _navigation_pane->push(_page);
                Application::instance()->setScene(_navigation_pane);

                emit initialize_card();

                emit opened_item(attributes, theData);

                break;
            }
        }

        jda.deleteLater();
    }
    else if(action == "bb.action.COMPOSE")
    {

    }
    else if(action == "bb.action.SHARE")
    {

        startHeadless();
    }
    else
    {
        startHeadless();
    }
}