示例#1
0
void App::query(int targetType, const QString& action, const QString& mime, const QString& uri) {
	iManager = new InvokeManager(this);

	InvokeQueryTargetsRequest iQuery;

	if (targetType == 0) {
		iQuery.setTargetType(InvokeTarget::All);
	} else if (targetType == 1) {
		iQuery.setTargetType(InvokeTarget::Application);
	} else if (targetType == 2) {
		iQuery.setTargetType(InvokeTarget::Viewer);
	} else if (targetType == 3) {
		iQuery.setTargetType(InvokeTarget::Service);
	}

	if (action != 0 && action.length() > 0) {
		printf("################");
		printf(action.toAscii().constData());
		if (action.compare("All") == 0) {
			iQuery.setActionType(InvokeAction::All);
		} else if (action.compare("Menu Actions") == 0) {
			iQuery.setActionType(InvokeAction::Menu);
		} else {
			iQuery.setAction(action);
		}
	}
	if (mime != 0 && mime.length() > 0) {
		printf("################");
		printf(mime.toAscii().constData());
		iQuery.setMimeType(mime);
	} else if (uri.length() <= 0) {
		root->findChild<QObject*>("qlDialogMessage")->setProperty("text", "MIME type OR URI must be specified!");
		root->findChild<QObject*>("qcdDialog")->setProperty("visible", true);
		return;
	}

	if (uri != 0 && uri.length() > 0) {
		printf("################");
		printf(uri.toAscii().constData());
		iQuery.setUri(uri);
	} else if (mime.length() <= 0) {
		root->findChild<QObject*>("qlDialogMessage")->setProperty("text", "MIME type OR URI must be specified!");
		root->findChild<QObject*>("qcdDialog")->setProperty("visible", true);
		return;
	}

	iQueryReply = iManager->queryTargets(iQuery);
	QObject::connect(iQueryReply, SIGNAL(finished()), this, SLOT(processQueryReply()));
}
示例#2
0
//! [2]
void App::query() {
    // Create a new query targets request
    InvokeQueryTargetsRequest request;

    // Setup the request properties according to the current configuration
    if (m_targetType == 0)
        request.setTargetTypes(
                InvokeTarget::Application | InvokeTarget::Card
                        | InvokeTarget::Viewer | InvokeTarget::Service);
    else if (m_targetType == 1)
        request.setTargetTypes(InvokeTarget::Application);
    else if (m_targetType == 2)
        request.setTargetTypes(InvokeTarget::Viewer);
    else if (m_targetType == 3)
        request.setTargetTypes(InvokeTarget::Service);
    else if (m_targetType == 4)
        request.setTargetTypes(InvokeTarget::Card);

    if (!m_action.isEmpty()) {
        if (m_action == QLatin1String("__All"))
            request.setActionType(InvokeAction::All);
        else if (m_action == QLatin1String("__MenuActions"))
            request.setActionType(InvokeAction::Menu);
        else
            request.setAction(m_action);
    }

    if (!m_mimeType.isEmpty())
        request.setMimeType(m_mimeType);

    if (!m_uri.isEmpty())
        request.setUri(m_uri);

    // Start the query
    const InvokeReply *reply = m_invokeManager->queryTargets(request);

    // Ensure that processQueryReply() is called when the query has finished
    bool ok = connect(reply, SIGNAL(finished()), this,
                      SLOT(processQueryReply()));
    Q_ASSERT(ok);
    Q_UNUSED(ok);
}