Пример #1
0
/*
 * Processes the map message response. Returns 0 in case of success, an
 * error code in case of error.
 * It feeds the given source with the server side modifications
 *
 * @param source the source
 * @param msg the response from the server
 */
int SyncMLProcessor::processMapResponse(SyncSource& source, SyncBody* syncBody) {
    int ret = -1;

    //
    // for now it is always ok
    //
    //
    // First of all check the status for the SyncHead
    //
    // TBD
    ret = getStatusCode(syncBody, &source, SYNC_HDR);

    // Fire Sync Status Event: map status from server (TBD)
    //fireSyncStatusEvent(MAP, ret, source.getConfig().getURI(), NULL, SERVER_STATUS);

    if ((ret < 200) || (ret >299)) {
        goto finally;
    }

    ret = 0;

finally:

    return ret;
}
Пример #2
0
	QString Status::toString(){
		OC_METHODGATE();
		if(isOK()){
			return "STATUS{OK}";
		}
		return "STATUS{ERROR MSG=" +getStatusMessage()+", CODE=" +QString::number(getStatusCode())+"}";
	}
Пример #3
0
long
getPostsOnDelicious(
        const char      *url,
        const char      *userName,
        const char      *password,
        long            *numOfPosts,
        DELICIOUS_POSTS *posts 
    )
{
    long    num = 0;
    long    blocks = *numOfPosts / 64;
    char    *response;
    size_t  sz;

    if ( blocks <= 16 )
        blocks = 16;

    sz = MAX_CONTENT_SIZE * blocks;
    response = (char *)malloc( sz );
    if ( !response )
        return ( num );

    setUpReceiveBuffer( response, sz );
    http_getBASIC( url, userName, password, response );

    num = getAllPostsFromDeliciousXML( response, numOfPosts, posts );
    free( response );

    if ( (num == 0) || (getStatusCode() == 503) )
        if ( !strncmp( url, "https://api.del.icio.us/", 24 ) )
            num = getAllPostsFromDeliciousHTML( userName, password,
                                                numOfPosts, posts );

    return ( num );
}
Пример #4
0
EJ_BIND_GET(EJBindingHttpRequest, statusText, ctx) {
    // FIXME: should be "200 OK" instead of just "200"

    NSString *code = new NSString();
    code->autorelease();
    code->initWithFormat("%d", getStatusCode());
    return NSStringToJSValue(ctx, code);
}
Пример #5
0
int SyncMLProcessor::processSyncHdrStatus(SyncML* syncml) {
    int ret = getStatusCode(syncml->getSyncBody(), NULL, SYNC_HDR);

    // Fire Sync Status Event: syncHdr status from server
    fireSyncStatusEvent(SYNC_HDR, ret, NULL, NULL, NULL , SERVER_STATUS);

    return ret;
}
Пример #6
0
void WinHttpStream::sendRequest()
{
	if (!exceptionDisabled) {
		curState = stReadResponse;
		 natural status = getStatusCode();
		 if (status >= 300)
			 throw HttpStatusException(THISLOCATION,url,status,String());

	}
}
Пример #7
0
// Unpause a plugin
void CPluginMngr::CPlugin::unpausePlugin()
{
	if (isValid() && (getStatusCode() != ps_stopped))
	{
		// set status first so the function will be marked executable
		setStatus(ps_running);

		// call plugin_unpause if provided
		if (m_UnpauseFwd != -1)
		{
			executeForwards(m_UnpauseFwd);
		}
	}
}
Пример #8
0
int sendHTTPErrorMessage(int i_status)
{
    char* cp_body = NULL;
    int i_success = 0;
    
    if(i_status > STATUS_OK && i_status <= STATUS_HTTP_VERSION_NOT_SUPPORTED)
    {
        strAppend(&cp_body, "<html><body>");
        strAppend(&cp_body, getStatusCode(i_status));
        strAppend(&cp_body, "</body></html>");
        
        i_success = sendHTTPResponse(i_status, TEXT_HTML, cp_body);
    
        return i_success;
    }
    
    return EXIT_FAILURE;
}
Пример #9
0
bool
CJaiku::CheckOAuthResult( const char *response )
{
    bool    ret = true;
    unsigned short responseCode = getStatusCode();

    if ( (responseCode == 401) ||
         strstr(response, "maintenance") ||
         strstr(response, "{\"status\":\"error\"") ) {
        MessageBox(
            NULL,
            "OAuth 認証に失敗、もしくは何らかのエラーが発生しました。\r\n"
            "このエラーが続く場合は「従来の認証」の方をお使いください。  ",
            "OAuth 認証エラー",
            MB_OK|MB_ICONERROR );
        ret = false;
    }

    return ( ret );
}
Пример #10
0
bool HTTPPacket::encodeStartLine(DataBuffer *output) {
    if (PT_REQUEST == getPacketType()) {
        const char *methodStr = getMethodString();
        const char *uri = getURI();
        if( NULL == methodStr || NULL == uri) {
            return false;
        }
        output->writeBytes(methodStr, strlen(methodStr));
        output->writeBytes(" ", 1);
        output->writeBytes(uri, strlen(uri));
        output->writeBytes(" ", 1);
        if (HTTP_1_0 == getVersion()) {
            output->writeBytes("HTTP/1.0", 8);
        } else {
            output->writeBytes("HTTP/1.1", 8);
        }
        output->writeBytes("\r\n ", 2);
    } else {
        int statusCode = getStatusCode();
        if (0 == statusCode) {
            return false;
        }
        if (HTTP_1_0 == getVersion()) {
            output->writeBytes("HTTP/1.0", 8);
        } else {
            output->writeBytes("HTTP/1.1", 8);
        }
        output->writeBytes(" ", 1);
        char codeStr[32];
        snprintf(codeStr, 32, "%d", statusCode);
        output->writeBytes(codeStr, 3);
        output->writeBytes(" ", 1);
        const char *reasonPhrase = getReasonPhrase();
        if (NULL != reasonPhrase) {
            output->writeBytes(reasonPhrase, strlen(reasonPhrase));
        }
        output->writeBytes("\r\n", 2);
    }
    return true;
}
Пример #11
0
int sendHTTPResponseHeader(int i_status, int i_content_type, int i_content_length)
{     
    int i_success = 0;
    char* cp_http_response_header = NULL;
    
    cp_http_response_header = secPrint2String("HTTP/1.1 %s\n", getStatusCode(i_status));
    strAppend(&cp_http_response_header, "Server: tiniweb/1.0\n");
    strAppend(&cp_http_response_header, "Connection: close\n");
    strAppendFormatString(&cp_http_response_header, "Content-Type: %s\n", getContentType(i_content_type));
    
    if(i_content_length >= 0)
    {
        strAppendFormatString(&cp_http_response_header, "Content-Length: %i\n", i_content_length);
    }
    
    strAppend(&cp_http_response_header, "\n");
    
	
    i_success = writeStringToFile(STDOUT_FILENO, cp_http_response_header);
        
    return i_success;
}
Пример #12
0
int sendHTTPAuthorizationResponse(const char* ccp_realm, const char* ccp_nonce)
{
    int i_success = 0;
    char* cp_http_auth_response = NULL;
    char* cp_body = "<html><body>Access Denied!</body></html>";

    if(ccp_realm == NULL || ccp_nonce == NULL)
        return EXIT_FAILURE;
        
    cp_http_auth_response = secPrint2String("HTTP/1.1 %s\n", getStatusCode(STATUS_UNAUTHORIZED));
    strAppend(&cp_http_auth_response, "Server: tiniweb/1.0\n");
    strAppend(&cp_http_auth_response, "Connection: close\n");
    strAppendFormatString(&cp_http_auth_response, 
                          "WWW-Authenticate: Digest realm=\"%s\", nonce=\"%s\"\n", ccp_realm, ccp_nonce);
    strAppendFormatString(&cp_http_auth_response, "Content-Type: %s\n", getContentType(TEXT_HTML));
    strAppendFormatString(&cp_http_auth_response, "Content-Length: %d\n\n", strlen(cp_body));
    strAppendFormatString(&cp_http_auth_response, "%s", cp_body);
    
    i_success = writeStringToFile(STDOUT_FILENO, cp_http_auth_response);
        
    return i_success;
}
Пример #13
0
Sync* SyncMLProcessor::processSyncResponse(SyncSource& source, SyncML* syncml) {

    int iterator = 0, ret = 0;

    AbstractCommand* a  = NULL;
    Sync* sync          = NULL;

    ret = getStatusCode(syncml->getSyncBody(), &source, SYNC_HDR);
    if ((ret < 200) || (ret > 299)) {
        goto finally;
    }

    while((a = getCommand(syncml->getSyncBody(), SYNC, iterator)) != NULL){
        sync = (Sync*)a;
        const char *locuri = ((Target*)(sync->getTarget()))->getLocURI();
        if (strcmp(locuri, _wcc(source.getName())) == 0) {

            //
            // To handle the NumberOfChanges. The default is -1 that means the server doesn't send
            // any tag <NumberOfChanges>. Whit value >= 0 the value is correct
            //

            long noc = sync->getNumberOfChanges();
            fireSyncSourceEvent(source.getConfig().getURI(), source.getConfig().getName(), source.getSyncMode(), noc, SYNC_SOURCE_TOTAL_SERVER_ITEMS);

            break;
        }
        sync = NULL;
        iterator++;
    }

finally:

    return sync;

}
Пример #14
0
/*******************************************************************************
	isPrinterWorking
********************************************************************************/
static int isPrinterWorking(CNNLHANDLE h, const int retry, const unsigned long timeout){
	char *buf;
	char buffer[512];
	unsigned long readsz = 0;
	
	fprintf(stderr, "DEBUG: [cnijnetprn] IsPrinterWorking starts.\n");
	CheckParentProcess(h);
	
	if (CNNL_GetDeviceID(h, buffer, &readsz, sizeof(buffer), 3, 6000) != CNNL_RET_SUCCESS){
		return CNNL_RET_FAILURE;
	} else {
		buf = buffer+2;
		fprintf(stderr, "DEBUG: [cnijnetprn] DeviceID=[%s]\n", buf);
		if (getStatusCode((char *)buf, "STA:", "20", 1) == CNNL_RET_SUCCESS){
			return CNNL_RET_NOT_WORKING;
		}
	}

	if (getPrinterStatus(h, buffer, sizeof(buffer)) < 0){
		return CNNL_RET_FAILURE;
	} else {
		buf = buffer+2;
		
		// check wether job is cancelled by cancel button
		if (getStatusCode((char *)buf, "DJS:", "CC", 1) == CNNL_RET_SUCCESS){
			mode |= CNNL_JOB_CANCELLED;
			return CNNL_RET_SUCCESS;
		}
		if (getStatusCode((char *)buf, "DJS:", "SC", 1) == CNNL_RET_SUCCESS){
			mode |= CNNL_JOB_CANCELLED;
			return CNNL_RET_SUCCESS;
		}
		
		// check wether printer is work
		if (getStatusCode((char *)buf, "DBS:", "DS", 1) == CNNL_RET_SUCCESS) return CNNL_RET_NOT_WORKING;
		
		// check wether printer is poweroff
		if (getStatusCode((char *)buf, "DBS:", "SL", 1) == CNNL_RET_SUCCESS) return CNNL_RET_POWEROFF;
		if (getStatusCode((char *)buf, "DBS:", "SD", 1) == CNNL_RET_SUCCESS) return CNNL_RET_POWEROFF;
		
		// check wether printer is work
		if (getStatusCode((char *)buf, "DBS:", "NO", 1) != CNNL_RET_SUCCESS
		 && getStatusCode((char *)buf, "DBS:", "UK", 1) != CNNL_RET_SUCCESS) return CNNL_RET_SUCCESS;
			
		// check pid
		if (getStatusCode((char *)buf, "PID:", "00", 2) != CNNL_RET_SUCCESS) return CNNL_RET_SUCCESS;
		
		// check doc
		if (getStatusCode((char *)buf, "DOC:", "NO", 3) != CNNL_RET_SUCCESS) return CNNL_RET_SUCCESS;
			
		// check dsc
		if (getStatusCode((char *)buf, "DSC:", "NO", 1) != CNNL_RET_SUCCESS) return CNNL_RET_SUCCESS;
		
		return CNNL_RET_NOT_WORKING;
	}
}
bool
SynchronousStatus::operator()() const
{
   return getStatusCode() == OK;
}
Пример #16
0
EJ_BIND_GET(EJBindingHttpRequest, status, ctx) {
    return JSValueMakeNumber(ctx, getStatusCode());
}