1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
|
#ifdef _WIN32
#pragma warning (disable : 4100)
#include <Windows.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <shlwapi.h>
#pragma comment(lib, "shlwapi.lib")
#include "shlobj.h"
#include "public_errors.h"
#include "public_errors_rare.h"
#include "public_definitions.h"
#include "public_rare_definitions.h"
#include "ts3_functions.h"
#include "plugin.h"
static struct TS3Functions ts3Functions;
#ifdef _WIN32
#define _strcpy(dest, destSize, src) strcpy_s(dest, destSize, src)
#define snprintf sprintf_s
#else
#define _strcpy(dest, destSize, src) { strncpy(dest, src, destSize-1); (dest)[destSize-1] = '\0'; }
#endif
#define PLUGIN_API_VERSION 20
#define PATH_BUFSIZE 512
#define COMMAND_BUFSIZE 128
#define INFODATA_BUFSIZE 128
#define SERVERINFO_BUFSIZE 256
#define CHANNELINFO_BUFSIZE 512
#define RETURNCODE_BUFSIZE 128
static char* pluginID = NULL;
#ifdef _WIN32
static int wcharToUtf8(const wchar_t* str, char** result) {
int outlen = WideCharToMultiByte(CP_UTF8, 0, str, -1, 0, 0, 0, 0);
*result = (char*)malloc(outlen);
if (WideCharToMultiByte(CP_UTF8, 0, str, -1, *result, outlen, 0, 0) == 0) {
*result = NULL;
return -1;
}
return 0;
}
#endif
/*********************************** Required functions ************************************/
const char* ts3plugin_name() {
#ifdef _WIN32
static char* result = NULL;
if (!result) {
const wchar_t* name = L"Support Notification";
if (wcharToUtf8(name, &result) == -1) {
result = "Support Notification";
}
}
return result;
#else
return "Support Notification";
#endif
}
const char* ts3plugin_version() {
return "1.0";
}
int ts3plugin_apiVersion() {
return PLUGIN_API_VERSION;
}
const char* ts3plugin_author() {
return "Dione";
}
const char* ts3plugin_description() {
return "This plugin will play a notification sound, if a user joins a support channel.";
}
void ts3plugin_setFunctionPointers(const struct TS3Functions funcs) {
ts3Functions = funcs;
}
int ts3plugin_init() {
char appPath[PATH_BUFSIZE];
char resourcesPath[PATH_BUFSIZE];
char configPath[PATH_BUFSIZE];
char pluginPath[PATH_BUFSIZE];
printf("PLUGIN: init\n");
ts3Functions.getAppPath(appPath, PATH_BUFSIZE);
ts3Functions.getResourcesPath(resourcesPath, PATH_BUFSIZE);
ts3Functions.getConfigPath(configPath, PATH_BUFSIZE);
ts3Functions.getPluginPath(pluginPath, PATH_BUFSIZE);
printf("PLUGIN: App path: %s\nResources path: %s\nConfig path: %s\nPlugin path: %s\n", appPath, resourcesPath, configPath, pluginPath);
return 0;
}
void ts3plugin_shutdown() {
printf("PLUGIN: shutdown\n");
if (pluginID) {
free(pluginID);
pluginID = NULL;
}
}
/************************** TeamSpeak callbacks ***************************/
void ts3plugin_onClientMoveEvent(uint64 serverConnectionHandlerID, anyID clientID, uint64 oldChannelID, uint64 newChannelID, int visibility, const char* moveMessage) {
char appPath[PATH_BUFSIZE];
ts3Functions.getAppPath(appPath, PATH_BUFSIZE);
std::string applicationPath(appPath);
std::string restOfPath = "sound/default/talkpower_requested.wav";
std::string soundPath = applicationPath + restOfPath;
if (newChannelID == 33948)
{
ts3Functions.playWaveFile(1, soundPath);
// ts3Functions.requestSendChannelTextMsg(serverConnectionHandlerID, appPath, 17148, NULL);
}
if (newChannelID == 33949)
{
ts3Functions.playWaveFile(1, soundPath);
// ts3Functions.requestSendChannelTextMsg(serverConnectionHandlerID, appPath, 17148, NULL);
}
}
|