Exemplo n.º 1
0
//TODO: this is kind of funky; a launchpoint of an app should really just present the info for the app.
json_object* LaunchPoint::toJSON() const
{
	json_object* json = json_object_new_object();
	json_object_object_add(json, (char*) "id",   json_object_new_string((char*) id().c_str()));
	if (m_appDesc) {
		json_object_object_add(json, (char*) "version", json_object_new_string(m_appDesc->version().c_str()));
		json_object_object_add(json, (char*) "appId", json_object_new_string((char*) m_appDesc->id().c_str()));
		json_object_object_add(json, (char*) "vendor", json_object_new_string((char*) m_appDesc->vendorName().c_str()));
		json_object_object_add(json, (char*) "vendorUrl", json_object_new_string((char *) m_appDesc->vendorUrl().c_str()));
		int appSize = 0;
		std::string packageId = m_appDesc->id();
		if (this->isDefault()) {
			PackageDescription* packageDesc = ApplicationManager::instance()->getPackageInfoByAppId(m_appDesc->id());
			if (packageDesc) {
				appSize = packageDesc->packageSize();
				packageId = packageDesc->id();
			}

		}
		json_object_object_add(json, (char*) "size", json_object_new_int(appSize));
		json_object_object_add(json, (char*) "packageId", json_object_new_string((char*) packageId.c_str()));

		if (m_appDesc->dockModeStatus()) {
			json_object_object_add(json, (char*) "exhibitionMode", json_object_new_boolean(true));
			json_object_object_add(json, (char*) "exhibitionModeTitle", json_object_new_string((char*)m_appDesc->dockModeTitle().c_str()));
		}
	} else {
		json_object_object_add(json, (char*) "size", json_object_new_int(0));
		json_object_object_add(json, (char*) "packageId", json_object_new_string((char*) m_appDesc->id().c_str()));
	}
	json_object_object_add(json, (char*) "removable", json_object_new_boolean(m_removable));

	json_object_object_add(json, (char*) "launchPointId", json_object_new_string((char*) launchPointId().c_str()));
	json_object_object_add(json, (char*) "title", json_object_new_string((char*) title().c_str()));
	json_object_object_add(json, (char*) "appmenu", json_object_new_string((char*)menuName().c_str()));
	json_object_object_add(json, (char*) "icon", json_object_new_string((char*) iconPath().c_str()));

	if (!params().empty() && m_appDesc->type() != ApplicationDescription::Type_Qt) {
        if (m_appDesc->type() == ApplicationDescription::Type_Qt) {
            json_object_object_add(json, (char*) "params", json_object_new_string(params().c_str()));
        }
        else {
    		json_object* paramsJson = json_tokener_parse(params().c_str());
	    	json_object_object_add(json, (char*) "params", paramsJson);
        }
	}

	return json;
}
Exemplo n.º 2
0
bool PackageDescription::operator!=(const PackageDescription& cmp) const {
	return (m_id != cmp.id());
}