void ServiceProvider::sendOperations(Jolie::Message message) { kDebug() << "send operations."; //kDebug() << printJolieMessage(message); Jolie::Message response(message.resourcePath(), message.operationName(), message.id()); //FIXME: this is duplicated from Plasma::Service QString path = KStandardDirs::locate("data", "plasma/services/" + m_service->name() + ".operations"); if (path.isEmpty()) { kDebug() << "Cannot find operations description:" << m_service->name() << ".operations"; response.setFault(Jolie::Fault("NoOperationsDescription")); } else { kDebug() << "file = " << path; QFile file(path); file.open(QIODevice::ReadOnly); Jolie::Value value; value.children(JolieMessage::Field::OPERATIONSDESCRIPTION) << Jolie::Value(file.readAll()); file.close(); response.setData(value); } QByteArray id = JolieMessage::field(JolieMessage::Field::IDENTITYID, message); QByteArray uuid = JolieMessage::field(JolieMessage::Field::UUID, message); response = appendToken(response, id, uuid); kDebug() << "caller = " << id.toBase64(); //hack around the not yet async service adaptor api in qtjolie if (m_descriptorMap.contains(id + uuid)) { kDebug() << "descriptor found, sending message"; AuthorizationManager::self()->d->server->sendReply( m_descriptorMap.value(id + uuid), response); } else { kDebug() << "no valid entry in descriptormap."; } }
void ServiceProvider::sendEnabledOperations(Jolie::Message message) { kDebug() << "send enabled operations."; Jolie::Message response(message.resourcePath(), message.operationName(), message.id()); QStringList enabledOperationsList; foreach (const QString &operation, m_service->operationNames()) { if (m_service->isOperationEnabled(operation)) { enabledOperationsList << operation; } } kDebug() << "enabled operations: " << enabledOperationsList; QByteArray enabledOperationsArray; QDataStream out(&enabledOperationsArray, QIODevice::WriteOnly); out << enabledOperationsList; Jolie::Value value; value.children(JolieMessage::Field::ENABLEDOPERATIONS) << Jolie::Value(enabledOperationsArray); response.setData(value); QByteArray id = JolieMessage::field(JolieMessage::Field::IDENTITYID, message); QByteArray uuid = JolieMessage::field(JolieMessage::Field::UUID, message); response = appendToken(response, id, uuid); kDebug() << "caller = " << id.toBase64(); //hack around the not yet async service adaptor api in qtjolie if (m_descriptorMap.contains(id + uuid)) { kDebug() << "descriptor found, sending message"; AuthorizationManager::self()->d->server->sendReply( m_descriptorMap.value(id + uuid), response); } else { kDebug() << "no valid entry in descriptormap."; } }
const Jolie::Message &message) { Q_UNUSED(server) if (message.operationName() == "startConnection") { kDebug() << "reset token"; //add the identity Credentials identity; QByteArray identityByteArray = JolieMessage::field(JolieMessage::Field::IDENTITY, message); QDataStream stream(&identityByteArray, QIODevice::ReadOnly); stream >> identity; AuthorizationManager::self()->d->addCredentials(identity); Jolie::Message response(message.resourcePath(), message.operationName(), message.id()); QByteArray uuid = JolieMessage::field(JolieMessage::Field::UUID, message); response = appendToken(response, identity.id().toAscii(), uuid); AuthorizationManager::self()->d->server->sendReply(descriptor, response); return; } if (JolieMessage::field(JolieMessage::Field::TOKEN, message).isEmpty()) { Jolie::Message response(message.resourcePath(), message.operationName(), message.id()); response.setFault(Jolie::Fault(JolieMessage::Error::INVALIDTOKEN)); AuthorizationManager::self()->d->server->sendReply(descriptor, response); return; } //m_descriptor = descriptor; QByteArray id = JolieMessage::field(JolieMessage::Field::IDENTITYID, message); QByteArray uuid = JolieMessage::field(JolieMessage::Field::UUID, message);
//function only called when run button pressed int scannar::splitStr() { deallocateVector(); //need to add this otherwise the last value will be cut of. //Space used because space will be ignored srcCode+=" \n"; //position size_t pos=0; size_t range=1; bool push=false; //numerals,alphabets and _ string regex="abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ_."; //filtering all the non aplhabetical and numerical symbols size_t delimiter = srcCode.find_first_not_of(regex); size_t oldPos=0; while (delimiter!=std::string::npos) { size_t length=delimiter-pos; //if not string,char or comment if(srcCode.substr(delimiter,1).compare("\"")!=0 &&srcCode.substr(delimiter,1).compare("'")!=0 &&srcCode.substr(delimiter,2).compare("//")!=0) { //length>0 because when then :: problems get eliminated ie //problems related to continues delimiters. if(length>0) { codeFragments.push_back(srcCode.substr(pos,length)); } //gets rid of space if(srcCode.substr(delimiter,1).compare(" ")!=0) { codeFragments.push_back(srcCode.substr(delimiter,1)); } range=1; } else{ bool comment=false; found=false; size_t findQuotes=0; //if it is a string type if(srcCode.substr(delimiter,1).compare("\"")==0) { findQuotes= srcCode.find_first_of("\"",delimiter+1); } //if it is a comment else if(srcCode.substr(delimiter,1).compare("/")==0){ if(srcCode.substr(delimiter+1,1).compare("/")==0) { if(length>0) { codeFragments.push_back(srcCode.substr(pos,length)); } findQuotes= srcCode.find_first_of("\n",delimiter+2); comment=true; } } else { findQuotes= srcCode.find_first_of("'",delimiter+1); } if(findQuotes==string::npos&&comment==false) { range=delimiter; return 6; } else { length=findQuotes-delimiter; range=length+1; if(!comment) { codeFragments.push_back(srcCode.substr(delimiter,length+1)); } else { ++lineNumber; codeFragments.push_back("\n"); } } push=true; } pos=delimiter+range; //used only for comments oldPos=delimiter; delimiter=srcCode.find_first_not_of(regex,delimiter+range); } int msg= appendToken(); return msg; }