Esempio n. 1
0
File* File::create(QString name)
{
    if (sr_session_load(name.toLocal8Bit().data()) == SR_OK) {
		GSList *devlist = NULL;
		sr_session_dev_list(&devlist);
		sr_session_destroy();

		if (devlist) {
			sr_dev_inst *const sdi = (sr_dev_inst*)devlist->data;
			g_slist_free(devlist);
			if (sdi) {
				sr_dev_close(sdi);
				sr_dev_clear(sdi->driver);
				return new SessionFile(name);
			}
		}
	}

	return new InputFile(name);
}
Esempio n. 2
0
void SessionFile::use(SigSession *owner) throw(QString)
{
	assert(!_sdi);

	if (sr_session_load(_path.c_str()) != SR_OK)
		throw tr("Failed to open file.\n");

	GSList *devlist = NULL;
	sr_session_dev_list(&devlist);

	if (!devlist || !devlist->data) {
		if (devlist)
			g_slist_free(devlist);
		throw tr("Failed to start session.");
	}

	_sdi = (sr_dev_inst*)devlist->data;
	g_slist_free(devlist);

	File::use(owner);
}
Esempio n. 3
0
File* File::create(const string &name)
{
	struct sr_session *temp_session;
	if (sr_session_load(name.c_str(), &temp_session) == SR_OK) {
		GSList *devlist = NULL;
		sr_session_dev_list(temp_session, &devlist);
		sr_session_destroy(temp_session);

		if (devlist) {
			sr_dev_inst *const sdi = (sr_dev_inst*)devlist->data;
			g_slist_free(devlist);
			if (sdi) {
				sr_dev_close(sdi);
				sr_dev_clear(sdi->driver);
				return new SessionFile(name);
			}
		}
	}

	return NULL;
}