Пример #1
0
void dispatchEvent(Message* msg) {
	printMessage(msg);
	if (strcmp(msg->resource, "login") == 0) {
		if (strcmp(msg->method, "success") == 0) {
			setLogin(msg->body);
		} else if (strcmp(msg->method, "error") == 0) {
			printf("%s\n", msg->body);
		}
	} else if (strcmp(msg->resource, "register") == 0) {
		if (strcmp(msg->method, "success") == 0) {
			printf("User Registered Successfully, proceed to Log In\n");
		} else if (strcmp(msg->method, "error") == 0) {
			printf("%s\n", msg->body);
		}
	} else if (strcmp(msg->resource, "client") == 0) {
		if (strcmp(msg->method, "success") == 0) {
			clientRegistered();
		}
	}else if(strcmp(msg->resource, "mail") == 0){
		if(strcmp(msg->method, "receive") == 0){
			recieveEmails(atoi(msg->body));
		}else if(strcmp(msg->method, "success") == 0){
			printf("%s\n", msg->body);
		}else if(strcmp(msg->method, "error") == 0){
			printf("%s\n", msg->body);
		}else if(strcmp(msg->method, "continue") == 0){
			printf("Continue with message\n");
		}
	}else if(strcmp(msg->resource, "user") == 0){
		if(strcmp(msg->method, "fee") == 0){
			printf("Tarifacion: %s\n", msg->body);
		}
	}
}
GraphicsClientItemsClient::GraphicsClientItemsClient(QGraphicsScene *scene_) :
    JackClient("GraphicsClientItemsClient"),
    scene(scene_),
    clientStyle(3),
    audioPortStyle(1),
    midiPortStyle(3),
    font("Helvetica", 12),
    contextName(RecursiveJackContext::getInstance()->getCurrentContext()->get_name())
{
    setCallProcess(false);
    setEmitPortSignals(true);
    setEmitClientSignals(true);
    activate();
    // get all clients and create visual representations for them:
    QStringList clientNames = getClients();
    for (int i = 0; i < clientNames.size(); i++) {
        onClientRegistered(clientNames[i]);
    }
    // make sure we're notified when clients are registered or unregistered:
    QObject::connect(this, SIGNAL(clientRegistered(QString)), this, SLOT(onClientRegistered(QString)), Qt::QueuedConnection);
    QObject::connect(this, SIGNAL(clientUnregistered(QString)), this, SLOT(onClientUnregistered(QString)), Qt::QueuedConnection);
    // the same for ports:
    QObject::connect(this, SIGNAL(portRegistered(QString,QString,int)), this, SLOT(onPortRegistered(QString,QString,int)), Qt::QueuedConnection);
    QObject::connect(this, SIGNAL(portUnregistered(QString,QString,int)), this, SLOT(onPortRegistered(QString,QString,int)), Qt::QueuedConnection);
}
Пример #3
0
void OAuthWizard::onOAuthClientRegDone() {
  QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender());
  if (reply->error() != QNetworkReply::NoError) {
    errorMessage(tr("Network error: ") + reply->errorString());
    return;
  }

  QByteArray data = reply->readAll();

  QVariantMap json = parseJson(data);
  m_clientId = json["client_id"].toString();
  m_clientSecret = json["client_secret"].toString();

  emit clientRegistered(m_username, m_server, m_clientId, m_clientSecret);

  notifyMessage(QString(tr("Registered client to [%1] successfully.")).
                arg(m_server));

  getOAuthAccess();
}
Пример #4
0
ServerCatchcopy::inputReturnType ServerCatchcopy::parseInputCurrentProtocol(const uint32_t &client,const uint32_t &orderId,const std::vector<std::string> &returnList)
{
    if(returnList.size()==0)
        return WrongArgumentListSize;
    //if is supported
    std::string firstArgument=returnList.front();
    if(firstArgument=="protocol")
    {
        if(returnList.size()!=2)
            return WrongArgumentListSize;
        emit askProtocolCompatibility(client,orderId,returnList.back());
        return Ok;
    }
    else if(firstArgument=="protocol extension")
    {
        if(returnList.size()>3 || returnList.size()<2)
            return WrongArgumentListSize;
        return ExtensionWrong;
    }
    else if(firstArgument=="client")
    {
        if(returnList.size()!=2)
            return WrongArgumentListSize;
        int index=0;
        int size=clientList.size();
        while(index<size)
        {
            if(clientList.at(index).id==client)
            {
                clientList[index].name=returnList.back();
                break;
            }
            index++;
        }
        emit clientName(client,returnList.back());
        clientRegistered(client,orderId);
        return Replied;
    }
    else if(firstArgument=="server")
    {
        if(returnList.size()!=2)
            return WrongArgumentListSize;
        if(returnList.back()!="name?")
            return WrongArgument;
        serverName(client,orderId,name);
        return Replied;
    }
    else if(firstArgument=="cp")
    {
        if(returnList.size()<3)
            return WrongArgumentListSize;
        std::vector<std::string> sourceList=returnList;
        sourceList.erase(sourceList.cbegin());
        sourceList.pop_back();
        emitNewCopy(client,orderId,sourceList,returnList.back());
        return Ok;
    }
    else if(firstArgument=="cp-?")
    {
        if(returnList.size()<2)
            return WrongArgumentListSize;
        std::vector<std::string> sourceList=returnList;
        sourceList.erase(sourceList.cbegin());
        emitNewCopyWithoutDestination(client,orderId,sourceList);
        return Ok;
    }
    else if(firstArgument=="mv")
    {
        if(returnList.size()<3)
            return WrongArgumentListSize;
        std::vector<std::string> sourceList=returnList;
        sourceList.erase(sourceList.cbegin());
        sourceList.pop_back();
        emitNewMove(client,orderId,sourceList,returnList.back());
        return Ok;
    }
    else if(firstArgument=="mv-?")
    {
        if(returnList.size()<2)
            return WrongArgumentListSize;
        std::vector<std::string> sourceList=returnList;
        sourceList.erase(sourceList.cbegin());
        emitNewMoveWithoutDestination(client,orderId,sourceList);
        return Ok;
    }
    else //if is not supported
        return UnknowOrder;
}
Пример #5
0
ServerCatchcopy::inputReturnType ServerCatchcopy::parseInputCurrentProtocol(quint32 client,quint32 orderId,QStringList returnList)
{
	if(returnList.size()==0)
		return WrongArgumentListSize;
	//if is supported
	QString firstArgument=returnList.first();
	if(firstArgument=="protocol")
	{
		if(returnList.size()!=2)
			return WrongArgumentListSize;
		emit askProtocolCompatibility(client,orderId,returnList.last());
		return Ok;
	}
	else if(firstArgument=="protocol extension")
	{
		if(returnList.size()>3 || returnList.size()<2)
			return WrongArgumentListSize;
		if(!autoReply)
		{
			if(returnList.size()==2)
				emit askProtocolExtension(client,orderId,returnList.last());
			else
				emit askProtocolExtension(client,orderId,returnList.at(1),returnList.last());
		}
		return ExtensionWrong;
	}
	else if(firstArgument=="client")
	{
		if(returnList.size()!=2)
			return WrongArgumentListSize;
		emit clientName(client,returnList.last());
		if(autoReply)
		{
			clientRegistered(client,orderId);
			return Replied;
		}
		else
		{
			emit clientName(client,orderId,returnList.last());
			return Ok;
		}
	}
	else if(firstArgument=="server")
	{
		if(returnList.size()!=2)
			return WrongArgumentListSize;
		if(returnList.last()!="name?")
			return WrongArgument;
		if(autoReply)
		{
			serverName(client,orderId,name);
			return Replied;
		}
		else
		{
			askServerName(client,orderId);
			return Ok;
		}
	}
	else if(firstArgument=="cp")
	{
		if(returnList.size()<3)
			return WrongArgumentListSize;
		QStringList sourceList=returnList;
		sourceList.removeFirst();
		sourceList.removeLast();
		emitNewCopy(client,orderId,sourceList,returnList.last());
		return Ok;
	}
	else if(firstArgument=="cp-?")
	{
		if(returnList.size()<2)
			return WrongArgumentListSize;
		QStringList sourceList=returnList;
		sourceList.removeFirst();
		emitNewCopy(client,orderId,sourceList);
		return Ok;
	}
	else if(firstArgument=="mv")
	{
		if(returnList.size()<3)
			return WrongArgumentListSize;
		QStringList sourceList=returnList;
		sourceList.removeFirst();
		sourceList.removeLast();
		emitNewMove(client,orderId,sourceList,returnList.last());
		return Ok;
	}
	else if(firstArgument=="mv-?")
	{
		if(returnList.size()<2)
			return WrongArgumentListSize;
		QStringList sourceList=returnList;
		sourceList.removeFirst();
		emitNewMove(client,orderId,sourceList);
		return Ok;
	}
	else //if is not supported
		return UnknowOrder;
}