Commit 8a63ca0f authored by Carsten Fuhrmann's avatar Carsten Fuhrmann

support more callback events

parent 0f0350e1
......@@ -19,7 +19,8 @@ struct channelInfo {
enum nodeType {
channel,
client
client,
spacer
};
Q_DECLARE_METATYPE(nodeType);
......@@ -230,12 +231,16 @@ void OverlayController::displayChannelList()
channelInfo tmp;
tmp.id = channelIDList[i];
tmp.name = channelID2Name(m_SCHID, channelIDList[i]);
ts3.getParentChannelOfChannel(m_SCHID, channelIDList[i], &tmp.parent);
tmp.entry = new QTreeWidgetItem;
tmp.entry->setData(0, Qt::DisplayRole, tmp.name);
tmp.entry->setData(1, Qt::UserRole, tmp.id);
tmp.entry->setData(2, Qt::UserRole, channel);
if (tmp.name.startsWith('[') && tmp.name.contains("spacer"))
tmp.entry->setData(2, Qt::UserRole, spacer);
else
tmp.entry->setData(2, Qt::UserRole, channel);
channelList.push_back(tmp);
i++;
......
......@@ -242,10 +242,8 @@ uint64 getCurrentChannel(uint64 serverConnectionHandlerID)
QString clientID2Name(uint64 serverConnectionHandlerID, anyID clientID)
{
char* tmp = NULL;
ts3Functions.getClientVariableAsString(serverConnectionHandlerID, clientID, CLIENT_NICKNAME, &tmp);
if (tmp == NULL)
char* tmp;
if(ts3Functions.getClientVariableAsString(serverConnectionHandlerID, clientID, CLIENT_NICKNAME, &tmp) != ERROR_ok)
return QString();
QString name(tmp);
......@@ -255,10 +253,8 @@ QString clientID2Name(uint64 serverConnectionHandlerID, anyID clientID)
QString channelID2Name(uint64 serverConnectionHandlerID, uint64 channelID)
{
char* tmp = NULL;
ts3Functions.getChannelVariableAsString(serverConnectionHandlerID, channelID, CHANNEL_NAME, &tmp);
if (tmp == NULL)
char* tmp;
if(ts3Functions.getChannelVariableAsString(serverConnectionHandlerID, channelID, CHANNEL_NAME, &tmp) != ERROR_ok)
return QString();
QString name(tmp);
......@@ -340,26 +336,35 @@ void ts3plugin_onClientMoveEvent(uint64 serverConnectionHandlerID, anyID clientI
getController(serverConnectionHandlerID)->updateChannelList();
QString name = clientID2Name(serverConnectionHandlerID, clientID);
QString ClientName = clientID2Name(serverConnectionHandlerID, clientID);
QString oldChannel = channelID2Name(serverConnectionHandlerID, oldChannelID);
QString newChannel = channelID2Name(serverConnectionHandlerID, newChannelID);
anyID myID;
ts3Functions.getClientID(serverConnectionHandlerID, &myID);
if (!name.isEmpty() && !oldChannel.isEmpty() && !newChannel.isEmpty())
if (!ClientName.isEmpty() && !oldChannel.isEmpty() && !newChannel.isEmpty())
{
// joined my channel
if (newChannelID == getCurrentChannel(serverConnectionHandlerID))
getController(serverConnectionHandlerID)->addChatLine(QString("<font color=\"#00FF00\">%1 <font size=\"-5\">entered from</font> %2</font>").arg(name).arg(oldChannel));
getController(serverConnectionHandlerID)->addChatLine(QString("<font color=\"#00FFFF\">%1 <font size=\"-5\">entered from</font> %2</font>").arg(ClientName).arg(oldChannel));
// quit my channel
else if (oldChannelID == getCurrentChannel(serverConnectionHandlerID))
getController(serverConnectionHandlerID)->addChatLine(QString("<font color=\"#FF0000\">%1 <font size=\"-5\">left to</font> %2</font>").arg(name).arg(newChannel));
getController(serverConnectionHandlerID)->addChatLine(QString("<font color=\"#00FFFF\">%1 <font size=\"-5\">left to</font> %2</font>").arg(ClientName).arg(newChannel));
// somewhere else
else
getController(serverConnectionHandlerID)->addChatLine(QString("<font size=\"-5\">%1 moved from %2 to %3</font>").arg(name).arg(oldChannel).arg(newChannel));
getController(serverConnectionHandlerID)->addChatLine(QString("<font size=\"-5\">%1 moved from %2 to %3</font>").arg(ClientName).arg(oldChannel).arg(newChannel));
}
else if (!ClientName.isEmpty() && oldChannel.isEmpty() && !newChannel.isEmpty())
{
getController(serverConnectionHandlerID)->addChatLine(QString("%1 <font size=\"-5\">connected to</font> %2").arg(ClientName).arg(newChannel));
}
else if (!ClientName.isEmpty() && !oldChannel.isEmpty() && newChannel.isEmpty())
{
if(oldChannelID == getCurrentChannel(serverConnectionHandlerID))
getController(serverConnectionHandlerID)->addChatLine(QString("<font color=\"#00FFFF\">%1 <font size=\"-5\">disconnected from</font> %2</font>").arg(ClientName).arg(oldChannel));
else
getController(serverConnectionHandlerID)->addChatLine(QString("%1 <font size=\"-5\">disconnected from</font> %2").arg(ClientName).arg(oldChannel));
}
}
......@@ -368,15 +373,79 @@ 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();
QString ClientName = clientID2Name(serverConnectionHandlerID, clientID);
QString oldChannel = channelID2Name(serverConnectionHandlerID, oldChannelID);
QString newChannel = channelID2Name(serverConnectionHandlerID, newChannelID);
anyID myID;
ts3Functions.getClientID(serverConnectionHandlerID, &myID);
if (!ClientName.isEmpty() && !oldChannel.isEmpty() && !newChannel.isEmpty())
{
// joined my channel
if (newChannelID == getCurrentChannel(serverConnectionHandlerID))
getController(serverConnectionHandlerID)->addChatLine(QString("<font color=\"#00FFFF\">%1 <font size=\"-5\">timeout from</font> %2</font>").arg(ClientName).arg(oldChannel));
// quit my channel
else if (oldChannelID == getCurrentChannel(serverConnectionHandlerID))
getController(serverConnectionHandlerID)->addChatLine(QString("<font color=\"#00FFFF\">%1 <font size=\"-5\">timeout to</font> %2</font>").arg(ClientName).arg(newChannel));
// somewhere else
else
getController(serverConnectionHandlerID)->addChatLine(QString("<font size=\"-5\">%1 timeout from %2 to %3</font>").arg(ClientName).arg(oldChannel).arg(newChannel));
}
}
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();
QString ClientName = clientID2Name(serverConnectionHandlerID, clientID);
QString oldChannel = channelID2Name(serverConnectionHandlerID, oldChannelID);
QString newChannel = channelID2Name(serverConnectionHandlerID, newChannelID);
anyID myID;
ts3Functions.getClientID(serverConnectionHandlerID, &myID);
if (!ClientName.isEmpty() && !oldChannel.isEmpty() && !newChannel.isEmpty())
{
// joined my channel
if (newChannelID == getCurrentChannel(serverConnectionHandlerID))
getController(serverConnectionHandlerID)->addChatLine(QString("<font color=\"#00FFFF\">%1 <font size=\"-5\">entered from</font> %2 <font size=\"-5\">by</font> %3</font>").arg(ClientName).arg(oldChannel).arg(moverName));
// quit my channel
else if (oldChannelID == getCurrentChannel(serverConnectionHandlerID))
getController(serverConnectionHandlerID)->addChatLine(QString("<font color=\"#00FFFF\">%1 <font size=\"-5\">left to</font> %2 <font size=\"-5\">left by</font> %3</font>").arg(ClientName).arg(newChannel).arg(moverName));
// somewhere else
else
getController(serverConnectionHandlerID)->addChatLine(QString("<font size=\"-5\">%1 moved from %2 to %3 by %4</font>").arg(ClientName).arg(oldChannel).arg(newChannel).arg(moverName));
}
}
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();
QString ClientName = clientID2Name(serverConnectionHandlerID, clientID);
QString oldChannel = channelID2Name(serverConnectionHandlerID, oldChannelID);
QString newChannel = channelID2Name(serverConnectionHandlerID, newChannelID);
if (!ClientName.isEmpty() && !oldChannel.isEmpty() && !newChannel.isEmpty())
{
getController(serverConnectionHandlerID)->addChatLine(QString("<font color=\"#FF0000\">%1 <font size=\"-5\">was from</font> %2 <font size=\"-5\">to</font> %3 <font size=\"-5\">by</font> %4 <font size=\"-5\">because</font> %5</font>").arg(ClientName).arg(oldChannel).arg(newChannel).arg(kickerName).arg(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();
QString ClientName = clientID2Name(serverConnectionHandlerID, clientID);
if (!ClientName.isEmpty())
{
getController(serverConnectionHandlerID)->addChatLine(QString("<font color=\"#FF0000\">%1 <font size=\"-5\">was from Server by</font> %2 <font size=\"-5\">because</font> %3</font>").arg(ClientName).arg(kickerName).arg(kickMessage));
}
}
void ts3plugin_onClientIDsEvent(uint64 serverConnectionHandlerID, const char* uniqueClientIdentifier, anyID clientID, const char* clientName) {
......@@ -480,7 +549,7 @@ void ts3plugin_onClientBanFromServerEvent(uint64 serverConnectionHandlerID, anyI
int ts3plugin_onClientPokeEvent(uint64 serverConnectionHandlerID, anyID fromClientID, const char* pokerName, const char* pokerUniqueIdentity, const char* message, int ffIgnored) {
getController(serverConnectionHandlerID)->addChatLine(QString("<font color=\"#00FFFF\"><font size=\"-5\">%1</font> Wake up! %2</font>").arg(pokerName).arg(message));
getController(serverConnectionHandlerID)->addChatLine(QString("<font color=\"#00FF00\"><font size=\"-5\">%1</font> Wake up! %2</font>").arg(pokerName).arg(message));
return 0; /* 0 = handle normally, 1 = client will ignore the poke */
}
......
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