nettoyage

This commit is contained in:
2026-04-04 22:54:01 +02:00
parent 0d353b4d61
commit ada4d7ed99
-140
View File
@@ -124,10 +124,6 @@ void Pws2mqtt::init()
QMetaObject::invokeMethod(this, [this, query = request.query()]() {
this->parseData(query.queryItems());
}, Qt::QueuedConnection);
//QThreadPool::globalInstance()->start([this, query = request.query()]() {
// this->parseData(query.queryItems());
//});
//this->parseData(queryList);
debug(DEBUGMACRO, "Returning 'success'", DEBUG);
}
//mqttClient.send_message(jsonString);
@@ -570,143 +566,7 @@ QString formatNotifString (QString name, QString unit ,QByteArray value)
return text += "\n";
}
/*static size_t ReadFile(void *ptr, size_t size, size_t nmemb, void *stream) {
FILE *f = (FILE *)stream;
size_t n = fread(ptr, size, nmemb, f);
return n;
}
// Callback for curl library
static size_t WriteCallback(void *contents, size_t size, size_t nmemb, std::string *output)
{
size_t total_size = size * nmemb;
output->append((char*)contents, total_size);
return total_size;
}
*/
/*void notify(QString notif, QString priority, QString inputPath, QString tag)
{
CURL *curl;
CURLcode res;
std::string readBuffer;
priority = "Priority: " + priority;
debug (DEBUGMACRO, "notifying at priority " + priority + "with tag : " + tag + " - message : " + notif, DEBUG);
// Initialise libcurl
curl_global_init(CURL_GLOBAL_DEFAULT);
curl = curl_easy_init();
if (curl)
{
// Définis les en-têtes pour le titre et les priorités
struct curl_slist *headers = NULL;
notif.replace("\\", "\\\\\\'"); // Échappe les apostrophes
if (!tag.isEmpty())
{
headers = curl_slist_append(headers, ("Tags: " + tag).toStdString().c_str());
}
headers = curl_slist_append(headers, "Title: Météo");
headers = curl_slist_append(headers, priority.toStdString().c_str());
headers = curl_slist_append(headers, "Markdown: yes");
// headers = curl_slist_append(headers, "Config: /etc/ntfy.client.yml");
headers = curl_slist_append(headers, "Firebase: no");
// headers = curl_slist_append(headers, "Content-Type: charset=UTF-8; text/markdown"); // Ajout de l'encodage
struct curl_slist *h = headers;
while (h) {
debug(DEBUGMACRO, "Header: " + QString(h->data), DEBUG);
h = h->next;
}
debug(DEBUGMACRO, "Notif: " + notif, DEBUG);
// Configure la requête POST
curl_easy_setopt(curl, CURLOPT_URL, "http://localhost:81/Meteo");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, notif.toUtf8().constData());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
// Exécute la requête
res = curl_easy_perform(curl);
// Vérifie les erreurs
if (res != CURLE_OK)
{
debug(DEBUGMACRO, "Erreur libcurl :" + QString(curl_easy_strerror(res)), DEBUG);
} else
{
debug(DEBUGMACRO, "Réponse du serveur: " + QString::fromStdString(readBuffer), DEBUG);
}
// Nettoie les ressources
//curl_mime_free(mime);
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
}
// Nettoie libcurl
curl_global_cleanup();
if (!inputPath.isEmpty())
{
FILE *fd = fopen(inputPath.toStdString().c_str(), "rb");
if (!fd) {
perror("Erreur lors de l'ouverture du fichier");
return;
}
// Initialise libcurl
curl_global_init(CURL_GLOBAL_DEFAULT);
curl = curl_easy_init();
if (curl)
{
// Définis les en-têtes pour le titre et les priorités
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Title: Météo");
headers = curl_slist_append(headers, priority.toStdString().c_str());
// headers = curl_slist_append(headers, "Config: /etc/ntfy.client.yml");
headers = curl_slist_append(headers, "Firebase: no");
headers = curl_slist_append(headers, "Content-Type: image/png");
headers = curl_slist_append(headers, "X-Original-Size: true");
headers = curl_slist_append(headers, "X-Filename: fleche.png");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); // Configurer l'URL
curl_easy_setopt(curl, CURLOPT_URL, "localhost:81/Meteo");
// Utiliser la méthode PUT (comme `curl -T`)
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
// Lire le fichier et l'envoyer en tant que body
curl_easy_setopt(curl, CURLOPT_READFUNCTION, ReadFile);
curl_easy_setopt(curl, CURLOPT_READDATA, fd);
// Définir la taille du fichier (optionnel mais recommandé)
struct stat file_info;
fstat(fileno(fd), &file_info);
curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)file_info.st_size);
// Exécuter la requête
res = curl_easy_perform(curl);
// Vérifie les erreurs
if (res != CURLE_OK)
{
debug(DEBUGMACRO, "Erreur libcurl :" + QString(curl_easy_strerror(res)), DEBUG);
} else
{
debug(DEBUGMACRO, "Notification envoyée avec succès", DEBUG);
}
// Nettoyer
fclose(fd);
curl_easy_cleanup(curl);
}
// Nettoie libcurl
curl_global_cleanup();
}
}
*/
void rotateAndSaveImage(const QString &inputPath, const QString &outputPath, qreal angle)
{
QImage image(inputPath);