OsStatus LoginCGI::execute(UtlString* out) { OsStatus result ; if( m_fromWebUI ) result = handleWebRequest( out ) ; else result = handleOpenVXIRequest( out ) ; return result; }
void Server::handleRequest(SOCKET connection, Request & request) { // If the request is for a MFD if (request.resource.substr(0, 5) == "/mfd/") { // Remove the "/mfd/" from the resource string request.resource = request.resource.substr(5); // Handle the request handleMFDRequest(connection, request); } // If the request is for a file else if (request.resource.substr(0, 5) == "/web/") { // Remove the "/web/" from the resource string request.resource = request.resource.substr(5); // Handle the request handleWebRequest(connection, request); } // If the request is for a button WebSocket else if (request.resource.substr(0, 5) == "/btn/") { // Remove the "/btn/" from the resource string request.resource = request.resource.substr(5); // Handle the request handleBtnRequest(connection, request); } // If the request is for a button classic HTTP enquiry else if (request.resource.substr(0, 7) == "/btn_h/") { // Remove the "/btn_h/" from the resource string request.resource = request.resource.substr(7); // Handle the request handleBtnHRequest(connection, request); } // If the request is for root, redirect to /web/ else if (request.resource == "/") ssend(connection, "HTTP/1.0 301 Moved Permanently\r\nLocation: /web/\r\n\r\n"); // The request is unknown: send a 404 error else ssend(connection, "HTTP/1.0 404 Not Found\r\n\r\n"); }
OsStatus RecycleDeletedMsgsCGI::execute(UtlString* out) { // Validate the mailbox id and extension. ValidateMailboxCGIHelper validateMailboxHelper ( m_mailboxIdentity ); OsStatus result = validateMailboxHelper.execute( out ); if( result == OS_SUCCESS ) { validateMailboxHelper.getMailboxIdentity( m_mailboxIdentity ); if( m_fromWeb ) result = handleWebRequest( out ) ; else result = handleOpenVXIRequest( out ) ; } return result; }
OsStatus UpdateMessageStatesCGI::execute(UtlString* out) { // Validate the mailbox id and extension. ValidateMailboxCGIHelper validateMailboxHelper ( m_mailboxIdentity ); OsStatus result = validateMailboxHelper.execute( out ); if( result == OS_SUCCESS ) { validateMailboxHelper.getMailboxIdentity( m_mailboxIdentity ); if( m_fromWeb ) { if( m_linkInEmail ) result = handleEmailRequest( out ); else result = handleWebRequest( out ) ; } else result = handleOpenVXIRequest( out ) ; } return result; }
void networkManage() { uint16_t size; if (sendClient.available()) { // int size = sendClient.read((uint8_t *) buf2, BUFFER_SIZE); size = readHttpFrame(sendClient); #ifdef HMAC if (!isTimeReady()) { uint16_t endPos = strstrpos_P((char *) buf, DOUBLE_ENDL); receiveTime((char *) &buf[endPos + 4]); } #endif } #ifdef HMAC if (!isTimeReady() && sendClient.status() == SnSR::CLOSED && (lastFailTime == 0 || millis() - lastFailTime > dateFailRetryWait)) { if (sendClient.connect(NotifyDstIp, notifyDstPort)) { int len = clientBuildTimeQuery((char *) buf); sendClient.write(buf, len); } else { lastFailTime = millis(); sendClient.stop(); } } #endif if (!sendClient.connected()) { sendClient.stop(); } if (notification != 0 && sendClient.status() == SnSR::CLOSED) { // there is a notif and we are not handling another one if (lastFailTime == 0 || millis() - lastFailTime > notifFailRetryWait) { if (sendClient.connect(NotifyDstIp, notifyDstPort)) { int len = clientBuildNextQuery((char *) buf); sendClient.write(buf, len); } else { lastFailTime = millis(); sendClient.stop(); } } } EthernetClient client = server.available(); if (client) { while (client.connected()) { if (client.available()) { size = readHttpFrame(client); if (size > 0) { buf[size] = 0; size = handleWebRequest((char *) buf, 0, size); buf[size] = 0; client.println((const char *) buf); } delay(1); client.stop(); } } } if (needReboot) { resetFunc(); } }