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();
}
// The Foursquare invocation calls are based on the sample available here:
// https://github.com/kylefowler/foursquare-bb10-sdk
//
// Launches a native Foursquare venue search in your app.
// This card will call back to your childCardDone slot with the appropriate
// response for the actions taken by the user.
//
// URI Params:
// query: (optional) prime the venue search with a query
// client_id: (required) the client id from your oauth consumer
// client_secret: (required) the client secret from your oauth consumer
// oauth_token: (required if no client_id/client_secret) pass this if you
//              already have an authenticated user token, this way venue
//              search results will be fitted to the user requesting them
//              for a higher quality queryless search
//
// Response:
// When the user selects a venue, you will get the venue information in
// JSON format back through the childCardDone slot in the data object.
// The venue format will match what is listed here in the core venue fields:
// https://developer.foursquare.com/docs/responses/venue
//
// If the user cancels the search without any action: the reason message will be "canceled"
// If any of the parameters are missing you will get a reason message of "invalid_credentials"
void SocialInvocation::invokeFoursquareVenueCard(const QString &venue) {
	InvokeRequest cardRequest;
	cardRequest.setTarget("com.foursquare.blackberry.venuesearch.card");
	cardRequest.setAction("bb.action.VIEW");
	cardRequest.setMimeType("venuesearch/foursquare");

	// The client_id and client_secret are the Foursquare API credentials
	// 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

	QUrl uri = QUrl("foursquare://venues/search");

	// Replace the following values with your app's client ID and secret
	uri.addQueryItem("client_id", "UFVANV2FBBFRPXSBXHCCKECVUDANDKP5KQFKICRCA1VAFV4V");
	uri.addQueryItem("client_secret","11AY4DWL0A2CV1NXPKDMS2PJTEACRZJP0BMFXORNCKBSNVMH");

	uri.addQueryItem("query", venue);
	cardRequest.setUri(uri);

	m_invokeManager->invoke(cardRequest);
}
Example #3
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()));
}
Example #4
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&)));
	}
}
void ApplicationUIBase::invoke_bbworld(QString uri)
{
    InvokeRequest request;
    request.setMimeType("application/x-bb-appworld");
    request.setAction("bb.action.OPEN");
    request.setUri(uri);
    _invoke_manager->invoke(request);
}
void ApplicationUI::shareTextWithMail(const QString& text) {
	InvokeRequest mailRequest;
	mailRequest.setTarget("sys.pim.uib.email.hybridcomposer");
	mailRequest.setAction("bb.action.SENDEMAIL");
	mailRequest.setMimeType("settings/view");
	mailRequest.setUri("mailto:?subject=" + text);
	qDebug() << "share with Mail: " << text;
	mInvokeManager->invoke(mailRequest);
}
void ApplicationUI::leaveReview() {
	InvokeRequest bbmRequest;
	bbmRequest.setAction("bb.action.OPEN");
	bbmRequest.setMimeType("application/x-bb-appworld");
	QString uri = "appworld://content/";
	uri += mOdsData->applicationId();
	bbmRequest.setUri(uri);
	qDebug() << "leave review";
	mInvokeManager->invoke(bbmRequest);
}
/**
 * uses Invokation Framework to View the file from URI
 * for a specific MimeType
 *
 */
void ApplicationUI::showInViewForMimeType(QString uri, QString mimeType) {
	qDebug() << "showInViewForMimeType called: " << uri;
	InvokeRequest invokeRequest;
	invokeRequest.setAction("bb.action.VIEW");
	invokeRequest.setUri(uri);
	invokeRequest.setMimeType(mimeType);
	qDebug() << "showInViewForMimeType URI: " << invokeRequest.uri() << " Mime:"
			<< mimeType;
	mInvokeManager->invoke(invokeRequest);
}
// handles SLOT from feedbackItem
void ApplicationUI::feedbackTriggered() {
	qDebug() << "invoke sendFeedback";
	InvokeRequest request;
	request.setAction("bb.action.SENDEMAIL");
	request.setTarget("sys.pim.uib.email.hybridcomposer");
	request.setMimeType("settings/view");
	request.setUri(
			"mailto:" + mOdsData->feedbackMail() + "?subject=Feedback%20"
					+ mOdsData->applicationName());
	mInvokeManager->invoke(request);
}
void ApplicationUI::sendMail(const QString title) {
	qDebug() << "invoke sendMail";
	InvokeRequest request;
	request.setAction("bb.action.SENDEMAIL");
	request.setTarget("sys.pim.uib.email.hybridcomposer");
	request.setMimeType("settings/view");
	request.setUri(
			"mailto:" + mOdsData->supportMail() + "?subject="
					+ mOdsData->applicationName() + "%20" + title);
	mInvokeManager->invoke(request);
}
Example #11
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);
}
/**
 * uses Invokation Framework to View the file from URI
 * for a specific MimeType
 * and for a specific target like "sys.pictures.app"
 *
 */
void OpenDataSpace::showInTargetForMimeType(QString uri, QString mimeType,
		QString target) {
	qDebug() << "showInTargetForMimeType called: " << uri;
	InvokeRequest invokeRequest;
	invokeRequest.setAction("bb.action.VIEW");
	invokeRequest.setUri(uri);
	invokeRequest.setTarget(target);
	invokeRequest.setMimeType(mimeType);
	qDebug() << "showInTargetForMimeType URI: " << invokeRequest.uri()
			<< " MimeType:" << mimeType;
	m_invokeManager->invoke(invokeRequest);
}
Example #13
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);
}
Example #14
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;
	}
}
// 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);
}
Example #16
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());
}
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>
}
//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);

}
//invoke adobe reader application as a card
void ApplicationUI::invokeAdobe() {
	InvokeManager invokeManager;
	InvokeRequest request;

	QString uri = "file:" + QDir::currentPath() + "/app/native/assets/docs/panther.pdf";

	// Target ID for app we're invoking
	request.setTarget("com.rim.bb.app.adobeReader.viewer");

	// Action we want target application to perform
	request.setAction("bb.action.VIEW");

	// Type of data we're sending
	request.setMimeType("application/pdf");

	// The actual data
	request.setUri(uri);

	InvokeTargetReply *reply = invokeManager.invoke(request);
}
Example #20
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())));
}
Example #21
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;
    }
}
Example #22
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();
    }
}
Example #23
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();
        }