den eigenen Channel herausfinden (Einfach aus meinem Plugin heraus kopiert, daher nur als Beispiel):
anyID funcwrapper::getOwnClientID(uint64 connectionHandlerID) { anyID clientID; if(this->ts3Functions.getClientID(connectionHandlerID, &clientID) != ERROR_ok) { clientID = 0; } return clientID;}uint64 funcwrapper::getChannelID(uint64 connectionHandlerID, anyID clientID) { uint64 channelID; if(this->ts3Functions.getChannelOfClient(connectionHandlerID, clientID, &channelID) != ERROR_ok) { channelID = 0; } return channelID;}
Hotkeys, welche über die normale Konfiguration gesetzt werden, aber im Plugin genutzt werden:
/* Helper function to create a hotkey */static struct PluginHotkey* createHotkey(const char* keyword, const char* description) { struct PluginHotkey* hotkey = (struct PluginHotkey*)malloc(sizeof(struct PluginHotkey)); _strcpy(hotkey->keyword, PLUGIN_HOTKEY_BUFSZ, keyword); _strcpy(hotkey->description, PLUGIN_HOTKEY_BUFSZ, description); return hotkey;}/* Some makros to make the code to create hotkeys a bit more readable */#define BEGIN_CREATE_HOTKEYS(x) const size_t sz = x + 1; size_t n = 0; *hotkeys = (struct PluginHotkey**)malloc(sizeof(struct PluginHotkey*) * sz);#define CREATE_HOTKEY(a, b) (*hotkeys)[n++] = createHotkey(a, b);#define END_CREATE_HOTKEYS (*hotkeys)[n++] = NULL; assert(n == sz);/* * Initialize plugin hotkeys. If your plugin does not use this feature, this function can be omitted. * Hotkeys require ts3plugin_registerPluginID and ts3plugin_freeMemory to be implemented. * This function is automatically called by the client after ts3plugin_init. */void ts3plugin_initHotkeys(struct PluginHotkey*** hotkeys) { QVariantHash hotkeyEntries = moduleLoader::instance()->getHotkeyEntries(); BEGIN_CREATE_HOTKEYS((hotkeyEntries.keys().count())); foreach(QString keyword, hotkeyEntries.keys()) { CREATE_HOTKEY(keyword.toStdString().c_str(), hotkeyEntries.value(keyword).toString().toStdString().c_str()); } END_CREATE_HOTKEYS;}
Wobei die Liste in etwa mit dem Code erstellt worden ist:
QList<QVariantHash> homeChannel::getHotkeyKeywords() { QList<QVariantHash> entries; QVariantHash entry; entry.insert("keyword", "homechannel.toggle"); entry.insert("name", tr("Toggle Homechannel")); entries.append(entry); return entries;}
Und was die Informationen über den Channel betrifft, so bin auch ich dabei, mir alle Informationen selbst zu speichern, wenn die entsprechenden Events auftreten:
void ts3plugin_onClientMoveEvent(uint64 serverConnectionHandlerID, anyID clientID, uint64 oldChannelID, uint64 newChannelID, int visibility, const char* moveMessage) {
anyID ownClientID = funcwrapper::instance()->getOwnClientID(serverConnectionHandlerID);
if(ownClientID == 0)
return;
uint64 ownChannelID = funcwrapper::instance()->getChannelID(serverConnectionHandlerID, ownClientID);
if(clientID == ownClientID) {
funcwrapper::instance()->readChannelClients(serverConnectionHandlerID, ownChannelID);
QVariantHash channelObj;
channelObj.insert("source", server::instance()->getChannelObj(QString::number(serverConnectionHandlerID))
->getData(QString::number(oldChannelID)));
channelObj.insert("dest", server::instance()->getChannelObj(QString::number(serverConnectionHandlerID))
->getData(QString::number(newChannelID)));
moduleLoader::instance()->eventParser(EVENT_CLIENT_MOVE,
server::instance()->getData(QString::number(serverConnectionHandlerID)),
channelObj,
QVariantHash());
return;
}
if(visibility != LEAVE_VISIBILITY)
funcwrapper::instance()->readClient(serverConnectionHandlerID, clientID);
if(newChannelID == ownChannelID) {
//Client joins Channel
QVariantHash clientObj;
clientObj.insert("affected", server::instance()->getClientsObj(QString::number(serverConnectionHandlerID))
->getData(QString::number(clientID)));
moduleLoader::instance()->eventParser(EVENT_CHANNEL_JOIN_OTHER,
server::instance()->getData(QString::number(serverConnectionHandlerID)),
QVariantHash(),
clientObj);
return;
}
if(oldChannelID == ownChannelID && newChannelID == 0) {
//Client leaves Server
QVariantHash clientObj;
clientObj.insert("affected", server::instance()->getClientsObj(QString::number(serverConnectionHandlerID))
->getData(QString::number(clientID)));
moduleLoader::instance()->eventParser(EVENT_CHANNEL_DISCONNECT_OTHER,
server::instance()->getData(QString::number(serverConnectionHandlerID)),
QVariantHash(),
clientObj);
return;
}
if(oldChannelID == ownChannelID) {
//Client leaves Channel
QVariantHash clientObj;
clientObj.insert("affected", server::instance()->getClientsObj(QString::number(serverConnectionHandlerID))
->getData(QString::number(clientID)));
moduleLoader::instance()->eventParser(EVENT_CHANNEL_LEAVE_OTHER,
server::instance()->getData(QString::number(serverConnectionHandlerID)),
QVariantHash(),
clientObj);
}
}
void ts3plugin_onClientMoveMovedEvent(uint64 serverConnectionHandlerID, anyID clientID, uint64 oldChannelID, uint64 newChannelID, int visibility, anyID moverID, const char* moverName, const char* moverUniqueIdentifier, const char* moveMessage) {
anyID ownClientID = funcwrapper::instance()->getOwnClientID(serverConnectionHandlerID);
if(ownClientID == 0)
return;
funcwrapper::instance()->readClient(serverConnectionHandlerID, clientID);
funcwrapper::instance()->readClient(serverConnectionHandlerID, moverID);
if(clientID == ownClientID) {
funcwrapper::instance()->readChannelClients(serverConnectionHandlerID, newChannelID);
QVariantHash clientObj, channelObj;
clientObj.insert("executor", server::instance()->getClientsObj(QString::number(serverConnectionHandlerID))
->getData(QString::number(moverID)));
channelObj.insert("source", server::instance()->getChannelObj(QString::number(serverConnectionHandlerID))
->getData(QString::number(oldChannelID)));
channelObj.insert("dest", server::instance()->getChannelObj(QString::number(serverConnectionHandlerID))
->getData(QString::number(newChannelID)));
moduleLoader::instance()->eventParser(EVENT_CLIENT_MOVED,
server::instance()->getData(QString::number(serverConnectionHandlerID)),
channelObj,
clientObj);
}
}
Alles anzeigen
Als weitere Information. Ich programmiere meine Plugins primär unter Linux mit dem Qt-Framework, welches ebenfalls bei Teamspeak verwendet wird, daher sind die nötigen Libraries bereits vorhanden. Unter Windows ist aber das entsprechende Visual-Studio, bzw. der entsprechende Compiler von Visual-Studio erforderlich, welcher für Teamspeak3 verwendet wird. Dann kann das Plugin ohne weitere "Abhängigkeiten" direkt verwendet werden.