Save/Open Session: saved streams and deviceGroups in file; open code pending

This commit is contained in:
Srivats P 2016-04-15 19:03:52 +05:30
parent bcb5376f9d
commit 9bd6b536a3
4 changed files with 35 additions and 4 deletions

View File

@ -66,6 +66,11 @@ Port::~Port()
delete mStreams.takeFirst();
}
void Port::protoDataCopyInto(OstProto::Port *data)
{
data->CopyFrom(d);
}
void Port::updatePortConfig(OstProto::Port *port)
{
bool recalc = false;

View File

@ -126,6 +126,8 @@ public:
return capFile_;
}
void protoDataCopyInto(OstProto::Port *data);
// FIXME(MED): naming inconsistency - PortConfig/Stream; also retVal
void updatePortConfig(OstProto::Port *port);

View File

@ -128,12 +128,15 @@ void PortGroupList::removePortGroup(PortGroup &portGroup)
void PortGroupList::removeAllPortGroups()
{
while (!mPortGroups.isEmpty()) {
if (mPortGroups.isEmpty())
return;
do {
PortGroup *pg = mPortGroups.at(0);
mPortGroupListModel.portGroupAboutToBeRemoved(pg);
mPortGroups.removeFirst();
delete pg;
}
} while (!mPortGroups.isEmpty());
mPortGroupListModel.portGroupRemoved();
mPortGroupListModel.when_portListChanged();

View File

@ -222,13 +222,34 @@ bool PortsWindow::saveSession(
for (int i = 0; i < n; i++)
{
OstProto::PortGroupContent *pgc = session->add_port_groups();
PortGroup &pg = plm->portGroupByIndex(i);
OstProto::PortGroupContent *pgc = session->add_port_groups();
pgc->set_server_name(pg.serverName().toStdString());
pgc->set_server_port(pg.serverPort());
// TODO: ports
for (int j = 0; j < pg.numPorts(); j++)
{
OstProto::PortContent *pc = pgc->add_ports();
OstProto::Port *p = pc->mutable_port_config();
// XXX: We save the entire OstProto::Port even though some
// fields may be ephemeral; while opening we use only relevant
// fields
pg.mPorts.at(j)->protoDataCopyInto(p);
for (int k = 0; k < pg.mPorts.at(j)->numStreams(); k++)
{
OstProto::Stream *s = pc->add_streams();
pg.mPorts.at(j)->streamByIndex(k)->protoDataCopyInto(*s);
}
for (int k = 0; k < pg.mPorts.at(j)->numDeviceGroups(); k++)
{
OstProto::DeviceGroup *dg = pc->add_device_groups();
dg->CopyFrom(*(pg.mPorts.at(j)->deviceGroupByIndex(k)));
}
}
if (progress) {
if (progress->wasCanceled())