Beispiel #1
0
void clockRefresh(void *)
{
	// Handle user's format preference
	Fl_String timestr = Fl_Date_Time::Now().time_string();
	Fl_String timestrsec;
	Fl_String format;
	pGlobalConfig.get("Clock", "TimeFormat", format, "");
	Fl_String seconds = timestr.sub_str(6, 2);
	Fl_String minutes = timestr.sub_str(3, 2);
	int hours = atoi(timestr.sub_str(0, 2));
	if(format == "12") {
		if(hours > 12) {
			hours -= 12;
		}
	}
	timestr = Fl_String(hours) + ":" + minutes;
	timestrsec = timestr + ":" + seconds;
	mClockBox->label(timestr);

	strncpy(Fl_Date_Time::datePartsOrder, _("MDY"), 3);
	Fl_String pClockTooltip = Fl_Date_Time::Now().day_name() + ", ";
	pClockTooltip += Fl_Date_Time::Now().date_string() + ", " + timestrsec;
	mClockBox->tooltip(pClockTooltip);

	mClockBox->redraw();
	Fl::add_timeout(1.0, clockRefresh);
}
Beispiel #2
0
void parse_header(Fl_Buffer &buf)
{
	if(!header.empty()) return;

	char *ptr = buf.data();
	char *header_end = strstr(ptr, "\r\n\r\n");
	if(header_end) {
		header = Fl_String(ptr, header_end-ptr);		
		int hlen = header.length()+4;
		buf.set(buf.data()+hlen, buf.bytes()-hlen);

		printf("HEADER (%s)\n", header.c_str());
		int pos = header.pos("Content-Length");
		if(pos>-1) {
			pos += 15;
			int pos2 = header.pos("\r\n", pos);
			content_len = header.sub_str(pos, pos2-pos).to_int();	
			p_bar->range(0, content_len);
		}		
	}
}