dropped http client support
This commit is contained in:
parent
aaf7e00a5b
commit
d25d387e13
|
@ -54,33 +54,18 @@ Parser::Parser(SnarlNetworkFrontend *snarl):
|
|||
}
|
||||
|
||||
|
||||
bool Parser::parse(Notification &sNotification,const QString &msg,QTcpSocket* client)
|
||||
void Parser::parse(Notification &sNotification,const QString &msg,QTcpSocket* client)
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << msg;
|
||||
QStringList splitted;
|
||||
bool isHttp = false;
|
||||
|
||||
QStringList splitted(msg.split("#?"));
|
||||
snpTypes action(ERROR);
|
||||
if(msg.startsWith("GET "))
|
||||
{
|
||||
QString tmp = msg.mid(msg.indexOf("/")+1);
|
||||
tmp = tmp.mid(0,tmp.indexOf(" "));
|
||||
tmp = QString(QByteArray::fromBase64(tmp.toLatin1().data()));
|
||||
qDebug()<<"Notification from a browser"<<msg;
|
||||
isHttp = true;
|
||||
splitted = tmp.split("#?");
|
||||
}
|
||||
else
|
||||
{
|
||||
splitted = msg.split("#?");
|
||||
}
|
||||
|
||||
QString appName;
|
||||
QString alertName;
|
||||
QString title;
|
||||
QString text;
|
||||
QString icon;
|
||||
int timeout=10;
|
||||
int timeout = Notification::defaultTimeout();
|
||||
|
||||
QString key;
|
||||
QString value;
|
||||
|
@ -127,7 +112,6 @@ bool Parser::parse(Notification &sNotification,const QString &msg,QTcpSocket* cl
|
|||
}
|
||||
|
||||
|
||||
|
||||
if(!alertName.isEmpty() && app.isValid())
|
||||
{
|
||||
if(app.alerts().contains(alertName))
|
||||
|
@ -155,7 +139,6 @@ bool Parser::parse(Notification &sNotification,const QString &msg,QTcpSocket* cl
|
|||
sNotification = Notification(app,alert,title,text,icon,timeout);
|
||||
sNotification.data()->setSource(snarl);
|
||||
sNotification.hints().setValue("snarl_clientSocket", qVariantFromValue(client));
|
||||
sNotification.hints().setValue("snarl_isHttpCLient", isHttp);
|
||||
break;
|
||||
}
|
||||
case ADD_CLASS:
|
||||
|
@ -192,6 +175,5 @@ bool Parser::parse(Notification &sNotification,const QString &msg,QTcpSocket* cl
|
|||
default:
|
||||
break;
|
||||
}
|
||||
return isHttp;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ class Parser : public QObject
|
|||
public:
|
||||
Parser(class SnarlNetworkFrontend* snarl);
|
||||
|
||||
bool parse(Snore::Notification &sNotification, const QString &msg, class QTcpSocket* client);
|
||||
void parse(Snore::Notification &sNotification, const QString &msg, class QTcpSocket* client);
|
||||
|
||||
private:
|
||||
class SnarlNetworkFrontend *snarl;
|
||||
|
|
|
@ -114,7 +114,7 @@ void SnarlNetworkFrontend::handleMessages()
|
|||
continue;
|
||||
}
|
||||
Notification noti;
|
||||
bool isHttp = parser->parse(noti, s, client);
|
||||
parser->parse(noti, s, client);
|
||||
if(noti.isValid())
|
||||
{
|
||||
snore()->broadcastNotification(noti);
|
||||
|
@ -124,13 +124,6 @@ void SnarlNetworkFrontend::handleMessages()
|
|||
{
|
||||
write(client, QString("%1\r\n").arg(out));
|
||||
}
|
||||
|
||||
|
||||
if(isHttp)
|
||||
{
|
||||
client->disconnectFromHost();
|
||||
client->waitForDisconnected();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -140,13 +133,6 @@ void SnarlNetworkFrontend::callback(Notification &sn, const QString msg)
|
|||
{
|
||||
QTcpSocket *client = qvariant_cast<QTcpSocket*>(sn.hints().value("snarl_clientSocket"));
|
||||
write(client, QString("%1%2\r\n").arg(msg, QString::number(sn.id())));
|
||||
client->flush();
|
||||
|
||||
if(sn.hints().value("snarl_isHttpClient",false).toBool())
|
||||
{
|
||||
client->waitForBytesWritten(-1);
|
||||
client->disconnectFromHost();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue