void ApplicationUI::invoke(QString platform)
{
    // Create a new invocation request
    InvokeRequest request;
    if (platform == "BBM") {
        request.setAction("bb.action.BBMCHAT");
        request.setUri("pin:2B1F7E7B");
        request.setTarget("sys.bbm.sharehandler");
    }
    if (platform == "EMAIL") {
        request.setAction("bb.action.COMPOSE");
        bb::Application* thisApp;
        const QString uri = "mailto:[email protected]?subject=" + thisApp->applicationName() + "%20version%20" + thisApp->applicationVersion();
        request.setUri(uri);
        request.setMimeType("text/plain");
        request.setData("Test");
        request.setTarget("sys.pim.uib.email.hybridcomposer");
    }
    if (platform == "TWITTER") {
        request.setAction("bb.action.VIEW");
        request.setUri("twitter:connect:RodgerLeblanc");
        request.setTarget("com.twitter.urihandler");
    }
    if (platform == "BBW") {
        request.setAction("bb.action.OPEN");
        request.setUri("appworld://vendor/70290");
        request.setTarget("sys.appworld");
    }
    // Start the invocation
    InvokeManager* invokeManager = new InvokeManager(this);
    invokeManager->invoke(request);
    invokeManager->deleteLater();
}
Пример #2
0
void ApplicationUI::invoke(const QString& platform, const QString& data) {
    // Some invoke only works in C++, that's why all my invoke are done in C++
    qDebug() << "ApplicationUI::invoke()" << platform << data;

    // Load from previous saved information
    const QString jsonPathFile = QDir::currentPath() + "/app/native/assets/InvokeTargets.json";
    QVariantMap invokeTargets = jda.load(jsonPathFile).toMap()[platform].toMap();
    qDebug() << "invokeTargets:" << invokeTargets;

    // Create a new invocation request
    InvokeRequest request;
    if (!invokeTargets["target"].isNull())
        request.setTarget(invokeTargets["target"].toString());

    if (!invokeTargets["action"].isNull())
        request.setAction(invokeTargets["action"].toString());

    if (!invokeTargets["mimeType"].isNull())
        request.setMimeType(invokeTargets["mimeType"].toString());

    if (!invokeTargets["uri"].isNull())
        request.setUri(invokeTargets["uri"].toString() + data);

    request.setData(data.toUtf8());

    // Start the invocation
    m_invokeManager->invoke(request);
    connect(m_invokeManager, SIGNAL(childCardDone(const bb::system::CardDoneMessage&)), this, SLOT(invokeNext()));
}
Пример #3
0
void ApplicationUI::loadEvent(int id, int account, QDateTime start)
{
	QString startString = start.toString("yyyy-MM-dd hh:mm:ss");
	qDebug() << "FMI ######### received event " << id << " account " << account << " beginning " << startString;

	InvokeRequest invokeRequest;
	invokeRequest.setAction("bb.calendar.OPEN");
	invokeRequest.setTarget("sys.pim.calendar.viewer.ics");
	invokeRequest.setMimeType("text/calendar");
	QVariantMap data;
	data.insert("accountId", account);
	data.insert("eventId", id);
	data.insert("type", "event");
	data.insert("start", startString);
//	data.insert("start", "2013-12-07 11:00:00");

	//invokeRequest.setData(bb::PpsObject::encode(data, NULL));
	bool ok;
	QByteArray encData = bb::PpsObject::encode(data, &ok);
	if (ok) {
		invokeRequest.setData(encData);
		// Start the invocation
		const InvokeReply *reply = m_invokeManager->invoke(invokeRequest);
	//	reply->setParent(this);

		connect(reply, SIGNAL(finished()), this, SLOT(processInvokeReply()));

		connectResult = connect(m_invokeManager, SIGNAL(childCardDone(const bb::system::CardDoneMessage&)), this, SLOT(childCardDone(const bb::system::CardDoneMessage&)));
	}
}
Пример #4
0
void ApplicationUI::sendToHL(const QString& command, QString data) {
    InvokeRequest request;
    request.setTarget(SERVICE_APP_TARGET);
    request.setAction(QString(SERVICE_APP_TARGET) + "." + command.toUpper());
    if (!data.isEmpty())
        request.setData(data.toUtf8());
    m_invokeManager->invoke(request);
}
void ApplicationUI::startChat(const QString& text) {
	InvokeRequest bbmRequest;
	bbmRequest.setTarget("sys.bbm.chathandler");
	bbmRequest.setAction("bb.action.BBMCHAT");
	bbmRequest.setData(text.toUtf8());
	qDebug() << "start chat with BBM: " << text;
	mInvokeManager->invoke(bbmRequest);
}
void ApplicationUI::onRemoveScanRequest(const QString &address) {
    QByteArray data(address.toAscii().data());
    InvokeRequest request;
    request.setTarget(WAKEME_INVOKE_HEADLESS_SERVICE);
    request.setAction(WAKEME_INVOKE_ACTION_REMOVESCAN);
    request.setData(data);
    _invokeManager->invoke(request);
}
void ApplicationUI::shareTextWithBBM(const QString& text) {
	InvokeRequest bbmRequest;
	bbmRequest.setTarget("sys.bbm.sharehandler");
	bbmRequest.setAction("bb.action.SHARE");
	bbmRequest.setData(text.toUtf8());
	qDebug() << "share with BBM: " << text;
	mInvokeManager->invoke(bbmRequest);
	// TODO listen to InvokeTargetReply *reply to see if invocation was successfull
	// https://developer.blackberry.com/cascades/documentation/device_platform/invocation/sending_invocation.html
}
Пример #8
0
void ApplicationUI::lockThisApp(const QString& app)
{
    InvokeRequest request;
    request.setTarget(SERVICE_APP_TARGET);
    request.setAction(SERVICE_LOCK_THIS_APP_ACTION);
    request.setData(app.toUtf8());
    m_invokeManager->invoke(request);

    bb::Application::instance()->requestExit();
}
Пример #9
0
void ApplicationUI::openCalendar()
{
	InvokeRequest invokeRequest;
	invokeRequest.setAction("bb.calendar.OPEN");
	invokeRequest.setMimeType("text/calendar");
	QVariantMap data;
	data.insert("view", "agenda");
	invokeRequest.setData(bb::PpsObject::encode(data, NULL));

	// Start the invocation
	m_invokeManager->invoke(invokeRequest);
}
Пример #10
0
void TCUFPE::showCamera() {
	InvokeRequest cardRequest;
	cardRequest.setTarget("sys.camera.card");
	cardRequest.setAction("bb.action.CAPTURE");
	cardRequest.setData("photo");
	InvokeTargetReply* reply = m_iManager->invoke(cardRequest);
	reply->setParent(this);

	connect(m_iManager,
			SIGNAL(childCardDone(const bb::system::CardDoneMessage &)), this,
			SLOT(onCameraCardDone(const bb::system::CardDoneMessage &)));
	qDebug() << "waiting for you";
}
Пример #11
0
void App::createWinnerScrapCard()
{
    InvokeRequest cardRequest;
    cardRequest.setTarget("scrapcard.target");
    cardRequest.setAction("bb.action.CREATE");
    cardRequest.setMimeType("application/custom");
    qDebug() << "score" << m_pScoreCounter->seconds();
    cardRequest.setData(
            QByteArray().append(
                    QString(m_pSettings->getValueFor("player_name", "playerName")).append(",")).append(
                    QString::number(m_pScoreCounter->seconds())));

    m_pInvokeManager->invoke(cardRequest);
}
Пример #12
0
void App::invoke(int targetType, const QString &action, const QString &mime, const QString &uri, const QString &data, const QString &target) {
	iManager = new InvokeManager(this);

	InvokeRequest iRequest;

	if (action != 0 && action.length() > 0) {
		printf("################");
		printf(action.toAscii().constData());
		if (action != QString("All") && action != QString("Menu Actions")) {
			iRequest.setAction(action);
		} else if(target.length() <= 0){
			root->findChild<QObject*>("qlDialogMessage")->setProperty("text", "[" + action + "] is not a valid action type for an unbound invocation.");
			root->findChild<QObject*>("qcdDialog")->setProperty("visible", true);
			return;
		}
	}
	if (mime != 0 && mime.length() > 0) {
		printf("################");
		printf(mime.toAscii().constData());
		iRequest.setMimeType(mime);
	} else {
		root->findChild<QObject*>("qlDialogMessage")->setProperty("text", "MIME type must be specified!");
		root->findChild<QObject*>("qcdDialog")->setProperty("visible", true);
		return;
	}
	if (uri != 0 && uri.length() > 0) {
		printf("################");
		printf(uri.toAscii().constData());
		iRequest.setUri(uri);
	}
	if (data != 0 && data.length() > 0) {
		printf("################");
		printf(data.toAscii().constData());
		iRequest.setData(data.toUtf8());
	}
	if (target != 0 && target.length() > 0) {
		printf("################");
		printf(target.toAscii().constData());
		iRequest.setTarget(target);
	}

	iReply = iManager->invoke(iRequest);
	QObject::connect(iReply, SIGNAL(finished()), this, SLOT(processInvokeReply()));
	if (iReply == NULL) {
		root->findChild<QObject*>("qlDialogMessage")->setProperty("text", "Invoke Failed! InvokeReply is NULL.");
		root->findChild<QObject*>("qcdDialog")->setProperty("visible", true);
		return;
	}
}
void ApplicationUIBase::invoke_sms_compose(QString to, QString body, bool send)
{
    InvokeRequest request;
    request.setTarget("sys.pim.text_messaging.composer");
    request.setAction("bb.action.COMPOSE");

    QVariantMap map;
    map.insert("to", to);
    map.insert("body", body);
    map.insert("send", send);
    QByteArray requestData = PpsObject::encode(map, NULL);

    request.setData(requestData);
    _invoke_manager->invoke(request);
}
// Login/Connect with Foursquare
// This card will call back to your childCardDone slot with the appropriate
// response for the actions taken by the user.
//
// Pass in your client_id from your Foursquare API consumer.
//
// If the user authorizes your app or has already authorized you:
// The response reason will be "success" and the data block will have a
// json encoded access token which you can use for authenticated Foursquare
// requests. That response string looks something like this:
// { access_token: "masdfvasvawefafawvwef90we0900990092012" }
//
// If the user denies the authentication: the response reason will be "denied".
// If the user cancels the login without any action: the reason message will be "canceled"
void SocialInvocation::onSSO() {
	InvokeRequest cardRequest;
	cardRequest.setTarget("com.foursquare.blackberry.sso.card");
	cardRequest.setAction("bb.action.VIEW");
	cardRequest.setMimeType("sso/foursquare");

	// Pass in the client_id that you receive when registering
	// your app with Foursquare.
	//
	// You can register your app with Foursquare here:
	// https://foursquare.com/developers/apps
	//
	// For more information on Foursquare API credentials, see here:
	// https://developer.foursquare.com/overview/auth
	cardRequest.setData(QString("UFVANV2FBBFRPXSBXHCCKECVUDANDKP5KQFKICRCA1VAFV4V").toUtf8());

	m_invokeManager->invoke(cardRequest);
}
void CameraInvocation::show() {
    if (invokeReply_ && !invokeReply_->isFinished()) {
        // Don't send another invoke request if one is already pending.
        return;
    }

    InvokeRequest request;
    request.setTarget("sys.camera.card");
    request.setAction("bb.action.CAPTURE");
    request.setData("photo");  // TODO: use CameraOptionsType.mediaTypes
    invokeReply_ = invokeManager_.invoke(request);
    if (!invokeReply_) {
        fprintf(stderr, "Failed to send camera card invoke\n");
        return;
    }

    connect(invokeReply_, SIGNAL(finished()), SLOT(cameraCardReplyFinished));
}
void ApplicationUI::sendEmail() {
	ApplicationInfo appInfo(this);
	InvokeManager *manager = new InvokeManager(this);
	InvokeRequest request;
	request.setTarget("sys.pim.uib.email.hybridcomposer");
	request.setAction("bb.action.COMPOSE");
	request.setMimeType("message/rfc822");
	QVariantMap contentMap;
	contentMap.insert("to", QVariantList() << "*****@*****.**");
	contentMap.insert("subject", "[DS Package Tracker] Support or suggestion");
	contentMap.insert("body", "App version: " + appInfo.version());
	QVariantMap data;
	data.insert("data", contentMap);
	bool ok;
	request.setData(bb::PpsObject::encode(data, &ok));
	manager->invoke(request);
//	InvokeTargetReply* reply =
	manager->invoke(request); // #include <bb/system/InvokeTargetReply>
}
Пример #17
0
void ApplicationUI::pushNotificationHandler(bb::network::PushPayload &pushPayload)
{
    qDebug() <<pushPayload.data();
    createToast(pushPayload.data());

    Notification *notification = new Notification(NOTIFICATION_PREFIX + QString::number(1),this);
    notification->setTitle("FlippIt");
    notification->setBody(pushPayload.data());

    InvokeRequest invokeRequest;
    invokeRequest.setTarget("com.luan.FlippIt.invoke.open");
    invokeRequest.setAction(BB_OPEN_INVOCATION_ACTION);
    invokeRequest.setMimeType("text/plain");
    invokeRequest.setData(pushPayload.data());
    notification->setInvokeRequest(invokeRequest);

    notification->notify();
    copyItem(pushPayload.data());
}
Пример #18
0
//invoke the phone with a number prepoulated
void ApplicationUI::invokePhone() {
	InvokeManager invokeManager;
	InvokeRequest request;

	// What do we want the target application to do with it?
	request.setAction("bb.action.DIAL");

	// What are we sending?
	request.setMimeType("application/vnd.blackberry.phone.startcall");

    // Where is the data?
    QVariantMap map;
    map.insert("number", "15559223145"); // required
    map.insert("line_id", "cellular"); // optional
    QByteArray requestData = bb::PpsObject::encode(map, NULL);
    request.setData(requestData);

    InvokeTargetReply *reply = invokeManager.invoke(request);

}
Пример #19
0
void App::sendCommandToHeadless(const CommandMessage &command, const User &user)
{
	QVariantList invokeData;
	invokeData.append(QVariant(command.toMap()));

	if (!user.isEmpty()){
		invokeData.append(QVariant(user.toMap()));
	}

	QByteArray buffer;
	m_jsonDA->saveToBuffer(invokeData, &buffer);

    InvokeRequest request;
    request.setTarget(INVOKE_TARGET_KEY_PUSH);
    request.setAction(BB_PUSH_COLLECTOR_COMMAND_ACTION);
    request.setMimeType("text/plain");
    request.setData(buffer);
    m_invokeTargetReply = m_invokeManager->invoke(request);

    // Connect to the reply finished signal.
    checkConnectResult(QObject::connect(m_invokeTargetReply, SIGNAL(finished()), this, SLOT(onInvokeResult())));
}
Пример #20
0
//! [1]
void App::invoke() {
    // Create a new invocation request
    InvokeRequest request;

    // Setup the request properties according to the current configuration
    if (m_action.length() > 0) {
        request.setAction(m_action);
    }

    if (m_mimeType.length() > 0) {
        request.setMimeType(m_mimeType);
    }

    if (m_uri.length() > 0) {
        request.setUri(m_uri);
    }

    if (m_data.length() > 0) {
        request.setData(m_data.toUtf8());
    }

    if (m_target.length() > 0) {
        request.setTarget(m_target);
    }

    // Start the invocation
    const InvokeReply *reply = m_invokeManager->invoke(request);
    if (reply) {
        // Ensure that processInvokeReply() is called when the invocation has finished
        bool ok = connect(reply, SIGNAL(finished()), this,
                          SLOT(processInvokeReply()));
        Q_ASSERT(ok);
        Q_UNUSED(ok);
    } else {
        m_errorMessage = tr("Invoke Failed! Reply object is empty.");
        showErrorDialog();
        return;
    }
}
Пример #21
0
void App::pushNotificationHandler(bb::network::PushPayload &pushPayload)
{
    // Check for a duplicate push
    PushHistoryItem pushHistoryItem(pushPayload.id());

    if (m_pushNotificationService.checkForDuplicatePush(pushHistoryItem)) {
        // A duplicate was found, stop processing. Silently discard this push from the user
        qWarning() << QString("Duplicate push was found with ID: %0.").arg(pushPayload.id());

        // Exit the application if it has not been brought to the foreground
        if (!m_hasBeenInForeground) {
        	Application::instance()->requestExit();
        }

        return;
    }

    // Convert from PushPayload to Push so that it can be stored in the database
    Push push(pushPayload);

    // Save the push and set the sequence number (ID) of the push
    push.setSeqNum(m_pushNotificationService.savePush(push));

    // Create a notification for the push that will be added to the BlackBerry Hub
    Notification *notification = new Notification(NOTIFICATION_PREFIX + QString::number(push.seqNum()),this);
    notification->setTitle("Push Collector");
    notification->setBody(QString("New %0 push received").arg(push.fileExtension()));

    // Add an invoke request to the notification
    // This invoke will contain the seqnum of the push.
    // When the notification in the BlackBerry Hub is selected, this seqnum will be used to lookup the push in
    // the database and display it
    InvokeRequest invokeRequest;
    invokeRequest.setTarget(INVOKE_TARGET_KEY_OPEN);
    invokeRequest.setAction(BB_OPEN_INVOCATION_ACTION);
    invokeRequest.setMimeType("text/plain");
    invokeRequest.setData(QByteArray::number(push.seqNum()));
    notification->setInvokeRequest(invokeRequest);

    // Add the notification for the push to the BlackBerry Hub
    // Calling this method will add a "splat" to the application icon, indicating that a new push has been received
    notification->notify();

    m_model->insert(push.toMap());

    // If an acknowledgement of the push is required (that is, the push was sent as a confirmed push
    // - which is equivalent terminology to the push being sent with application level reliability),
    // then you must either accept the push or reject the push
    if (pushPayload.isAckRequired()) {
        // In our sample, we always accept the push, but situations might arise where an application
        // might want to reject the push (for example, after looking at the headers that came with the push
        // or the data of the push, we might decide that the push received did not match what we expected
        // and so we might want to reject it)
        m_pushNotificationService.acceptPush(pushPayload.id());
    }

    // If the "Launch Application on New Push" checkbox was checked in the config settings, then
    // a new push will launch the app so that it's running in the background (if the app was not
    // already running when the push came in)
    // In this case, the push launched the app (not the user), so it makes sense
    // once our processing of the push is done to just exit the app
    // But, if the user has brought the app to the foreground at some point, then they know about the
    // app running and so we leave the app running after we're done processing the push
    if (!m_hasBeenInForeground) {
    	Application::instance()->requestExit();
    }
}
Пример #22
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();
        }