Subversion Repositories Kolibri OS

Rev

Rev 4364 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4364 Rev 5043
Line 218... Line 218...
218
}
218
}
Line 219... Line 219...
219
 
219
 
220
/* See hlcache.h for documentation */
220
/* See hlcache.h for documentation */
221
nserror hlcache_poll(void)
221
nserror hlcache_poll(void)
222
{
-
 
223
 
222
{
Line 224... Line 223...
224
	llcache_poll();
223
	llcache_poll();
225
 
224
 
Line 513... Line 512...
513
		const llcache_event *event, void *pw)
512
		const llcache_event *event, void *pw)
514
{
513
{
515
	hlcache_retrieval_ctx *ctx = pw;
514
	hlcache_retrieval_ctx *ctx = pw;
516
	lwc_string *effective_type = NULL;
515
	lwc_string *effective_type = NULL;
517
	nserror error;
516
	nserror error;
518
 
-
 
-
 
517
	/* LOG(("Asserting ctx->llcache == handle")); */
519
	assert(ctx->llcache == handle);
518
	assert(ctx->llcache == handle);
-
 
519
	/* LOG(("After Asserting ctx->llcache == handle")); */
Line 520... Line 520...
520
 
520
 
521
	switch (event->type) {
521
	switch (event->type) {
-
 
522
	case LLCACHE_EVENT_HAD_HEADERS:
522
	case LLCACHE_EVENT_HAD_HEADERS:
523
	  /* LOG(("LLCACHE_EVENT_HAD_HEADERS")); */
523
		error = mimesniff_compute_effective_type(handle, NULL, 0,
524
		error = mimesniff_compute_effective_type(handle, NULL, 0,
524
				ctx->flags & HLCACHE_RETRIEVE_SNIFF_TYPE,
525
				ctx->flags & HLCACHE_RETRIEVE_SNIFF_TYPE,
525
				ctx->accepted_types == CONTENT_IMAGE,
526
				ctx->accepted_types == CONTENT_IMAGE,
526
				&effective_type);
527
				&effective_type);
527
		if (error == NSERROR_OK || error == NSERROR_NOT_FOUND) {
528
		if (error == NSERROR_OK || error == NSERROR_NOT_FOUND) {
528
			/* If the sniffer was successful or failed to find
529
			/* If the sniffer was successful or failed to find
529
			 * a Content-Type header when sniffing was
530
			 * a Content-Type header when sniffing was
-
 
531
			 * prohibited, we must migrate the retrieval context. */
530
			 * prohibited, we must migrate the retrieval context. */
532
		  /* LOG(("hlcache_migraet_ctx from LLCACHE_HAD_HEADERS")); */
Line 531... Line 533...
531
			error = hlcache_migrate_ctx(ctx, effective_type);
533
			error = hlcache_migrate_ctx(ctx, effective_type);
532
 
534
 
533
			if (effective_type != NULL)
535
			if (effective_type != NULL)
Line 541... Line 543...
541
 
543
 
Line 542... Line 544...
542
		return error;
544
		return error;
543
 
545
 
-
 
546
		break;
544
		break;
547
	case LLCACHE_EVENT_HAD_DATA:
545
	case LLCACHE_EVENT_HAD_DATA:
548
	  	  /* LOG(("LLCACHE_EVENT_HAD_DATA")); */
546
		error = mimesniff_compute_effective_type(handle,
549
		error = mimesniff_compute_effective_type(handle,
547
				event->data.data.buf, event->data.data.len,
550
				event->data.data.buf, event->data.data.len,
548
				ctx->flags & HLCACHE_RETRIEVE_SNIFF_TYPE,
551
				ctx->flags & HLCACHE_RETRIEVE_SNIFF_TYPE,
549
				ctx->accepted_types == CONTENT_IMAGE,
552
				ctx->accepted_types == CONTENT_IMAGE,
550
				&effective_type);
553
				&effective_type);
551
		if (error != NSERROR_OK) {
554
		if (error != NSERROR_OK) {
552
			assert(0 && "MIME sniff failed with data");
-
 
-
 
555
			assert(0 && "MIME sniff failed with data");
553
		}
556
		}
Line 554... Line 557...
554
 
557
		/* LOG(("hlcache_migraet_ctx from LLCACHE_HAD_DATA")); */
Line 555... Line 558...
555
		error = hlcache_migrate_ctx(ctx, effective_type);
558
		error = hlcache_migrate_ctx(ctx, effective_type);
Line 556... Line 559...
556
 
559
 
557
		lwc_string_unref(effective_type);
560
		lwc_string_unref(effective_type);
-
 
561
 
558
 
562
		return error;
559
		return error;
563
 
560
 
564
		break;
561
		break;
565
	case LLCACHE_EVENT_DONE:
562
	case LLCACHE_EVENT_DONE:
566
	  	  /* LOG(("LLCACHE_EVENT_DONE")); */
-
 
567
		/* DONE event before we could determine the effective MIME type.
563
		/* DONE event before we could determine the effective MIME type.
568
		 */
Line 564... Line 569...
564
		 */
569
		error = mimesniff_compute_effective_type(handle,
Line 565... Line 570...
565
		error = mimesniff_compute_effective_type(handle,
570
				NULL, 0, false, false, &effective_type);
Line 575... Line 580...
575
		if (ctx->handle->cb != NULL) {
580
		if (ctx->handle->cb != NULL) {
576
			hlcache_event hlevent;
581
			hlcache_event hlevent;
Line 577... Line 582...
577
 
582
			
578
			hlevent.type = CONTENT_MSG_ERROR;
583
			hlevent.type = CONTENT_MSG_ERROR;
579
			hlevent.data.error = messages_get("BadType");
-
 
580
 
584
			hlevent.data.error = messages_get("BadType");
581
			ctx->handle->cb(ctx->handle, &hlevent, ctx->handle->pw);
585
			ctx->handle->cb(ctx->handle, &hlevent, ctx->handle->pw);
582
		}
586
		}
583
		break;
587
		break;
-
 
588
	case LLCACHE_EVENT_ERROR:
584
	case LLCACHE_EVENT_ERROR:
589
	  /* LOG(("LLCACHE_EVENT_ERROR")); */
585
		if (ctx->handle->cb != NULL) {
590
		if (ctx->handle->cb != NULL) {
Line 586... Line 591...
586
			hlcache_event hlevent;
591
			hlcache_event hlevent;
587
 
592
 
Line 588... Line 593...
588
			hlevent.type = CONTENT_MSG_ERROR;
593
			hlevent.type = CONTENT_MSG_ERROR;
589
			hlevent.data.error = event->data.msg;
594
			hlevent.data.error = event->data.msg;
590
 
595
 
591
			ctx->handle->cb(ctx->handle, &hlevent, ctx->handle->pw);
596
			ctx->handle->cb(ctx->handle, &hlevent, ctx->handle->pw);
-
 
597
		}
592
		}
598
		break;		
593
		break;
599
	case LLCACHE_EVENT_PROGRESS:
594
	case LLCACHE_EVENT_PROGRESS:
-
 
-
 
600
	  	  /* LOG(("LLCACHE_EVENT_PROGRESS")); */
595
		break;
601
		break;
596
	}
602
	}
Line 597... Line 603...
597
 
603
	/* LOG(("Returning OK from hlcache_llcache_callback")); */
598
	return NSERROR_OK;
604
	return NSERROR_OK;
Line 652... Line 658...
652
		error = NSERROR_NEED_DATA;
658
		error = NSERROR_NEED_DATA;
653
	} else {
659
	} else {
654
		/* Unacceptable type: report error */
660
		/* Unacceptable type: report error */
655
		if (ctx->handle->cb != NULL) {
661
		if (ctx->handle->cb != NULL) {
656
			hlcache_event hlevent;
662
			hlcache_event hlevent;
657
 
-
 
-
 
663
			/* LOG(("Unacceptable Type! CONTENT_MSG_ERROR set")); */
658
			hlevent.type = CONTENT_MSG_ERROR;
664
			hlevent.type = CONTENT_MSG_ERROR;
659
			hlevent.data.error = messages_get("UnacceptableType");
665
			hlevent.data.error = messages_get("UnacceptableType");
Line 660... Line 666...
660
 
666
 
661
			ctx->handle->cb(ctx->handle, &hlevent,
667
			ctx->handle->cb(ctx->handle, &hlevent,
Line 812... Line 818...
812
				ctx->handle->cb(ctx->handle, &event,
818
				ctx->handle->cb(ctx->handle, &event,
813
						ctx->handle->pw);
819
						ctx->handle->pw);
814
			}
820
			}
Line 815... Line 821...
815
 
821
 
-
 
822
			if (ctx->handle->cb != NULL) {
816
			if (ctx->handle->cb != NULL) {
823
			  /* LOG(("Calling with CONTENT_MSG_DONE")); */
817
				event.type = CONTENT_MSG_DONE;
824
				event.type = CONTENT_MSG_DONE;
818
				ctx->handle->cb(ctx->handle, &event,
825
				ctx->handle->cb(ctx->handle, &event,
819
						ctx->handle->pw);
826
						ctx->handle->pw);
820
			}
827
			}
821
		}
828
		}
822
	}
-
 
-
 
829
	}
823
 
830
	/* LOG(("Returning from "));  */
824
	return error;
831
	return error;
Line 825... Line 832...
825
}
832
}
826
 
833