static void process_request_func(void *ctx)
{
	struct request_stream *request_stream;
	struct mrpc_server_stream_processor *stream_processor;
	mrpc_server_stream_handler stream_handler;
	void *service_ctx;
	struct ff_stream *stream;
	enum ff_result result;

	request_stream = (struct request_stream *) ctx;
	ff_assert(request_stream->stream_processor != NULL);
	ff_assert(request_stream->packet_stream != NULL);
	ff_assert(request_stream->stream != NULL);

	stream_processor = request_stream->stream_processor;
	ff_assert(stream_processor->stream_handler != NULL);
	stream_handler = stream_processor->stream_handler;
	service_ctx = stream_processor->service_ctx;
	stream = request_stream->stream;

	result = stream_handler(stream, service_ctx);
	if (result != FF_SUCCESS)
	{
		ff_log_debug(L"cannot process remote call from the stream=%p using the stream_handler=%p, service_ctx=%p", stream, stream_handler, service_ctx);
		mrpc_server_stream_processor_stop_async(stream_processor);
	}
	release_request_stream(stream_processor, request_stream);
}
Пример #2
0
static void
load_to_stream( GncHtmlWebkit* self, URLType type,
                const gchar* location, const gchar* label )
{
    gchar* fdata = NULL;
    int fdata_len = 0;
    GncHtmlWebkitPrivate* priv = GNC_HTML_WEBKIT_GET_PRIVATE(self);

    DEBUG( "type %s, location %s, label %s", type ? type : "(null)",
           location ? location : "(null)", label ? label : "(null)");

    g_return_if_fail( self != NULL );

    if ( gnc_html_stream_handlers != NULL )
    {
        GncHTMLStreamCB stream_handler;

        stream_handler = g_hash_table_lookup( gnc_html_stream_handlers, type );
        if ( stream_handler )
        {
            gboolean ok = stream_handler( location, &fdata, &fdata_len );

            if ( ok )
            {
                fdata = fdata ? fdata : g_strdup( "" );

                // Until webkitgtk supports download requests, look for "<object classid="
                // indicating the beginning of an embedded graph.  If found, handle it
                if ( g_strstr_len( fdata, -1, "<object classid=" ) != NULL )
                {
                    gchar* new_fdata;
                    new_fdata = handle_embedded_object( self, fdata );
                    g_free( fdata );
                    fdata = new_fdata;
                }

                // Save a copy for export purposes
                if ( priv->html_string != NULL )
                {
                    g_free( priv->html_string );
                }
                priv->html_string = g_strdup( fdata );
                impl_webkit_show_data( GNC_HTML(self), fdata, strlen(fdata) );
//                webkit_web_view_load_html_string( priv->web_view, fdata, BASE_URI_NAME );
            }
            else
            {
                fdata = fdata ? fdata :
                        g_strdup_printf( error_404_format,
                                         _(error_404_title), _(error_404_body) );
                webkit_web_view_load_html_string( priv->web_view, fdata, BASE_URI_NAME );
            }

            g_free( fdata );

            if ( label )
            {
                while ( gtk_events_pending() )
                {
                    gtk_main_iteration();
                }
                /* No action required: Webkit jumps to the anchor on its own. */
            }

            return;
        }
    }

    do
    {
        if ( !g_strcmp0( type, URL_TYPE_SECURE ) ||
                !g_strcmp0( type, URL_TYPE_HTTP ) )
        {

            if ( !g_strcmp0( type, URL_TYPE_SECURE ) )
            {
                if ( !https_allowed() )
                {
                    gnc_error_dialog( priv->base.parent, "%s",
                                      _("Secure HTTP access is disabled. "
                                        "You can enable it in the Network section of "
                                        "the Preferences dialog."));
                    break;
                }
            }

            if ( !http_allowed() )
            {
                gnc_error_dialog( priv->base.parent, "%s",
                                  _("Network HTTP access is disabled. "
                                    "You can enable it in the Network section of "
                                    "the Preferences dialog."));
            }
            else
            {
                gnc_build_url( type, location, label );
            }

        }
        else
        {
            PWARN( "load_to_stream for inappropriate type\n"
                   "\turl = '%s#%s'\n",
                   location ? location : "(null)",
                   label ? label : "(null)" );
            fdata = g_strdup_printf( error_404_format,
                                     _(error_404_title), _(error_404_body) );
            webkit_web_view_load_html_string( priv->web_view, fdata, BASE_URI_NAME );
            g_free( fdata );
        }

    }
    while ( FALSE );
}