Esempio n. 1
0
File: whois.c Progetto: uhlin/swirc
/* event_whois_ssl: 275, 671

   Examples:
     :irc.server.com 275 <issuer> <target> :is connected via SSL (secure link)
     :irc.server.com 671 <issuer> <target> :is using a secure connection */
void
event_whois_ssl(struct irc_message_compo *compo)
{
    PRINTTEXT_CONTEXT ctx;
    char *state = "";
    char *tnick, *msg;

    printtext_context_init(&ctx, g_status_window, TYPE_SPEC1_WARN, true);

    if (strFeed(compo->params, 2) != 2) {
	printtext(&ctx, "On issuing event %s: strFeed(..., 2) != 2",
		  compo->command);
	return;
    }

    (void) strtok_r(compo->params, "\n", &state);
    tnick = strtok_r(NULL, "\n", &state);
    msg   = strtok_r(NULL, "\n", &state);

    if (tnick == NULL || msg == NULL) {
	printtext(&ctx, "On issuing event %s: Unable to extract message",
		  compo->command);
	return;
    }

    if (*msg == ':') {
	msg++;
    }

    if (*msg) {
	ctx.window    = g_active_window;
	ctx.spec_type = TYPE_SPEC1;
	printtext(&ctx, "%s %s %s", Theme("whois_ssl"), tnick, msg);
    }
}
Esempio n. 2
0
File: whois.c Progetto: uhlin/swirc
/* event_whois_channels: 319

   Example:
     :irc.server.com 319 <issuer> <target> :<channel list> */
void
event_whois_channels(struct irc_message_compo *compo)
{
    PRINTTEXT_CONTEXT ctx;
    char *chan_list;
    char *state = "";

    printtext_context_init(&ctx, g_status_window, TYPE_SPEC1_WARN, true);

    if (strFeed(compo->params, 2) != 2) {
	printtext(&ctx, "On issuing event %s: strFeed(..., 2) != 2",
		  compo->command);
	return;
    }

    (void) strtok_r(compo->params, "\n", &state);
    (void) strtok_r(NULL, "\n", &state);

    if ((chan_list = strtok_r(NULL, "\n", &state)) == NULL) {
	printtext(&ctx, "On issuing event %s: Unable to extract message",
		  compo->command);
	return;
    }

    if (*chan_list == ':') {
	chan_list++;
    }

    if (*chan_list) {
	ctx.window    = g_active_window;
	ctx.spec_type = TYPE_SPEC1;
	printtext(&ctx, "%s %s", Theme("whois_channels"), chan_list);
    }
}
Esempio n. 3
0
File: whois.c Progetto: uhlin/swirc
/* event_whois_host: 338, 616

   Example:
     :irc.server.com 338 <issuer> <target> <IP> :actually using host
     :irc.server.com 338 <issuer> <target> :is actually <user@host> [<IP>]
     :irc.server.com 616 <issuer> <target> :real hostname ... */
void
event_whois_host(struct irc_message_compo *compo)
{
    PRINTTEXT_CONTEXT ctx;
    char *state = "";
    char *str, *str_copy, *cp;

    if (strFeed(compo->params, 2) != 2) {
	goto bad;
    }

    (void) strtok_r(compo->params, "\n", &state);
    (void) strtok_r(NULL, "\n", &state);

    if ((str = strtok_r(NULL, "\n", &state)) == NULL) {
	goto bad;
    }

    str_copy = sw_strdup(str);
    cp       = &str_copy[0];
    squeeze(str_copy, ":");

    printtext_context_init(&ctx, g_active_window, TYPE_SPEC1, true);
    printtext(&ctx, "%s %s", Theme("whois_host"), cp);
    free(str_copy);
    return;

  bad:
    printtext_context_init(&ctx, g_status_window, TYPE_SPEC1_WARN, true);
    printtext(&ctx, "On issuing event %s: An error occurred", compo->command);
}
Esempio n. 4
0
File: whois.c Progetto: uhlin/swirc
/* event_whois_idle: 317

   Example:
     :irc.server.com 317 <issuer> <target> <sec idle> <signon time>
                         :<comment> */
void
event_whois_idle(struct irc_message_compo *compo)
{
    PRINTTEXT_CONTEXT ctx;
    char *ep1, *ep2;
    char *sec_idle_str, *signon_time_str;
    char *state = "";
    long int sec_idle, signon_time;
    struct time_idle *ti;

    if (strFeed(compo->params, 4) != 4) {
	goto bad;
    }

    (void) strtok_r(compo->params, "\n", &state);
    (void) strtok_r(NULL, "\n", &state);
    sec_idle_str    = strtok_r(NULL, "\n", &state);
    signon_time_str = strtok_r(NULL, "\n", &state);

    if (sec_idle_str == NULL || signon_time_str == NULL) {
	goto bad;
    }

    errno = 0;
    sec_idle = strtol(sec_idle_str, &ep1, 10);
    if (sec_idle_str[0] == '\0' || *ep1 != '\0') {
	goto bad;
    } else if (errno == ERANGE &&
	       (sec_idle == LONG_MAX || sec_idle == LONG_MIN)) {
	goto bad;
    } else {
	/* do nothing */;
    }

    errno = 0;
    signon_time = strtol(signon_time_str, &ep2, 10);
    if (signon_time_str[0] == '\0' || *ep2 != '\0') {
	goto bad;
    } else if (errno == ERANGE &&
	       (signon_time == LONG_MAX || signon_time == LONG_MIN)) {
	goto bad;
    } else {
	/* do nothing */;
    }

    if ((ti = get_time_idle(sec_idle, signon_time)) == NULL) {
	goto bad;
    }

    printtext_context_init(&ctx, g_active_window, TYPE_SPEC1, true);
    printtext(&ctx, "%s %ld days %ld hours %ld mins %ld secs %ssignon: %s%s",
	      Theme("whois_idle"), ti->days, ti->hours, ti->mins, ti->secs,
	      LEFT_BRKT, ti->buf, RIGHT_BRKT);
    free(ti);
    return;

  bad:
    printtext_context_init(&ctx, g_status_window, TYPE_SPEC1_WARN, true);
    printtext(&ctx, "On issuing event %s: An error occurred", compo->command);
}
Esempio n. 5
0
 InternalMod(FrontAPI & front, uint16_t front_width, uint16_t front_height, Font const & font,
             Theme const & theme = Theme())
     : mod_api(front_width, front_height)
     , front(front)
     , screen(*this, front_width, front_height, font, nullptr, theme)
 {
     this->front.server_resize(front_width, front_height, 24);
 }
Esempio n. 6
0
void FB_Config::LoadFBTheme ( wxString file ) 
{
    
    wxFileInputStream input( file );
    wxFileConfig Theme( input );
    
	wxString StyleTypes[]={	"default", 	    "comment", 	   "number",
                            "keyword",      "string",      "preprocessor",
							"operator", 	"identifier",  "date",
                            "stringeol",    "keyword2",    "keyword3",
                            "keyword4",     "constant",    "asm" };

    #define _STYLE(nr) Style_FB.Style[nr]
        Theme.SetPath("/default");
        _STYLE(0).Face          = Theme.Read("foreground",  0L);
        _STYLE(0).Back          = Theme.Read("background",  0xffffff);
        _STYLE(0).Case          = Theme.Read("capital",     0L);
        _STYLE(0).Size          = Theme.Read("fontsize",    10L);
        _STYLE(0).Style         = Theme.Read("fontstyle",   0L);
        _STYLE(0).Font          = Theme.Read("font",        "" );
    
        Theme.SetPath("/caret");
        Style_FB.CaretFace      = Theme.Read("caret",       _STYLE(0).Face);
        Style_FB.CaretLine      = Theme.Read("caretline",   _STYLE(0).Back);
       
    	//Line number
        Theme.SetPath("/linenumber");
        Style_FB.LineNumberFace = Theme.Read("foreground",  0xffffff);
        Style_FB.LineNumberBack = Theme.Read("background",  0xc0c0c0);
    	
        Theme.SetPath("/select");
        Style_FB.SelectFace     = Theme.Read("foreground",  0xffffff);
        Style_FB.SelectBack     = Theme.Read("background",  0xc0c0c0);
        
        Theme.SetPath("/brace");
        Style_FB.BraceFace      = Theme.Read("foreground",  _STYLE(0).Back);
        Style_FB.BraceBack      = Theme.Read("background",  _STYLE(0).Face);
        Style_FB.BraceStyle     = Theme.Read("fontstyle",   0L);
        
        Theme.SetPath("/badbrace");
        Style_FB.BadBraceFace   = Theme.Read("foreground",  _STYLE(0).Back);
        Style_FB.BadBraceBack   = Theme.Read("background",  _STYLE(0).Face);
        Style_FB.BadBraceStyle  = Theme.Read("fonstyle",    0L);
        
        for (int i=1; i<15;i++) {
            Theme.SetPath("/" + StyleTypes[i]);
            _STYLE(i).Face          = Theme.Read("foreground",  _STYLE(0).Face);
            _STYLE(i).Back          = Theme.Read("background",  _STYLE(0).Back);
            _STYLE(i).Case          = Theme.Read("capital",     _STYLE(0).Case);
            _STYLE(i).Size          = Theme.Read("fontsize",    _STYLE(0).Size);
            _STYLE(i).Style         = Theme.Read("fontstyle",   _STYLE(0).Style);
            _STYLE(i).Font          = Theme.Read("font",        _STYLE(0).Font);
        }
    #undef _STYLE
}
Esempio n. 7
0
const Themes lmcTheme::availableThemes(void) {
	QDir::Filters filters = QDir::Dirs | QDir::NoDotAndDotDot | QDir::Readable;
	QDir::SortFlags sort = QDir::Name;

	Themes themes;

	QDir dir(StdLocation::resThemeDir());
	QStringList entries = dir.entryList(QStringList(), filters, sort);
	foreach(QString dirName, entries) {
		themes.append(Theme(dirName, dir.absoluteFilePath(dirName)));
	}
Esempio n. 8
0
File: whois.c Progetto: uhlin/swirc
/* event_whois_user: 311

   Example:
     :irc.server.com 311 <issuer> <target> <username> <hostname> *
                         :<real name> */
void
event_whois_user(struct irc_message_compo *compo)
{
    PRINTTEXT_CONTEXT ctx;
    char *nick, *user, *host, *rl_name;
    char *state = "";

    printtext_context_init(&ctx, g_status_window, TYPE_SPEC1_WARN, true);

#if 0
    nick = user = host = rl_name = NULL;
#endif

    if (strFeed(compo->params, 5) != 5) {
	printtext(&ctx, "On issuing event %s: strFeed(..., 5) != 5",
		  compo->command);
	return;
    }

    (void) strtok_r(compo->params, "\n", &state); /* <issuer> */
    nick    = strtok_r(NULL, "\n", &state);
    user    = strtok_r(NULL, "\n", &state);
    host    = strtok_r(NULL, "\n", &state);
    (void) strtok_r(NULL, "\n", &state);
    rl_name = strtok_r(NULL, "\n", &state);

    if (nick == NULL || user == NULL || host == NULL || rl_name == NULL) {
	printtext(&ctx, "On issuing event %s: Erroneous server params",
		  compo->command);
	return;
    }

    ctx.window    = g_active_window;
    ctx.spec_type = TYPE_SPEC1;
    printtext(&ctx, "%c%s%c %s%s@%s%s", BOLD, nick, BOLD,
	      LEFT_BRKT, user, host, RIGHT_BRKT);

    if (*rl_name == ':') {
	rl_name++;
    }

    if (*rl_name) {
	printtext(&ctx, "%s %s", Theme("whois_ircName"), rl_name);
    }
}
Esempio n. 9
0
void ThemeManager::currentThemeChanged(QListWidgetItem* current)
{
	if (current) {
		bool is_default = current->listWidget() == m_default_themes;
		if (is_default) {
			m_themes->setCurrentIndex(m_themes->rootIndex());
		} else {
			m_default_themes->setCurrentIndex(m_default_themes->rootIndex());
		}

		selectionChanged(is_default);

		QString id = current->data(Qt::UserRole).toString();
		m_settings.setValue("ThemeManager/Theme", id);
		m_settings.setValue("ThemeManager/ThemeDefault", is_default);
		emit themeSelected(Theme(id, is_default));
	}
}
Esempio n. 10
0
File: whois.c Progetto: uhlin/swirc
/* event_whois_server: 312

   Example:
     :irc.server.com 312 <issuer> <target> <server> :<info> */
void
event_whois_server(struct irc_message_compo *compo)
{
    PRINTTEXT_CONTEXT ctx;
    char *srv, *info;
    char *state = "";

    printtext_context_init(&ctx, g_status_window, TYPE_SPEC1_WARN, true);

    if (strFeed(compo->params, 3) != 3) {
	printtext(&ctx, "On issuing event %s: strFeed(..., 3) != 3",
		  compo->command);
	return;
    }

    (void) strtok_r(compo->params, "\n", &state);
    (void) strtok_r(NULL, "\n", &state);
    srv  = strtok_r(NULL, "\n", &state);
    info = strtok_r(NULL, "\n", &state);

    if (srv == NULL || info == NULL) {
	printtext(&ctx, "On issuing event %s: Erroneous server params",
		  compo->command);
	return;
    }

    if (*info == ':') {
	info++;
    }

    if (*info) {
	ctx.window    = g_active_window;
	ctx.spec_type = TYPE_SPEC1;
	printtext(&ctx, "%s %s %s%s%s", Theme("whois_server"), srv,
		  LEFT_BRKT, info, RIGHT_BRKT);
    }
}
Esempio n. 11
0
File: whois.c Progetto: uhlin/swirc
/* event_whois_acc: 330

   Example:
     :irc.server.com 330 <issuer> <target> <account name> :is logged in as */
void
event_whois_acc(struct irc_message_compo *compo)
{
    PRINTTEXT_CONTEXT ctx;
    char *account_name, *comment;
    char *state = "";

    printtext_context_init(&ctx, g_status_window, TYPE_SPEC1_WARN, true);

    if (strFeed(compo->params, 3) != 3) {
	printtext(&ctx, "On issuing event %s: strFeed(..., 3) != 3",
		  compo->command);
	return;
    }

    (void) strtok_r(compo->params, "\n", &state);
    (void) strtok_r(NULL, "\n", &state);
    account_name = strtok_r(NULL, "\n", &state);
    comment      = strtok_r(NULL, "\n", &state);

    if (account_name == NULL || comment == NULL) {
	printtext(&ctx, "On issuing event %s: Erroneous server params",
		  compo->command);
	return;
    }

    if (*comment == ':') {
	comment++;
    }

    if (*comment) {
	ctx.window    = g_active_window;
	ctx.spec_type = TYPE_SPEC1;
	printtext(&ctx, "%s %s %s", Theme("whois_acc"), comment, account_name);
    }
}
Esempio n. 12
0
void ThemeManager::LoadThemeMetrics( const RString &sThemeName_, const RString &sLanguage_ )
{
	if( g_pLoadedThemeData == NULL )
		g_pLoadedThemeData = new LoadedThemeData;

	// Don't delete and recreate LoadedThemeData.  There are references iniMetrics and iniStrings 
	// on the stack, so Clear them instead.
	g_pLoadedThemeData->ClearAll();
	g_vThemes.clear();

	RString sThemeName(sThemeName_);
	RString sLanguage(sLanguage_);

	m_sCurThemeName = sThemeName;
	m_sCurLanguage = sLanguage;

	bool bLoadedBase = false;
	while(1)
	{
		ASSERT_M( g_vThemes.size() < 20, "Circular theme fallback references detected." );

		g_vThemes.push_back( Theme() );
		Theme &t = g_vThemes.back();
		t.sThemeName = sThemeName;

		IniFile iniMetrics;
		IniFile iniStrings;
		iniMetrics.ReadFile( GetMetricsIniPath(sThemeName) );
		// Load optional language inis (probably mounted by a package) first so that they can be overridden by the current theme.
		{
			vector<RString> vs;
			GetOptionalLanguageIniPaths(vs,sThemeName,sLanguage);
			FOREACH_CONST(RString,vs,s)
				iniStrings.ReadFile( *s );
		}
		iniStrings.ReadFile( GetLanguageIniPath(sThemeName,SpecialFiles::BASE_LANGUAGE) );
		if( sLanguage.CompareNoCase(SpecialFiles::BASE_LANGUAGE) )
			iniStrings.ReadFile( GetLanguageIniPath(sThemeName,sLanguage) );

		bool bIsBaseTheme = !sThemeName.CompareNoCase(SpecialFiles::BASE_THEME_NAME);
		iniMetrics.GetValue( "Global", "IsBaseTheme", bIsBaseTheme );
		if( bIsBaseTheme )
			bLoadedBase = true;

		/* Read the fallback theme. If no fallback theme is specified, and we haven't
		 * already loaded it, fall back on SpecialFiles::BASE_THEME_NAME.
		 * That way, default theme fallbacks can be disabled with
		 * "FallbackTheme=". */
		RString sFallback;
		if( !iniMetrics.GetValue("Global","FallbackTheme",sFallback) )
		{
			if( sThemeName.CompareNoCase( SpecialFiles::BASE_THEME_NAME ) && !bLoadedBase )
				sFallback = SpecialFiles::BASE_THEME_NAME;
		}

		/* We actually want to load themes bottom-to-top, loading fallback themes
		 * first, so derived themes overwrite metrics in fallback themes. But, we
		 * need to load the derived theme first, to find out the name of the fallback
		 * theme.  Avoid having to load IniFile twice, merging the fallback theme
		 * into the derived theme that we've already loaded. */
		XmlFileUtil::MergeIniUnder( &iniMetrics, &g_pLoadedThemeData->iniMetrics );
		XmlFileUtil::MergeIniUnder( &iniStrings, &g_pLoadedThemeData->iniStrings );

		if( sFallback.empty() )
			break;
		sThemeName = sFallback;
	}

	// Overlay metrics from the command line.
	RString sMetric;
	for( int i = 0; GetCommandlineArgument( "metric", &sMetric, i ); ++i )
	{
		/* sMetric must be "foo::bar=baz". "foo" and "bar" never contain "=", so
		 * in "foo::bar=1+1=2", "baz" is always "1+1=2". Neither foo nor bar may
		 * be empty, but baz may be. */
		Regex re( "^([^=]+)::([^=]+)=(.*)$" );
		vector<RString> sBits;
		if( !re.Compare( sMetric, sBits ) )
			RageException::Throw( "Invalid argument \"--metric=%s\".", sMetric.c_str() );

		g_pLoadedThemeData->iniMetrics.SetValue( sBits[0], sBits[1], sBits[2] );
	}

	LOG->MapLog( "theme", "Theme: %s", m_sCurThemeName.c_str() );
	LOG->MapLog( "language", "Language: %s", m_sCurLanguage.c_str() );
}
Esempio n. 13
0
	foreach(QString dirName, entries) {
		themes.append(Theme(dirName, dir.absoluteFilePath(dirName)));
	}
Esempio n. 14
0
int main(int argc, char *argv[]){
	// Window Main(argc, argv);
	Json Settings("../settings/heatmap.json");
	Message Msg("en");

	int i, j, k, m;
	char drop, buf[3];
	char string[1000];
	FILE *open;
	struct one_pixel *rawdata;
	struct {
		int byte_per_line;
		int block;
		int byte_per_pixel[2];
		char theme[100];
		struct rgb base;
	}setting;

	struct specification{
		long code;
		struct rgb color;
	};

	struct range{
		long begin;
		long end;
		struct rgb color;
	};

	struct {
		int num;
		struct specification *list;
	}specification_data;

	struct {
		int num;
		struct range *list;
	}range_data;

	// Loading Setting
	setting.byte_per_line = atoi( Settings.get("settings.block_per_line")->value );
	setting.block = atoi( Settings.get("settings.block")->value );

	setting.byte_per_pixel[0] = atoi( Settings.get("settings.block_per_pixel.width")->value );
	setting.byte_per_pixel[1] = atoi( Settings.get("settings.block_per_pixel.height")->value );

	strcpy( setting.theme, Settings.get("settings.default_theme")->value );
	color( &setting.base, Settings.get("settings.campus_color")->value );

	// Loading Theme
	sprintf(string, "../themes/%s.json", setting.theme);
	open = fopen(string, "r");
	if(!open){
		Msg.show(2);
		sprintf(string, "../themes/%s.json", setting.theme);
	}else{
		fclose(open);
	}

	Json Theme(string);

	// Default
	struct rgb theme_default;
	color( &theme_default, Theme.get("default")->value );

	// Specification
	specification_data.num = Theme.array_range("specification");

	specification_data.list = (struct specification *)calloc(specification_data.num, sizeof(struct specification));
	if(!specification_data.list)
		Msg.show(3);

	for(i=0; i<specification_data.num; i++){
		// Clear Buffer
		for(j=0; j<1000; j++)
			string[j] = 0x00;

		color( &specification_data.list[i].color, gcat(&Msg, Theme.get( gstr(string, "specification", i, "color") ))->value );
		specification_data.list[i].code = strtol( gcat(&Msg, Theme.get( gstr(string, "specification", i, "addr") ))->value, NULL, 16 );
	}

	// Range
	range_data.num = Theme.array_range("range");
	range_data.list = (struct range *)calloc(range_data.num, sizeof(struct range));
	if(!range_data.list)
		Msg.show(3);

	for(i=0; i<range_data.num; i++){
		// Clear Buffer
		for(j=0; j<1000; j++)
			string[j] = 0x00;

		color( &range_data.list[i].color, gcat(&Msg, Theme.get( gstr(string, "range", i, "color") ))->value );
		range_data.list[i].begin = strtol( Theme.get( gstr(string, "range", i, "begin") )->value, NULL, 16 );
		range_data.list[i].end = strtol( Theme.get( gstr(string, "range", i, "end") )->value, NULL, 16 );
	}

	// Prepare
	long buffer;
	int image_width = setting.byte_per_pixel[0] * setting.byte_per_line;
	int image_size = -1, image_height;

	open = fopen("../bin/main", "rb");
	if(!open)
		Msg.show(5);

	while(!feof(open)){
		fread(&buffer, (size_t)setting.block , (size_t)1, open);
		image_size++;
	}

	image_height = setting.byte_per_pixel[1] * ((image_size / setting.byte_per_line) + 1);

	rawdata = (struct one_pixel *)calloc(image_width * image_height, sizeof(struct one_pixel));
	if(!rawdata)
		Msg.show(3);


	rewind( open );

	struct rgb *line;
	line = (struct rgb *)calloc(setting.byte_per_line, sizeof(struct rgb));
	if(!line)
		Msg.show(3);

	int cur_line = 0;
	long size_pointer = 0;

	for(j=0; j<setting.byte_per_line; j++)
		line[j] = setting.base;

	int debug = 0;
	bool break_flag = false;
	while(!feof(open)){
		buffer = 0x20;
		if(fread(&buffer, (size_t)setting.block, (size_t)1, open) != 1)
			break_flag = true;

		if(!break_flag){
			// printf("%d (%d) %s\n", debug, cur_line, "Write!");
			debug++;

			// Default Color
			line[cur_line] = theme_default;

			// Range
			for(j=0; j<range_data.num; j++){
				if(buffer >= range_data.list[j].begin && buffer <= range_data.list[j].end){
					line[cur_line] = range_data.list[j].color;
					break;
				}
			}

			// Specification
			for(j=0; j<specification_data.num; j++){
				if( buffer == specification_data.list[j].code ){
					line[cur_line] = specification_data.list[j].color;
					break;
				}
			}
		}

		if(cur_line >= setting.byte_per_line - 1 || break_flag){
			// Height
			for(j=0; j<setting.byte_per_pixel[1]; j++){
				// Dots
				for(m=0; m<setting.byte_per_line; m++){
					for(k=0; k<setting.byte_per_pixel[0]; k++){
						rgb_one_pixel(&line[m], &rawdata[size_pointer]);
						size_pointer++;
					}
				}
			}

			for(j=0; j<setting.byte_per_line; j++)
				line[j] = setting.base;

			cur_line = 0;
		}else{
			cur_line++;
		}
	}

	fclose( open );

	Window Main(argc, argv, image_width, image_height, 24, rawdata);	
	Bitmap Img(&Msg, "../test_2.bmp", image_width, image_height, 24, rawdata);

	// char drop;

	struct color_set{
		char key;
	};

	// while(TRUE){
	// 	scanf("%c", &drop);

	// 	printf("%c", drop);
	// }

	return 0;
}