Example #1
0
/**
 * 读取JPEG文件内容发送
 * 参数:客户端套接字地址
 *       文件名
 */
void catJPEG(void *sock, char *filename){
       int clnt_sock = *((int *) sock);
    char buf[1024];
    FILE *fp;
    FILE *fw;

    char status[] = "HTTP/1.0 200 OK\r\n";
    char header[] = "Server: A Simple Web Server\r\nContent-Type: image/jpeg\r\n\r\n";

    // 发送响应报文状态行
    write(clnt_sock, status, strlen(status));
    // 发送响应报文消息头
    write(clnt_sock, header, strlen(header));
    // 图片文件以二进制格式打开
    fp = fopen(filename, "rb");
    if(NULL == fp){
        errorHandling(sock);
        close(clnt_sock);
        errorHandling("opne file failed!");
        return ;
    }

    // 在套接字上打开一个文件句柄
    fw = fdopen(clnt_sock, "w");
    fread(buf, 1, sizeof(buf), fp);
    while (!feof(fp)){
        fwrite(buf, 1, sizeof(buf), fw);
        fread(buf, 1, sizeof(buf), fp);
    }

    fclose(fw);
    fclose(fp);
    close(clnt_sock);
}
Example #2
0
/**
 * 读取HTML文件内容发送
 * 参数:客户端套接字地址
 *       文件名
 */
void catHTML(void *sock, char *filename){
    int clnt_sock = *((int *) sock);
    char buf[1024];
    FILE *fp;

    char status[] = "HTTP/1.0 200 OK\r\n";
    char header[] = "Server: A Simple Web Server\r\nContent-Type: text/html\r\n\r\n";
    // 发送响应报文状态行
    write(clnt_sock, status, strlen(status));
    // 发送响应报文消息头
    write(clnt_sock, header, strlen(header));

    fp = fopen(filename, "r");
    if(NULL == fp){
        errorHandling(sock);
        close(clnt_sock);
        errorHandling("opne file failed!");
        return ;
    }

    // 读取文件内容并发送
    fgets(buf, sizeof(buf), fp);
    while (!feof(fp))
    {
        write(clnt_sock, buf, strlen(buf));
        fgets(buf, sizeof(buf), fp);
    }

    fclose(fp);
    close(clnt_sock);
}
Example #3
0
void MailTransport::connectionFailed(const QList<QSslError>& errors)
{
    if (ignoreCertificateErrors(errors))
        mSocket->ignoreSslErrors();
    else
        errorHandling(QAbstractSocket::UnknownSocketError, "");
}
Example #4
0
void Updater::downloadUpdate()
{
    if(m_netManager->networkAccessible() != QNetworkAccessManager::NotAccessible)
    {
        m_progressDialog = new QProgressDialog(nullptr);
        m_progressDialog->setWindowModality(Qt::ApplicationModal);

        m_progressDialog->setWindowTitle(tr("Veuillez patienter"));
        m_progressDialog->setLabelText(tr("Téléchargement de la mise à jour de %1 en cours").arg(m_appName));
        m_progressDialog->setValue(0);
        connect(m_progressDialog, SIGNAL(canceled()),this, SLOT(cancelDownload()));
        m_progressDialog->show();

        m_netRequest.setUrl(m_urlExe);
        m_netReply = m_netManager->get(m_netRequest);

        connect(m_netReply, SIGNAL(error(QNetworkReply::NetworkError)), this,
                SLOT(errorHandling(QNetworkReply::NetworkError)));
        connect(m_netReply, SIGNAL(finished()),this, SLOT(writeUpdate()));
        connect(m_netReply, SIGNAL(downloadProgress(qint64, qint64)),this,
                SLOT(updateProgress(qint64, qint64)));
    }
    else
        noNetworkError();
}
Example #5
0
const rbVertexArray* Value::to() const
{
	errorHandling(T_DATA);
	const rbVertexArray* object = nullptr;
	if(myValue != Qnil)
	    Data_Get_Struct(myValue, rbVertexArray, object);
	return object;
}
Example #6
0
rbRenderTargetRef* Value::to() const
{
	errorHandling(T_DATA);
	rbRenderTargetRef* object = nullptr;
	if(myValue != Qnil)
	    Data_Get_Struct(myValue, rbRenderTargetRef, object);
	return object;
}
Example #7
0
const rbRenderWindow* Value::to() const
{
	errorHandling(T_DATA);
	const rbRenderWindow* object = nullptr;
	if(myValue != Qnil)
	    Data_Get_Struct(myValue, rbRenderWindow, object);
	return object;
}
Example #8
0
const rbImage* Value::to() const
{
	errorHandling(T_DATA);
	const rbImage* object = nullptr;
	if(myValue != Qnil)
	    Data_Get_Struct(myValue, rbImage, object);
	return object;
}
Example #9
0
sf::Vertex Value::to() const
{
    errorHandling(T_OBJECT);
    sf::Vertex vertex(
        getVar<symVarPosition, sf::Vector2f>(), getVar<symVarColor, sf::Color>(), getVar<symVarTexCoords, sf::Vector2f>()
    );
    return vertex;
}
Example #10
0
rbRectangleShape* Value::to() const
{
	errorHandling(T_DATA);
	rbRectangleShape* object = nullptr;
	if(myValue != Qnil)
	    Data_Get_Struct(myValue, rbRectangleShape, object);
	return object;
}
Example #11
0
void Updater::checkUpdate()
{
    a_netRequest.setUrl(a_urlVersion);
    a_netReply = a_netManager->get(a_netRequest);
    connect(a_netReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(errorHandling(QNetworkReply::NetworkError)));
    connect(a_netReply, SIGNAL(finished()), this, SLOT(processUpdateReading()));
    a_checkUpdateProgressDialog = new QProgressDialog (tr("Vérification des mises à jour..."), QString(), 0, 0);
    a_checkUpdateProgressDialog->setWindowTitle("Updater");
    a_progressTimer.setSingleShot(true);
    a_progressTimer.start(1000); //This delays the dialog
    connect(&a_progressTimer, SIGNAL(timeout()), this, SLOT(showCheckingProgress()));
}
Example #12
0
/**
 * 处理浏览器请求
 * 参数 *sock 客户端套接字地址
*/
void requestHandling(void *sock){
  int clnt_sock = *((int *) sock);
  printf("client socket is: %d\n", clnt_sock);

  //缓存区
  char buf[1024];
  //请求方法
  char method[10];
  //请求的文件名
  char filename[20];

  //读取浏览器请求内容
  read(clnt_sock, buf, sizeof(buf)-1);

  //检查请求协议是否正确
  if (NULL == strstr(buf, "HTTP/")) {
    errorHandling(sock);
    close(clnt_sock);
    return ;
  }

  //保存请求方法到method数组
  strcpy(method, strtok(buf, " /"));

  //保存文件名到filename数组
  strcpy(filename, strtok(NULL, " /"));
  printf("请求的文件名是: %s\n", filename);

  //判断请求方法是不是GET请求, 不是GET则进行请求错误处理
  if (0 != strcmp(method, "GET")) {
    errorHandling(sock);
    close(clnt_sock);
    return ;
  }

  //访问请求文件
  sendData(sock, filename);
}
Example #13
0
void MetaInfoParser::parseFile(const QString &path)
{
    QFile file;
    file.setFileName(path);
    if (!file.open(QIODevice::ReadOnly))
        throw new InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__);

    QXmlStreamReader reader;
    reader.setDevice(&file);

    while (!reader.atEnd()) {
        reader.readNext();
        tokenHandler(reader);
    }
    errorHandling(reader, file);
}
Example #14
0
unsigned WINAPI IOCPThreadMain(LPVOID pComPort)
{
	HANDLE hComPort = (HANDLE)pComPort;
	DWORD bytesTrans;
	Client* client;
	IOContext* context;
	char buffer[BUF_SIZE] = { 0, };

	while (true)
	{
		if (!GetQueuedCompletionStatus(hComPort, &bytesTrans,
			(PULONG_PTR)&client, (LPOVERLAPPED*)&context, INFINITE))
		{
			int error = GetLastError();

			if (error != ERROR_NETNAME_DELETED)
			{
				errorHandling("GetQueuedCompletionStatus() error!");
				break;
			}
		}

		if (context->recv)
		{
			if (bytesTrans == 0)
			{
				ClientManager::getInstance()->removeClient(client);
			}
			else
			{
				client->update(context->buf, bytesTrans);

				client->recv();
			}
		}

		delete context;
	}
	return 0;
}
Example #15
0
/**
 * 处理浏览器请求的文件
 * 参数:客户端套接字地址
 *      请求文件名
 */
void sendData(void *sock, char *filename){
    int clnt_sock = *((int *) sock);
    char buf[20];
    char ext[10];

    strcpy(buf, filename);

    // 判断文件类型
    strtok(buf, ".");
    strcpy(ext, strtok(NULL, "."));
    if(0 == strcmp(ext, "php")){ // 如果是php文件
        // 暂未处理
    }else if(0 == strcmp(ext, "html")){  // 如果是html文件
        catHTML(sock, filename);
    }else if(0 == strcmp(ext, "jpg")){ // 如果是jpg图片
        catJPEG(sock, filename);
    }else{
        errorHandling(sock);
        close(clnt_sock);
        return ;
    }
}
Example #16
0
void SmsClient::newConnection()
{
    // XXX need better way to handle this.
    QSettings c("PhoneProfile"); // no tr
    c.beginGroup("Profiles"); // no tr
    bool planeMode = c.value("PlaneMode", false).toBool();
    smsSending = true;
    if (planeMode) {
        errorHandling(0, tr("Messages cannot be sent in Airplane Mode."));
        return;
    }

    QList<RawSms>::iterator rawMsg;
    for ( rawMsg = smsList.begin(); rawMsg != smsList.end(); rawMsg++) {
        QSMSMessage msg;

        //check for vcard over sms
        if (rawMsg->mimetype == QLatin1String("text/x-vCard")) {
            QString vcardData = rawMsg->body;
            //restore CR's stripped by composer
            vcardData.replace("\n","\r\n");
            msg.setApplicationData(vcardData.toLatin1());
            msg.setDestinationPort(9204);
        } else {
            msg.setText( rawMsg->body );
        }

        msg.setRecipient( rawMsg->number );

        QString smsKey = sender->send( msg );
        sentMessages.insert( smsKey, *rawMsg );
        ++total;
    }
    success = true;
    smsSending = false;
    smsList.clear();
}
Example #17
0
void SupplierManageWindow::removeSupplier()
{
    int currentRow = tv_supplier->selectionModel()->currentIndex().row();
    if(currentRow < 0) {
	QMessageBox::critical(this,
	  trUtf8("Error"),
	  trUtf8("Debe seleccionar el Proveedor que desea dar de baja."));
	return;
    }

    currentRow = proxyModel->mapToSource(proxyModel->index(currentRow, 0)).row();
    QString name = m_model->data(m_model->index(currentRow, Name)).toString();

    QString msg;
    msg = trUtf8("¿Está seguro dar de baja al Proveedor: ");
    msg += name;
    msg += trUtf8("?");

    int r = QMessageBox::warning(this,
      trUtf8("Confirme la baja"),
      msg,
      QMessageBox::Ok | QMessageBox::Cancel);
    if(r != QMessageBox::Ok)
	return;

    if(!m_model->removeRow(currentRow)) {
	errorHandling(DATABASE_ERROR, m_model->lastError().number());
	return;
    }

    if(m_model->rowCount() == 0) {
	tb_edit->setEnabled(false);
	tb_remove->setEnabled(false);
    }

    le_filter->setFocus();
}
{
    /** Kommunikációs signalok-slotok.*/
    connect(&tcpClient,SIGNAL(dataReady(QDataStream&)),
            &dataParser,SLOT(dataInput(QDataStream&)));
    connect(&serialPort,SIGNAL(dataReady(QDataStream&)),
            &dataParser,SLOT(dataInput(QDataStream&)));

    /** Hibakezelő slothoz tartozó kötözések.*/
    connect(&tcpClient,SIGNAL(errorOccurred(const QString&)),
            this,SLOT(errorHandling(const QString&)));
    connect(&dataParser,SIGNAL(errorOccurred(const QString&)),
            this,SLOT(errorHandling(const QString&)));
    connect(&serialPort,SIGNAL(errorOccurred(const QString&)),
            this,SLOT(errorHandling(const QString&)));
    connect(&dataLogger,SIGNAL(errorOccurred(QString)),
            this,SLOT(errorHandling(QString)));

    /** A grafikon datainak frissítésért felelős signalok-slotok.*/
    QObject::connect(&eventhandler,SIGNAL(getData(QMap<QString,QVector<double>>&)),
                     &dataParser,SLOT(getData(QMap<QString,QVector<double>>&)));
    QObject::connect(&dataParser,SIGNAL(newToPlot()),
                     &eventhandler,SLOT(replot()));

    /** GUI kijelzéshez tartozó signalok-slotok.*/
    QObject::connect(&dataParser, SIGNAL(newString(QSharedPointer<QString>)),
                     &eventhandler, SLOT(stringMessage(QSharedPointer<QString>)));
    QObject::connect(&tcpClient, SIGNAL(connectedToServer()),
                     this, SLOT(connectedToServer()));

    /** A loggolásért felelős jelek összekötése.*/
    QObject::connect(&dataLogger, SIGNAL(getDataToLog()),
Example #19
0
int main(int argc, char *argv[]) {
	int serv_sock;
	int clnt_sock;

	char buf[1024];

	struct sockaddr_in serv_addr;
	struct sockaddr_in clnt_addr;
	socklen_t clnt_addr_size;

	char status[] = "HTTP/1.0 200 OK/r/n";
	char header[] = "Server:A Simple Web Server\r\nContent-type: text/html\r\n\r\n";
	char body[] = "<html><head><title>A Simple Web Server</title></head><body><h2>Welcome!></h2><p>This is Beginner!</p></body></html>";

	serv_sock = socket(PF_INET, SOCK_STREAM,0);
	if (-1 == serv_sock) {
		errorHandling("socket() error");
	}
	memset(&serv_addr, 0, sizeof(serv_addr));
	serv_addr.sin_family = AF_INET; 
	serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
	serv_addr.sin_port = htons(PORT);	
	
	if (-1 == bind(serv_sock,(struct sockaddr*)&serv_addr, sizeof(serv_addr))) {
		errorHandling("bind() error");	
	}

	if (-1 == listen(serv_sock, 5)) {
		errorHandling("listen() error");
	}
	//clnt_addr_size = sizeof(clnt_addr);
	//clnt_sock = accept(serv_sock, (struct sockaddr *) &clnt_addr, &clnt_addr_size);
//	if (-1 == clnt_sock) {
//		errorHandling("accept() error");
//	}
   
	   
    while(1){
        // 接受客户端的请求
        clnt_addr_size = sizeof(clnt_addr);
        clnt_sock = accept(serv_sock, (struct sockaddr *) &clnt_addr, &clnt_addr_size);
        if(-1 == clnt_sock){
            errorHandling("accept() error");
        }

        // 处理客户端请求
        requestHandling((void *) &clnt_sock);
    }

    // 关闭套接字
    close(serv_sock);

	
//	read(clnt_sock, buf, sizeof(buf)-1);
//	printf("%s",buf);
	

//	write(clnt_sock, status, sizeof(status));
//	write(clnt_sock, header, sizeof(header));
//	write(clnt_sock, body, sizeof(body));	
	
//	close(clnt_sock);
//	close(serv_sock);

} 
Example #20
0
sf::Texture::CoordinateType Value::to() const
{
    errorHandling(T_FIXNUM);
    return static_cast<sf::Texture::CoordinateType>(to<unsigned int>());
}
int mainU(int argc, SAP_UC** argv){
	RFC_RC rc;
	RFC_FUNCTION_DESC_HANDLE stfcDeepTableDesc;
	RFC_CONNECTION_PARAMETER repoCon[8], serverCon[3];
	RFC_CONNECTION_HANDLE repoHandle, serverHandle;
	RFC_ERROR_INFO errorInfo;

	serverCon[0].name = cU("program_id");	serverCon[0].value = cU("MY_SERVER");
	serverCon[1].name = cU("gwhost");		serverCon[1].value = cU("hostname");
	serverCon[2].name = cU("gwserv");		serverCon[2].value = cU("sapgw53");

	repoCon[0].name = cU("client");	repoCon[0].value = cU("000");
	repoCon[1].name = cU("user");		repoCon[1].value = cU("user");
	repoCon[2].name = cU("passwd");	repoCon[2].value = cU("****");
	repoCon[3].name = cU("lang");		repoCon[3].value = cU("DE");
	repoCon[4].name = cU("ashost");	repoCon[4].value = cU("hostname");
	repoCon[5].name = cU("sysnr");	repoCon[5].value = cU("53");

	printfU(cU("Logging in..."));
	repoHandle = RfcOpenConnection (repoCon, 6, &errorInfo);
	if (repoHandle == NULL) errorHandling(errorInfo.code, cU("Error in RfcOpenConnection()"), &errorInfo, NULL);
	printfU(cU(" ...done\n"));

	printfU(cU("Fetching metadata..."));
	stfcDeepTableDesc = RfcGetFunctionDesc(repoHandle, cU("STFC_DEEP_TABLE"), &errorInfo);
	// Note: STFC_DEEP_TABLE exists only from SAP_BASIS release 6.20 on
	if (stfcDeepTableDesc == NULL) errorHandling(errorInfo.code, cU("Error in Repository Lookup"), &errorInfo, repoHandle);
	printfU(cU(" ...done\n"));

	printfU(cU("Logging out..."));
	RfcCloseConnection(repoHandle, &errorInfo);
	printfU(cU(" ...done\n"));

	rc = RfcInstallServerFunction(NULL, stfcDeepTableDesc, stfcDeepTableImplementation, &errorInfo);
	if (rc != RFC_OK) errorHandling(rc, cU("Error Setting "), &errorInfo, repoHandle);

	printfU(cU("Registering Server..."));
	serverHandle = RfcRegisterServer(serverCon, 3, &errorInfo);
	if (serverHandle == NULL) errorHandling(errorInfo.code, cU("Error Starting RFC Server"), &errorInfo, NULL);
	printfU(cU(" ...done\n"));

	printfU(cU("Starting to listen...\n\n"));
	while(RFC_OK == rc || RFC_RETRY == rc || RFC_ABAP_EXCEPTION == rc){
		rc = RfcListenAndDispatch(serverHandle, 120, &errorInfo);
		printfU(cU("RfcListenAndDispatch() returned %s\n"), RfcGetRcAsString(rc));
		switch (rc){
			case RFC_OK:
				break;
			case RFC_RETRY:	// This only notifies us, that no request came in within the timeout period.
						    // We just continue our loop.
				printfU(cU("No request within 120s.\n"));
				break;
			case RFC_ABAP_EXCEPTION:	// Our function module implementation has returned RFC_ABAP_EXCEPTION.
								// This is equivalent to an ABAP function module throwing an ABAP Exception.
								// The Exception has been returned to R/3 and our connection is still open.
								// So we just loop around.
				printfU(cU("ABAP_EXCEPTION in implementing function: %s\n"), errorInfo.key);
				break;
			case RFC_NOT_FOUND:	// R/3 tried to invoke a function module, for which we did not supply
							    // an implementation. R/3 has been notified of this through a SYSTEM_FAILURE,
							    // so we need to refresh our connection.
				printfU(cU("Unknown function module: %s\n"), errorInfo.message);
            /*FALLTHROUGH*/
            case RFC_EXTERNAL_FAILURE:	// Our function module implementation raised a SYSTEM_FAILURE. In this case
								        // the connection needs to be refreshed as well.
				printfU(cU("SYSTEM_FAILURE has been sent to backend.\n\n"));
            /*FALLTHROUGH*/
			case RFC_COMMUNICATION_FAILURE:
			case RFC_ABAP_MESSAGE:		// And in these cases a fresh connection is needed as well
            default:
                serverHandle = RfcRegisterServer(serverCon, 3, &errorInfo);
				rc = errorInfo.code;
				break;
		}

		// This allows us to shutdown the RFC Server from R/3. The implementation of STFC_DEEP_TABLE
		// will set listening to false, if IMPORT_TAB-C == STOP.
		if (!listening){
			RfcCloseConnection(serverHandle, NULL);
			break;
		}
	}

	return 0;
}
Example #22
0
int main(int argc, char *argv[]){

  //保存创建的服务器端套接字
  int serv_sock;
  //保存接受请求的客户端套接字
  int clnt_sock;
  //缓冲区
  char buf[1024];

  //保存服务器套接字地址信息
  struct sockaddr_in serv_addr;
  //保存客户端套接字地址信息
  struct sockaddr_in clnt_addr;
  //套接字地址变量的大小
  socklen_t clnt_addr_size;

  //发送给客户端的固定内容
  char status[] = "HTTP/1.0 200 OK\r\n";
  char header[] = "Server: A Simple Web Server\r\nContent-Type: text/html\r\n\r\n";
  char body[] = "<html><head><title>A Simple Web Server</title><head><body><h1>This is my first Web server</h1></body></html>";

  //创建一个服务器套接字
  serv_sock = socket(PF_INET, SOCK_STREAM, 0);
  if(-1 == serv_sock){
    errorHandling("Socket error()");
  }

  //配置套接字IP和端口信息
  memset(&serv_addr, 0, sizeof(serv_addr));
  serv_addr.sin_family = AF_INET;
  serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
  serv_addr.sin_port = htons(PORT);

  //绑定服务器套接字
  if (-1 == bind(serv_sock, (struct sockaddr*)&serv_addr, sizeof(serv_addr))) {
    errorHandling("bind() error");
  }

  //监听服务器套接字
  if(-1 == listen(serv_sock, 5)){
    errorHandling("listen() error");
  }

  while (1) {
    //接受客户端的请求
    clnt_addr_size = sizeof(clnt_addr);
    clnt_sock = accept(serv_sock,(struct sockaddr *) &clnt_addr, &clnt_addr_size);
    if (-1 ==clnt_sock) {
      errorHandling("accept() error");
    }

    requestHandling((void *) &clnt_sock);
  }



  //读取客户端请求
  // read(clnt_sock, buf, sizeof(buf) -1);
  // printf("%s\n", buf);
  //
  // //向客户端套接字发送信息
  // write(clnt_sock, status, sizeof(status));
  // write(clnt_sock, header, sizeof(header));
  // write(clnt_sock, body, sizeof(body));
  //
  // //关闭套接字
  // close(clnt_sock);

  close(serv_sock);

  return 0;

}
Example #23
0
int main(int argc, char* argv[])
{
	WSADATA wsaData;
	HANDLE hComPort;

	SOCKET hServSock;
	SOCKADDR_IN servAdr;
	DWORD flags = 0;

	if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0)
	{
		errorHandling("WSAStartup() error!");
		return -1;
	}

	hComPort = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 0);

	_beginthreadex(NULL, 0, IOCPThreadMain, (LPVOID)hComPort, 0, NULL);

	hServSock = WSASocket(AF_INET, SOCK_STREAM, 0, NULL, 0, WSA_FLAG_OVERLAPPED);
	
	if (hServSock == INVALID_SOCKET)
	{
		errorHandling("WSASocket() error!");
		return -1;
	}
	
	memset(&servAdr, 0, sizeof(servAdr));
	servAdr.sin_family = AF_INET;
	servAdr.sin_addr.s_addr = htonl(INADDR_ANY);
#ifdef _DEBUG
	servAdr.sin_port = htons(atoi("41026"));
#else
	if (argc != 2)
	{
		printf("USAGE : %s <PORT>", argv[0]);
		return;
	}

	servAdr.sin_port = htons(atoi(argv[1]));
#endif

	char option = 1;
	if (setsockopt(hServSock, SOL_SOCKET, SO_REUSEADDR, &option, sizeof(option)))
	{
		errorHandling("setsockopt() error!");
		return -1;
	}

	if (bind(hServSock, (SOCKADDR*)&servAdr, sizeof(servAdr)))
	{
		errorHandling("bind() error!");
		return -1;
	}

	if (listen(hServSock, 5))
	{
		errorHandling("bind() error!");
		return -1;
	}

	while (true)
	{
		SOCKET hClntSock;
		SOCKADDR_IN clntAdr;
		int addrLen = sizeof(clntAdr);

		hClntSock = accept(hServSock, (SOCKADDR*)&clntAdr, &addrLen);

		if (hClntSock == INVALID_SOCKET)
		{
			continue;
		}

		Client* client = new Client(hClntSock);

		if (CreateIoCompletionPort((HANDLE)hClntSock, hComPort, (ULONG_PTR)client, 0) != hComPort)
		{
			errorHandling("CreateIoCompletionPort() error!");
			continue;
		}

		ClientManager::getInstance()->addClient(client);

		client->connect();
	}

	ClientManager::releaseInstance();
	CloseHandle(hComPort);
	closesocket(hServSock);
	WSACleanup();

	return 0;

}
Example #24
0
void SupplierManageWindow::init()
{
    m_model = new QSqlRelationalTableModel(0, core->database()->database());
    bool r = core->databaseQuery()->suppliers(m_model);
    if(!r) {
	errorHandling(DATABASE_ERROR, core->databaseQuery()->lastErrorNumber());
	return;
    }

    //
    int areaSize = m_model->relationModel(idArea)->rowCount();
    if(!areaSize) {
	QMessageBox::critical(0,
	  trUtf8("Datos incompletos"),
	  trUtf8("Debe ingresar al menos un Rubro en:\n"
		 "Panel General -> Rubros"));
	tb_add->setEnabled(false);
    }
    areaUpdateCombo(false);

    //
    proxyModel->setSourceModel(m_model);
    tv_supplier->setModel(proxyModel);
    tv_supplier->verticalHeader()->hide();
    tv_supplier->horizontalHeader()->setResizeMode(Email, QHeaderView::Stretch);

    m_model->setHeaderData(Name, Qt::Horizontal, trUtf8("Nombre"));
    m_model->setHeaderData(idArea, Qt::Horizontal, trUtf8("Rubro"));
    m_model->setHeaderData(Address, Qt::Horizontal, trUtf8("Dirección"));
    m_model->setHeaderData(Location, Qt::Horizontal, trUtf8("Localidad"));
    m_model->setHeaderData(Phone, Qt::Horizontal, trUtf8("Teléfono"));
    m_model->setHeaderData(Fax, Qt::Horizontal, trUtf8("Fax"));
    m_model->setHeaderData(Email, Qt::Horizontal, trUtf8("Mail"));
    m_model->setHeaderData(ContactName, Qt::Horizontal, trUtf8("Nom. Contacto"));
    m_model->setHeaderData(ContactPhone, Qt::Horizontal, trUtf8("Tel. Contacto"));

    tv_supplier->setColumnHidden(id, true);

    if(m_model->rowCount() == 0) {
	tb_edit->setEnabled(false);
	tb_remove->setEnabled(false);
    }

    connect(tb_add, SIGNAL(clicked()),
	    this, SLOT(addSupplier()));
    connect(tb_remove, SIGNAL(clicked()),
	    this, SLOT(removeSupplier()));
    connect(tb_edit, SIGNAL(clicked()),
	    this, SLOT(editSupplier()));
    connect(tv_supplier, SIGNAL(doubleClicked(const QModelIndex &)),
	    this, SLOT(editSupplier()));
    connect(tb_close, SIGNAL(clicked()),
	    this, SLOT(closeWindow()));
    connect(le_filter, SIGNAL(textChanged(const QString &)),
	    this, SLOT(filterChanged(const QString &)));
    connect(le_filter, SIGNAL(returnPressed()),
	    this, SLOT(filterReturnPressed()));
    connect(tb_areaUpdateCombo, SIGNAL(clicked()),
	    this, SLOT(areaUpdate()));
    connect(cb_area, SIGNAL(currentIndexChanged(int)),
	    this, SLOT(areaComboChanged(int)));


    le_filter->setFocus();
}