From e0838a2164cbf2cccd4cf981c3c6253bb1ecade9 Mon Sep 17 00:00:00 2001 From: Jordan Sherer Date: Thu, 31 Jan 2019 18:53:29 -0500 Subject: [PATCH] Message id for response to query and message id for a generic message retreival --- mainwindow.cpp | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 6c0a770..dea1b7d 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -9964,6 +9964,8 @@ void MainWindow::processCommandActivity() { // PROCESS BUFFERED QUERY else if (d.cmd == " QUERY" && ui->autoReplyButton->isChecked()){ + auto who = d.from; + QStringList segs = d.text.split(" "); if(segs.isEmpty()){ continue; @@ -9972,8 +9974,39 @@ void MainWindow::processCommandActivity() { auto cmd = segs.first(); segs.removeFirst(); - if(cmd == "MSG"){ + if(cmd == "MSG" && !segs.isEmpty()){ + auto inbox = Inbox(inboxPath()); + if(!inbox.open()){ + continue; + } + bool ok = false; + int mid = QString(segs.first()).toInt(&ok); + if(!ok){ + continue; + } + + auto msg = inbox.value(mid); + auto params = msg.params(); + if(params.isEmpty()){ + continue; + } + + auto from = params.value("FROM").toString().trimmed(); + if(from != who){ + continue; + } + + auto text = params.value("TEXT").toString().trimmed(); + if(text.isEmpty()){ + continue; + } + + reply = QString("%1>MSG %2 %3 DE %4"); + reply = reply.arg(who); + reply = reply.arg(mid); + reply = reply.arg(text); + reply = reply.arg(from); } } @@ -9986,12 +10019,14 @@ void MainWindow::processCommandActivity() { continue; } + // if this is an allcall or a directed call, check to see if we have a stored message for user. + // we reply yes if the user would be able to retreive a stored message auto v = inbox.values("STORE", "$.params.TO", who, 0, 10); foreach(auto pair, v){ auto params = pair.second.params(); auto text = params.value("TEXT").toString().trimmed(); if(!text.isEmpty()){ - reply = QString("%1 YES").arg(who); + reply = QString("%1 YES MSG %2").arg(who).arg(pair.first); break; } }