MCPcopy Create free account
hub / github.com/MayaPosch/NymphCast / loadGroups

Method loadGroups

player/NymphCastPlayer/mainwindow.cpp:1708–1759  ·  view source on GitHub ↗

--- LOAD GROUPS --- Load the remote groups from file, if exists.

Source from the content-addressed store, hash-verified

1706// --- LOAD GROUPS ---
1707// Load the remote groups from file, if exists.
1708bool MainWindow::loadGroups() {
1709 // Open the groups file.
1710 QFile file(appDataLocation + "/groups.bin");
1711 if (!file.exists()) { return false; }
1712 if (!file.open(QIODevice::ReadOnly)) {
1713 QMessageBox::warning(this, tr("Error loading groups"), tr("Error reading the groups.bin file!"));
1714 return false;
1715 }
1716
1717 // Read in the groups.
1718 QDataStream ds(&file);
1719 // First read in the number of groups.
1720 quint32 numGroups;
1721 ds >> numGroups;
1722 // Read group name, then the number of remotes in the group, followed by the remotes.
1723 for (uint32_t i = 0; i < numGroups; ++i) {
1724 QString gname;
1725 quint32 numRemotes;
1726 ds >> gname;
1727 ds >> numRemotes;
1728
1729 NCRemoteGroup rg;
1730 rg.name = gname.toStdString();
1731
1732 for (uint32_t j = 0; j < numRemotes; ++j) {
1733 QString rname;
1734 QString ipv4;
1735 QString ipv6;
1736 quint16 port;
1737
1738 ds >> rname;
1739 ds >> ipv4;
1740 ds >> ipv6;
1741 ds >> port;
1742
1743 NymphCastRemote ncr;
1744 ncr.name = rname.toStdString();
1745 ncr.ipv4 = ipv4.toStdString();
1746 ncr.ipv6 = ipv6.toStdString();
1747 ncr.port = (uint16_t) port;
1748
1749 NCRemoteInstance nci;
1750 nci.remote = ncr;
1751
1752 rg.remotes.push_back(nci);
1753 }
1754
1755 groups.push_back(rg);
1756 }
1757
1758 return true;
1759}
1760
1761
1762// --- SAVE GROUPS ---

Callers

nothing calls this directly

Calls 3

push_backMethod · 0.80
existsMethod · 0.45
openMethod · 0.45

Tested by

no test coverage detected