From 96a068e4911a5e98d09181548183765caaa300d7 Mon Sep 17 00:00:00 2001 From: Kevron Rees Date: Thu, 6 Jun 2013 08:14:15 -0700 Subject: silver version of bluemonkey --- plugins/bluemonkey/bluemonkey.cpp | 15 ++++++++++++++- plugins/bluemonkey/bluemonkey.h | 11 +---------- plugins/bluemonkey/irccoms.cpp | 11 ++++++----- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/plugins/bluemonkey/bluemonkey.cpp b/plugins/bluemonkey/bluemonkey.cpp index e8cfb0a1..05ea3eeb 100644 --- a/plugins/bluemonkey/bluemonkey.cpp +++ b/plugins/bluemonkey/bluemonkey.cpp @@ -91,12 +91,13 @@ BluemonkeySink::BluemonkeySink(AbstractRoutingEngine* e, map con { int i = codes.indexOf("authenticate"); - QString pin = codes.mid(i+10); + QString pin = codes.mid(i+13); pin = pin.trimmed(); if(!auth->authorize(prefix, pin)) irc->respond(sender,"failed"); + qDebug()< con irc->respond(sender, "denied"); return; } + + QString bm("bluemonkey"); + + codes = codes.mid(bm.length()+1); + irc->respond(sender, engine->evaluate(codes).toString()); } }); @@ -211,3 +217,10 @@ void Property::setType(QString t) routingEngine->getPropertyAsync(request); } + +void Property::propertyChanged(VehicleProperty::Property property, AbstractPropertyType *value, string uuid) +{ + mValue = value->copy(); + + changed(gvariantToQVariant(mValue->toVariant())); +} diff --git a/plugins/bluemonkey/bluemonkey.h b/plugins/bluemonkey/bluemonkey.h index 7ec155eb..96b7297d 100644 --- a/plugins/bluemonkey/bluemonkey.h +++ b/plugins/bluemonkey/bluemonkey.h @@ -46,16 +46,7 @@ public: virtual PropertyList subscriptions() { PropertyList list; list.push_back(type().toStdString()); return list; } virtual void supportedChanged(PropertyList ){ } - virtual void propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, std::string uuid) - { - mValue = value->copy(); - - QJsonDocument doc; - - doc.fromJson(mValue->toString().c_str()); - - changed(doc.toVariant()); - } + virtual void propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, std::string uuid); virtual std::string uuid() { return amb::createUuid(); } diff --git a/plugins/bluemonkey/irccoms.cpp b/plugins/bluemonkey/irccoms.cpp index 1cdb12e4..75d72317 100644 --- a/plugins/bluemonkey/irccoms.cpp +++ b/plugins/bluemonkey/irccoms.cpp @@ -39,10 +39,11 @@ void IrcCommunication::announce(QString s) void IrcCommunication::respond(QString target, QString s) { - IrcCommand command; - command.setType(IrcCommand::Message); - command.setParameters(QStringList()<sendCommand(&command); + IrcCommand *command = IrcCommand::createMessage(target,s); + session->sendCommand(command); + + delete command; + } void IrcCommunication::messageReceived(IrcMessage *msg) @@ -56,7 +57,7 @@ void IrcCommunication::messageReceived(IrcMessage *msg) QString sender = msg->parameters().at(0); QString m = msg->parameters().at(1); - message(sender,msg->sender().prefix(),m); + message(sender, msg->sender().prefix(), m); } } -- cgit v1.2.1