//! [1]
void SocialInvocation::invoke(const QString &target, const QString &action,
		const QString &mimetype, const QString &uri) {
	// Create a new invocation request
	InvokeRequest request;

	request.setTarget(target);
	request.setAction(action);

	if (target == QLatin1String("com.rim.bb.app.facebook")) {
		QVariantMap payload;

		if (!uri.isEmpty()) {
			payload["object_type"] = mimetype;
			payload["object_id"] = uri;
		} else {
			// Open the BlackBerry North America page by default
			payload["object_type"] = "page";
			payload["object_id"] = "328506290597521";
		}

		request.setMetadata(payload);
	} else {
		request.setUri(uri);
	}

	m_invokeManager->invoke(request);
}
Ejemplo n.º 2
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&)));
	}
}
Ejemplo n.º 3
0
void ApplicationUI::startHeadless()
{
    InvokeRequest request;
    request.setTarget("com.RogerLeblanc.callerService");
    request.setAction("com.RogerLeblanc.callerService.START");
    m_invokeManager->invoke(request);
}
// 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);
}
void ApplicationUI::onGetResponse(QString& response)
{
	m_pCardHolder->setProperty("visible", false);
	m_pResponseHolder->setProperty("visible", true);
	m_pResponseHolder->setProperty("text", response);

	QDir vcfPath;
	vcfPath.mkdir(QDir::tempPath()+"/data/");
	vcfPath.cd(QDir::tempPath()+"/data/");
	QFile vcfCard(QDir::tempPath()+"/data/readContact.vcf");
	if(!vcfCard.open(QIODevice::WriteOnly | QIODevice::Text))
	{
		showToast("Error Creating new file");
		return;
	}
	QTextStream out(&vcfCard);
	out << response;
	vcfCard.close();

	InvokeManager manager;
	InvokeRequest request;
	request.setTarget("sys.pim.contacts.card.viewer");
	request.setAction("bb.action.VIEW");
	request.setUri("file://" + QDir::tempPath()+"/data/readContact.vcf");
	manager.invoke(request);
}
Ejemplo n.º 6
0
void BarcodeInvoker::onInvokeButtonClicked() {
	qDebug() << "+++++++ Invoke button clicked" << endl;
	InvokeRequest invokeRequest;
	invokeRequest.setTarget("com.example.BarcodeScanner");
	invokeRequest.setAction("community.action.SCANBARCODE");
	InvokeTargetReply *invokeReply = _invokeManager->invoke(invokeRequest);
}
void ApplicationUI::enableAutoStart()
{

    //Create the InvokeTargetFilter, which matches the filter that was
    //commented out from the bar-descriptor.xml.
InvokeTargetFilter autoStartFilter;
autoStartFilter.addAction("bb.action.system.STARTED");
autoStartFilter.addMimeType("application/vnd.blackberry.system.event.STARTED");
autoStartFilter.addUri("data://local");

    //Create the InvokeUpdateTargetFilterRequest and add the filter we just created.
InvokeUpdateTargetFiltersRequest updateRequest;
updateRequest.setTarget("com.example.DeferredAutoStartService");
QList<InvokeTargetFilter> filterList;
filterList.append(autoStartFilter);
updateRequest.setTargetFilters(filterList);

    //Use InvokeManager to update the filter.
InvokeManager manager;
manager.updateTargetFilters(updateRequest);


    //At this point the headless entry point of the application will auto run when the BlackBerry Smartphone
    //boots up.  However note that this does not start headless portion.  Left as is, it won't start
    //until next reboot.  The code below starts the headless application.

InvokeRequest request;
request.setTarget("com.example.DeferredAutoStartService");
request.setAction("bb.action.system.STARTED");
manager.invoke(request);
}
Ejemplo n.º 8
0
void App::onInvoked(const InvokeRequest &request)
{
    if (m_configurationService.hasConfiguration()) {
        // The underlying PushService instance might not have been
        // initialized when an invoke first comes in
        // Make sure that we initialize it here if it hasn't been already
        // It requires an application ID (for consumer applications) so we have to check
        // that configuration settings have already been stored
        m_pushNotificationService.initializePushService();

        if (request.action().compare(BB_PUSH_INVOCATION_ACTION) == 0) {
            qDebug() << "Received push action";
            // Received an incoming push
            // Extract it from the invoke request and then process it
            PushPayload payload(request);
            if (payload.isValid()) {
                pushNotificationHandler(payload);
            }
        } else if (request.action().compare(BB_OPEN_INVOCATION_ACTION) == 0){
            qDebug() << "Received open action";
            // Received an invoke request to open an existing push (ie. from a notification in the BlackBerry Hub)
            // The payload from the open invoke is the seqnum for the push in the database
            openPush(request.data().toInt());
        }
    }
}
void ApplicationUI::resendNotification() {
	InvokeRequest request;
	request.setTarget("com.example.bb_france2UpFrontService");
	request.setAction("com.example.bb_france2UpFrontService.RESET");
	m_invokeManager->invoke(request);
	Application::instance()->minimize();
}
Ejemplo n.º 10
0
void ApplicationUI::stopLocking()
{
    InvokeRequest request;
    request.setTarget(SERVICE_APP_TARGET);
    request.setAction(SERVICE_STOP_LOCKING_ACTION);
    m_invokeManager->invoke(request);
}
void ApplicationUI::inviteBBM() {
	InvokeRequest bbmRequest;
	bbmRequest.setTarget("sys.bbm.invitehandler");
	bbmRequest.setAction("bb.action.INVITEBBM");
	qDebug() << "invite to BBM";
	mInvokeManager->invoke(bbmRequest);
}
Ejemplo n.º 12
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);
}
/**
 * uses Invokation Framework to View the file from URI
 *
 */
void OpenDataSpace::showInView(QString uri) {
	qDebug() << "showInView called: " << uri;
	InvokeRequest invokeRequest;
	invokeRequest.setAction("bb.action.VIEW");
	invokeRequest.setUri(uri);
	qDebug() << "showInView URI: " << invokeRequest.uri();
	m_invokeManager->invoke(invokeRequest);
}
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::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 ApplicationUIBase::invoke_browser(QString url)
{
    InvokeRequest request;
    request.setTarget("sys.browser");
    request.setAction("bb.action.OPEN");
    request.setUri(url);
    _invoke_manager->invoke(request);
}
void ApplicationUI::resendNotification()
{
    InvokeRequest request;
    request.setTarget(WAKEME_INVOKE_HEADLESS_SERVICE);
    request.setAction(WAKEME_INVOKE_ACTION_RESET);
    _invokeManager->invoke(request);
    Application::instance()->minimize();
}
void ApplicationUIBase::invoke_media_player(QString uri)
{
    InvokeRequest request;
    request.setTarget("sys.mediaplayer.previewer");
    request.setAction("bb.action.OPEN");
    request.setUri(uri);
    _invoke_manager->invoke(request);
}
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);
}
Ejemplo n.º 21
0
void App::onInvoked(const InvokeRequest &request)
{
	if (request.action().compare(BB_OPEN_INVOCATION_ACTION) == 0){
		qDebug() << "Received open action";
		// Received an invoke request to open an existing push (ie. from a notification in the BlackBerry Hub)
		// The payload from the open invoke is the seqnum for the push in the database
		openPush(request.data().toInt());
	}
}
// unbound Invokation
void ApplicationUI::invokeUnbound(QString uri) {
	if (uri.endsWith(".svg")) {
		invokeBrowser(uri);
		return;
	}
	InvokeRequest cardRequest;
	cardRequest.setUri(uri);
	mInvokeManager->invoke(cardRequest);
}
void ApplicationUI::onStartHeadlessService()
{
    InvokeRequest request;
    request.setTarget(WAKEME_INVOKE_HEADLESS_SERVICE);
    request.setAction(WAKEME_INVOKE_ACTION_STARTSERVICE);
    _invokeManager->invoke(request);

    connectToHeadless();
}
/**
 * uses Invokation Framework to View the file from URI
 * for a specific target like "sys.pictures.app"
 *
 */
void ApplicationUI::showInTarget(QString uri, QString target) {
	qDebug() << "showInTarget called: " << uri;
	InvokeRequest invokeRequest;
	invokeRequest.setAction("bb.action.VIEW");
	invokeRequest.setUri(uri);
	invokeRequest.setTarget(target);
	qDebug() << "showInTarget URI: " << invokeRequest.uri();
	mInvokeManager->invoke(invokeRequest);
}
// triggered if Application was invoked by a client
void OpenDataSpace::handleInvoke(const InvokeRequest& request) {
	// TODO
	qDebug() << "Invoke Request";
	qDebug() << "Invoke Request Action:" << request.action();
	qDebug() << "Invoke Request Mime:" << request.mimeType();
	qDebug() << "Invoke Request URI:" << request.uri();
	qDebug() << "Invoke Request Data:" << request.data();
	m_invokationTarget = request.target();
	m_invokationSource = QString::fromLatin1("%1 (%2)").arg(
			request.source().installId()).arg(request.source().groupId());
	qDebug() << "Invoke Target ID: " << m_invokationTarget << " from Source: "
			<< m_invokationSource;
	// Invoked as Application
	if (m_invokationTarget == "io.ods.bb10.invoke") {
		m_isCard = false;
		qDebug() << "Invoked";
	}
	// invoked as embedded Card (Previewer) from OPEN or SHARE
	else if (m_invokationTarget == "io.ods.bb10.card.upload.previewer") {
		m_isCard = true;
		qDebug() << "Invoked for UploadCard as Previewer";
	}
	// invoked as embedded Card (Composer) from OPEN
	else if (m_invokationTarget == "io.ods.bb10.upload.composer") {
		m_isCard = true;
		qDebug() << "Invoked for UploadCard as Composer";
	}
	// do some preparing-stuff for a invoked Card
	// reset values (can come from pool)
	// set some infos
	// tell the Card that its a new invocation
	if (m_isCard) {
		AbstractPane *p = Application::instance()->scene();
		bool ok = false;
		// if there's a URI we take the URI
		// else we take the data
		if (request.uri().isEmpty()) {
			ok = p->setProperty("filePath", request.data());
		} else {
			ok = p->setProperty("filePath", request.uri());
		}
		if (!ok) {
			qDebug() << "Cannot set filePath";
		}
		// start a new Card Game ;-)
		// setting newCard true causes testing if LogIn was needed before upload files
		ok = p->setProperty("newCard", true);
		if (ok) {
			qDebug() << "set newCard to true";
		} else {
			qDebug() << "cannot set newCard";
		}
	} else {
		// do what needed if Invoked, per ex. switch to Upload TAB
	}
}
Ejemplo n.º 26
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();
}
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
}
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);
}