Commit b1ee63c7 authored by Carsten Fuhrmann's avatar Carsten Fuhrmann

crashes again

parent a85c25c3
...@@ -11,14 +11,6 @@ ...@@ -11,14 +11,6 @@
//#pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" ) //#pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" )
//#endif //#endif
struct ChannelInfo {
uint64 id;
QString name;
uint64 parent;
QTreeWidgetItem* entry;
int order;
};
enum nodeType { enum nodeType {
channel, channel,
client, client,
...@@ -45,6 +37,8 @@ OverlayController::OverlayController(const struct TS3Functions funcs, quint64 se ...@@ -45,6 +37,8 @@ OverlayController::OverlayController(const struct TS3Functions funcs, quint64 se
m_tree = new ChannelListWidget; m_tree = new ChannelListWidget;
connect(m_tree->getTree(), &QTreeWidget::itemDoubleClicked, this, &OverlayController::treeItemClicked); connect(m_tree->getTree(), &QTreeWidget::itemDoubleClicked, this, &OverlayController::treeItemClicked);
updateChannelList();
} }
OverlayController::~OverlayController() OverlayController::~OverlayController()
...@@ -57,6 +51,11 @@ OverlayController::~OverlayController() ...@@ -57,6 +51,11 @@ OverlayController::~OverlayController()
delete it; delete it;
m_msgLines.clear(); m_msgLines.clear();
m_channelList.clear();
while (!m_clientList.isEmpty())
delete m_clientList.takeFirst();
delete m_debugWindow; delete m_debugWindow;
delete m_tree; delete m_tree;
} }
...@@ -213,12 +212,6 @@ void OverlayController::reset() ...@@ -213,12 +212,6 @@ void OverlayController::reset()
} }
void OverlayController::updateChannelList() void OverlayController::updateChannelList()
{
if (m_tree->isVisible())
displayChannelList();
}
void OverlayController::displayChannelList()
{ {
// remove old stuff // remove old stuff
while (int nb = m_tree->getTree()->topLevelItemCount()) while (int nb = m_tree->getTree()->topLevelItemCount())
...@@ -230,7 +223,6 @@ void OverlayController::displayChannelList() ...@@ -230,7 +223,6 @@ void OverlayController::displayChannelList()
return; return;
// get a list of all channels containing name, id, parent,.. // get a list of all channels containing name, id, parent,..
QVector<ChannelInfo> channelList;
int i(0); int i(0);
while (channelIDList[i] != NULL) while (channelIDList[i] != NULL)
{ {
...@@ -251,16 +243,16 @@ void OverlayController::displayChannelList() ...@@ -251,16 +243,16 @@ void OverlayController::displayChannelList()
else else
tmp.entry->setData(2, Qt::UserRole, channel); tmp.entry->setData(2, Qt::UserRole, channel);
channelList.push_back(tmp); m_channelList.push_back(tmp);
i++; i++;
} }
// for every channel // for every channel
for (auto &parent : channelList) for (auto &parent : m_channelList)
{ {
// collect all childs // collect all childs
QVector<ChannelInfo> childs; QVector<ChannelInfo> childs;
for (auto &child : channelList) for (auto &child : m_channelList)
if (child.parent == parent.id) if (child.parent == parent.id)
childs.push_back(child); childs.push_back(child);
...@@ -280,13 +272,13 @@ void OverlayController::displayChannelList() ...@@ -280,13 +272,13 @@ void OverlayController::displayChannelList()
// get all toplvl channels // get all toplvl channels
QVector<ChannelInfo> topLvlList; QVector<ChannelInfo> topLvlList;
for (auto &it : channelList) for (auto &it : m_channelList)
if (it.parent == 0) if (it.parent == 0)
topLvlList.push_back(it); topLvlList.push_back(it);
// add toplvl to tree in correct order // add toplvl to tree in correct order
int prevID = 0; int prevID = 0;
while(!topLvlList.isEmpty()) while (!topLvlList.isEmpty())
{ {
int i; int i;
for (i = 0; i < topLvlList.size(); i++) for (i = 0; i < topLvlList.size(); i++)
...@@ -297,8 +289,18 @@ void OverlayController::displayChannelList() ...@@ -297,8 +289,18 @@ void OverlayController::displayChannelList()
m_tree->getTree()->addTopLevelItem(topLvlList.takeAt(i).entry); m_tree->getTree()->addTopLevelItem(topLvlList.takeAt(i).entry);
} }
// insert clients updateClientList();
for (auto& it : channelList) 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; anyID* clientIDList;
ts3.getChannelClientList(m_SCHID, it.id, &clientIDList); ts3.getChannelClientList(m_SCHID, it.id, &clientIDList);
...@@ -310,14 +312,16 @@ void OverlayController::displayChannelList() ...@@ -310,14 +312,16 @@ void OverlayController::displayChannelList()
tmp->setData(0, Qt::DisplayRole, clientID2Name(m_SCHID, clientIDList[i])); tmp->setData(0, Qt::DisplayRole, clientID2Name(m_SCHID, clientIDList[i]));
tmp->setData(1, Qt::UserRole, clientIDList[i]); tmp->setData(1, Qt::UserRole, clientIDList[i]);
tmp->setData(2, Qt::UserRole, client); tmp->setData(2, Qt::UserRole, client);
m_clientList.push_back(tmp);
it.entry->addChild(tmp); it.entry->addChild(tmp);
i++; i++;
} }
} }
}
// display everything void OverlayController::displayChannelList()
m_tree->getTree()->expandAll(); {
m_tree->getTree()->adjustSize(); m_tree->getTree()->adjustSize();
m_tree->adjustSize(); m_tree->adjustSize();
m_tree->show(); m_tree->show();
......
...@@ -17,6 +17,14 @@ ...@@ -17,6 +17,14 @@
#define TIMEOUT 5000 #define TIMEOUT 5000
struct ChannelInfo {
uint64 id;
QString name;
uint64 parent;
QTreeWidgetItem* entry;
int order;
};
class QTTSOVERLAY_EXPORT OverlayController : public QObject class QTTSOVERLAY_EXPORT OverlayController : public QObject
{ {
Q_OBJECT Q_OBJECT
...@@ -36,6 +44,8 @@ private: ...@@ -36,6 +44,8 @@ private:
QVector<QWidget*> m_speakers; QVector<QWidget*> m_speakers;
QVector<QWidget*> m_msgLines; QVector<QWidget*> m_msgLines;
ChannelListWidget* m_tree; ChannelListWidget* m_tree;
QVector<ChannelInfo> m_channelList;
QVector<QTreeWidgetItem*> m_clientList;
private: private:
void deleteChatLine(QWidget* line, QTimer *timer = NULL); void deleteChatLine(QWidget* line, QTimer *timer = NULL);
...@@ -50,5 +60,6 @@ public: ...@@ -50,5 +60,6 @@ public:
void debugPrint(QString text); void debugPrint(QString text);
void reset(); void reset();
void updateChannelList(); void updateChannelList();
void updateClientList();
void displayChannelList(); void displayChannelList();
}; };
...@@ -354,34 +354,32 @@ void ts3plugin_onConnectStatusChangeEvent(uint64 serverConnectionHandlerID, int ...@@ -354,34 +354,32 @@ void ts3plugin_onConnectStatusChangeEvent(uint64 serverConnectionHandlerID, int
else if (newStatus == STATUS_CONNECTION_ESTABLISHED) else if (newStatus == STATUS_CONNECTION_ESTABLISHED)
{ {
g_serverList.insert(serverConnectionHandlerID, new OverlayController(ts3Functions, serverConnectionHandlerID)); 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(); getController(serverConnectionHandlerID)->displayChannelList();
} }
} }
void ts3plugin_onNewChannelEvent(uint64 serverConnectionHandlerID, uint64 channelID, uint64 channelParentID) { 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) { 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) { 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) { 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) { 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) { 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) { 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 ...@@ -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) { 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 ClientName = clientID2Name(serverConnectionHandlerID, clientID);
QString oldChannel = channelID2Name(serverConnectionHandlerID, oldChannelID); QString oldChannel = channelID2Name(serverConnectionHandlerID, oldChannelID);
...@@ -422,7 +420,7 @@ void ts3plugin_onClientMoveSubscriptionEvent(uint64 serverConnectionHandlerID, a ...@@ -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) { 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 ClientName = clientID2Name(serverConnectionHandlerID, clientID);
QString oldChannel = channelID2Name(serverConnectionHandlerID, oldChannelID); QString oldChannel = channelID2Name(serverConnectionHandlerID, oldChannelID);
...@@ -447,7 +445,7 @@ void ts3plugin_onClientMoveTimeoutEvent(uint64 serverConnectionHandlerID, anyID ...@@ -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) { 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 ClientName = clientID2Name(serverConnectionHandlerID, clientID);
QString oldChannel = channelID2Name(serverConnectionHandlerID, oldChannelID); QString oldChannel = channelID2Name(serverConnectionHandlerID, oldChannelID);
...@@ -472,7 +470,7 @@ void ts3plugin_onClientMoveMovedEvent(uint64 serverConnectionHandlerID, anyID cl ...@@ -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) { 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 ClientName = clientID2Name(serverConnectionHandlerID, clientID);
QString oldChannel = channelID2Name(serverConnectionHandlerID, oldChannelID); QString oldChannel = channelID2Name(serverConnectionHandlerID, oldChannelID);
...@@ -486,7 +484,7 @@ void ts3plugin_onClientKickFromChannelEvent(uint64 serverConnectionHandlerID, an ...@@ -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) { 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); 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