diff options
author | Kevron Rees <tripzero.kev@gmail.com> | 2013-06-06 08:14:15 -0700 |
---|---|---|
committer | Kevron Rees <tripzero.kev@gmail.com> | 2013-06-06 08:14:15 -0700 |
commit | 96a068e4911a5e98d09181548183765caaa300d7 (patch) | |
tree | 8a9937695fefff0852e5d88a6704e5e1e4d7754e | |
parent | 296a9bbfc489cad346c2b05b17ff9a2d1b8a7797 (diff) | |
download | automotive-message-broker-bluemonkey.tar.gz |
silver version of bluemonkeybluemonkey
-rw-r--r-- | plugins/bluemonkey/bluemonkey.cpp | 15 | ||||
-rw-r--r-- | plugins/bluemonkey/bluemonkey.h | 11 | ||||
-rw-r--r-- | 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<string, string> 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()<<sender; } else if(codes.startsWith("bluemonkey")) @@ -106,6 +107,11 @@ BluemonkeySink::BluemonkeySink(AbstractRoutingEngine* e, map<string, string> 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()<<target<<s); - session->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); } } |