Aufgrund einer Wartung wird GitLab am 18.05. zwischen 8:00 und 9:00 Uhr kurzzeitig nicht zur Verfügung stehen. / Due to maintenance, GitLab will be temporarily unavailable on 18.05. between 8:00 and 9:00 am.

Commit b1ee63c7 authored by Carsten Fuhrmann's avatar Carsten Fuhrmann
Browse files

crashes again

parent a85c25c3
......@@ -11,14 +11,6 @@
//#pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" )
//#endif
struct ChannelInfo {
uint64 id;
QString name;
uint64 parent;
QTreeWidgetItem* entry;
int order;
};
enum nodeType {
channel,
client,
......@@ -45,6 +37,8 @@ OverlayController::OverlayController(const struct TS3Functions funcs, quint64 se
m_tree = new ChannelListWidget;
connect(m_tree->getTree(), &QTreeWidget::itemDoubleClicked, this, &OverlayController::treeItemClicked);
updateChannelList();
}
OverlayController::~OverlayController()
......@@ -57,6 +51,11 @@ OverlayController::~OverlayController()
delete it;
m_msgLines.clear();
m_channelList.clear();
while (!m_clientList.isEmpty())
delete m_clientList.takeFirst();
delete m_debugWindow;
delete m_tree;
}
......@@ -213,12 +212,6 @@ void OverlayController::reset()
}
void OverlayController::updateChannelList()
{
if (m_tree->isVisible())
displayChannelList();
}
void OverlayController::displayChannelList()
{
// remove old stuff
while (int nb = m_tree->getTree()->topLevelItemCount())
......@@ -230,7 +223,6 @@ void OverlayController::displayChannelList()
return;
// get a list of all channels containing name, id, parent,..
QVector<ChannelInfo> channelList;
int i(0);
while (channelIDList[i] != NULL)
{
......@@ -251,16 +243,16 @@ void OverlayController::displayChannelList()
else
tmp.entry->setData(2, Qt::UserRole, channel);
channelList.push_back(tmp);
m_channelList.push_back(tmp);
i++;
}
// for every channel
for (auto &parent : channelList)
for (auto &parent : m_channelList)
{
// collect all childs
QVector<ChannelInfo> childs;
for (auto &child : channelList)
for (auto &child : m_channelList)
if (child.parent == parent.id)
childs.push_back(child);
......@@ -280,13 +272,13 @@ void OverlayController::displayChannelList()
// get all toplvl channels
QVector<ChannelInfo> topLvlList;
for (auto &it : channelList)
for (auto &it : m_channelList)
if (it.parent == 0)
topLvlList.push_back(it);
// add toplvl to tree in correct order
int prevID = 0;
while(!topLvlList.isEmpty())
while (!topLvlList.isEmpty())
{
int i;
for (i = 0; i < topLvlList.size(); i++)
......@@ -297,8 +289,18 @@ void OverlayController::displayChannelList()
m_tree->getTree()->addTopLevelItem(topLvlList.takeAt(i).entry);
}
// insert clients
for (auto& it : channelList)
updateClientList();
m_tree->getTree()->expandAll();
}
void OverlayController::updateClientList()
{
//TODO: remove all clients
while (!m_clientList.isEmpty())
delete m_clientList.takeFirst();
//add all clients
for (auto& it : m_channelList)
{
anyID* clientIDList;
ts3.getChannelClientList(m_SCHID, it.id, &clientIDList);
......@@ -310,14 +312,16 @@ void OverlayController::displayChannelList()
tmp->setData(0, Qt::DisplayRole, clientID2Name(m_SCHID, clientIDList[i]));
tmp->setData(1, Qt::UserRole, clientIDList[i]);
tmp->setData(2, Qt::UserRole, client);
m_clientList.push_back(tmp);
it.entry->addChild(tmp);
i++;
}
}
}
// display everything
m_tree->getTree()->expandAll();
void OverlayController::displayChannelList()
{
m_tree->getTree()->adjustSize();
m_tree->adjustSize();
m_tree->show();
......
......@@ -17,6 +17,14 @@
#define TIMEOUT 5000
struct ChannelInfo {
uint64 id;
QString name;
uint64 parent;
QTreeWidgetItem* entry;
int order;
};
class QTTSOVERLAY_EXPORT OverlayController : public QObject
{
Q_OBJECT
......@@ -36,6 +44,8 @@ private:
QVector<QWidget*> m_speakers;
QVector<QWidget*> m_msgLines;
ChannelListWidget* m_tree;
QVector<ChannelInfo> m_channelList;
QVector<QTreeWidgetItem*> m_clientList;
private:
void deleteChatLine(QWidget* line, QTimer *timer = NULL);
......@@ -50,5 +60,6 @@ public:
void debugPrint(QString text);
void reset();
void updateChannelList();
void updateClientList();
void displayChannelList();
};
......@@ -354,34 +354,32 @@ void ts3plugin_onConnectStatusChangeEvent(uint64 serverConnectionHandlerID, int
else if (newStatus == STATUS_CONNECTION_ESTABLISHED)
{
g_serverList.insert(serverConnectionHandlerID, new OverlayController(ts3Functions, serverConnectionHandlerID));
char* name;
ts3Functions.getServerVariableAsString(serverConnectionHandlerID, VIRTUALSERVER_NAME, &name);
getController(serverConnectionHandlerID)->debugPrint(QString("Welcome at: %1").arg(name));
ts3Functions.freeMemory(name);
getController(serverConnectionHandlerID)->displayChannelList();
}
}
void ts3plugin_onNewChannelEvent(uint64 serverConnectionHandlerID, uint64 channelID, uint64 channelParentID) {
//getController(serverConnectionHandlerID)->updateChannelList();
}
void ts3plugin_onNewChannelCreatedEvent(uint64 serverConnectionHandlerID, uint64 channelID, uint64 channelParentID, anyID invokerID, const char* invokerName, const char* invokerUniqueIdentifier) {
//getController(serverConnectionHandlerID)->updateChannelList();
}
void ts3plugin_onDelChannelEvent(uint64 serverConnectionHandlerID, uint64 channelID, anyID invokerID, const char* invokerName, const char* invokerUniqueIdentifier) {
//getController(serverConnectionHandlerID)->updateChannelList();
}
void ts3plugin_onChannelMoveEvent(uint64 serverConnectionHandlerID, uint64 channelID, uint64 newChannelParentID, anyID invokerID, const char* invokerName, const char* invokerUniqueIdentifier) {
//getController(serverConnectionHandlerID)->updateChannelList();
}
void ts3plugin_onUpdateChannelEvent(uint64 serverConnectionHandlerID, uint64 channelID) {
//getController(serverConnectionHandlerID)->updateChannelList();
}
void ts3plugin_onUpdateChannelEditedEvent(uint64 serverConnectionHandlerID, uint64 channelID, anyID invokerID, const char* invokerName, const char* invokerUniqueIdentifier) {
//getController(serverConnectionHandlerID)->updateChannelList();
}
void ts3plugin_onUpdateClientEvent(uint64 serverConnectionHandlerID, anyID clientID, anyID invokerID, const char* invokerName, const char* invokerUniqueIdentifier) {
......@@ -389,7 +387,7 @@ void ts3plugin_onUpdateClientEvent(uint64 serverConnectionHandlerID, anyID clien
void ts3plugin_onClientMoveEvent(uint64 serverConnectionHandlerID, anyID clientID, uint64 oldChannelID, uint64 newChannelID, int visibility, const char* moveMessage) {
getController(serverConnectionHandlerID)->updateChannelList();
getController(serverConnectionHandlerID)->updateClientList();
QString ClientName = clientID2Name(serverConnectionHandlerID, clientID);
QString oldChannel = channelID2Name(serverConnectionHandlerID, oldChannelID);
......@@ -422,7 +420,7 @@ void ts3plugin_onClientMoveSubscriptionEvent(uint64 serverConnectionHandlerID, a
void ts3plugin_onClientMoveTimeoutEvent(uint64 serverConnectionHandlerID, anyID clientID, uint64 oldChannelID, uint64 newChannelID, int visibility, const char* timeoutMessage) {
getController(serverConnectionHandlerID)->updateChannelList();
getController(serverConnectionHandlerID)->updateClientList();
QString ClientName = clientID2Name(serverConnectionHandlerID, clientID);
QString oldChannel = channelID2Name(serverConnectionHandlerID, oldChannelID);
......@@ -447,7 +445,7 @@ void ts3plugin_onClientMoveTimeoutEvent(uint64 serverConnectionHandlerID, anyID
void ts3plugin_onClientMoveMovedEvent(uint64 serverConnectionHandlerID, anyID clientID, uint64 oldChannelID, uint64 newChannelID, int visibility, anyID moverID, const char* moverName, const char* moverUniqueIdentifier, const char* moveMessage) {
getController(serverConnectionHandlerID)->updateChannelList();
getController(serverConnectionHandlerID)->updateClientList();
QString ClientName = clientID2Name(serverConnectionHandlerID, clientID);
QString oldChannel = channelID2Name(serverConnectionHandlerID, oldChannelID);
......@@ -472,7 +470,7 @@ void ts3plugin_onClientMoveMovedEvent(uint64 serverConnectionHandlerID, anyID cl
void ts3plugin_onClientKickFromChannelEvent(uint64 serverConnectionHandlerID, anyID clientID, uint64 oldChannelID, uint64 newChannelID, int visibility, anyID kickerID, const char* kickerName, const char* kickerUniqueIdentifier, const char* kickMessage) {
getController(serverConnectionHandlerID)->updateChannelList();
getController(serverConnectionHandlerID)->updateClientList();
QString ClientName = clientID2Name(serverConnectionHandlerID, clientID);
QString oldChannel = channelID2Name(serverConnectionHandlerID, oldChannelID);
......@@ -486,7 +484,7 @@ void ts3plugin_onClientKickFromChannelEvent(uint64 serverConnectionHandlerID, an
void ts3plugin_onClientKickFromServerEvent(uint64 serverConnectionHandlerID, anyID clientID, uint64 oldChannelID, uint64 newChannelID, int visibility, anyID kickerID, const char* kickerName, const char* kickerUniqueIdentifier, const char* kickMessage) {
getController(serverConnectionHandlerID)->updateChannelList();
getController(serverConnectionHandlerID)->updateClientList();
QString ClientName = clientID2Name(serverConnectionHandlerID, clientID);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment