urls->owner_id = (int)flags;
IL_GetImage(const char* image_url,            IL_GroupContext *img_cx,            XP_ObserverList obs_list,            NI_IRGB *background_color,            uint32 req_width, uint32 req_height,            uint32 flags,            IL_NetContext *net_cx){    NET_ReloadMethod cache_reload_policy = net_cx->cache_reload_policy;   IL_URL *urls = NULL;    IL_ImageReq *image_req;	il_container *ic = NULL;    int req_depth = img_cx->color_space->pixmap_depth;	int err;    int is_internal_external_reconnect = FALSE;    int is_view_image;    /* Create a new instance for this image request. */    image_req = XP_NEW_ZAP(IL_ImageReq);    if (!image_req)        return NULL;    image_req->img_cx = img_cx;    /*     * Remember the net context for this image request, It is possible that     * the lifetime of the image container's net context will not be as     * long as that of the image request itself (for example if the image     * request for which the container was originally created happens to     * be destroyed,) in which case we may need to give the container a     * handle on this backup net context.     */    image_req->net_cx = IL_CloneDummyNetContext(net_cx);	if (!image_req->net_cx) {		XP_FREE(image_req);		return NULL;	}    image_req->obs_list = obs_list;    XP_SetObserverListObservable(obs_list, (void *)image_req);        ILTRACE(1, ("il: IL_GetImage, url=%s\n", image_url));	if (!image_url)	{		ILTRACE(0,("il: no url, sending delayed icon"));        il_icon_notify(image_req, IL_IMAGE_DELAYED, IL_ERROR_NO_DATA);        return image_req;	}    /* Check for any special internal-use URLs */	if (*image_url == 'i'                  ||        !XP_STRNCMP(image_url, "/mc-", 4)  ||        !XP_STRNCMP(image_url, "/ns-", 4))	{		uint32 icon;        /* A built-in icon ? */        icon = il_internal_image(image_url);		if (icon)		{			ILTRACE(4,("il: internal icon %d", icon));            /* XXXM12N In response to this notification, layout should set               lo_image->image_attr->attrmask |= LO_ATTR_INTERNAL_IMAGE; */            il_icon_notify(image_req, icon, IL_INTERNAL_IMAGE);            return image_req;		}        /* Image viewer URLs look like "internal-external-reconnect:REALURL.gif"         * Strip off the prefix to get the real URL name.         */		if (!XP_STRNCMP(image_url, "internal-external-reconnect:", 28)) {            image_url += 28;			is_internal_external_reconnect = TRUE;        }	}    ic = il_get_container(img_cx, cache_reload_policy, image_url,                          background_color, img_cx->dither_mode, req_depth,                          req_width, req_height);    if (!ic)    {        ILTRACE(0,("il: MEM il_container"));        il_icon_notify(image_req, IL_IMAGE_DELAYED, IL_ERROR_INTERNAL);        if (is_internal_external_reconnect)            il_abort_reconnect();        return image_req;    }         /* Give the client a handle into the imagelib world. */    image_req->ic = ic;    /* Is this a call to the image viewer ? */#ifndef M12N /* XXXM12N fix me. */    is_view_image = is_internal_external_reconnect &&        (cx->type != MWContextNews) && (cx->type != MWContextMail);#else    is_view_image = is_internal_external_reconnect;#endif /* M12N */    if (!il_add_client(img_cx, ic, image_req, is_view_image))    {        il_icon_notify(image_req, IL_IMAGE_DELAYED, IL_ERROR_INTERNAL);        if (is_internal_external_reconnect)            il_abort_reconnect();        return image_req;    }    /* If the image is already in memory ... */	if (ic->state != IC_VIRGIN) {        switch (ic->state) {        case IC_BAD:            il_icon_notify(image_req, IL_IMAGE_BAD_DATA,                           IL_ERROR_IMAGE_DATA_ILLEGAL);            break;        case IC_MISSING:            il_icon_notify(image_req, IL_IMAGE_NOT_FOUND, IL_ERROR_NO_DATA);            XP_ASSERT(! is_internal_external_reconnect);            break;        case IC_INCOMPLETE:            il_icon_notify(image_req, IL_IMAGE_DELAYED,                           IL_ERROR_IMAGE_DATA_TRUNCATED);            break;        case IC_SIZED:        case IC_MULTI:            /* This is a cached image that hasn't completed decoding. */            il_cache_return_notify(image_req);            break;        case IC_COMPLETE:#ifndef M12N            /* M12N Fix custom colormaps. */            il_set_color_palette(cx, ic);#else#endif /* M12N */            /* This is a cached image that has already completed decoding. */            il_cache_return_notify(image_req);            break;        case IC_START:        case IC_STREAM:        case IC_ABORT_PENDING:        case IC_NOCACHE:            break;                    default:            XP_ASSERT(0);            IL_DestroyDummyNetContext(image_req->net_cx);            XP_FREE(image_req);            return NULL;        }        if (is_internal_external_reconnect) {            /* Since we found the image in the cache, we don't             * need any of the data now streaming into the image viewer.             */            il_abort_reconnect();        }		/* NOCACHE falls through to be tried again */        if (ic->state != IC_NOCACHE)             return image_req;    }    /* This is a virgin (never-used) image container. */	else    {		ic->forced = FORCE_RELOAD(cache_reload_policy);	}	ic->state = IC_START;    #ifdef DEBUG    ic->start_time = XP_TIME();#endif    /* Record the context that actually initiates and controls the transfer. */    ic->net_cx = IL_CloneDummyNetContext(net_cx); 	if (is_internal_external_reconnect)	{        /* "Reconnect" to the stream feeding IL_ViewStream(), already           created. */        il_reconnect(ic);        return image_req;    }            /* need to make a net request */    ILTRACE(1,("il: net request for %s, %s", image_url,               ic->forced ? "force" : ""));    urls = NET_CreateURLStruct(image_url, cache_reload_policy);    if (!urls)    {#ifndef M12N /* XXXM12N fix me. */        /* xxx clean up previously allocated objects */        return MK_OUT_OF_MEMORY;#else        IL_DestroyDummyNetContext(image_req->net_cx);        XP_FREE(image_req);        return NULL;#endif /* M12N */    }                /* Add the referer to the URL. */    IL_AddReferer(ic->net_cx, urls);        ic->is_looping = FALSE;    ic->url = urls;	/* Record the fact that we are calling NetLib to load a URL. */    ic->is_url_loading = PR_TRUE;    /* save away the container */    urls->fe_data = (void *)ic;    err = NET_GetURL(urls, (cache_reload_policy == NET_CACHE_ONLY_RELOAD) ?                     FO_ONLY_FROM_CACHE_AND_INTERNAL_IMAGE :                     FO_CACHE_AND_INTERNAL_IMAGE,                      ic->net_cx->cx,                     (Net_GetUrlExitFunc*)&il_netgeturldone);	return image_req;}