Beispiel #1
0
void Updater::CheckTriggerUpdateDialog()
{
//    TSLogging::Print(QString("Stable: %1").arg(m_VersionStable));
//    TSLogging::Print(QString("Beta: %1").arg(m_VersionBeta));
//    TSLogging::Print(QString("Local: %1").arg(ts3plugin_version()));

    if (!m_isBetaChannel)
    {
        if (m_VersionStable != ts3plugin_version())
            ShowUpdateDialog(m_VersionStable);
        else
            TSLogging::Log(QString("%1 version %2 is up to date.").arg(ts3plugin_name()).arg(ts3plugin_version()));
    }
    else
    {
        // Is Stable newer than beta?
        bool isStableNewer = false;
        if (m_VersionStable.isEmpty() && m_VersionBeta.isEmpty())
        {
            TSLogging::Log(QString("(Updater) Could not check for updates."));
        }
        else if (m_VersionStable.isEmpty()) // TS site is down
        {
            TSLogging::Log("(Updater) Could not get stable version info. Aborting.");
        }
        else if (m_VersionBeta.isEmpty()) // Beta site is down
        {
            TSLogging::Log("(Updater) Could not get beta version info.");
            isStableNewer = true;
        }
        else if (m_VersionBeta == m_VersionStable)
            isStableNewer = true;
        else
        {
            QStringList stable = m_VersionStable.split(".",QString::SkipEmptyParts);
            QStringList beta = m_VersionBeta.split(".",QString::SkipEmptyParts);
            bool isOk;
            for (int i = 0; i< stable.length(); ++i)
            {
                int stableInt = stable[i].toInt(&isOk,10);
                if (!isOk)
                    break;

                int betaInt = beta[i].toInt(&isOk,10);
                if (!isOk)
                    break;

                if (stableInt > betaInt)
                {
                    isStableNewer = true;
                    break;
                }
            }
            if (!isOk)
            {
                TSLogging::Log("(Updater) Problem with version comparison.");
                isStableNewer = true;
            }
//            TSLogging::Print(QString("(Updater) Remote Stable is %1 than beta.").arg((isStableNewer)?"newer":"older"));
        }

        if (isStableNewer && (m_VersionStable != ts3plugin_version()))
            ShowUpdateDialog(m_VersionStable);
        else if (!isStableNewer && (m_VersionBeta != ts3plugin_version()))
            ShowUpdateDialog(m_VersionBeta);
        else
            TSLogging::Log(QString("%1 version %2 is up to date.").arg(ts3plugin_name()).arg(ts3plugin_version()));
    }
}
Beispiel #2
0
void ts3plugin_onConnectStatusChangeEvent(uint64 serverConnectionHandlerID, int newStatus, unsigned int errorNumber) {
    /* Some example code following to show how to use the information query functions. */

    if(newStatus == STATUS_CONNECTION_ESTABLISHED) {  /* connection established and we have client and channels available */
        char* s;
        char msg[1024];
        anyID myID;
        uint64* ids;
        size_t i;
		unsigned int error;

        /* Print clientlib version */
        if(ts3Functions.getClientLibVersion(&s) == ERROR_ok) {
            printf("PLUGIN: Client lib version: %s\n", s);
            ts3Functions.freeMemory(s);  /* Release string */
        } else {
            ts3Functions.logMessage("Error querying client lib version", LogLevel_ERROR, "Plugin", serverConnectionHandlerID);
            return;
        }

		/* Write plugin name and version to log */
        snprintf(msg, sizeof(msg), "Plugin %s, Version %s, Author: %s", ts3plugin_name(), ts3plugin_version(), ts3plugin_author());
        ts3Functions.logMessage(msg, LogLevel_INFO, "Plugin", serverConnectionHandlerID);

        /* Print virtual server name */
        if((error = ts3Functions.getServerVariableAsString(serverConnectionHandlerID, VIRTUALSERVER_NAME, &s)) != ERROR_ok) {
			if(error != ERROR_not_connected) {  /* Don't spam error in this case (failed to connect) */
				ts3Functions.logMessage("Error querying server name", LogLevel_ERROR, "Plugin", serverConnectionHandlerID);
			}
            return;
        }
        printf("PLUGIN: Server name: %s\n", s);
        ts3Functions.freeMemory(s);

        /* Print virtual server welcome message */
        if(ts3Functions.getServerVariableAsString(serverConnectionHandlerID, VIRTUALSERVER_WELCOMEMESSAGE, &s) != ERROR_ok) {
            ts3Functions.logMessage("Error querying server welcome message", LogLevel_ERROR, "Plugin", serverConnectionHandlerID);
            return;
        }
        printf("PLUGIN: Server welcome message: %s\n", s);
        ts3Functions.freeMemory(s);  /* Release string */

        /* Print own client ID and nickname on this server */
        if(ts3Functions.getClientID(serverConnectionHandlerID, &myID) != ERROR_ok) {
            ts3Functions.logMessage("Error querying client ID", LogLevel_ERROR, "Plugin", serverConnectionHandlerID);
            return;
        }
        if(ts3Functions.getClientSelfVariableAsString(serverConnectionHandlerID, CLIENT_NICKNAME, &s) != ERROR_ok) {
            ts3Functions.logMessage("Error querying client nickname", LogLevel_ERROR, "Plugin", serverConnectionHandlerID);
            return;
        }
        printf("PLUGIN: My client ID = %d, nickname = %s\n", myID, s);
        ts3Functions.freeMemory(s);

        /* Print list of all channels on this server */
        if(ts3Functions.getChannelList(serverConnectionHandlerID, &ids) != ERROR_ok) {
            ts3Functions.logMessage("Error getting channel list", LogLevel_ERROR, "Plugin", serverConnectionHandlerID);
            return;
        }
        printf("PLUGIN: Available channels:\n");
        for(i=0; ids[i]; i++) {
            /* Query channel name */
            if(ts3Functions.getChannelVariableAsString(serverConnectionHandlerID, ids[i], CHANNEL_NAME, &s) != ERROR_ok) {
                ts3Functions.logMessage("Error querying channel name", LogLevel_ERROR, "Plugin", serverConnectionHandlerID);
                return;
            }
            printf("PLUGIN: Channel ID = %llu, name = %s\n", (long long unsigned int)ids[i], s);
            ts3Functions.freeMemory(s);
        }
        ts3Functions.freeMemory(ids);  /* Release array */

        /* Print list of existing server connection handlers */
        printf("PLUGIN: Existing server connection handlers:\n");
        if(ts3Functions.getServerConnectionHandlerList(&ids) != ERROR_ok) {
            ts3Functions.logMessage("Error getting server list", LogLevel_ERROR, "Plugin", serverConnectionHandlerID);
            return;
        }
        for(i=0; ids[i]; i++) {
            if((error = ts3Functions.getServerVariableAsString(ids[i], VIRTUALSERVER_NAME, &s)) != ERROR_ok) {
				if(error != ERROR_not_connected) {  /* Don't spam error in this case (failed to connect) */
					ts3Functions.logMessage("Error querying server name", LogLevel_ERROR, "Plugin", serverConnectionHandlerID);
				}
                continue;
            }
            printf("- %llu - %s\n", (long long unsigned int)ids[i], s);
            ts3Functions.freeMemory(s);
        }
        ts3Functions.freeMemory(ids);
    }
}
Beispiel #3
0
void Updater::ShowUpdateDialog(QString remoteVersion)
{
    QWidget* mainWindow = TSHelpers::GetMainWindow();
    // Create Dialog
    QMessageBox updateMsgBox(mainWindow);
//    updateMsgBox = new QMessageBox();
    updateMsgBox.moveToThread(mainWindow->thread());
//    updateMsgBox->setAttribute( Qt::WA_DeleteOnClose, true ); //makes sure the msgbox is deleted automatically when closed
    updateMsgBox.setIcon(QMessageBox::Question);
    updateMsgBox.setText(QString("An update for %1 is available!").arg(ts3plugin_name()));
    updateMsgBox.setInformativeText(QString("Local Version: %1\nRemote Version: %2\n\nContinue to download site?\n\nNote that due to client limitations, Teamspeak will be closed to enable plugin installation.").arg(ts3plugin_version()).arg(remoteVersion));
    //updateMsgBox.setDetailedText(QString("Local Version: %1\nRemote Version: %2").arg(ts3plugin_version()).arg(remoteVersion));
    updateMsgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
    updateMsgBox.setDefaultButton(QMessageBox::Ok);
    updateMsgBox.setWindowTitle(ts3plugin_name());
    int ret = updateMsgBox.exec();    // blocking variant; might work to workaround api check disaster
//    updateMsgBox->open(this,SLOT(onButtonClicked(QAbstractButton*)));
//    updateMsgBox->deleteLater();

    // I must be missing something for the non-blocking variant to work -.-
    if (ret == QMessageBox::Ok || ret == QMessageBox::Yes)
    {
        QDesktopServices::openUrl((remoteVersion==m_VersionStable)?STABLE:BETA_DOWNLOAD);
        qApp->quit();
    }
    else if (ret == QMessageBox::Cancel || ret == QMessageBox::No)
        TSLogging::Log("Update Rejected",LogLevel_INFO);
    else
        TSLogging::Print("Could not find button role");
}