// 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
	}
}
Example #2
0
TripMaster::TripMaster(bb::cascades::Application *app)
: QObject(app),m_dataModel(0)
{
	initDataModel();
		// create scene document from main.qml asset
	    // set parent to created document to ensure it exists for the whole application lifetime
	    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
	    qml->setContextProperty("_app", this);
	    // create root object for the UI
	    AbstractPane *root = qml->createRootObject<AbstractPane>();
	    // set created root object as a scene
	    app->setScene(root);
	    const bool dbInited = initDatabase();
	    // Inform the UI if the database was successfully initialized or not
	    root->setProperty("databaseOpen", dbInited);
}
Example #3
0
ApplicationUI::ApplicationUI(bb::cascades::Application *app) :
        QObject(app)
{
	// Initialize the Group Data Model before setitng up our QML Scene
	// as the QML scene will bind to the data model
	initDataModel();

	//add custom object Request class as a qml type
	qmlRegisterType<Request>("Network.Request", 1, 0, "Request");

    // prepare the localization
    m_pTranslator = new QTranslator(this);
    m_pLocaleHandler = new LocaleHandler(this);

    bool res = QObject::connect(m_pLocaleHandler, SIGNAL(systemLanguageChanged()), this, SLOT(onSystemLanguageChanged()));
    // This is only available in Debug builds
    Q_ASSERT(res);
    // Since the variable is not used in the app, this is added to avoid a
    // compiler warning
    Q_UNUSED(res);

    // initial load
    onSystemLanguageChanged();

    this->m_pNetConfigMngr = new QNetworkConfigurationManager();

    // Create scene document from main.qml asset, the parent is set
    // to ensure the document gets destroyed properly at shut down.
    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
    qml->setContextProperty("app", this);

    Settings *settings = new Settings();
    qml->setContextProperty("Settings", settings);
    // Create root object for the UI
    AbstractPane *root = qml->createRootObject<AbstractPane>();

    // Set created root object as the application scene
    app->setScene(root);

    // Initialize the database, ensure a connection can be established
	// and that all the required tables and initial data exists
	const bool dbInited = initDatabase();
	// Inform the UI if the database was successfully initialized or not
	root->setProperty("databaseOpen", dbInited);
}