TInt Cstif_3::stif_dbus_connection_steal_borrowed_message0( CStifItemParser& aItem )
	{

		TestModuleIf().SetBehavior( CTestModuleIf::ETestLeaksRequests ); 
		TestModuleIf().SetBehavior( CTestModuleIf::ETestLeaksHandles );  
		
		//_dbus_wsd_reset();
		DBusConnection* connection;
		DBusError error; 
		DBusMessage* msg;
		DBusMessage*message;
		DBusMessage* reply = NULL;
		char error_name[40];
		char error_msg[40];
		
		dbus_error_init(&error);
		
		connection = dbus_bus_get_private(DBUS_BUS_SESSION, &error);
	
		if(!connection)
		{
			sprintf(error_name, "Error_name : %s", error.name);
			iLog->Log(_L8(error_name));
			sprintf(error_msg, "Error_msg : %s", error.message);
			iLog->Log(_L8(error_msg));
			return 1;
		}  
		
		msg = dbus_message_new_method_call("Test.Method.Call1", "/Test/Method/Object", "test.Method.Call", "dbus_connection_steal_borrowed_message0");
		
		if(msg == NULL)
			{ 
			iLog->Log(_L8("message error"));
			return 1;
			}
		
	
// reply 		
		reply = dbus_connection_send_with_reply_and_block(connection, msg, 10000, &error);
		if(!reply)
			return handle_error(&error);
		message =  dbus_connection_borrow_message (connection )   ;
		
		dbus_connection_steal_borrowed_message(connection,message);
		
		message =  dbus_connection_borrow_message (connection )   ;
		
	
		if(message== NULL)
		{
			iLog->Log(_L8("Queue is empty"));
			iLog->Log(_L8("Test success as the message is been stealed "));
			iLog->Log( KSuccess );
			dbus_message_unref(msg);  
	   
	   dbus_connection_close(connection);
	   dbus_connection_unref(connection);
	   dbus_shutdown();

		    return KErrNone;  
		}
		else
			{
				iLog->Log(_L8("steal borrowed message is not executed properly "));
				iLog->Log(_L8("Test case failed "));
				return 1;
			}	// end of else 	
			
		
	}
static int dbus_selector_process_recv(DBusConnection* conn, int iswaiting_rpcreply,
                                      DBusPendingCall** pendingargptr)
{
    int ret = 1; /* default fail */

    /* remove this call that consumes .1ms because dbus is already read 
     * by dbus_watch_handle():
     * dbus_connection_read_write(conn, 0);
     * 
     * according to dbus_connection_dispatch(): The incoming data buffer 
     * is filled when the connection reads from its underlying transport 
     * (such as a socket). Reading usually happens in dbus_watch_handle() 
     * or dbus_connection_read_write().
     */
    DBusDispatchStatus dispatch_rc = dbus_connection_get_dispatch_status(conn);
    if ( DBUS_DISPATCH_DATA_REMAINS != dispatch_rc ) {
        printf(" ERROR recv no message in queue \n");
    }
    while( DBUS_DISPATCH_DATA_REMAINS == dispatch_rc ) {
        DBusMessage* msg = dbus_connection_borrow_message(conn);
        if ( msg == NULL ) {
            printf(" ERROR recv pending check FAILED: remains but "
                            "no message borrowed. \n");
            break;
        }
        int mtype = dbus_message_get_type(msg);
        if ( iswaiting_rpcreply &&  
             ( mtype == DBUS_MESSAGE_TYPE_METHOD_RETURN ||
               mtype == DBUS_MESSAGE_TYPE_ERROR           ) ) {
            printf(" RPC REPLY pending check SUCCESS: received rpc reply \n");
            dbus_connection_return_message(conn, msg);
            dbus_connection_dispatch(conn);
                                  /* dispatch so the received message at the 
                                   * head of queue is passed to the pendingcall
                                   */
            dbus_selector_process_post_reply( conn, pendingargptr );
                struct timeval tmn = {0,0}; gettimeofday(&tmn,NULL);
                printf(" RPC returned time  %lu.%06lu\n", tmn.tv_sec, tmn.tv_usec);

                unsigned int tmncost = usdiff(&tmn0, &tmn);
                printf(" RPC cost time      %19s.%06u\n", "", tmncost);

                if ( tmnlistcnt < tmnmax ) {
                    tmnlist[tmnlistcnt] = tmncost;
                    tmnlistcnt ++;
                } else if ( tmnlistcnt == tmnmax ) {
                    unsigned int tmnavg = 0;
                    unsigned int i;
                    for (i=0; i<tmnmax; i++) {
                        tmnavg += tmnlist[i];
                    }
                    tmnavg /= tmnmax;
                    tmnlistcnt ++;
                    printf("time consumed           %9s.%06u\n", "", tmncost);
                    printf("time consumed avg       %30s.%06u tmnmax %u\n", 
                           "", tmnavg, tmnmax);
exit(0);
                }

            printf(" RPC REPLY pending check SUCCESS: processed rpc reply \n");
        } else if ( mtype == DBUS_MESSAGE_TYPE_METHOD_RETURN ) {
            printf(" RECV pending check FAILED: received rpc reply \n");
            dbus_connection_steal_borrowed_message(conn, msg);
            dbus_message_unref(msg);
        } else if ( mtype == DBUS_MESSAGE_TYPE_ERROR ) {
            printf(" RECV pending check FAILED: received ERROR \n");
            dbus_connection_steal_borrowed_message(conn, msg);
            dbus_message_unref(msg);
        } else if ( mtype == DBUS_MESSAGE_TYPE_SIGNAL ) {
            printf(" SIGNAL pending check SUCCESS: received and drop \n");
            dbus_connection_steal_borrowed_message(conn, msg);
            dbus_message_unref(msg);
        } else if ( mtype == DBUS_MESSAGE_TYPE_METHOD_CALL ) {
            printf(" RPC RECV check SUCCESS: received rpc call. \n");
            dbus_connection_steal_borrowed_message(conn, msg);
            DBusMessage* reply = NULL;
            do {
                /* craft a reply message */
                DBusMessageIter args;
                dbus_uint32_t serial = 111;
                dbus_bool_t   stat    = TRUE;
                dbus_uint32_t retval1 = 555;
                const char *strval    = "good";
                reply = dbus_message_new_method_return(msg);
                dbus_message_iter_init_append(reply, &args);
                if ( !dbus_message_iter_append_basic(
                                       &args, DBUS_TYPE_BOOLEAN, &stat) ) {
                    printf(" error rpc reply Out Of Memory!\n");
                    break;
                }
                if ( !dbus_message_iter_append_basic(
                                       &args, DBUS_TYPE_UINT32, &retval1) ) {
                    printf(" error rpc reply Out Of Memory!\n");
                    break;
                }
                if ( !dbus_message_iter_append_basic(
                                       &args, DBUS_TYPE_STRING, &strval) ) {
                    printf(" error rpc reply Out Of Memory!\n");
                    break;
                }
                if ( !dbus_connection_send(conn, reply, &serial)) {
                    printf(" error rpc reply Out Of Memory!\n");
                    break;
                }
                dbus_connection_flush(conn);
            } while(0);
            if ( reply != NULL ) { dbus_message_unref(reply); }
            if ( msg != NULL ) { /* msg not consumed */
                //dbus_connection_return_message(conn, msg);
                dbus_message_unref(msg);
            }
            ret = 0; /* success */
        } else {
            printf(" error unknown msg type %d \n", mtype);
        }
        dispatch_rc = dbus_connection_get_dispatch_status(conn);
    }
    return ret;
}