Example #1
0
PyObject *wrap_setEntry(PyObject *o, PyObject * args, PyObject * kwargs)
{
	const char *module_id;
	ppk_entry entry;
	ppk_data data;
	unsigned int type, data_type;
	const char *host = 0, *login = 0, *app_name = 0, *username = 0, *item = 0, *string = 0, *blob = 0;
	int size = 0;
	unsigned int port = 0;
	unsigned int flags = 0;
	static char *kwlist[] = { "module_id", "type", "data_type", "host", "login", "port", "app_name", "username", "item", "string", "blob", "flags", NULL };
	int ok = PyArg_ParseTupleAndKeywords(args, kwargs, "sII|ssHsssst#I", kwlist, &module_id,
			&type, &data_type, &host, &login, &port, &app_name, &username, &item, &string, &blob, &size, &flags);

	switch (type)
	{
	case ppk_network:
		ok = ok && host && login && port && ! app_name && ! username && ! item;
		break;
	case ppk_application:
		ok = ok && ! host && ! login && ! port && app_name && username && ! item;
		break;
	case ppk_item:
		ok = ok && ! host && ! login && ! port && ! app_name && ! username && item;
		break;
	default:
		ok = 0;
	};

	switch (data_type)
	{
	case ppk_string:
		ok = ok && string && ! blob;
		break;
	case ppk_blob:
		ok = ok && blob && size && ! string;
		break;
	default:
		ok = 0;
	}

	if (! ok)
	{
	    PyErr_BadArgument();
	    return 0;
	}

	buildEntry(&entry, type, host, login, port, app_name, username, item);
	buildData(&data, data_type, string, blob, size);

	return (ppk_setEntry(module_id, entry, data, flags)) ? Py_True : Py_False;
}
Example #2
0
      ColorMapSelector():
	_min(0), _max(1)
      {
	m_refTreeModel = ::Gtk::ListStore::create(m_Columns);
	_comboBox.set_model(m_refTreeModel);
	
	buildEntry(SEBASTIAN, "Heat");
	buildEntry(HSV, "HSV");
	buildEntry(MARCUS, "Grayscale safe");
	
	_comboBox.pack_start(m_Columns.m_col_name, true);
	_comboBox.pack_start(m_Columns.m_col_icon, false);
	_comboBox.signal_changed().connect(sigc::mem_fun(*this, &ColorMapSelector::on_combobox_changed));
	_comboBox.set_active(0);
	_comboBox.show();

	show();

	_minValue.set_text("0");
	_minValue.set_width_chars(5);
	_minValue.show();
	_minValue.signal_changed().connect(sigc::mem_fun(*this, &ColorMapSelector::on_limits_changed));

	_maxValue.set_text("1.0");
	_maxValue.set_width_chars(5);
	_maxValue.show();
	_maxValue.signal_changed().connect(sigc::mem_fun(*this, &ColorMapSelector::on_limits_changed));

	Gtk::Label* label = Gtk::manage(new Gtk::Label("Range")); label->show();
	pack_start(*label, false, false, 5);
	pack_start(_minValue, false, false, 5);
	label = Gtk::manage(new Gtk::Label(":")); label->show();
	pack_start(*label, false, false, 2);
	pack_start(_maxValue, false, false, 5);

	label = Gtk::manage(new Gtk::Label("Scale")); label->show(); label->set_alignment(0.95, 0.5);
	pack_start(*label, true, true, 5);
	pack_start(_comboBox, false, false, 5);
      }
Example #3
0
PyObject *wrap_getEntry(PyObject *o, PyObject * args, PyObject * kwargs)
{
	const char *module_id;
	ppk_entry entry;
	unsigned int type;
	const char *host = 0, *login = 0, *app_name = 0, *username = 0, *item = 0;
	unsigned int port = 0;
	unsigned int flags = 0;
	static char *kwlist[] = { "module_id", "type", "host", "login", "port", "app_name", "username", "item", "flags", NULL };
	int ok = PyArg_ParseTupleAndKeywords(args, kwargs, "sI|ssHsssI", kwlist, &module_id,
			&type, &host, &login, &port, &app_name, &username, &item, &flags);
	switch (type)
	{
	case ppk_network:
		ok = ok && host && login && port && ! app_name && ! username && ! item;
		break;
	case ppk_application:
		ok = ok && ! host && ! login && ! port && app_name && username && ! item;
		break;
	case ppk_item:
		ok = ok && ! host && ! login && ! port && ! app_name && ! username && item;
		break;
	default:
		ok = 0;
	};

	if (! ok)
	{
	    PyErr_BadArgument();
	    return 0;
	}

	buildEntry(&entry, type, host, login, port, app_name, username, item);

	ppk_data data;

	if (! ppk_getEntry(module_id, entry, &data, flags))
		return Py_None;
	
	PyObject *result = PyDict_New();
	PyDict_SetItemString(result, "type", Py_BuildValue("I", data.type));
	if (data.type == ppk_string)
		PyDict_SetItemString(result, "string", Py_BuildValue("s", data.string));
	else if (data.type == ppk_blob)
		//Untested
		PyDict_SetItemString(result, "blob", Py_BuildValue("t#", data.blob.data, data.blob.size));

	return result;
}
Example #4
0
PyObject *wrap_entryExists(PyObject *o, PyObject * args, PyObject * kwargs)
{
	const char *module_id;
	ppk_entry entry;
	unsigned int type;
	const char *host = 0, *login = 0, *app_name = 0, *username = 0, *item = 0;
	unsigned int port = 0;
	unsigned int flags = 0;
	static char *kwlist[] = { "module_id", "type", "host", "login", "port", "app_name", "username", "item","flags", NULL };
	int ok = PyArg_ParseTupleAndKeywords(args, kwargs, "sI|ssHsssI", kwlist, &module_id, &type, &host, &login, &port, &app_name, &username, &item, &flags);

	switch (type)
	{
	case ppk_network:
		ok = ok && host && login && port && ! app_name && ! username && ! item;
		break;
	case ppk_application:
		ok = ok && ! host && ! login && ! port && app_name && username && ! item;
		break;
	case ppk_item:
		ok = ok && ! host && ! login && ! port && ! app_name && ! username && item;
		break;
	default:
		ok = 0;
	};

	if (! ok)
	{
	    PyErr_BadArgument();
	    return 0;
	}

	buildEntry(&entry, type, host, login, port, app_name, username, item);

	return (ppk_entryExists(module_id, entry, flags)) ? Py_True : Py_False;
}
Example #5
0
status_t TiffWriter::addSubIfd(uint32_t parentIfd, uint32_t ifd, SubIfdType type) {
    ssize_t index = mNamedIfds.indexOfKey(ifd);
    if (index >= 0) {
        ALOGE("%s: Ifd with ID 0x%x already exists.", __FUNCTION__, ifd);
        return BAD_VALUE;
    }

    ssize_t parentIndex = mNamedIfds.indexOfKey(parentIfd);
    if (parentIndex < 0) {
        ALOGE("%s: Parent IFD with ID 0x%x does not exist.", __FUNCTION__, parentIfd);
        return BAD_VALUE;
    }

    sp<TiffIfd> parent = mNamedIfds[parentIndex];
    sp<TiffIfd> newIfd = new TiffIfd(ifd);

    uint16_t subIfdTag;
    if (type == SUBIFD) {
        subIfdTag = TAG_SUBIFDS;
    } else if (type == GPSINFO) {
        subIfdTag = TAG_GPSINFO;
    } else {
        ALOGE("%s: Unknown SubIFD type %d.", __FUNCTION__, type);
        return BAD_VALUE;
    }

    sp<TiffEntry> subIfds = parent->getEntry(subIfdTag);
    if (subIfds == NULL) {
        if (buildEntry(subIfdTag, 1, &newIfd, &subIfds) < 0) {
            ALOGE("%s: Failed to build SubIfd entry in IFD 0x%x.", __FUNCTION__, parentIfd);
            return BAD_VALUE;
        }
    } else {
        if (type == GPSINFO) {
            ALOGE("%s: Cannot add GPSInfo SubIFD to IFD %u, one already exists.", __FUNCTION__,
                    ifd);
            return BAD_VALUE;
        }

        Vector<sp<TiffIfd> > subIfdList;
        const sp<TiffIfd>* oldIfdArray = subIfds->getData<sp<TiffIfd> >();
        if (subIfdList.appendArray(oldIfdArray, subIfds->getCount()) < 0) {
            ALOGE("%s: Failed to build SubIfd entry in IFD 0x%x.", __FUNCTION__, parentIfd);
            return BAD_VALUE;
        }

        if (subIfdList.add(newIfd) < 0) {
            ALOGE("%s: Failed to build SubIfd entry in IFD 0x%x.", __FUNCTION__, parentIfd);
            return BAD_VALUE;
        }

        uint32_t count = subIfdList.size();
        if (buildEntry(subIfdTag, count, subIfdList.array(), &subIfds) < 0) {
            ALOGE("%s: Failed to build SubIfd entry in IFD 0x%x.", __FUNCTION__, parentIfd);
            return BAD_VALUE;
        }
    }

    if (parent->addEntry(subIfds) < 0) {
        ALOGE("%s: Failed to add SubIfd entry in IFD 0x%x.", __FUNCTION__, parentIfd);
        return BAD_VALUE;
    }

    if(mNamedIfds.add(ifd, newIfd) < 0) {
        ALOGE("%s: Failed to add new IFD 0x%x.", __FUNCTION__, ifd);
        return BAD_VALUE;
    }

    return OK;
}