void DToolTip::EnableTips(bool value) { MakeValid(); fTipWindow->PostMessage(value ? M_SET_ENABLED : M_SET_DISABLED); }
void BadiDate::Increment( int days ) { JDDate::Increment( days ); m_day += days; MakeValid( DateFixup::Carry ); }
void BadiDate::Increment( int days, int months, int years, int vahids, long kulliShays, DateFixup::EMethod fixupMethod ) { JDDate::Set( JDDate::INVALID ); m_day += days; m_month += months; m_year += years; m_vahid += vahids; m_kulliShay += kulliShays; MakeValid( fixupMethod ); }
void DToolTip::SetTip(BView *view, char *text) { if (!view) return; MakeValid(); BMessage msg(M_SET_TIP); msg.AddPointer("view",view); if (text) msg.AddString("text",text); fTipWindow->PostMessage(&msg); }
void XMLProcedureCall::AddParameter(const char *pzName, const char *pzValue) { // Make the param name a valid XML element name. Change the // user supplied name if necessary since we bind by order not // by name. The name is a comment for readability. This is faster // at the server and lowest common denominator in object technologies. GString strTemp; const char *pzTag = MakeValid(pzName,strTemp); ObjQueryParameter *pParam = new ObjQueryParameter(pzTag); if (pzValue) pParam->SetObjectValue( pzValue, -1, 3 ); else pParam->SetObjectValue( "", -1, 3 ); AddParameter( pParam ); }
/* --------------------------------------------------------------------------------------------- * Generate the payload message. */ void Generate() { char body[32]; // Generate the post data if (snprintf(body, sizeof(body), "port=%d", g_Settings.port) < 0) { VerboseError("Unable to generate the post data for '%s'", m_Addr.Host()); // Make sure the data is null terminated m_Data[0] = '\0'; // Make sure this is marked as invalid m_Valid = false; } // Generate the payload message sent with each message else if (snprintf(m_Data, sizeof(m_Data), "POST %s HTTP/1.1\r\n" "Host: %s\r\n" "Connection: close\r\n" "User-Agent: VCMP/0.4\r\n" "VCMP-Version: %u\r\n" "Content-Type: application/x-www-form-urlencoded\r\n" "Content-Length: %u\r\n" "\r\n" /* ... */ "%s" , m_Addr.Path(), m_Addr.Host() , g_ServerVersion, strlen(body), body) < 0) { VerboseError("Unable to generate the payload message for '%s'", m_Addr.Host()); // Make sure the data is null terminated m_Data[0] = '\0'; // Make sure this is marked as invalid m_Valid = false; } else { VerboseMessage("Payload for master-server '%s' is:\n%s", m_Addr.Host(), m_Data); // Make sure this is marked as valid MakeValid(); } }
/* --------------------------------------------------------------------------------------------- * Handle the dispatched connection events. */ void HandleEvent(mg_connection * nc, int ev, void * ev_data) { // Identify the event type switch (ev) { case MG_EV_CONNECT: { const int status = *reinterpret_cast< int * >(ev_data); // Validate the connection status if (status != 0) { MtVerboseError("Unable to connect to master-server '%s' because: %s", m_Addr.Host(), strerror(status)); // This operation failed Failed(); } // Specify that this connection is valid and should continue to be updated else { MakeValid(); } } break; case MG_EV_HTTP_REPLY: { // Close this connection immediately (explicit) nc->flags |= MG_F_CLOSE_IMMEDIATELY; // Disassociate this connection with this server m_Conn = nullptr; // Obtain the event data http_message * msg = reinterpret_cast< http_message * >(ev_data); // Output the received info MtVerboseMessage("Received data from '%s'\n%.*s", m_Addr.Host(),msg->message.len, msg->message.p); // Inspect response switch (msg->resp_code) { case 400: { MtVerboseError("Master-server '%s' denied request due to malformed data", m_Addr.Host()); // This operation failed Failed(); } break; case 403: { MtVerboseError("Master-server '%s' denied request, server version may not have been accepted", m_Addr.Host()); // This operation failed Failed(); } break; case 405: { MtVerboseError("Master-server '%s' denied request, GET is not supported", m_Addr.Host()); // This operation failed Failed(); } break; case 408: { MtVerboseError("Master-server '%s' timed out while trying to reach your server; are your ports forwarded?", m_Addr.Host()); // This operation failed Failed(); } break; case 500: { MtVerboseError("Master-server '%s' had an unexpected error while processing your request", m_Addr.Host()); // This operation failed Failed(); } break; case 200: { MtVerboseMessage("Successfully announced on master-server '%s'", m_Addr.Host()); // This operation succeeded MakeValid(); } break; default: /* Unknown response */ break; } } break; case MG_EV_SEND: { MtVerboseMessage("Sent %d bytes to master-server '%s'", *reinterpret_cast< int * >(ev_data), m_Addr.Host()); } break; case MG_EV_RECV: { MtVerboseMessage("Received %d bytes from master-server '%s'", *reinterpret_cast< int * >(ev_data), m_Addr.Host()); } break; case MG_EV_CLOSE: { MtVerboseMessage("Closed connection to master-server '%s'", m_Addr.Host()); // Disassociate this connection with this server m_Conn = nullptr; } break; default: /* Ignore event... */ break; } }