示例#1
0
static void
tray_priv (char *from, char *text)
{
	const char *network;

	if (alert_match_word (from, prefs.irc_no_hilight))
		return;

	tray_set_flash (ICON_HILIGHT);

	network = xchat_get_info (ph, "network");
	if (!network)
		network = xchat_get_info (ph, "server");

	tray_priv_count++;
	if (tray_priv_count == 1)
		tray_set_tipf (_("XChat: Private message from: %s (%s)"),
							from, network);
	else
		tray_set_tipf (_("XChat: %u private messages, latest from: %s (%s)"),
							tray_priv_count, from, network);

	if (prefs.input_balloon_priv)
		tray_set_balloonf (text, _("XChat: Private message from: %s (%s)"),
								 from, network);
}
示例#2
0
static int
tray_hilight_cb (char *word[], void *userdata)
{
	/*if (tray_status == TS_HIGHLIGHT)
		return XCHAT_EAT_NONE;*/

	if (prefs.input_tray_hilight)
	{
		tray_set_flash (ICON_HILIGHT);

		/* FIXME: hides any previous private messages */
		tray_hilight_count++;
		if (tray_hilight_count == 1)
			tray_set_tipf (_("XChat: Highlighted message from: %s (%s)"),
								word[1], xchat_get_info (ph, "channel"));
		else
			tray_set_tipf (_("XChat: %u highlighted messages, latest from: %s (%s)"),
								tray_hilight_count, word[1], xchat_get_info (ph, "channel"));
	}

	if (prefs.input_balloon_hilight)
		tray_set_balloonf (word[2], _("XChat: Highlighted message from: %s (%s)"),
								 word[1], xchat_get_info (ph, "channel"));

	return XCHAT_EAT_NONE;
}
示例#3
0
static int
tray_dcc_cb (char *word[], void *userdata)
{
	const char *network;

/*	if (tray_status == TS_FILEOFFER)
		return XCHAT_EAT_NONE;*/

	network = xchat_get_info (ph, "network");
	if (!network)
		network = xchat_get_info (ph, "server");

	if (prefs.input_tray_priv)
	{
		tray_set_flash (ICON_FILE);

		tray_file_count++;
		if (tray_file_count == 1)
			tray_set_tipf (_("XChat: File offer from: %s (%s)"),
								word[1], network);
		else
			tray_set_tipf (_("XChat: %u file offers, latest from: %s (%s)"),
								tray_file_count, word[1], network);
	}

	if (prefs.input_balloon_priv)
		tray_set_balloonf ("", _("XChat: File offer from: %s (%s)"),
								word[1], network);

	return XCHAT_EAT_NONE;
}
示例#4
0
static int
connected_cb (char *word[], gpointer data)
{
	GList *chans, *chan;
	const char *server;
	xchat_context *context;

	if (channels == NULL)
		return XCHAT_EAT_NONE;

	server = xchat_get_info (ph, "server");

	context = g_hash_table_lookup (networks, server);
	if (context) {
		xchat_set_context (ph, context);

		chans = g_hash_table_lookup (channels, server);
		for (chan = chans; chan; chan = g_list_next (chan)) {
			xchat_commandf (ph, "JOIN %s", chan->data);
		}

		g_list_foreach (chans, (GFunc) g_free, NULL);
		g_list_free (chans);

		/* Now that we've connected and re-joined, we can remove this server
		 * from the list */
		g_hash_table_remove (networks, server);
		g_hash_table_remove (channels, server);
	}

	return XCHAT_EAT_NONE;
}
示例#5
0
static int
new_action_cb (char *word[], gpointer data)
{
	const char *channel;
	gchar *stripped, *message, *summary;

	if (focused)
		return XCHAT_EAT_NONE;

	channel = xchat_get_info (ph, "channel");
	stripped = xchat_strip (ph, word[2], -1, STRIP_COLORS | STRIP_ATTRS);

	message = g_strdup_printf ("* %s %s", word[1], stripped);
	if (channel[0] == '#')
		summary = g_strdup_printf (_("Message in %s"), channel);
	else
		summary = g_strdup_printf (_("Message from %s"), channel);

	add_notify (summary, message);

	xchat_free (ph, stripped);
	g_free (message);
	g_free (summary);
	return XCHAT_EAT_NONE;
}
示例#6
0
文件: xdcc.c 项目: arinity/gchat
static void
xdcc_save (void)
{
    char buf[512];
    FILE *fp;
    GSList *list;
    fileoffer *offer;

    snprintf (buf, sizeof (buf), "%s/xdcclist.conf",
              xchat_get_info (ph, "xchatdir"));

    fp = fopen (buf, "w");
    if (!fp)
        return;

    list = file_list;
    while (list)
      {
          offer = (fileoffer *) list->data;
          fprintf (fp, "%s\n%s\n%s\n%d\n\n\n", offer->file, offer->fullpath,
                   offer->desc, offer->downloads);
          list = list->next;
      }

    fclose (fp);
}
示例#7
0
文件: xdcc.c 项目: arinity/gchat
static void
xdcc_load (void)
{
    char buf[512];
    char file[128];
    char path[128];
    char desc[128];
    char dl[128];
    FILE *fp;

    snprintf (buf, sizeof (buf), "%s/xdcclist.conf",
              xchat_get_info (ph, "xchatdir"));

    fp = fopen (buf, "r");
    if (!fp)
        return;

    while (fgets (file, sizeof (file), fp))
      {
          file[strlen (file) - 1] = 0;
          fgets (path, sizeof (path), fp);
          path[strlen (path) - 1] = 0;
          fgets (desc, sizeof (desc), fp);
          desc[strlen (desc) - 1] = 0;
          fgets (dl, sizeof (dl), fp);
          dl[strlen (dl) - 1] = 0;
          fgets (buf, sizeof (buf), fp);
          fgets (buf, sizeof (buf), fp);
          xdcc_add (file, path, desc, atoi (dl));
      }

    fclose (fp);
}
示例#8
0
文件: perl.c 项目: hananh/xchat-aqua
static
XS (XS_Xchat_get_info)
{
	SV *temp = NULL;
	dXSARGS;
	if (items != 1) {
		xchat_print (ph, "Usage: Xchat::get_info(id)");
	} else {
		SV *id = ST (0);
		const char *RETVAL;

		RETVAL = xchat_get_info (ph, SvPV_nolen (id));
		if (RETVAL == NULL) {
			XSRETURN_UNDEF;
		}

		if (!strncmp ("win_ptr", SvPV_nolen (id), 7)) {
			XSRETURN_IV (PTR2IV (RETVAL));
		} else {
			
			if (
				!strncmp ("libdirfs", SvPV_nolen (id), 8) ||
				!strncmp ("xchatdirfs", SvPV_nolen (id), 10)
			) {
				XSRETURN_PV (RETVAL);
			} else {
				temp = newSVpv (RETVAL, 0);
				SvUTF8_on (temp);
				PUSHMARK (SP);
				XPUSHs (sv_2mortal (temp));
				PUTBACK;
			}
		}
	}
}
示例#9
0
static int
perl_auto_load (void *unused)
{
	const char *xdir;
	char *sub_dir;
#ifdef WIN32
	int copied = 0;
	char *slash = NULL;
#endif

	/* get the dir in local filesystem encoding (what opendir() expects!) */
	xdir = xchat_get_info (ph, "xchatdirfs");
	if (!xdir)			/* xchatdirfs is new for 2.0.9, will fail on older */
		xdir = xchat_get_info (ph, "xchatdir");

	/* don't pollute the filesystem with script files, this only causes misuse of the folders
	 * only use ~/.config/hexchat/addons/ and %APPDATA%\HexChat\addons */
#if 0
	/* autoload from ~/.config/hexchat/ or %APPDATA%\HexChat\ on win32 */
	perl_auto_load_from_path (xdir);
#endif

	sub_dir = malloc (strlen (xdir) + 8);
	strcpy (sub_dir, xdir);
	strcat (sub_dir, "/addons");
	perl_auto_load_from_path (sub_dir);
	free (sub_dir);

#if 0
#ifdef WIN32
	/* autoload from  C:\Program Files\HexChat\plugins\ */
	sub_dir = malloc (1025 + 9);
	copied = GetModuleFileName( 0, sub_dir, 1024 );
	sub_dir[copied] = '\0';
	slash = strrchr( sub_dir, '\\' );
	if( slash != NULL ) {
		*slash = '\0';
	}
	perl_auto_load_from_path ( strncat (sub_dir, "\\plugins", 9));
	free (sub_dir);
#endif
#endif
	return 0;
}
示例#10
0
/* 
 * lua:  xchat.get_info(id)
 * desc: Returns information based on your current context.
 * ret:  the requested string or nil on error
 * args: 
 *       * id (string): the wanted information
 */
static int lxc_get_info(lua_State *L)
{
	const char *id    = luaL_checkstring(L, 1);
	const char *value = xchat_get_info(ph, id);
	if (value == NULL)
		lua_pushnil(L);
	else
		lua_pushstring(L, value);
	return 1;
}
示例#11
0
文件: perl.c 项目: hananh/xchat-aqua
static int
perl_auto_load (void *unused)
{
	const char *xdir;

	/* get the dir in local filesystem encoding (what opendir() expects!) */
	xdir = xchat_get_info (ph, "xchatdirfs");
	if (!xdir)						  /* xchatdirfs is new for 2.0.9, will fail on older */
		xdir = xchat_get_info (ph, "xchatdir");

	/* autoload from ~/.xchat2/ or ${APPDATA}\X-Chat 2\ on win32 */
	perl_auto_load_from_path (xdir);

#ifdef WIN32
	/* autoload from  C:\program files\xchat\plugins\ */
	perl_auto_load_from_path (XCHATLIBDIR"/plugins");
#endif
	return 0;
}
示例#12
0
static int
perl_auto_load (void *unused)
{
	const char *xdir;
	char *sub_dir;
#ifdef WIN32
	int copied = 0;
	char *slash = NULL;
#endif

	/* get the dir in local filesystem encoding (what opendir() expects!) */
	xdir = xchat_get_info (ph, "xchatdirfs");
	if (!xdir)			/* xchatdirfs is new for 2.0.9, will fail on older */
		xdir = xchat_get_info (ph, "xchatdir");

	/* autoload from ~/.xchat2/ or ${APPDATA}\X-Chat 2\ on win32 */
	perl_auto_load_from_path (xdir);

	sub_dir = malloc (strlen (xdir) + 9);
	strcpy (sub_dir, xdir);
	strcat (sub_dir, "/plugins");
	perl_auto_load_from_path (sub_dir);
	free (sub_dir);

#ifdef WIN32
	/* autoload from  C:\program files\xchat\plugins\ */
	sub_dir = malloc (1025 + 9);
	copied = GetModuleFileName( 0, sub_dir, 1024 );
	sub_dir[copied] = '\0';
	slash = strrchr( sub_dir, '\\' );
	if( slash != NULL ) {
		*slash = '\0';
	}
	perl_auto_load_from_path ( strncat (sub_dir, "\\plugins", 9));
	free (sub_dir);
#endif
	return 0;
}
示例#13
0
static VALUE static_ruby_xchat_get_info( VALUE klass,
                                         VALUE id )
{
  char *s_id;
  const char *s_info;

  s_id = StringValueCStr( id );

  s_info = xchat_get_info( static_plugin_handle, s_id );

  if( s_info == NULL ) return Qnil;

  return rb_str_new2( s_info );
}
示例#14
0
文件: winsys.cpp 项目: NCDS/hexchat
static int
printInfo (char *word[], char *word_eol[], void *user_data)
{
	/* query WMI info only at the first time WinSys is called, then cache it to save time */
	if (firstRun)
	{
		xchat_printf (ph, "%s first execution, querying and caching WMI info...\n", name);
		wmiOs = getWmiInfo (0);
		wmiCpu = getWmiInfo (1);
		wmiVga = getWmiInfo (2);
		firstRun = 0;
	}
	if (xchat_list_int (ph, NULL, "type") >= 2)
	{
		/* uptime will work correctly for up to 50 days, should be enough */
		xchat_commandf (ph, "ME ** WinSys ** Client: HexChat %s (x%d) ** OS: %s ** CPU: %s (%s) ** RAM: %s ** VGA: %s ** Uptime: %.2f Hours **",
			xchat_get_info (ph, "version"),
			getCpuArch (),
			wmiOs,
			wmiCpu,
			getCpuMhz (),
			getMemoryInfo (),
			wmiVga, (float) GetTickCount() / 1000 / 60 / 60);
	}
	else
	{
		xchat_printf (ph, " * Client:  HexChat %s (x%d)\n", xchat_get_info (ph, "version"), getCpuArch ());
		xchat_printf (ph, " * OS:      %s\n", wmiOs);
		xchat_printf (ph, " * CPU:     %s (%s)\n", wmiCpu, getCpuMhz ());
		xchat_printf (ph, " * RAM:     %s\n", getMemoryInfo ());
		xchat_printf (ph, " * VGA:     %s\n", wmiVga);
		xchat_printf (ph, " * Uptime:  %.2f Hours\n", (float) GetTickCount() / 1000 / 60 / 60);
	}

	return XCHAT_EAT_XCHAT;
}
示例#15
0
文件: sasl.c 项目: PChat/PChat
static sasl_info*
get_info (void)
{
	const char* name;
	name = xchat_get_info (ph, "network");

	if (name)
	{
		return find_info (name);
	}
	else
	{
		return NULL;
	}
}
示例#16
0
static int
tray_message_cb (char *word[], void *userdata)
{
	if (/*tray_status == TS_MESSAGE ||*/ tray_status == TS_HIGHLIGHT)
		return XCHAT_EAT_NONE;

	if (prefs.input_tray_chans)
	{
		tray_set_flash (ICON_MSG);

		tray_pub_count++;
		if (tray_pub_count == 1)
			tray_set_tipf (_("XChat: New public message from: %s (%s)"),
								word[1], xchat_get_info (ph, "channel"));
		else
			tray_set_tipf (_("XChat: %u new public messages."), tray_pub_count);
	}

	if (prefs.input_balloon_chans)
		tray_set_balloonf (word[2], _("XChat: New public message from: %s (%s)"),
								 word[1], xchat_get_info (ph, "channel"));

	return XCHAT_EAT_NONE;
}
示例#17
0
static WinStatus
tray_get_window_status (void)
{
	const char *st;

	st = xchat_get_info (ph, "win_status");

	if (!st)
		return WS_HIDDEN;

	if (!strcmp (st, "active"))
		return WS_FOCUSED;

	if (!strcmp (st, "hidden"))
		return WS_HIDDEN;

	return WS_NORMAL;
}
示例#18
0
void loadThemes(){
    char *hDir, *hFile, *line, *val;
	FILE *f;
	xchat_print(ph,"loading themes\n");
    hDir=(char*)calloc(1024,sizeof(char));
    strcpy(hDir,xchat_get_info(ph,"xchatdirfs"));
    hFile=str3cat(hDir,"\\","mpcInfo.theme.txt");
    f = fopen(hFile,"r");
    if(f==NULL)
	{
		xchat_print(ph,"no theme in homedir, checking global theme");
		f=fopen("mpcInfo.theme.txt","r");
    }
	//xchat_printf(ph,"file_desc: %p\n",f);
	if (f==NULL) xchat_print(ph, "no theme found, using hardcoded\n");
	else {
		if (f > 0)
		{
			line=" ";
		} else
		{
			line="\0";
		}

		while (line[0]!=0)
		{
			line=readLine(f);
			val=split(line,'=');
			printf("line: %s\n",line);
			printf("val: %s\n",val);
			if (strcmp(toUpper(line),"OFF_LINE")==0) notRunTheme=themeAdd(notRunTheme,val);
			if (strcmp(toUpper(line),"TITLE_LINE")==0) titleTheme=themeAdd(titleTheme,val);
			if (strcmp(toUpper(line),"MP3_LINE")==0) mp3Theme=themeAdd(mp3Theme,val);
			if (strcmp(toUpper(line),"OGG_LINE")==0) mp3Theme=themeAdd(oggTheme,val);
		}
		fclose(f);
		xchat_print(ph, "theme loaded successfull\n");
	}
	if (notRunTheme.size==0) notRunTheme=themeAdd(notRunTheme,"say Media Player Classic not running");
	if (titleTheme.size==0) titleTheme=themeAdd(titleTheme,"say Playing %title in Media Player Classic");
	if (mp3Theme.size==0) mp3Theme=themeAdd(mp3Theme,"me listens to %art with %tit from %alb [%gen|%br kbps|%frq kHz|%mode] in Media Player Classic ");
	if (oggTheme.size==0) oggTheme=themeAdd(oggTheme,"me listens to %art with %tit from %alb [%gen|%br kbps|%frq kHz|%chan channels] in Media Player Classic ");
	//mp3Theme=themeAdd(mp3Theme,"me listens to %art with %tit from %alb [%time|%length|%perc%|%br kbps|%frq kHz|%mode] in Media Player Classic ");
}
示例#19
0
gboolean
tray_toggle_visibility (gboolean force_hide)
{
	static int x, y;
	static GdkScreen *screen;
	GtkWindow *win;

	if (!sticon)
		return FALSE;

	/* ph may have an invalid context now */
	xchat_set_context (ph, xchat_find_context (ph, NULL, NULL));

	win = (GtkWindow *)xchat_get_info (ph, "win_ptr");

	tray_stop_flash ();
	tray_reset_counts ();

	if (!win)
		return FALSE;

#if GTK_CHECK_VERSION(2,20,0)
	if (force_hide || gtk_widget_get_visible (win))
#else
	if (force_hide || GTK_WIDGET_VISIBLE (win))
#endif
	{
		gtk_window_get_position (win, &x, &y);
		screen = gtk_window_get_screen (win);
		gtk_widget_hide (GTK_WIDGET (win));
	}
	else
	{
		gtk_window_set_screen (win, screen);
		gtk_window_move (win, x, y);
		gtk_widget_show (GTK_WIDGET (win));
		gtk_window_present (win);
	}

	return TRUE;
}
示例#20
0
void SavePrefs(int iDlg)
{
	/**************************************************************************************************/
	/********** allocate space for our string, and then set it to the currently logged on user ********/
	/**************************************************************************************************/
	DWORD dBuff = 257;
	TCHAR szUser[257];

	GetUserName(szUser, &dBuff);

	/**************************************************************************************************/
	/*********************** Test if the file exists, If it doesn't, Create It ************************/
	/**************************************************************************************************/
	TCHAR XTRAY_INI_FILE[1024];
	
#ifdef UNICODE
	char temp[1024];
    TCHAR TEMP_INI_FILE[1024];
	
	_snprintf(temp, 1024, "%s\\xtray.conf", xchat_get_info(ph, "xchatdir"));
	ConvertString(temp, TEMP_INI_FILE, 1024);

	// ok this one is really ugly
	// it checks to see if the file exists in two locations
	// HexChat default config dir, if that fails it tries hexchat\plugins\config
	// if neither one exists it tries to create it in
	// HexChat default config dir, if that fails it tries hexchat\plugins\config
	// In either case it writes \xFF\xFE to the file ( on creation )
	// so that we can save unicode away messages WritePrivateProfile doesn't 
	// do this for us, though I think it really should

	if(FileExists(TEMP_INI_FILE))
	{
		_tcscpy(XTRAY_INI_FILE, TEMP_INI_FILE);
	}
	else
	{
		if(FileExists(BACKUP_INI_FILE))
		{
			_tcscpy(XTRAY_INI_FILE, BACKUP_INI_FILE);
		}
		else
		{
			HANDLE xTemp;
			DWORD dwBytesTemp;

			if(xTemp = CreateFile(TEMP_INI_FILE, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL))
			{
				if(GetLastError() != ERROR_ALREADY_EXISTS)
				{
					WriteFile(xTemp, _T("\xFF\xFE"), 4, &dwBytesTemp, NULL);
				}
				CloseHandle(xTemp);
			}

			if(FileExists(TEMP_INI_FILE))
			{
				_tcscpy(XTRAY_INI_FILE, TEMP_INI_FILE);
			}
			else
			{
				HANDLE xBackup;
				DWORD dwBytesBackup;

				if(xBackup = CreateFile(TEMP_INI_FILE, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL))
				{
					if(GetLastError() != ERROR_ALREADY_EXISTS)
					{
						WriteFile(xBackup, _T("\xFF\xFE"), 4, &dwBytesBackup, NULL);
					}

					CloseHandle(xBackup);
				}

				if(FileExists(BACKUP_INI_FILE))
				{
					_tcscpy(XTRAY_INI_FILE, BACKUP_INI_FILE);
				}
			}
		}
	}

#else
	_tcscpy(XTRAY_INI_FILE, BACKUP_INI_FILE);
#endif

	WritePrivateProfileInt(szUser, _T("SETTINGS"),		g_dwPrefs,		XTRAY_INI_FILE);
	WritePrivateProfileInt(szUser, _T("AOT"),			g_iTime,		XTRAY_INI_FILE);
	WritePrivateProfileInt(szUser, _T("KEY"),			g_hHotKey.key,	XTRAY_INI_FILE);
	WritePrivateProfileInt(szUser, _T("MOD"),			g_hHotKey.mod,	XTRAY_INI_FILE);
	WritePrivateProfileString(szUser, _T("AWAY"),		g_szAway,		XTRAY_INI_FILE);
}
示例#21
0
void LoadPrefs()
{
	/**************************************************************************************************/
	/*********************** Our Settings Section *****************************************************/
	/**************************************************************************************************/
	DWORD dBuff = 257;
	TCHAR szUser[257];

	GetUserName(szUser, &dBuff);

	/**************************************************************************************************/
	/*********************** Test if the file exists, If it doesn't, Create It ************************/
	/**************************************************************************************************/
	TCHAR XTRAY_INI_FILE[1024];

#ifdef UNICODE
	char temp[1024];
	TCHAR TEMP_INI_FILE[1024];

	_snprintf(temp, 1024, "%s\\xtray.conf", xchat_get_info(ph, "xchatdir"));
	ConvertString(temp, TEMP_INI_FILE, 1024);

	if(FileExists(TEMP_INI_FILE))
	{
		_tcscpy(XTRAY_INI_FILE, TEMP_INI_FILE);
	}
	else
	{
		if(FileExists(BACKUP_INI_FILE))
		{
			_tcscpy(XTRAY_INI_FILE, BACKUP_INI_FILE);
		}
		else
		{
			HANDLE xTemp;
			DWORD dwBytesTemp;

			if(xTemp = CreateFile(TEMP_INI_FILE, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL))
			{
				if(GetLastError() != ERROR_ALREADY_EXISTS)
				{
					WriteFile(xTemp, _T("\xFF\xFE"), 4, &dwBytesTemp, NULL);
				}

				CloseHandle(xTemp);
			}

			if(FileExists(TEMP_INI_FILE))
			{
				_tcscpy(XTRAY_INI_FILE, TEMP_INI_FILE);
			}
			else
			{
				HANDLE xBackup;
				DWORD dwBytesBackup;

				if(xBackup = CreateFile(TEMP_INI_FILE, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL))
				{
					if(GetLastError() != ERROR_ALREADY_EXISTS)
					{
						WriteFile(xBackup, _T("\xFF\xFE"), 4, &dwBytesBackup, NULL);
					}

					CloseHandle(xBackup);
				}

				if(FileExists(BACKUP_INI_FILE))
				{
					_tcscpy(XTRAY_INI_FILE, BACKUP_INI_FILE);
				}
			}
		}
	}

#else
	_tcscpy(XTRAY_INI_FILE, BACKUP_INI_FILE);
#endif

	/**************************************************************************************************/
	/*************************** Get the value for each of our preferances ****************************/
	/**************************************************************************************************/
	g_dwPrefs = GetPrivateProfileInt(szUser, _T("SETTINGS"),	0,  XTRAY_INI_FILE);

	// backwards compatability
	// also allows us to set defaults if its a new installation
	// disable topic change, channel message and server notice by default
	if(g_dwPrefs == 0)
	{
		g_dwPrefs	|= (GetPrivateProfileInt(szUser, _T("HILIGHT"),		1,  XTRAY_INI_FILE)<<1);
		g_dwPrefs	|= (GetPrivateProfileInt(szUser, _T("INVITE"),		1,  XTRAY_INI_FILE)<<2);
		/* g_dwPrefs	|= (GetPrivateProfileInt(szUser, _T("TOPIC"),		1,  XTRAY_INI_FILE)<<3); */
		g_dwPrefs	|= (GetPrivateProfileInt(szUser, _T("BANNED"),		1,  XTRAY_INI_FILE)<<4);
		g_dwPrefs	|= (GetPrivateProfileInt(szUser, _T("KICKED"),		1,  XTRAY_INI_FILE)<<5);
		g_dwPrefs	|= (GetPrivateProfileInt(szUser, _T("CTCP"),		1,  XTRAY_INI_FILE)<<6);
		g_dwPrefs	|= (GetPrivateProfileInt(szUser, _T("PMSG"),		1,  XTRAY_INI_FILE)<<7);
		g_dwPrefs	|= (GetPrivateProfileInt(szUser, _T("KILLED"),		1,  XTRAY_INI_FILE)<<8);
		/* g_dwPrefs	|= (GetPrivateProfileInt(szUser, _T("NOTICE"),		1,  XTRAY_INI_FILE)<<9); */
		g_dwPrefs	|= (GetPrivateProfileInt(szUser, _T("DISCONNECT"),	1,  XTRAY_INI_FILE)<<10);

		g_dwPrefs	|= (GetPrivateProfileInt(szUser, _T("AOM"),			0,  XTRAY_INI_FILE)<<11);
		g_dwPrefs	|= (GetPrivateProfileInt(szUser, _T("TOT"),			1,  XTRAY_INI_FILE)<<12);
		g_dwPrefs	|= (GetPrivateProfileInt(szUser, _T("AMAE"),		1,  XTRAY_INI_FILE)<<13);
		g_dwPrefs	|= (GetPrivateProfileInt(szUser, _T("OSBWM"),		0,  XTRAY_INI_FILE)<<14);
		g_dwPrefs	|= (GetPrivateProfileInt(szUser, _T("UWIOB"),		0,  XTRAY_INI_FILE)<<15);
		g_dwPrefs	|= (GetPrivateProfileInt(szUser, _T("KAOI"),		0,  XTRAY_INI_FILE)<<16);
		g_dwPrefs	|= (GetPrivateProfileInt(szUser, _T("MIOC"),		0,  XTRAY_INI_FILE)<<17);
	}
	
	g_hHotKey.key	= GetPrivateProfileInt(szUser, _T("KEY"),	84, XTRAY_INI_FILE);
	g_hHotKey.mod	= GetPrivateProfileInt(szUser, _T("MOD"),	(MOD_CONTROL | MOD_SHIFT),  XTRAY_INI_FILE);
	g_iTime			= GetPrivateProfileInt(szUser, _T("AOT"),	5,  XTRAY_INI_FILE);

	GetPrivateProfileString(szUser, _T("AWAY"), _T(""),	g_szAway, 1024, XTRAY_INI_FILE);
	
	/**************************************************************************************************/
	/******************************** Register our hotkey with windows ********************************/
	/**************************************************************************************************/
	if(g_dwPrefs & (1<<PREF_UWIOB))
	{
		RegisterHotKey(g_hHotkeyWnd, 1, g_hHotKey.mod, g_hHotKey.key);
	}
}
示例#22
0
static int lxc_cb_load(char *word[], char *word_eol[], void *userdata)
{
	int len;
	struct lxc_States *state;
	lua_State *L;
	const char *name, *desc, *vers;
	const char *xdir = "";
	char  *buf;
	char file[PATH_MAX+1];
	struct stat *st;

	if (word_eol[2][0] == 0)
		return XCHAT_EAT_NONE;
	
	buf = malloc(PATH_MAX + 1);
	if (!buf) {
		xchat_printf(ph, "malloc() failed: %s\n", strerror(errno));
		return XCHAT_EAT_NONE;
	}

	st = malloc(sizeof(struct stat));
	if (!st) {
		xchat_printf(ph, "malloc() failed: %s\n", strerror(errno));
		free(buf);
		return XCHAT_EAT_NONE;
	}

 	len = strlen(word[2]);
	if (len > 4 && strcasecmp (".lua", word[2] + len - 4) == 0) {
#ifdef WIN32
		if (strrchr(word[2], '\\') != NULL)
#else
		if (strrchr(word[2], '/') != NULL)
#endif
			strncpy(file, word[2], PATH_MAX);
		else {
			if (stat(word[2], st) == 0)
			{
				xdir = getcwd (buf, PATH_MAX);
				snprintf (file, PATH_MAX, "%s/%s", xdir, word[2]);
			}
			else
			{
				xdir = xchat_get_info (ph, "xchatdirfs");
				snprintf (file, PATH_MAX, "%s/addons/%s", xdir, word[2]);
			}
		}

		if (lxc_load_file((const char *)file) == 0) {
			free(st);
			free(buf);
			return XCHAT_EAT_ALL;
		}

		state = lxc_states;
		while (state) {
			if (state->next == NULL) {
				L = state->state;

				lua_pushstring(L, "xchat_register");
				lua_gettable(L, LUA_GLOBALSINDEX);
				if (lua_pcall(L, 0, 3, 0)) {
					xchat_printf(ph, "Lua plugin: error registering script %s", 	
								lua_tostring(L, -1));
					lua_pop(L, 1);
					free(st);
					free(buf);
					return XCHAT_EAT_ALL;
				}

				name = lua_tostring(L, -3);
				desc = lua_tostring(L, -2);
				vers = lua_tostring(L, -1);
				lua_pop(L, 4); /* func + 3 ret value */
				state->gui = xchat_plugingui_add(ph, state->file, 
																 name, desc, vers, NULL
															);

				lua_pushstring(L, "xchat_init");
				lua_gettable(L, LUA_GLOBALSINDEX);
				if (lua_type(L, -1) != LUA_TFUNCTION) 
					lua_pop(L, 1);
				else {
					if (lua_pcall(L, 0, 0, 0)) {
						xchat_printf(ph, 
									"Lua plugin: error calling xchat_init() %s", 	
									lua_tostring(L, -1));
						lua_pop(L, 1);
					}
				}
				free(st);
				free(buf);
				return XCHAT_EAT_ALL;
			}
			state = state->next;
		}
	}
	free(st);
	free(buf);
	return XCHAT_EAT_NONE;
}
示例#23
0
int xchat_plugin_init(xchat_plugin *plugin_handle,
                      char **plugin_name,
                      char **plugin_desc,
                      char **plugin_version,
                      char *arg)
{
	struct lxc_States	*state;	
	lua_State *L;
	const char *xdir;
	const char *name, *desc, *vers;
	char *xsubdir;
   /* we need to save this for use with any xchat_* functions */
   ph = plugin_handle;

   /* tell xchat our info */
   *plugin_name = LXC_NAME;
   *plugin_desc = LXC_DESC;
   *plugin_version = LXC_VERSION;

	xchat_hook_command(ph, "LOAD", XCHAT_PRI_NORM, lxc_cb_load, NULL, NULL);
	xchat_hook_command(ph, "UNLOAD", XCHAT_PRI_NORM, lxc_cb_unload, NULL, NULL);
	xchat_hook_command(ph, "LUA", XCHAT_PRI_NORM, lxc_cb_lua, "Usage: LUA <code>, executes <code> in a new lua state", NULL);

	xdir = xchat_get_info (ph, "xchatdirfs");
	xsubdir = g_build_filename (xdir, "addons", NULL);
	lxc_autoload_from_path (xsubdir);
	g_free (xsubdir);

	/* put this here, otherwise it's only displayed when a script is autoloaded upon start */
	xchat_printf(ph, "Lua interface loaded");

	if (!lxc_states) /* no scripts loaded */
		return 1;
	
	state = lxc_states;
	while (state) {
		L = state->state;
		lua_pushstring(L, "xchat_register");
		lua_gettable(L, LUA_GLOBALSINDEX);
		if (lua_pcall(L, 0, 3, 0)) {
			xchat_printf(ph, "Lua plugin: error registering script %s", 	
								lua_tostring(L, -1));
			lua_pop(L, 1);
			state = state->next;
			continue;
		}

		name = lua_tostring(L, -3);
		desc = lua_tostring(L, -2);
		vers = lua_tostring(L, -1);
		lua_pop(L, 4); /* func + 3 ret value */
		state->gui = xchat_plugingui_add(ph, state->file, name, desc, vers, NULL);

		lua_pushstring(L, "xchat_init");
		lua_gettable(L, LUA_GLOBALSINDEX);
		if (lua_type(L, -1) != LUA_TFUNCTION) 
			lua_pop(L, 1);
		else {
			if (lua_pcall(L, 0, 0, 0)) {
				xchat_printf(ph, "Lua plugin: error calling xchat_init() %s", 	
								lua_tostring(L, -1));
				lua_pop(L, 1);
			}
		}
		state = state->next;
	}
	return 1; 
}