void tst_QWidgetsVariant::debugStream() { QFETCH(QVariant, variant); QFETCH(int, typeId); MessageHandler msgHandler(typeId); qDebug() << variant; QVERIFY(msgHandler.testPassed()); }
bool FLJasperEngine::setReportTemplate(const QString &t) { QString xml(FLSqlConnections::database()->managerModules()->content(t + ".jrxml")); QTextCodec *codec = QTextCodec::codecForName("utf8"); bool ret = FLUtil::domDocumentSetContent(d->xmlTemplate_, codec->toUnicode(xml)); if (ret) { QDomElement e(d->xmlTemplate_.documentElement()); if (e.isNull() || e.tagName().lower() != "jasperreport") { msgHandler(AQErrorMsg, tr("La plantilla del informe no es del tipo JasperReport")); ret = false; } } return ret; }
void tcpRxTxThread(void *args) { int *sock = (int *)args; while (msgHandler(*sock) == 0); close(*sock); }
void Logger::msgHandler4(const QtMsgType type, const char* message) { msgHandler(type,message); }
void Logger::msgHandler5(const QtMsgType type, const QMessageLogContext &context, const QString &message) { (void)(context); // suppress "unused parameter" warning msgHandler(type,message,context.file,context.function,context.line); }
bool IrcBot::bot() { char *text; char buf[1024]; int bytes_read; int bytes_send; string sendCommands[5] = { "PONG", "USER "+userName+" 8 * :"+userName, "NICK "+nickName, "PRIVMSG nickserv identify "+userPass, "JOIN "+channelName }; printf("Connecting to %s:%s\nNick: %s | Channel: %s\n", hostName.c_str(), portString.c_str(), nickName.c_str(), channelName.c_str()); ConnectSocket = INVALID_SOCKET; struct addrinfo *result = NULL, *ptr = NULL, hints; const char *sendbuf = "\nPONG :Bot\n"; char recvbuf[DEFAULT_BUFLEN] = { }; int recvbuflen = DEFAULT_BUFLEN; #ifdef WIN32 // start WinSock Initialization WSADATA wsaData; // Initialize Winsock iResult = WSAStartup(MAKEWORD(2,2), &wsaData); if (iResult != 0) { printf("WSAStartup failed with error: %d\n", iResult); return 1; } #endif // WIN32 ZeroMemory( &hints, sizeof(hints) ); hints.ai_family = AF_INET; hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = IPPROTO_TCP; // Resolve the server address and port iResult = getaddrinfo(hostName.c_str(), portString.c_str(), &hints, &result); if ( iResult != 0 ) { printf("getaddrinfo failed with error: %d\n", iResult); #ifdef WIN32 WSACleanup(); #endif // WIN32 return 1; } // Attempt to connect to an address until one succeeds for(ptr=result; ptr != NULL ;ptr=ptr->ai_next) { // Create a SOCKET for connecting to server ConnectSocket = socket(ptr->ai_family, ptr->ai_socktype, ptr->ai_protocol); if (ConnectSocket == INVALID_SOCKET) { printf("socket failed with error: %ld\n", WSAGetLastError()); WSACleanup(); return 1; } // Connect to server. iResult = connect( ConnectSocket, ptr->ai_addr, (int)ptr->ai_addrlen); if (iResult == SOCKET_ERROR) { closesocket(ConnectSocket); ConnectSocket = INVALID_SOCKET; continue; } break; } freeaddrinfo(result); if (ConnectSocket == INVALID_SOCKET) { printf("Unable to connect to server!\n"); #ifdef WIN32 WSACleanup(); #endif // WIN32 return 1; } // Send an initial buffer iResult = send( ConnectSocket, sendbuf, (int)strlen(sendbuf), 0 ); if(DEBUG == true) printf("Sendbuf: %s\n", sendbuf); if (iResult == SOCKET_ERROR) { #ifdef WIN32 printf("send failed with error: %d\n", WSAGetLastError()); closesocket(ConnectSocket); WSACleanup(); #endif // WIN32 return 1; } printf("Bytes Sent: %ld\n", iResult); // Receive until the peer closes the connection int count = 0; while(1) { count++; switch(count) { case 2: // we send data to server after 3 counts // nick sendCommand(ConnectSocket, "\nUSER %s Bot Bot : %s\n", userName.c_str(), userName.c_str()); // user sendCommand(ConnectSocket, "\nNICK %s\r\n", nickName.c_str()); break; case 11: // register sendCommand(ConnectSocket, "\nPRIVMSG nickserv identify %s\r\n", userPass.c_str()); break; case 12: // we join channel sendCommand(ConnectSocket, "\nJOIN %s\r\n", channelName.c_str()); default: break; } // Recv and print data bytes_read = recv(ConnectSocket, buf, MAXDATASIZE-1, 0); buf[bytes_read]='\0'; cout << buf << endl; // buf is the data that is recieved // pass buffer to message handler msgHandler(buf); // if we get ping if(charSearch(buf,"PING")) { sendPong(buf); } //break if connection closed if(bytes_read == 0) { cout << "Connection closed!" << endl; cout << timeNow() << endl; break; } } #ifdef WIN32 // cleanup closesocket(ConnectSocket); WSACleanup(); #elif LINUX close(ConnectSocket); #endif return true; }