summary refs log blame commit diff stats
path: root/share/doc/python.md
blob: 1020d6458a93ff22e1a9184ac0b3e6b3dea8f69f (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
                          
 
           


                                                             





                                                    
                                                  


                          
 
           
 
                                                                                                    
 




                                                                                               
 



                                                   
 



                                                                                
 
                                                                          

 
                      


                                                                        

                                                                                                                
 
                 

                                                               
                                                                          


                                                                
                                                                          


                                                                  


                                                                     


                                                                 
 
              
 
                                              
 



                                                
 



                                                                       


                                                                        
                
 
 
               
 
                                                                        

                                                        



                          


                                                          
 

                     
 






                                                                     
                                                                                            
 

                                           





                                                                           



                                                            



                                                                   
                                                                         

                                           



                                            








                                                                        




                                      


                                    

                          




                                                                       
                                                     

                                                    
                                                                     

                                                                      

                                                          

                                             

                                                            

                                                                                                   
                                                                             
                                       


        



                                    
 
 


                                                                        

                                                



                                                             
 
                          





                                                                        
                                                                     

                                                                     
                        
 







                                                                       


                                                     


                                                                                          

                        
 




                                                                       
                                      
                                         
                                                                       


                                    
                                                           


                                                  
                                                         
                                             



                             
 












                                     





                                                                       




















                                                                                    
 





                                                                      

                                                     
                                                                     
                       
                                                                       

                                                 
 





                                                                      








                                                           
                
 


                  
                                                      
 
 


                                                                 

                                                                    

                                                                      

                                             






                                                                    











                                                  
 





                                                                       
                                       
 
                                                                      
                                                                       

                                                
                                                                 
                                                              

                                                


                                                     
 


                                                                                      






                                                                         









                                                                                              

                                                                   

                                       
 
                                                                         

                                                                 
                                                                       



                                                                    


                                          
                                                                     


                                        

                                                                   

                                       
 
                                                                          







                                                                       


                                                                        
                                                                    



                                  

                                                                   

                                       
 
                                                        





                                                                        
















                                                                    



                                                                       

                                                         





                                                                        






                                 




                                                          
 



                                                                                                             
                                       
 
                                                                                                                                                        


                                                                                                                                  

                                


                                                                                                                                                      
 
                                
 



                                                                                       


                                                
 



                                                                
 


                                                                      
                                                                 
                                                                       
                                                                       








                                                                        





                                                                                                                       
 
 
                         


                                                               
                                                   





                                                                       



                                              
 
   
 


                                                                                     
# HexChat Python Interface

## Features

Here are some of the features of the python plugin interface:

 * Comprehensive, consistent and straightforward API
 * Load, unload, reload, and autoload support
 * Per plugin independent interpreter state
 * Python interactive console
 * Python interactive command execution
 * Full thread support
 * Stdout and stderr redirected to HexChat console
 * Dynamic list management
 * Nice context treatment
 * Plugin preferences

## Commands

The following commands will be intercepted by the Python Plugin interface module, when it is loaded.

 * **/py load <filename>:** Load module with given filename.
 * **/py unload <filename|module name>:** Unload module with given filename, or module name.
 * **/py reload <filename|module name>:** Reload module with given filename, or module name.
 * **/py list:** List Python modules loaded.
 * **/py exec <command>:** Execute given Python command interactively. For example:

<pre>
	/py exec import xchat
	/py exec print xchat.get_info('channel')
</pre>

 * **/py console:** Open the Python interactive console in a query (>>python<<).
Every message sent will be intercepted by the Python plugin interface,
and interpreted interactively. Notice that the console and /py exec
commands live in the same interpreter state.

 * **/py about:** Show some information about the Python plugin interface.


## Autoloading modules

If you want some module to be autoloaded together with the Python plugin
interface (which usually loads at startup time), just make sure it has a
`.py` extension and put it in your HexChat directory (`~/.config/hexchat/addons`, `%APPDATA%\\HexChat\\addons`).


## Context theory

Before starting to explain what the API offers, I'll do a short
introduction about the HexChat context concept. Not because it's something
hard to understand, but because you'll understand better the API
explanations if you know what I'm talking about.

You can think about a context as an HexChat channel, server, or query tab.
Each of these tabs, has its own context, and is related to a given
server and channel (queries are a special kind of channel).

The *current* context is the one where HexChat passes control to the
module. For example, when HexChat receives a command in a specific
channel, and you have asked HexChat to tell you about this event, the
current context will be set to this channel before your module is
called.


## Hello world

Here is the traditional _hello world_ example.

<pre>
__module_name__ = "helloworld"
__module_version__ = "1.0"
__module_description__ = "Python module example"

print "Hello world!"
</pre>

This module will print "Hello world!" in the HexChat console, and sleep
forever until it's unloaded. It's a simple module, but already
introduces some concepts. Notice how the module information is set. This
information is obligatory, and will be shown when listing the loaded
HexChat modules.


## xchat module

The xchat module is your passport to every HexChat functionality offered
by the Python plugin interface. Here's a simple example:

<pre>
import xchat
xchat.prnt("Hi everyone!")
</pre>

The following functions are available in the xchat module.


### Generic functions


#### xchat.prnt(string)

This function will print string in the current context. It's mainly
useful as a parameter to pass to some other function, since the usual
print statement will have the same results. You have a usage example
above.

This function is badly named because `"print"` is a reserved keyword of the Python language.


#### xchat.emit\_print(event\_name, \*args)

This function will generate a *print event* with the given arguments. To
check which events are available, and the number and meaning of
arguments, have a look at the `Settings > Lists > Text Events` window.
Here is one example:

<pre>
xchat.emit_print("Channel Message", "John", "Hi there", "@")
</pre>


#### xchat.command(string)

Execute the given command in the current context. This has the same
results as executing a command in the HexChat window, but notice that the
`/` prefix is not used. Here is an example:

<pre>
xchat.command("server irc.openprojects.net")
</pre>


#### xchat.nickcmp(s1, s2)

This function will do an RFC1459 compliant string comparing between `s1`
and `s2`, and is useful to compare channels and nicknames. It returns an
integer less than, equal to, or greater than zero if `s1` is found,
respectively, to be less than, to match, or be greater than `s2`. For
example:

<pre>
if xchat.nickcmp(nick, "mynick") == 0:
    print "They are the same!"
</pre>


### Information retreiving functions


#### xchat.get\_info(type)

Retrieve the information specified by the `type` string in the current
context. At the moment of this writing, the following information types
are available to be queried:

 * **away:** Away reason or None if you are not away.
 * **channel:** Channel name of the current context.
 * **charset:** Charset in current context.
 * **configdir:** HexChat config directory e.g.: "~/.config/hexchat".
 * **event_name NAME:** Returns text event string for requested event.
 * **gtkwin_ptr:** Current Gtk Window.
 * **host:** Real hostname of the server you connected to.
 * **inputbox:** Contents of inputbox.
 * **network:** Current network name or None.
 * **nick:** Your current nick name.
 * **nickserv:** Current networks nickserv password or None.
 * **modes:** Current channel modes or None.
 * **server:** Current server name (what the server claims to be) or None if you are not connected.
 * **topic:** Current channel topic.
 * **win_status:** Returns status of window: 'active', 'hidden', or 'normal'.
 * **version:** HexChat version number.

Example:

<pre>
if xchat.get_info("server") is None:
    print "Not connected!"
</pre>


#### xchat.get\_prefs(name)

Retrieve the HexChat setting information specified by the `name` string,
as available by the `/set` command. For example:

<pre>
print "Current preferred nick:", xchat.get_prefs("irc_nick1")
</pre>


#### xchat.get\_list(type)

With this function you may retrieve a list containing the selected
information from the current context, like a DCC list, a channel list, a
user list, etc. Each list item will have its attributes set dynamically
depending on the information provided by the list type.

The example below is a rewrite of the example provided with HexChat's
plugin API documentation. It prints a list of every DCC transfer
happening at the moment. Notice how similar the interface is to the C
API provided by HexChat.

<pre>
list = xchat.get_list("dcc")
if list:
    print "--- DCC LIST ------------------"
    print "File  To/From   KB/s   Position"
    for i in list:
        print "%6s %10s %.2f  %d" % (i.file, i.nick, i.cps/1024, i.pos)
</pre>

Below you will find what each list type has to offer.

This information was taken from HexChat's plugin documentation. You may find any types not
listed here, if they exist at all, in an updated HexChat documentation.
Any list types accepted by HexChat should be dynamically accepted by the
Python plugin interface.


##### channels

The channels list type gives you access to the channels, queries and
their servers. The folloing attributes are available in each list item:

 * **channel:** Channel or query name.
 * **chantypes:** Channel types e.g. #!&.
 * **context:** A context object, giving access to that channel/server.
 * **id:** Unique server id.
 * **lag:** Latency in milliseconds.
 * **maxmodes:** Max modes per line.
 * **network:** Network name to which this channel belongs.
 * **nickprefixes:** Nickname prefixes e.g. @%+.
 * **nickmodes:** Nickname mode chars e.g. ov.
 * **queue:** Number of bytes in the send-queue.  
 * **server:** Server name to which this channel belongs.
 * **users:** Number of users in the channel.
 * **type:** Type of context.
	* 1: Server
	* 2: Channel
	* 3: Dialog

 * **flags:** Bit field of flags:
    * 0: Connected
    * 1: Connecting
    * 2: Away
    * 3: End of MOTD (Login Complete)
    * 4: Has WHOX
    * 5: Has IDMSG
    * 6: Join/Parts hidden
    * 7: Unused
    * 8: Beep on Message
    * 9: Blink Tray
    * 10: Blink Task Bar


##### dcc

The dcc list type gives you access to a list of DCC file transfers. The
following attributes are available in each list item:

 * **address32:** Address of the remote user (ipv4 address, as an int).
 * **cps:** Bytes per second (speed).
 * **destfile:** Destination full pathname.
 * **file:** Filename.
 * **nick:** Nickname of person who the file is from/to.
 * **port:** TCP port number.
 * **pos:** Bytes sent/received.
 * **resume:** Point at which this file was resumed (or zero if it was not resumed).
 * **size:** File size in bytes.
 * **status:** DCC status:
	* 0: queued
	* 1: active
	* 2: failed
	* 3: done
	* 4: connecting
	* 5: aborted
 * **type:** DCC type:
	* 0: send
	* 1: receive
	* 2: chatrecv
	* 3: chatsend


##### users

The users list type gives you access to a list of users in the current
channel. The following attributes are available in each list item:

 * **away:** Away status.
 * **lasttalk:** Last time the user was seen talking.
 * **host:** Host name in the form user@host (or None, if not known).
 * **nick:** Nick name.
 * **prefix:** Prefix character, .e.g: @ or +. Points to a single char.
 * **realname:** Real name.
 * **selected:** Selected status in the userlist.


##### ignore

The ignore list type gives you access to the current ignored list. The
following attributes are available in each list item:

 * **mask:** Ignore mask (for example, "\*!\*@\*.aol.com").
 * **flags:** Bit field of flags:
	* 0: private
	* 1: notice
	* 2: channel
	* 3: ctcp
	* 4: invite
	* 5: unignore
	* 6: nosave
	* 7: dcc


### Hook functions

These functions allow one to hook into HexChat events.


#### Priorities

When a priority keyword parameter is accepted, it means that this
callback may be hooked with five different priorities: PRI\_HIGHEST,
PRI\_HIGH, PRI\_NORM, PRI\_LOW, and PRI\_LOWEST. The usage of these
constants, which are available in the xchat module, will define the
order in which your plugin will be called. Most of the time, you won't
want to change its default value (PRI\_NORM).


#### Parameters word and word_eol

These parameters, when available in a callback, are lists of strings
which contain the parameters the user entered for the particular
command. For example, if you executed:

<pre>
/command NICK Hi there!
</pre>

 * **word[0]** is `command`
 * **word[1]** is `NICK`
 * **word[2]** is `Hi`
 * **word[3]** is `there!`
 * **word\_eol[0]** is `command NICK Hi there!`
 * **word\_eol[1]** is `NICK Hi there!`
 * **word\_eol[2]** is `Hi there!`
 * **word\_eol[3]** is `there!`


#### Parameter userdata

The parameter userdata, if given, allows you to pass a custom object to
your callback.

#### Callback return constants (EAT\_*)

When a callback is supposed to return one of the EAT\_\* macros, it is
able control how HexChat will proceed after the callback returns. These
are the available constants, and their meanings:

 * **EAT_PLUGIN:** Don't let any other plugin receive this event.
 * **EAT_XCHAT:** Don't let HexChat treat this event as usual.
 * **EAT_ALL:** Eat the event completely.
 * **EAT_NONE:** Let everything happen as usual.

Returning `None` is the same as returning `EAT_NONE`.


#### xchat.hook\_command(name, callback, userdata=None, priority=PRI\_NORM, help=None)

This function allows you to hook into the name HexChat command. It means
that everytime you type `/name ...`, `callback` will be called.
Parameters `userdata` and `priority` have their meanings explained
above, and the parameter help, if given, allows you to pass a help text
which will be shown when `/help name` is executed. This function returns
a hook handler which may be used in the `xchat.unhook()` function. For
example:

<pre>
def onotice_cb(word, word_eol, userdata):
    if len(word) < 2:
        print "Second arg must be the message!"
    else:
        xchat.command("NOTICE @%s %s" % (xchat.get_info("channel"), word_eol[1]))
    return xchat.EAT_ALL

xchat.hook_command("ONOTICE", onotice_cb, help="/ONOTICE <message> Sends a notice to all ops")
</pre>

You may return one of `EAT_*` constants in the callback, to control
HexChat's behavior, as explained above.


#### xchat.hook\_print(name, callback, userdata=None, priority=PRI\_NORM)

This function allows you to register a callback to trap any print
events. The event names are available in the _Edit Event Texts_ window.
Parameters `userdata` and `priority` have their meanings explained
above. This function returns a hook handler which may be used in the
`xchat.unhook()` function. For example:

<pre>
def youpart_cb(word, word_eol, userdata):
    print "You have left channel", word[2]
    return xchat.EAT_XCHAT # Don't let HexChat do its normal printing

xchat.hook_print("You Part", youpart_cb)
</pre>

You may return one of `EAT_*` constants in the callback, to control
HexChat's behavior, as explained above.


#### xchat.hook\_server(name, callback, userdata=None, priority=PRI\_NORM)

This function allows you to register a callback to be called when a
certain server event occurs. You can use this to trap `PRIVMSG`,
`NOTICE`, `PART`, a server numeric, etc. Parameters `userdata` and
`priority` have their meanings explained above. This function returns a
hook handler which may be used in the `xchat.unhook()` function. For
example:

<pre>
def kick_cb(word, word_eol, userdata):
    print "%s was kicked from %s (%s)" % (word[3], word[2], word_eol[4])
    # Don't eat this event, let other plugins and HexChat see it too
    return xchat.EAT_NONE

xchat.hook_server("KICK", kick_cb)
</pre>

You may return one of `EAT_*` constants in the callback, to control
HexChat's behavior, as explained above.


#### xchat.hook\_timer(timeout, callback, userdata=None)

This function allows you to register a callback to be called every
timeout milliseconds. Parameters userdata and priority have their
meanings explained above. This function returns a hook handler which may
be used in the `xchat.unhook()` function. For example:

<pre>
myhook = None

def stop_cb(word, word_eol, userdata):
    global myhook
    if myhook is not None:
        xchat.unhook(myhook)
        myhook = None
        print "Timeout removed!"

def timeout_cb(userdata):
    print "Annoying message every 5 seconds! Type /STOP to stop it."
    return 1 # Keep the timeout going

myhook = xchat.hook_timer(5000, timeout_cb)
xchat.hook_command("STOP", stop_cb)
</pre>

If you return a true value from the callback, the timer will be keeped,
otherwise it is removed.


#### xchat.hook\_unload(timeout, callback, userdata=None)

This function allows you to register a callback to be called when the
plugin is going to be unloaded. Parameters `userdata` and `priority`
have their meanings explained above. This function returns a hook
handler which may be used in the `xchat.unhook()` function. For example:

<pre>
def unload_cb(userdata):
    print "We're being unloaded!"

xchat.hook_unload(unload_cb)
</pre>


#### xchat.unhook(handler)

Unhooks any hook registered with the hook functions above.


### Plugin preferences

You can use pluginpref to easily store and retrieve settings. This was added in the Python plugin version 0.9

#### xchat.set\_pluginpref(name, value)

If neccessary creates a .conf file in the HexChat config folder named addon\_python.conf and stores the value in it. Returns 1 on success, 0 on failure.

> Note: Until the plugin uses different a conf file per script it's recommened to use 'PluginName-SettingName' to avoid conflicts.


#### xchat.get\_pluginpref(name)

This will return the value of the variable of that name. If there is none by this name it will return `None`. Numbers are always returned as Integers.


#### xchat.del\_pluginpref(name)

Deletes the specified variable. Returns 1 on success (or never existing), 0 on failure.


#### xchat.list\_pluginpref()

Returns a list of all currently set preferences.


### Context handling

Below you will find information about how to work with contexts.


#### Context objects

As explained in the Context theory session above, contexts give access
to a specific channel/query/server tab of HexChat. Every function
available in the xchat module will be evaluated in the current context,
which will be specified by HexChat itself before passing control to the
module. Sometimes you may want to work in a specific context, and that's
where context objects come into play.

You may create a context object using the `xchat.get_context()` or
`xchat.find_context()`, functions as explained below, or trough the
`xchat.get_list()` function, as explained in its respective session.

Each context object offers the following methods:

 * **context.set():** Changes the current context to be the one represented by this context object.
 * **context.prnt(string):** Does the same as the xchat.prnt() function, but in the given context.
 * **context.emit\_print(event\_name, \*args):** Does the same as the emit\_print() function, but in the given context.
 * **context.command(string):** Does the same as the xchat.command() function, but in the given context.
 * **context.get\_info(type):** Does the same as the xchat.get\_info() function, but in the given context.
 * **context.get\_list(type):** Does the same as the xchat.get\_list() function, but in the given context.


#### xchat.get\_context()

Returns a context object corresponding the the current context.

#### xchat.find\_context(server=None, channel=None)

Finds a context based on a channel and servername. If `server` is
`None`, it finds any channel (or query) by the given name. If `channel`
is `None`, it finds the front-most tab/window of the given server. For
example:

<pre>
cnc = xchat.find_context(channel='#conectiva')
cnc.command('whois niemeyer')
</pre>

***

Original Author: Gustavo Niemeyer [gustavo@niemeyer.net](mailto:gustavo@niemeyer.net)

For purty html: `pandoc --toc python.md -s --highlight-style haddock -o python.html`
g if using tabs on bottom' href='/git-repos/torxchat.git/commit/xchat-wdk.patch?id=ed217600232f3cf93efe1d93da0eb70068195831'>ed217600 ^
41066d08 ^
ed217600 ^
41066d08 ^


ed217600 ^
41066d08 ^



7984e546 ^

















41066d08 ^
2d4f9e33 ^










41066d08 ^
2d4f9e33 ^










ec117f17 ^
a9eb880e ^
f09eb322 ^
ff21b26a ^
7586119d






ec117f17 ^
a9eb880e ^
f09eb322 ^
ff21b26a ^
7586119d






ec117f17 ^
a9eb880e ^
c5a9da75 ^
cbcf58ab ^
7586119d



cbcf58ab ^
c5a9da75 ^
7586119d

cbcf58ab ^
7c13de9b ^












12f39a6d ^








7c13de9b ^









































































cbcf58ab ^
a9eb880e ^
c5a9da75 ^
cbcf58ab ^




c5a9da75 ^
cbcf58ab ^


3c21396a ^





e6067fb6 ^

3c21396a ^


ec117f17 ^
a9eb880e ^
f09eb322 ^
ff21b26a ^
7586119d






6e62006b ^
a9eb880e ^
f09eb322 ^
6e62006b ^








3ca6f5dd ^
a9eb880e ^
f09eb322 ^
b6b615de ^
7d954d3a ^







00039714 ^
a9eb880e ^
c5a9da75 ^
de264bba ^
af90df9f ^







de264bba ^

af90df9f ^
de264bba ^





f6a56f78 ^
00039714 ^






f6a56f78 ^
00039714 ^






f6a56f78 ^
fe319dfe ^







f6a56f78 ^
fe319dfe ^






ec117f17 ^
a9eb880e ^
f09eb322 ^
11a9adb1 ^
7586119d


11a9adb1 ^
7586119d



11a9adb1 ^
17a432a6 ^



21c22c2b ^
17a432a6 ^








ec117f17 ^
a9eb880e ^
f09eb322 ^
7586119d







f14741dc ^








e0b7f000 ^
a9eb880e ^
f09eb322 ^
e0b7f000 ^










































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
                                                                                              
                                                                 
                                                                 
                   



                       


                    

                     
                     


















                                                                                                   
                                                                                   
                                                                                                                                                     
                                                                                                

                                                                                                                              
                                                                                                                            

                                 
                                                                                                      
                                                                         
                                                                 
                   
 










                                     
                 



                                                                 
                                                            


                      
                      


























                                                                                                           
                     







                                                                  
                                                                                                      
                                                                         
                                                                 








                                                                








                                                                                                                                                                                                         
                                                                                              
                                                                 
                                                                 












                                                   
                                                                                                  
                                                                         
                                                                 







                    


                  
                    
                      
 



                             

                            

                               


                     


                                     
                                              













                                                                                                 


                       








                                                                                  















                                                                  
                                                            


                                                                  








                                                                      








                                                
                   


                                  
                             


                                   
                                                                                                
                                                                 
                                                                 







                       
                                                                                          
                                                                 
                                                         







                    
                   



                                                                                        
                                                                                              


                                                         
                                                                                        
                                                                 
                                                         







                      








                                              
                            

                                                                
             
                                                               

              

                                                                                            
                             
                                                                                              
                                                                 
                                                                 







                       
                                                                                                
                                                                 
                                                                 







                       
                                                                                          
                                                                 
                                                         










                                   
                                                                                                
                                                                 
                                                                 







                    
                                                                                                
                                                                 
                                                                 







                                                                                                 
                                                                                              
                                                                 
                                                                 







                       
                                                                                                  
                                                                         
                                                                 







                      
                                                                                                          
                                                                         
                                                                 




                          
                                        



                                                                                              
                                                                 
                                                                 




                                      
                                        


                    








                                                                                                            
                                                                                                    
                                                                         
                                                                 







                                                                     
                                                                                              
                                                                 
                                                                 







                    


































                                                                                    

                                                           
  

                                                                     
                                              
      
                                             



                                                                           
                     
         




                                                                                        

  
                                                                                                  
                                                                         
                                                                 







                        
                                                                                        
                                                                 
                                                         
                   


                                                                             
                                                                                                  


                                                                         





                                                                                
                                                                                          
                                                                 
                                                         













                        






                                


                                                 

                     

                       




































                                                                          
 

                                    


                                                                                    
                                      


                   
                                                                                          
                                                                 
                                                         

                                                                             

    


                                                                                                
                                       






                             
                 







                         










                                                   










                            





























                                                                                    



                               

                               
                             
                   
 

                                                            
                             

                            
                                    
         

















































                                                                                          
         
 






                                                                                                      

                                                               

                                                                                      
 
                                                                                       


            
                                                       

         

                      
 














                                                                                          
                                                                                            
                                                                 
                                                                 







                       




                          
                                        


                          
                   

                                                             
                                                                



                                                                    
                                                                                            
                                                                 
                                                                 






                            




                              
       


                 
                 







                                                                       
                   



                                 

                               


                                                              
                                                                                            
                                                                 
                                                                 
                 






                                




















                                                             







                                                                                   
                     



                                                                                                           
             
                                                                                           
                                                                                           
       
                                      
                                                              
                                                 
                                                     

                                                         
                                                               

                                                            
                                                                                                


                                                                                                                                                           
                                               



                                                  

                                                                  






                                                                 
                                                                                                                   





                                                                        
                                                         

                                                                
                                               
                                       
               











                                                                      
                                                                                                
                                                                 
                                                                 
                 






                    
                                                                                                  
                                                                         
                                                                 







                    
                                                                                                            
                                                                         
                                                                         





















                                                                                          
                                                                                                  
                                                                         
                                                                 







                       
                                                                                              
                                                                 
                                                                 
                 






                    
                 







                                  
                 






                                








                                                           
                                                                                              
                                                                 
                                                                 

                                                                     


                                                                   



                                 
                                                                                            
                                                                 
                                                                 







                       
                                                                                                
                                                                 
                                                                 







                       
















                                                 



                                           



                                
                     

















                                                                                  
                                                                                                     
                     
         
                                                
         







                                                                                  







                                                                                                 
                       
 
                                   
 










                                                                                                     
 
                                    















































                                                                                                     

                            
 


                                                        
 




                                                                                    
 













                                                                                                     
 





                                                                        
 

                                               
 
                    
  













































                                                                                   
                    













                                                                      




                                                                               
                    
                 
                                              
                 
















                                                                                              


                                                            
                    


                                              










                                                                                              
                                                                                            
                                                                 
                                                                 







                       
                                                                                                
                                                                 
                                                                 
















































































                                                                                               




                                                                                                    
                                                            
                 
                                                                                                    


                    
                                                                                         



                                         

















                                                                            
                      










                                                                                         
                      










                                                                                
                                                                                          
                                                                 
                                                         
                 






                     
                                                                                                
                                                                 
                                                                 
                 






                       
                                                                                                        
                                                                         
                                                                 
               



                                             
                                    
                                        

                              
                               












                                                                                                








                                                                    









































































                                                                                                                             
                                                                                                    
                                                                         
                                                                 




                                      
                                        


                                





                                                                                           

                                                                                                            


            
                                                                                              
                                                                 
                                                                 
                 






                    
                                                                                              
                                                                 
                                                                 








                                                                                              
                                                                                                        
                                                                         
                                                                 
                     







                                                                                      
                                                                                            
                                                                 
                                                                 
                     







                                                                                               

                                                           
                                                            





                                                                           
                   






                                                       
                   






                                          
                     







                                    
                     






                                                                               
                                                                                                                  
                                                                                 
                                                                         
                 


                                  
                     



                                                                         
                     



                                                 
                                                     








                                                              
                                                                                            
                                                                 
                                                                 







                              








                                                                                  
                                                                                                  
                                                                         
                                                                 










































































                                                                                         
diff -ruN --strip-trailing-cr xchat-wdk.orig/plugins/perl/perl.c xchat-wdk/plugins/perl/perl.c
--- xchat-wdk.orig/plugins/perl/perl.c	2010-08-26 04:18:04 +0200
+++ xchat-wdk/plugins/perl/perl.c	2010-10-09 12:53:27 +0200
@@ -22,12 +22,15 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
-#include <dirent.h>
 #ifdef ENABLE_NLS
 #include <locale.h>
 #endif
 #ifdef WIN32
 #include <windows.h>
+#define  _INC_DIRENT
+#include "../../src/common/dirent.h"
+#else
+#include <dirent.h>
 #endif
 
 #undef PACKAGE
@@ -1339,7 +1342,11 @@
 			if (GetLastError () == ERROR_BAD_EXE_FORMAT)
 				/* http://forum.xchat.org/viewtopic.php?t=3277 */
 				thread_mbox ("Cannot use this " PERL_DLL "\n\n"
+#ifdef _WIN64
+								 "64-bit ActivePerl is required.");
+#else
 								 "32-bit ActivePerl is required.");
+#endif
 			else {
 				/* a lot of people install this old version */
 				lib = LoadLibraryA ("perl56.dll");
@@ -1354,7 +1361,7 @@
 					thread_mbox ("Cannot open " PERL_DLL "\n\n"
 									 "You must have ActivePerl " PERL_REQUIRED_VERSION " installed in order to\n"
 									 "run perl scripts.\n\n"
-									 "http://www.activestate.com/ActivePerl/\n\n"
+									 "http://www.activestate.com/activeperl/downloads\n\n"
 									 "Make sure perl's bin directory is in your PATH.");
 				}
 			}
diff -ruN --strip-trailing-cr xchat-wdk.orig/plugins/python/python.c xchat-wdk/plugins/python/python.c
--- xchat-wdk.orig/plugins/python/python.c	2010-05-16 06:31:54 +0200
+++ xchat-wdk/plugins/python/python.c	2010-10-09 12:53:27 +0200
@@ -53,10 +53,10 @@
 
 #include <glib.h>
 #include <string.h>
-#include <unistd.h>
 #include <stdlib.h>
 #include <sys/types.h>
-#include <dirent.h>
+#include "../../src/common/dirent.h"
+#include "../../config.h"
 
 #include "xchat-plugin.h"
 #include "Python.h"
@@ -68,7 +68,7 @@
 
 #ifdef WIN32
 #undef WITH_THREAD /* Thread support locks up xchat on Win32. */
-#define VERSION "0.8/2.4"	/* Linked to python24.dll */
+#define VERSION "0.8/2.6"	/* Linked to python26.dll */
 #else
 #define VERSION "0.8"
 #endif
@@ -1161,6 +1161,27 @@
 	PyObject_SetAttrString(m, "__version__", o);
 
 	if (filename) {
+#ifdef WIN32
+		/*	more info: 
+		 *	http://bytes.com/topic/python/answers/840542-pyrun_simplefile-crashes#post3364174
+		 *	http://effbot.org/pyfaq/pyrun-simplefile-crashes-on-windows-but-not-on-unix-why.htm
+		 */
+		PyObject* PyFileObject = PyFile_FromString(filename, "r");
+		if (PyFileObject == NULL) {
+			xchat_printf(ph, "Can't open file %s: %s\n",
+				     filename, strerror(errno));
+			goto error;
+		}
+
+		if (PyRun_SimpleFile(PyFile_AsFile(PyFileObject), filename) != 0) {
+			xchat_printf(ph, "Error loading module %s\n",
+				     filename);
+			goto error;
+		}
+
+		plugin->filename = filename;
+		filename = NULL;
+#else
 		FILE *fp;
 
 		plugin->filename = filename;
@@ -1184,7 +1205,7 @@
 			goto error;
 		}
 		fclose(fp);
-
+#endif
 		m = PyDict_GetItemString(PyImport_GetModuleDict(),
 					 "__main__");
 		if (m == NULL) {
diff -ruN --strip-trailing-cr xchat-wdk.orig/plugins/tcl/tclplugin.c xchat-wdk/plugins/tcl/tclplugin.c
--- xchat-wdk.orig/plugins/tcl/tclplugin.c	2010-03-21 01:49:42 +0100
+++ xchat-wdk/plugins/tcl/tclplugin.c	2010-10-09 12:53:27 +0200
@@ -32,8 +32,6 @@
 #include <windows.h>
 #define bzero(mem, sz) memset((mem), 0, (sz))
 #define bcopy(src, dest, count) memmove((dest), (src), (count))
-#else
-#include <unistd.h>
 #endif
 
 #include "xchat-plugin.h"
@@ -2221,7 +2219,7 @@
 #ifdef WIN32
     lib = LoadLibraryA(TCL_DLL);
     if (!lib) {
-        xchat_print(ph, "You must have ActiveTCL installed in order to run Tcl scripts.\n" "http://aspn.activestate.com/ASPN/Tcl/\n" "Make sure Tcl's bin directory is in your PATH.\n\n");
+        xchat_print(ph, "You must have ActiveTCL 8.5 installed in order to run Tcl scripts.\n" "http://www.activestate.com/activetcl/downloads\n" "Make sure Tcl's bin directory is in your PATH.\n\n");
         return 0;
     }
     FreeLibrary(lib);
diff -ruN --strip-trailing-cr xchat-wdk.orig/plugins/xdcc/xdcc.c xchat-wdk/plugins/xdcc/xdcc.c
--- xchat-wdk.orig/plugins/xdcc/xdcc.c	2002-12-26 04:35:09 +0100
+++ xchat-wdk/plugins/xdcc/xdcc.c	2010-10-09 12:53:27 +0200
@@ -2,11 +2,11 @@
 
 #include <glib.h>
 #include <string.h>
-#include <unistd.h>
 #include <stdlib.h>
 #include <stdio.h>
 
 #include "xchat-plugin.h"
+#include "../../src/common/xchat.h"
 
 static xchat_plugin *ph;	/* plugin handle */
 
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/common/cfgfiles.c xchat-wdk/src/common/cfgfiles.c
--- xchat-wdk.orig/src/common/cfgfiles.c	2010-08-07 09:14:45 +0200
+++ xchat-wdk/src/common/cfgfiles.c	2010-10-09 12:53:27 +0200
@@ -17,7 +17,6 @@
  */
 
 #include <fcntl.h>
-#include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
@@ -30,10 +29,9 @@
 #include "fe.h"
 #include "text.h"
 #include "xchatc.h"
+#include "portable.h"
 
-#ifdef WIN32
-#define XCHAT_DIR "X-Chat 2"
-#else
+#ifndef WIN32
 #define XCHAT_DIR ".xchat2"
 #endif
 #define DEF_FONT "Monospace 9"
@@ -308,12 +306,19 @@
 {
 	if (!xdir_fs)
 	{
-		char out[256];
+		if (portable_mode ())
+		{
+			xdir_fs = ".\\config";
+		}
+		else
+		{
+			char out[256];
 
-		if (!get_reg_str ("Software\\Microsoft\\Windows\\CurrentVersion\\"
-				"Explorer\\Shell Folders", "AppData", out, sizeof (out)))
-			return "./config";
-		xdir_fs = g_strdup_printf ("%s\\" XCHAT_DIR, out);
+			if (!get_reg_str ("Software\\Microsoft\\Windows\\CurrentVersion\\"
+					"Explorer\\Shell Folders", "AppData", out, sizeof (out)))
+				return "./config";
+			xdir_fs = g_strdup_printf ("%s\\" "X-Chat 2", out);
+		}
 	}
 	return xdir_fs;
 }
@@ -393,7 +398,7 @@
 	{"dcc_blocksize", P_OFFINT (dcc_blocksize), TYPE_INT},
 	{"dcc_completed_dir", P_OFFSET (dcc_completed_dir), TYPE_STR},
 	{"dcc_dir", P_OFFSET (dccdir), TYPE_STR},
-	{"dcc_fast_send", P_OFFINT (fastdccsend), TYPE_BOOL},
+	/* {"dcc_fast_send", P_OFFINT (fastdccsend), TYPE_BOOL}, */
 	{"dcc_global_max_get_cps", P_OFFINT (dcc_global_max_get_cps), TYPE_INT},
 	{"dcc_global_max_send_cps", P_OFFINT (dcc_global_max_send_cps), TYPE_INT},
 	{"dcc_ip", P_OFFSET (dcc_ip_str), TYPE_STR},
@@ -536,6 +541,7 @@
 
 	{"tab_chans", P_OFFINT (tabchannels), TYPE_BOOL},
 	{"tab_dialogs", P_OFFINT (privmsgtab), TYPE_BOOL},
+	{"tab_icons", P_OFFINT (tab_icons), TYPE_BOOL},
 	{"tab_layout", P_OFFINT (tab_layout), TYPE_INT},
 	{"tab_new_to_front", P_OFFINT (newtabstofront), TYPE_INT},
 	{"tab_notices", P_OFFINT (notices_tabs), TYPE_BOOL},
@@ -546,9 +552,11 @@
 	{"tab_sort", P_OFFINT (tab_sort), TYPE_BOOL},
 	{"tab_trunc", P_OFFINT (truncchans), TYPE_INT},
 	{"tab_utils", P_OFFINT (windows_as_tabs), TYPE_BOOL},
+	{"tab_xp", P_OFFINT (tab_xp), TYPE_BOOL},
 
 	{"text_background", P_OFFSET (background), TYPE_STR},
 	{"text_color_nicks", P_OFFINT (colorednicks), TYPE_BOOL},
+	{"text_emoticons", P_OFFINT (emoticons), TYPE_BOOL},
 	{"text_font", P_OFFSET (font_normal), TYPE_STR},
 	{"text_indent", P_OFFINT (indent_nicks), TYPE_BOOL},
 	{"text_max_indent", P_OFFINT (max_auto_indent), TYPE_INT},
@@ -561,7 +569,7 @@
 	{"text_tint_blue", P_OFFINT (tint_blue), TYPE_INT},
 	{"text_tint_green", P_OFFINT (tint_green), TYPE_INT},
 	{"text_tint_red", P_OFFINT (tint_red), TYPE_INT},
-	{"text_transparent", P_OFFINT (transparent), TYPE_BOOL},
+	/* {"text_transparent", P_OFFINT (transparent), TYPE_BOOL}, */
 	{"text_wordwrap", P_OFFINT (wordwrap), TYPE_BOOL},
 
 	{0, 0, 0},
@@ -624,7 +632,7 @@
 	prefs.indent_nicks = 1;
 	prefs.thin_separator = 1;
 	prefs._tabs_position = 2; /* 2 = left */
-	prefs.fastdccsend = 1;
+	/* prefs.fastdccsend = 1; */
 	prefs.wordwrap = 1;
 	prefs.autosave = 1;
 	prefs.autodialog = 1;
@@ -648,6 +656,7 @@
 	prefs.dialog_height = 256;
 	prefs.gui_join_dialog = 1;
 	prefs.gui_quit_dialog = 1;
+	prefs.slist_skip = 1;
 	prefs.dcctimeout = 180;
 	prefs.dccstalltimeout = 60;
 	prefs.notify_timeout = 15;
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/common/chanopt.c xchat-wdk/src/common/chanopt.c
--- xchat-wdk.orig/src/common/chanopt.c	2008-06-15 06:40:29 +0200
+++ xchat-wdk/src/common/chanopt.c	2010-10-09 12:53:27 +0200
@@ -3,7 +3,6 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/common/ctcp.c xchat-wdk/src/common/ctcp.c
--- xchat-wdk.orig/src/common/ctcp.c	2010-05-30 04:28:04 +0200
+++ xchat-wdk/src/common/ctcp.c	2010-10-09 12:53:27 +0200
@@ -18,7 +18,6 @@
 
 #include <stdio.h>
 #include <string.h>
-#include <unistd.h>
 #include <stdlib.h>
 
 #include "xchat.h"
@@ -134,7 +133,7 @@
 
 	if (!strcasecmp (msg, "VERSION") && !prefs.hidever)
 	{
-		snprintf (outbuf, sizeof (outbuf), "VERSION xchat "PACKAGE_VERSION" %s",
+		snprintf (outbuf, sizeof (outbuf), "VERSION XChat-WDK "PACKAGE_VERSION" / %s",
 					 get_cpu_str ());
 		serv->p_nctcp (serv, nick, outbuf);
 	}
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/common/dcc.c xchat-wdk/src/common/dcc.c
--- xchat-wdk.orig/src/common/dcc.c	2010-05-30 04:28:04 +0200
+++ xchat-wdk/src/common/dcc.c	2010-10-09 12:53:27 +0200
@@ -31,7 +31,6 @@
 #include <time.h>
 #include <errno.h>
 #include <sys/stat.h>
-#include <unistd.h>
 #include <fcntl.h>
 
 #define WANTSOCKET
@@ -57,6 +56,7 @@
 
 #ifdef USE_DCC64
 #define BIG_STR_TO_INT(x) strtoull(x,NULL,10)
+#define stat _stat64
 #else
 #define BIG_STR_TO_INT(x) strtoul(x,NULL,10)
 #endif
@@ -1983,9 +1983,7 @@
 		return TRUE;
 
 	/* now handle case-insensitive Filesystems: HFS+, FAT */
-#ifdef WIN32
-#warning no win32 implementation - behaviour may be unreliable
-#else
+#ifndef WIN32
 	/* this fstat() shouldn't really fail */
 	if ((dcc->fp == -1 ? stat (dcc->destfile_fs, &st_a) : fstat (dcc->fp, &st_a)) == -1)
 		return FALSE;
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/common/ignore.c xchat-wdk/src/common/ignore.c
--- xchat-wdk.orig/src/common/ignore.c	2006-04-15 09:00:39 +0200
+++ xchat-wdk/src/common/ignore.c	2010-10-09 12:53:27 +0200
@@ -19,7 +19,6 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-#include <unistd.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/common/inbound.c xchat-wdk/src/common/inbound.c
--- xchat-wdk.orig/src/common/inbound.c	2010-05-30 04:28:04 +0200
+++ xchat-wdk/src/common/inbound.c	2010-10-09 12:53:27 +0200
@@ -21,7 +21,6 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <sys/types.h>
-#include <unistd.h>
 #include <time.h>
 
 #define WANTARPA
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/common/inet.h xchat-wdk/src/common/inet.h
--- xchat-wdk.orig/src/common/inet.h	2005-09-03 12:57:48 +0200
+++ xchat-wdk/src/common/inet.h	2010-10-09 12:53:27 +0200
@@ -24,9 +24,8 @@
 #ifdef USE_IPV6
 #include <winsock2.h>
 #include <ws2tcpip.h>
-#include <tpipv6.h>
 #else
-#include <winsock.h>
+#include <winsock2.h>
 #endif
 
 #define set_blocking(sok)	{ \
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/common/msproxy.c xchat-wdk/src/common/msproxy.c
--- xchat-wdk.orig/src/common/msproxy.c	2006-04-16 17:32:17 +0200
+++ xchat-wdk/src/common/msproxy.c	2010-10-09 12:53:27 +0200
@@ -26,7 +26,6 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <fcntl.h>
 
 #define WANTSOCKET
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/common/network.c xchat-wdk/src/common/network.c
--- xchat-wdk.orig/src/common/network.c	2006-04-16 10:11:26 +0200
+++ xchat-wdk/src/common/network.c	2010-10-09 12:53:27 +0200
@@ -21,7 +21,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
-#include <unistd.h>
 #include <glib.h>
 
 #include "../../config.h"				  /* grab USE_IPV6 and LOOKUPD defines */
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/common/notify.c xchat-wdk/src/common/notify.c
--- xchat-wdk.orig/src/common/notify.c	2008-06-08 09:58:58 +0200
+++ xchat-wdk/src/common/notify.c	2010-10-09 12:53:27 +0200
@@ -22,7 +22,6 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
-#include <unistd.h>
 #include <time.h>
 
 #include "xchat.h"
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/common/outbound.c xchat-wdk/src/common/outbound.c
--- xchat-wdk.orig/src/common/outbound.c	2010-05-30 04:28:04 +0200
+++ xchat-wdk/src/common/outbound.c	2010-10-09 12:53:27 +0200
@@ -32,7 +32,6 @@
 #include <sys/wait.h>
 #endif
 
-#include <unistd.h>
 #include <time.h>
 #include <signal.h>
 #include <sys/stat.h>
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/common/plugin-timer.c xchat-wdk/src/common/plugin-timer.c
--- xchat-wdk.orig/src/common/plugin-timer.c	2005-02-02 11:03:51 +0100
+++ xchat-wdk/src/common/plugin-timer.c	2010-10-29 19:33:21 +0200
@@ -1,7 +1,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <glib.h>
-#include "xchat-plugin.h"
+#include "../../plugins/xchat-plugin.h"
 
 #ifdef WIN32
 #define strcasecmp stricmp
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/common/plugin.c xchat-wdk/src/common/plugin.c
--- xchat-wdk.orig/src/common/plugin.c	2010-08-14 03:46:21 +0200
+++ xchat-wdk/src/common/plugin.c	2010-10-29 19:32:39 +0200
@@ -34,7 +34,7 @@
 #include "text.h"
 #define PLUGIN_C
 typedef struct session xchat_context;
-#include "xchat-plugin.h"
+#include "../../plugins/xchat-plugin.h"
 #include "plugin.h"
 
 
@@ -1212,7 +1212,7 @@
 	static const char * const dcc_fields[] =
 	{
 		"iaddress32","icps",		"sdestfile","sfile",		"snick",	"iport",
-		"ipos", "iposhigh", "iresume", "iresumehigh" "isize", "isizehigh", "istatus", "itype", NULL
+		"ipos", "iposhigh", "iresume", "iresumehigh", "isize", "isizehigh", "istatus", "itype", NULL
 	};
 	static const char * const channels_fields[] =
 	{
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/common/proto-irc.c xchat-wdk/src/common/proto-irc.c
--- xchat-wdk.orig/src/common/proto-irc.c	2010-05-30 04:28:04 +0200
+++ xchat-wdk/src/common/proto-irc.c	2010-10-09 12:53:27 +0200
@@ -18,7 +18,6 @@
 
 /* IRC RFC1459(+commonly used extensions) protocol implementation */
 
-#include <unistd.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/common/server.c xchat-wdk/src/common/server.c
--- xchat-wdk.orig/src/common/server.c	2010-05-30 04:28:04 +0200
+++ xchat-wdk/src/common/server.c	2010-11-12 07:13:21 +0100
@@ -26,7 +26,6 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <errno.h>
 #include <fcntl.h>
 
@@ -838,33 +837,6 @@
 	fe_set_throttle (serv);
 }
 
-#ifdef WIN32
-
-static int
-waitline2 (GIOChannel *source, char *buf, int bufsize)
-{
-	int i = 0;
-	int len;
-
-	while (1)
-	{
-		if (g_io_channel_read (source, &buf[i], 1, &len) != G_IO_ERROR_NONE)
-			return -1;
-		if (buf[i] == '\n' || bufsize == i + 1)
-		{
-			buf[i] = 0;
-			return i;
-		}
-		i++;
-	}
-}
-
-#else
-
-#define waitline2(source,buf,size) waitline(serv->childread,buf,size,0)
-
-#endif
-
 /* connect() successed */
 
 static void
@@ -1388,12 +1360,7 @@
 static int
 http_read_line (int print_fd, int sok, char *buf, int len)
 {
-#ifdef WIN32
-	/* make sure waitline() uses recv() or it'll fail on win32 */
-	len = waitline (sok, buf, len, FALSE);
-#else
 	len = waitline (sok, buf, len, TRUE);
-#endif
 	if (len >= 1)
 	{
 		/* print the message out (send it to the parent process) */
@@ -1738,7 +1705,7 @@
 	}
 #endif
 	serv->childpid = pid;
-	serv->iotag = fe_input_add (serv->childread, FIA_READ, server_read_child,
+	serv->iotag = fe_input_add (serv->childread, FIA_READ|FIA_FD, server_read_child,
 										 serv);
 }
 
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/common/servlist.c xchat-wdk/src/common/servlist.c
--- xchat-wdk.orig/src/common/servlist.c	2010-05-16 09:43:49 +0200
+++ xchat-wdk/src/common/servlist.c	2010-10-09 12:53:27 +0200
@@ -21,7 +21,6 @@
 #include <string.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <unistd.h>
 
 #include "xchat.h"
 #include <glib/ghash.h>
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/common/ssl.c xchat-wdk/src/common/ssl.c
--- xchat-wdk.orig/src/common/ssl.c	2007-03-28 10:35:06 +0200
+++ xchat-wdk/src/common/ssl.c	2010-10-09 12:53:27 +0200
@@ -17,12 +17,12 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  */
 
+#include "inet.h"				  /* make it first to avoid macro redefinitions */
 #include <openssl/ssl.h>		  /* SSL_() */
 #include <openssl/err.h>		  /* ERR_() */
 #include <time.h>					  /* asctime() */
 #include <string.h>				  /* strncpy() */
 #include "ssl.h"					  /* struct cert_info */
-#include "inet.h"
 #include "../../config.h"		  /* HAVE_SNPRINTF */
 
 #ifndef HAVE_SNPRINTF
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/common/text.c xchat-wdk/src/common/text.c
--- xchat-wdk.orig/src/common/text.c	2010-05-30 04:28:04 +0200
+++ xchat-wdk/src/common/text.c	2010-10-09 12:53:27 +0200
@@ -19,13 +19,11 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-#include <unistd.h>
 #include <ctype.h>
 #include <time.h>
 #include <sys/types.h>
 #include <fcntl.h>
 #include <sys/stat.h>
-#include <sys/mman.h>
 
 #include "xchat.h"
 #include <glib/ghash.h>
@@ -271,9 +269,6 @@
 	char *text;
 	time_t stamp;
 	int lines;
-	char *map, *end_map;
-	struct stat statbuf;
-	const char *begin, *eol;
 
 	if (sess->text_scrollback == SET_DEFAULT)
 	{
@@ -293,32 +288,9 @@
 	if (fh == -1)
 		return;
 
-	if (fstat (fh, &statbuf) < 0)
-		return;
-
-	map = mmap (NULL, statbuf.st_size, PROT_READ, MAP_PRIVATE, fh, 0);
-	if (map == MAP_FAILED)
-		return;
-
-	end_map = map + statbuf.st_size;
-	
 	lines = 0;
-	begin = map;
-	while (begin < end_map)
+	while (waitline (fh, buf, sizeof buf, FALSE) != -1)
 	{
-		int n_bytes;
-
-		eol = memchr (begin, '\n', end_map - begin);
-
-		if (!eol)
-			eol = end_map;
-
-		n_bytes = MIN (eol - begin, sizeof (buf) - 1);
-		
-		strncpy (buf, begin, n_bytes);
-
-		buf[n_bytes] = 0;
-		
 		if (buf[0] == 'T')
 		{
 			if (sizeof (time_t) == 4)
@@ -334,8 +306,6 @@
 			}
 			lines++;
 		}
-
-		begin = eol + 1;
 	}
 
 	sess->scrollwritten = lines;
@@ -349,7 +319,6 @@
 		/*EMIT_SIGNAL (XP_TE_GENMSG, sess, "*", buf, NULL, NULL, NULL, 0);*/
 	}
 
-	munmap (map, statbuf.st_size);
 	close (fh);
 }
 
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/common/util.c xchat-wdk/src/common/util.c
--- xchat-wdk.orig/src/common/util.c	2008-02-07 02:50:37 +0100
+++ xchat-wdk/src/common/util.c	2010-11-12 07:12:28 +0100
@@ -16,11 +16,13 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  */
 
+#define WANTSOCKET
+#include "inet.h"				/* make it first to avoid macro redefinitions */
+
 #define __APPLE_API_STRICT_CONFORMANCE
 
 #define _FILE_OFFSET_BITS 64
 #include <stdio.h>
-#include <unistd.h>
 #include <string.h>
 #include <stdlib.h>
 #include <sys/types.h>
@@ -35,7 +37,7 @@
 #include <sys/utsname.h>
 #endif
 #include <fcntl.h>
-#include <dirent.h>
+#include "dirent.h"
 #include <errno.h>
 #include "xchat.h"
 #include "xchatc.h"
@@ -44,9 +46,6 @@
 #include "util.h"
 #include "../../config.h"
 
-#define WANTSOCKET
-#include "inet.h"
-
 #if defined (USING_FREEBSD) || defined (__APPLE__)
 #include <sys/sysctl.h>
 #endif
@@ -54,9 +53,11 @@
 #include <socks.h>
 #endif
 
+#ifndef ENABLE_NLS
 #ifndef HAVE_SNPRINTF
 #define snprintf g_snprintf
 #endif
+#endif
 
 #ifdef USE_DEBUG
 
@@ -383,6 +384,28 @@
 	}
 }
 
+#ifdef WIN32
+/* waitline2 using win32 file descriptor and glib instead of _read */
+int
+waitline2 (GIOChannel *source, char *buf, int bufsize)
+{
+	int i = 0;
+	int len;
+
+	while (1)
+	{
+		if (g_io_channel_read (source, &buf[i], 1, &len) != G_IO_ERROR_NONE)
+			return -1;
+		if (buf[i] == '\n' || bufsize == i + 1)
+		{
+			buf[i] = 0;
+			return i;
+		}
+		i++;
+	}
+}
+#endif
+
 /* checks for "~" in a file and expands */
 
 char *
@@ -628,26 +651,79 @@
 get_cpu_str (void)
 {
 	static char verbuf[64];
-	OSVERSIONINFO osvi;
-	SYSTEM_INFO si;
+	static char winver[20];
+	OSVERSIONINFOEX osvi;
 	double mhz;
 
-	osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
+	osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX);
 	GetVersionEx (&osvi);
-	GetSystemInfo (&si);
+
+	switch (osvi.dwMajorVersion)
+	{
+		case 5:
+			switch (osvi.dwMinorVersion)
+			{
+				case 1:
+					strcpy (winver, "XP");
+					break;
+				case 2:
+					if (osvi.wProductType == VER_NT_WORKSTATION)
+					{
+						strcpy (winver, "XP x64 Edition");
+					}
+					else
+					{
+						if (GetSystemMetrics(SM_SERVERR2) == 0)
+						{
+							strcpy (winver, "Server 2003");
+						}
+						else
+						{
+							strcpy (winver, "Server 2003 R2");
+						}
+					}
+					break;
+			}
+			break;
+		case 6:
+			switch (osvi.dwMinorVersion)
+			{
+				case 0:
+					if (osvi.wProductType == VER_NT_WORKSTATION)
+					{
+						strcpy (winver, "Vista");
+					}
+					else
+					{
+						strcpy (winver, "Server 2008");
+					}
+					break;
+				case 1:
+					if (osvi.wProductType == VER_NT_WORKSTATION)
+					{
+						strcpy (winver, "7");
+					}
+					else
+					{
+						strcpy (winver, "Server 2008 R2");
+					}
+					break;
+			}
+			break;
+	}
 
 	mhz = get_mhz ();
 	if (mhz)
 	{
 		double cpuspeed = ( mhz > 1000 ) ? mhz / 1000 : mhz;
 		const char *cpuspeedstr = ( mhz > 1000 ) ? "GHz" : "MHz";
-		sprintf (verbuf, "Windows %ld.%ld [i%d86/%.2f%s]",
-					osvi.dwMajorVersion, osvi.dwMinorVersion, si.wProcessorLevel, 
-					cpuspeed, cpuspeedstr);
-	} else
-		sprintf (verbuf, "Windows %ld.%ld [i%d86]",
-			osvi.dwMajorVersion, osvi.dwMinorVersion, si.wProcessorLevel);
-
+		sprintf (verbuf, "Windows %s [%.2f%s]",	winver, cpuspeed, cpuspeedstr);
+	}
+	else
+	{
+		sprintf (verbuf, "Windows %s", winver);
+	}
+	
 	return verbuf;
 }
 
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/common/util.h xchat-wdk/src/common/util.h
--- xchat-wdk.orig/src/common/util.h	2008-02-07 02:50:37 +0100
+++ xchat-wdk/src/common/util.h	2010-11-12 07:13:10 +0100
@@ -43,6 +43,11 @@
 int strip_hidden_attribute (char *src, char *dst);
 char *errorstring (int err);
 int waitline (int sok, char *buf, int bufsize, int);
+#ifdef WIN32
+int waitline2 (GIOChannel *source, char *buf, int bufsize);
+#else
+#define waitline2(source,buf,size) waitline(serv->childread,buf,size,0)
+#endif
 unsigned long make_ping_time (void);
 void move_file_utf8 (char *src_dir, char *dst_dir, char *fname, int dccpermissions);
 int mkdir_utf8 (char *dir);
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/common/xchat.c xchat-wdk/src/common/xchat.c
--- xchat-wdk.orig/src/common/xchat.c	2008-06-08 09:58:58 +0200
+++ xchat-wdk/src/common/xchat.c	2010-10-29 19:33:53 +0200
@@ -22,7 +22,6 @@
 #include <time.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <unistd.h>
 
 #define WANTSOCKET
 #include "inet.h"
@@ -38,7 +37,7 @@
 #include "cfgfiles.h"
 #include "chanopt.h"
 #include "ignore.h"
-#include "xchat-plugin.h"
+#include "../../plugins/xchat-plugin.h"
 #include "plugin.h"
 #include "plugin-timer.h"
 #include "notify.h"
@@ -583,6 +582,7 @@
 	"NAME DMSG\n"			"CMD msg =%2 &3\n\n"\
 	"NAME EXIT\n"			"CMD quit\n\n"\
 	"NAME GREP\n"			"CMD lastlog -r &2\n\n"\
+	"NAME IGNALL\n"			"CMD ignore %2!*@* ALL\n\n"\
 	"NAME J\n"				"CMD join &2\n\n"\
 	"NAME KILL\n"			"CMD quote KILL %2 :&3\n\n"\
 	"NAME LEAVE\n"			"CMD part &2\n\n"\
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/common/xchat.h xchat-wdk/src/common/xchat.h
--- xchat-wdk.orig/src/common/xchat.h	2010-08-07 09:14:45 +0200
+++ xchat-wdk/src/common/xchat.h	2010-10-09 12:53:27 +0200
@@ -12,12 +12,14 @@
 
 #include "history.h"
 
+#ifndef ENABLE_NLS
 #ifndef HAVE_SNPRINTF
 #define snprintf g_snprintf
 #endif
 
 #ifndef HAVE_VSNPRINTF
-#define vsnprintf g_vsnprintf
+#define vsnprintf _vsnprintf
+#endif
 #endif
 
 #ifdef USE_DEBUG
@@ -58,7 +60,7 @@
 
 #ifdef WIN32						/* for win32 */
 #define OFLAGS O_BINARY
-#define sleep(t) _sleep(t*1000)
+#define sleep(t) Sleep(t*1000)
 #include <direct.h>
 #define	F_OK	0
 #define	X_OK	1
@@ -297,6 +299,9 @@
 	unsigned int confmode;
 	unsigned int utf8_locale;
 	unsigned int identd;
+	unsigned int emoticons;
+	unsigned int tab_icons;
+	unsigned int tab_xp;
 
 	unsigned int ctcp_number_limit;	/*flood */
 	unsigned int ctcp_time_limit;	/*seconds of floods */
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/fe-gtk/about.c xchat-wdk/src/fe-gtk/about.c
--- xchat-wdk.orig/src/fe-gtk/about.c	2010-05-16 09:43:49 +0200
+++ xchat-wdk/src/fe-gtk/about.c	2010-10-20 21:35:47 +0200
@@ -39,6 +39,7 @@
 
 #include "../common/xchat.h"
 #include "../common/util.h"
+#include "../common/portable.h"
 #include "palette.h"
 #include "pixmaps.h"
 #include "gtkutil.h"
@@ -87,6 +88,19 @@
 	char buf[512];
 	const char *locale = NULL;
 	extern GtkWindow *parent_window;      /* maingui.c */
+	SYSTEM_INFO si;
+	unsigned short int cpu_arch;
+
+	GetSystemInfo (&si);
+
+	if (si.wProcessorArchitecture == 9)
+	{
+		cpu_arch = 64;
+	}
+	else
+	{
+		cpu_arch = 86;
+	}
 
 	if (about)
 	{
@@ -95,7 +109,7 @@
 	}
 
 	about = gtk_dialog_new ();
-	gtk_window_set_position (GTK_WINDOW (about), GTK_WIN_POS_CENTER);
+	gtk_window_set_position (GTK_WINDOW (about), GTK_WIN_POS_CENTER_ON_PARENT);
 	gtk_window_set_resizable (GTK_WINDOW (about), FALSE);
 	gtk_window_set_title (GTK_WINDOW (about), _("About "DISPLAY_NAME));
 	if (parent_window)
@@ -114,35 +128,42 @@
 	g_get_charset (&locale);
 	(snprintf) (buf, sizeof (buf),
 				"<span size=\"x-large\"><b>"DISPLAY_NAME" "PACKAGE_VERSION"</b></span>\n\n"
-				"%s\n\n"
 #ifdef WIN32
-				/* leave this message to avoid time wasting bug reports! */
-				"This version is unofficial and comes with no support.\n\n"
-#endif
-				"%s\n"
+				"<b>XChat Base</b>: 2.8.8\n\n"
+				"<b>OS</b>: %s\n"
 				"<b>Charset</b>: %s "
-#ifdef WIN32 
 				"<b>GTK+</b>: %i.%i.%i\n"
+				"<b>Compiled</b>: "__DATE__"\n"
+				"<b>Portable Mode</b>: %s\n"
+				"<b>Build Type</b>: x%d\n\n"
+				"<small>This version is unofficial and comes with no support.\n"
+				"\302\251 1998-2010 Peter \305\275elezn\303\275 &lt;zed@xchat.org>"
+				/* "\n<a href=\"http://code.google.com/p/xchat-wdk/\">http://code.google.com/p/xchat-wdk/</a>" this is broken in gtk ATM */
+				"</small>",
+				get_cpu_str (),
+				locale,
+				gtk_major_version,
+				gtk_minor_version,
+				gtk_micro_version,
+				(portable_mode () ? "Yes" : "No"),
+				cpu_arch
 #else
+				"%s\n\n"
+				"%s\n"
+				"<b>Charset</b>: %s "
 				"<b>Renderer</b>: %s\n"
-#endif
 				"<b>Compiled</b>: "__DATE__"\n\n"
 				"<small>\302\251 1998-2010 Peter \305\275elezn\303\275 &lt;zed@xchat.org></small>",
-					_("A multiplatform IRC Client"),
-					get_cpu_str(),
-					locale,
-#ifdef WIN32
-					gtk_major_version,
-					gtk_minor_version,
-					gtk_micro_version
-#else
+				_("A multiplatform IRC Client"),
+				get_cpu_str (),
+				locale,
 #ifdef USE_XFT
-					"Xft"
+				"Xft"
 #else
-					"Pango"
+				"Pango"
 #endif
 #endif
-					);
+				);
 	gtk_label_set_markup (GTK_LABEL (label), buf);
 	gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_CENTER);
 
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/fe-gtk/banlist.c xchat-wdk/src/fe-gtk/banlist.c
--- xchat-wdk.orig/src/fe-gtk/banlist.c	2010-05-16 05:20:22 +0200
+++ xchat-wdk/src/fe-gtk/banlist.c	2010-10-09 12:53:27 +0200
@@ -19,7 +19,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 #include <fcntl.h>
 #include <time.h>
 
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/fe-gtk/chanlist.c xchat-wdk/src/fe-gtk/chanlist.c
--- xchat-wdk.orig/src/fe-gtk/chanlist.c	2008-02-24 04:46:02 +0100
+++ xchat-wdk/src/fe-gtk/chanlist.c	2010-10-09 12:53:27 +0200
@@ -19,7 +19,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 #include <fcntl.h>
 #include <time.h>
 
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/fe-gtk/chanview-tabs.c xchat-wdk/src/fe-gtk/chanview-tabs.c
--- xchat-wdk.orig/src/fe-gtk/chanview-tabs.c	2005-11-21 06:25:39 +0100
+++ xchat-wdk/src/fe-gtk/chanview-tabs.c	2010-10-09 12:53:27 +0200
@@ -144,8 +144,8 @@
 		for (i = adj->value; ((i > new_value) && (tab_left_is_moving)); i -= 0.1)
 		{
 			gtk_adjustment_set_value (adj, i);
-			while (g_main_pending ())
-				g_main_iteration (TRUE);
+			while (g_main_context_pending (NULL))
+				g_main_context_iteration (NULL, TRUE);
 		}
 
 		gtk_adjustment_set_value (adj, new_value);
@@ -191,8 +191,8 @@
 		for (i = adj->value; ((i < new_value) && (tab_right_is_moving)); i += 0.1)
 		{
 			gtk_adjustment_set_value (adj, i);
-			while (g_main_pending ())
-				g_main_iteration (TRUE);
+			while (g_main_context_pending (NULL))
+				g_main_context_iteration (NULL, TRUE);
 		}
 
 		gtk_adjustment_set_value (adj, new_value);
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/fe-gtk/editlist.c xchat-wdk/src/fe-gtk/editlist.c
--- xchat-wdk.orig/src/fe-gtk/editlist.c	2006-03-13 09:33:45 +0100
+++ xchat-wdk/src/fe-gtk/editlist.c	2010-10-09 12:53:27 +0200
@@ -19,7 +19,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 #include <fcntl.h>
 #include <sys/types.h>
 #include <sys/stat.h>
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/fe-gtk/fe-gtk.c xchat-wdk/src/fe-gtk/fe-gtk.c
--- xchat-wdk.orig/src/fe-gtk/fe-gtk.c	2010-08-14 03:46:21 +0200
+++ xchat-wdk/src/fe-gtk/fe-gtk.c	2010-10-09 14:32:05 +0200
@@ -19,7 +19,6 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
-#include <unistd.h>
 
 #include "fe-gtk.h"
 
@@ -32,6 +31,8 @@
 #include <gtk/gtkmessagedialog.h>
 #include <gtk/gtkversion.h>
 
+#include <gdk/gdkwin32.h>
+
 #include "../common/xchat.h"
 #include "../common/fe.h"
 #include "../common/util.h"
@@ -39,6 +40,7 @@
 #include "../common/cfgfiles.h"
 #include "../common/xchatc.h"
 #include "../common/plugin.h"
+#include "../common/server.h"
 #include "gtkutil.h"
 #include "maingui.h"
 #include "pixmaps.h"
@@ -330,7 +332,7 @@
 {
 	session *sess;
 
-	if (getenv ("XCHAT_WARNING_IGNORE"))
+	/* if (getenv ("XCHAT_WARNING_IGNORE")) */
 		return;
 
 	sess = find_dialog (serv_list->data, "(warnings)");
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/fe-gtk/fe-gtk.h xchat-wdk/src/fe-gtk/fe-gtk.h
--- xchat-wdk.orig/src/fe-gtk/fe-gtk.h	2010-05-30 08:31:29 +0200
+++ xchat-wdk/src/fe-gtk/fe-gtk.h	2010-10-17 00:26:18 +0200
@@ -4,7 +4,7 @@
 /* If you're compiling this for Windows, your release is un-official
  * and not condoned. Please don't use the XChat name. Make up your
  * own name! */
-#define DISPLAY_NAME "XChat-Unofficial"
+#define DISPLAY_NAME "XChat-WDK"
 #else
 #define DISPLAY_NAME "XChat"
 #endif
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/fe-gtk/fkeys.c xchat-wdk/src/fe-gtk/fkeys.c
--- xchat-wdk.orig/src/fe-gtk/fkeys.c	2008-02-24 06:09:34 +0100
+++ xchat-wdk/src/fe-gtk/fkeys.c	2010-10-09 12:53:27 +0200
@@ -20,7 +20,6 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <unistd.h>
 #include <string.h>
 #include <fcntl.h>
 #include <ctype.h>
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/fe-gtk/gtkutil.c xchat-wdk/src/fe-gtk/gtkutil.c
--- xchat-wdk.orig/src/fe-gtk/gtkutil.c	2009-07-18 14:38:10 +0200
+++ xchat-wdk/src/fe-gtk/gtkutil.c	2010-11-12 07:08:34 +0100
@@ -22,7 +22,6 @@
 #include <stdarg.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <unistd.h>
 #include <fcntl.h>
 #include "fe-gtk.h"
 
@@ -51,6 +50,10 @@
 #include "../common/util.h"
 #include "gtkutil.h"
 #include "pixmaps.h"
+#ifdef WIN32
+#include "../common/fe.h"
+#include "../common/thread.h"
+#endif
 
 /* gtkutil.c, just some gtk wrappers */
 
@@ -63,6 +66,13 @@
 	void *userdata;
 	filereqcallback callback;
 	int flags;		/* FRF_* flags */
+
+#ifdef WIN32
+	int multiple;
+	thread *th;
+	char *title;	/* native locale */
+	char *filter;
+#endif
 };
 
 static char last_dir[256] = "";
@@ -164,6 +174,190 @@
 	}
 }
 
+#ifdef WIN32
+static int
+win32_openfile (char *file_buf, int file_buf_len, char *title_text, char *filter,
+			   int multiple)
+{
+	OPENFILENAME o;
+
+	memset (&o, 0, sizeof (o));
+
+	o.lStructSize = sizeof (o);
+	o.lpstrFilter = filter;
+	o.lpstrFile = file_buf;
+	o.nMaxFile = file_buf_len;
+	o.lpstrTitle = title_text;
+	o.Flags = 0x02000000 | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY |
+				OFN_NOCHANGEDIR | OFN_EXPLORER | OFN_LONGNAMES | OFN_NONETWORKBUTTON;
+	if (multiple)
+	{
+		o.Flags |= OFN_ALLOWMULTISELECT;
+	}
+
+	return GetOpenFileName (&o);
+}
+
+static int
+win32_savefile (char *file_buf, int file_buf_len, char *title_text, char *filter,
+               int multiple)
+{
+	/* we need the filter to get the default filename. it is from fe-gtk.c (fe_confirm);
+	 * but that filter is actually the whole filename, so apply an empty filter and all good.
+	 * in win32_thread2 we copy the filter ( = the filename) after the last dir into our
+	 * LPTSTR file buffer to make it actually work. the docs for this amazingly retard api:
+	 *
+	 * http://msdn.microsoft.com/en-us/library/ms646839%28VS.85%29.aspx
+	 */
+
+	OPENFILENAME o;
+
+	memset (&o, 0, sizeof (o));
+
+	o.lStructSize = sizeof (o);
+	o.lpstrFilter = "All files\0*.*\0\0";
+	o.lpstrFile = file_buf;
+	o.nMaxFile = file_buf_len;
+	o.lpstrTitle = title_text;
+	o.Flags = 0x02000000 | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY |
+				OFN_NOCHANGEDIR | OFN_EXPLORER | OFN_LONGNAMES | OFN_NONETWORKBUTTON;
+	if (multiple)
+	{
+		o.Flags |= OFN_ALLOWMULTISELECT;
+	}
+
+	return GetSaveFileName (&o);
+}
+
+static void *
+win32_thread (struct file_req *freq)
+{
+	char buf[1024 + 32];
+	char file[1024];
+
+	memset (file, 0, sizeof (file));
+	safe_strcpy (file, last_dir, sizeof (file));
+
+	if (win32_openfile (file, sizeof (file), freq->title, freq->filter, freq->multiple))
+	{
+		if (freq->multiple)
+		{
+			char *f = file;
+
+			if (f[strlen (f) + 1] == 0)	/* only selected one file */
+			{
+				snprintf (buf, sizeof (buf), "1\n%s\n", file);
+				write (freq->th->pipe_fd[1], buf, strlen (buf));
+			} else
+			{
+				f += strlen (f) + 1; /* skip first, it's only the dir */
+				while (f[0])
+				{
+					snprintf (buf, sizeof (buf), "1\n%s\\%s\n", /*dir!*/file, f);
+					write (freq->th->pipe_fd[1], buf, strlen (buf));
+					f += strlen (f) + 1;
+				}
+			}
+
+		} else
+		{
+			snprintf (buf, sizeof (buf), "1\n%s\n", file);
+			write (freq->th->pipe_fd[1], buf, strlen (buf));
+		}
+	}
+
+	write (freq->th->pipe_fd[1], "0\n", 2);
+	Sleep (2000);
+
+	return NULL;
+}
+
+static void *
+win32_thread2 (struct file_req *freq)
+{
+	char buf[1024 + 32];
+	char file[1024];
+
+	memset (file, 0, sizeof (file));
+	safe_strcpy (file, last_dir, sizeof (file));
+	safe_strcpy (file, freq->filter, sizeof (file));
+
+	if (win32_savefile (file, sizeof (file), freq->title, NULL, freq->multiple))
+	{
+		if (freq->multiple)
+		{
+			char *f = file;
+
+			if (f[strlen (f) + 1] == 0)    /* only selected one file */
+			{
+				snprintf (buf, sizeof (buf), "1\n%s\n", file);
+				write (freq->th->pipe_fd[1], buf, strlen (buf));
+			} else
+			{
+				f += strlen (f) + 1; /* skip first, it's only the dir */
+				while (f[0])
+				{
+					snprintf (buf, sizeof (buf), "1\n%s\\%s\n", /*dir!*/file, f);
+					write (freq->th->pipe_fd[1], buf, strlen (buf));
+					f += strlen (f) + 1;
+				}
+			}
+
+		} else
+		{
+			snprintf (buf, sizeof (buf), "1\n%s\n", file);
+			write (freq->th->pipe_fd[1], buf, strlen (buf));
+		}
+	}
+
+	write (freq->th->pipe_fd[1], "0\n", 2);
+	Sleep (2000);
+
+	return NULL;
+}
+
+static gboolean
+win32_close_pipe (int fd)
+{
+	close (fd);
+	return 0;
+}
+
+static gboolean
+win32_read_thread (GIOChannel *source, GIOCondition cond, struct file_req *freq)
+{
+	char buf[512];
+	char *file;
+
+	waitline2 (source, buf, sizeof buf);
+
+	switch (buf[0])
+	{
+	case '0':	/* filedialog has closed */
+		freq->callback (freq->userdata, NULL);
+		break;
+
+	case '1':	/* got a filename! */
+		waitline2 (source, buf, sizeof buf);
+		file = g_filename_to_utf8 (buf, -1, 0, 0, 0);
+		freq->callback (freq->userdata, file);
+		g_free (file);
+		return TRUE;
+	}
+
+	/* it doesn't work to close them here, because of the weird
+		way giowin32 works. We must _return_ before closing them */
+	g_timeout_add(3000, (GSourceFunc)win32_close_pipe, freq->th->pipe_fd[0]);
+	g_timeout_add(2000, (GSourceFunc)win32_close_pipe, freq->th->pipe_fd[1]);
+
+	g_free (freq->title);
+	free (freq->th);
+	free (freq);
+
+	return FALSE;
+}
+#endif
+
 void
 gtkutil_file_req (const char *title, void *callback, void *userdata, char *filter,
 						int flags)
@@ -172,6 +366,58 @@
 	GtkWidget *dialog;
 	extern char *get_xdir_fs (void);
 
+#ifdef WIN32
+	if (!(flags & FRF_WRITE))
+	{
+		freq = malloc (sizeof (struct file_req));
+		freq->th = thread_new ();
+		freq->flags = 0;
+		freq->multiple = (flags & FRF_MULTIPLE);
+		freq->callback = callback;
+		freq->userdata = userdata;
+		freq->title = g_locale_from_utf8 (title, -1, 0, 0, 0);
+		if (!filter)
+		{
+			freq->filter =	"All files\0*.*\0"
+							"Executables\0*.exe\0"
+							"ZIP files\0*.zip\0\0";
+		}
+		else
+		{
+			freq->filter = filter;
+		}
+
+		thread_start (freq->th, win32_thread, freq);
+		fe_input_add (freq->th->pipe_fd[0], FIA_FD|FIA_READ, win32_read_thread, freq);
+
+		return;
+
+	}
+	
+	else {
+		freq = malloc (sizeof (struct file_req));
+		freq->th = thread_new ();
+		freq->flags = 0;
+		freq->multiple = (flags & FRF_MULTIPLE);
+		freq->callback = callback;
+		freq->userdata = userdata;
+		freq->title = g_locale_from_utf8 (title, -1, 0, 0, 0);
+		if (!filter)
+		{
+			freq->filter = "All files\0*.*\0\0";
+		}
+		else
+		{
+			freq->filter = filter;
+		}
+
+		thread_start (freq->th, win32_thread2, freq);
+		fe_input_add (freq->th->pipe_fd[0], FIA_FD|FIA_READ, win32_read_thread, freq);
+
+	return;
+	}
+#endif
+
 	if (flags & FRF_WRITE)
 	{
 		dialog = gtk_file_chooser_dialog_new (title, NULL,
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/fe-gtk/joind.c xchat-wdk/src/fe-gtk/joind.c
--- xchat-wdk.orig/src/fe-gtk/joind.c	2006-12-26 05:56:55 +0100
+++ xchat-wdk/src/fe-gtk/joind.c	2010-10-09 12:53:27 +0200
@@ -9,7 +9,6 @@
 
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <unistd.h>
 #include <string.h>
 #include <stdio.h>
 
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/fe-gtk/maingui.c xchat-wdk/src/fe-gtk/maingui.c
--- xchat-wdk.orig/src/fe-gtk/maingui.c	2010-05-16 05:20:22 +0200
+++ xchat-wdk/src/fe-gtk/maingui.c	2010-11-08 11:14:47 +0100
@@ -214,60 +214,10 @@
 	away_list = mg_attr_list_create (&colors[COL_AWAY], FALSE);
 }
 
-#ifdef WIN32
-#define WINVER 0x0501	/* needed for vc6? */
-#include <windows.h>
-#include <gdk/gdkwin32.h>
-
-/* Flash the taskbar button on Windows when there's a highlight event. */
-
-static void
-flash_window (GtkWidget *win)
-{
-	FLASHWINFO fi;
-	static HMODULE user = NULL;
-	static BOOL (*flash) (PFLASHWINFO) = NULL;
-
-	if (!user)
-	{
-		user = GetModuleHandleA ("USER32");
-		if (!user)
-			return;	/* this should never fail */
-	}
-
-	if (!flash)
-	{
-		flash = (void *)GetProcAddress (user, "FlashWindowEx");
-		if (!flash)
-			return;	/* this fails on NT4.0 and Win95 */
-	}
-
-	fi.cbSize = sizeof (fi);
-	fi.hwnd = GDK_WINDOW_HWND (win->window);
-	fi.dwFlags = FLASHW_ALL | FLASHW_TIMERNOFG;
-	fi.uCount = 0;
-	fi.dwTimeout = 500;
-	flash (&fi);
-	/*FlashWindowEx (&fi);*/
-}
-#else
-
-#ifdef USE_XLIB
-#include <gdk/gdkx.h>
-
 static void
 set_window_urgency (GtkWidget *win, gboolean set)
 {
-	XWMHints *hints;
-
-	hints = XGetWMHints(GDK_WINDOW_XDISPLAY(win->window), GDK_WINDOW_XWINDOW(win->window));
-	if (set)
-		hints->flags |= XUrgencyHint;
-	else
-		hints->flags &= ~XUrgencyHint;
-	XSetWMHints(GDK_WINDOW_XDISPLAY(win->window),
-	            GDK_WINDOW_XWINDOW(win->window), hints);
-	XFree(hints);
+	gtk_window_set_urgency_hint (GTK_WINDOW (win), set);
 }
 
 static void
@@ -281,18 +231,14 @@
 {
 	set_window_urgency (win, FALSE);
 }
-#endif
-#endif
 
 /* flash the taskbar button */
 
 void
 fe_flash_window (session *sess)
 {
-#if defined(WIN32) || defined(USE_XLIB)
 	if (fe_gui_info (sess, 0) != 1)	/* only do it if not focused */
 		flash_window (sess->gui->window);
-#endif
 }
 
 /* set a tab plain, red, light-red, or blue */
@@ -1190,7 +1136,14 @@
 						  "Close them all?"), i);
 		g_signal_connect (G_OBJECT (dialog), "response",
 								G_CALLBACK (mg_tab_close_cb), sess);
-		gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
+		if (!prefs.tab_layout && prefs.tab_pos == 6)
+		{
+			gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER_ON_PARENT);
+		}
+		else
+		{
+			gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
+		}
 		gtk_widget_show (dialog);
 	}
 }
@@ -2489,7 +2442,7 @@
 	if (prefs.lagometer & 1)
 	{
 		gui->lagometer = wid = gtk_progress_bar_new ();
-		gtk_widget_set_size_request (wid, 1, 8);
+		gtk_widget_set_size_request (wid, 1, 10);
 
 		wid = gtk_event_box_new ();
 		gtk_container_add (GTK_CONTAINER (wid), gui->lagometer);
@@ -2504,7 +2457,7 @@
 	if (prefs.throttlemeter & 1)
 	{
 		gui->throttlemeter = wid = gtk_progress_bar_new ();
-		gtk_widget_set_size_request (wid, 1, 8);
+		gtk_widget_set_size_request (wid, 1, 10);
 
 		wid = gtk_event_box_new ();
 		gtk_container_add (GTK_CONTAINER (wid), gui->throttlemeter);
@@ -2957,11 +2910,7 @@
 		gtk_xtext_check_marker_visibility (GTK_XTEXT (current_sess->gui->xtext));
 		plugin_emit_dummy_print (current_sess, "Focus Window");
 	}
-#ifndef WIN32
-#ifdef USE_XLIB
 	unflash_window (GTK_WIDGET (win));
-#endif
-#endif
 	return FALSE;
 }
 
@@ -2972,11 +2921,7 @@
 	if (!sess->server->server_session)
 		sess->server->server_session = sess;
 	gtk_xtext_check_marker_visibility(GTK_XTEXT (current_sess->gui->xtext));
-#ifndef WIN32
-#ifdef USE_XLIB
 	unflash_window (GTK_WIDGET (win));
-#endif
-#endif
 	plugin_emit_dummy_print (sess, "Focus Window");
 	return FALSE;
 }
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/fe-gtk/menu.c xchat-wdk/src/fe-gtk/menu.c
--- xchat-wdk.orig/src/fe-gtk/menu.c	2010-05-16 06:24:24 +0200
+++ xchat-wdk/src/fe-gtk/menu.c	2010-10-09 12:53:27 +0200
@@ -20,7 +20,6 @@
 #include <stdlib.h>
 #include <fcntl.h>
 #include <string.h>
-#include <unistd.h>
 
 #ifdef WIN32
 #include <windows.h>
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/fe-gtk/palette.c xchat-wdk/src/fe-gtk/palette.c
--- xchat-wdk.orig/src/fe-gtk/palette.c	2010-05-16 05:20:22 +0200
+++ xchat-wdk/src/fe-gtk/palette.c	2010-10-09 12:53:27 +0200
@@ -18,7 +18,6 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/fe-gtk/plugin-tray.c xchat-wdk/src/fe-gtk/plugin-tray.c
--- xchat-wdk.orig/src/fe-gtk/plugin-tray.c	2010-08-14 03:46:21 +0200
+++ xchat-wdk/src/fe-gtk/plugin-tray.c	2010-11-08 11:01:30 +0100
@@ -1,8 +1,7 @@
 /* Copyright (C) 2006-2007 Peter Zelezny. */
 
 #include <string.h>
-#include <unistd.h>
-#include "../common/xchat-plugin.h"
+#include "../../plugins/xchat-plugin.h"
 #include "../common/xchat.h"
 #include "../common/xchatc.h"
 #include "../common/inbound.h"
@@ -298,10 +297,10 @@
 		nets = tray_count_networks ();
 		chans = tray_count_channels ();
 		if (nets)
-			tray_set_tipf (_("XChat: Connected to %u networks and %u channels"),
+			tray_set_tipf (_("XChat-WDK: Connected to %u networks and %u channels"),
 								nets, chans);
 		else
-			tray_set_tipf ("XChat: %s", _("Not connected."));
+			tray_set_tipf ("XChat-WDK: %s", _("Not connected."));
 	}
 
 	if (custom_icon1)
@@ -451,7 +450,7 @@
 	/* 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");
+	win = xchat_get_info (ph, "gtkwin_ptr");
 
 	tray_stop_flash ();
 	tray_reset_counts ();
@@ -651,15 +650,15 @@
 		/* FIXME: hides any previous private messages */
 		tray_hilight_count++;
 		if (tray_hilight_count == 1)
-			tray_set_tipf (_("XChat: Highlighted message from: %s (%s)"),
+			tray_set_tipf (_("XChat-WDK: 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_set_tipf (_("XChat-WDK: %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)"),
+		tray_set_balloonf (word[2], _("XChat-WDK: Highlighted message from: %s (%s)"),
 								 word[1], xchat_get_info (ph, "channel"));
 
 	return XCHAT_EAT_NONE;
@@ -677,14 +676,14 @@
 
 		tray_pub_count++;
 		if (tray_pub_count == 1)
-			tray_set_tipf (_("XChat: New public message from: %s (%s)"),
+			tray_set_tipf (_("XChat-WDK: 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);
+			tray_set_tipf (_("XChat-WDK: %u new public messages."), tray_pub_count);
 	}
 
 	if (prefs.input_balloon_chans)
-		tray_set_balloonf (word[2], _("XChat: New public message from: %s (%s)"),
+		tray_set_balloonf (word[2], _("XChat-WDK: New public message from: %s (%s)"),
 								 word[1], xchat_get_info (ph, "channel"));
 
 	return XCHAT_EAT_NONE;
@@ -706,14 +705,14 @@
 
 	tray_priv_count++;
 	if (tray_priv_count == 1)
-		tray_set_tipf (_("XChat: Private message from: %s (%s)"),
+		tray_set_tipf (_("XChat-WDK: Private message from: %s (%s)"),
 							from, network);
 	else
-		tray_set_tipf (_("XChat: %u private messages, latest from: %s (%s)"),
+		tray_set_tipf (_("XChat-WDK: %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)"),
+		tray_set_balloonf (text, _("XChat-WDK: Private message from: %s (%s)"),
 								 from, network);
 }
 
@@ -759,15 +758,15 @@
 
 		tray_file_count++;
 		if (tray_file_count == 1)
-			tray_set_tipf (_("XChat: File offer from: %s (%s)"),
+			tray_set_tipf (_("XChat-WDK: File offer from: %s (%s)"),
 								word[1], network);
 		else
-			tray_set_tipf (_("XChat: %u file offers, latest from: %s (%s)"),
+			tray_set_tipf (_("XChat-WDK: %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)"),
+		tray_set_balloonf ("", _("XChat-WDK: File offer from: %s (%s)"),
 								word[1], network);
 
 	return XCHAT_EAT_NONE;
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/fe-gtk/plugingui.c xchat-wdk/src/fe-gtk/plugingui.c
--- xchat-wdk.orig/src/fe-gtk/plugingui.c	2010-05-16 05:20:22 +0200
+++ xchat-wdk/src/fe-gtk/plugingui.c	2010-10-29 19:34:09 +0200
@@ -35,7 +35,7 @@
 #include "../common/xchat.h"
 #define PLUGIN_C
 typedef struct session xchat_context;
-#include "../common/xchat-plugin.h"
+#include "../../plugins/xchat-plugin.h"
 #include "../common/plugin.h"
 #include "../common/util.h"
 #include "../common/outbound.h"
@@ -147,7 +147,9 @@
 plugingui_load (void)
 {
 	gtkutil_file_req (_("Select a Plugin or Script to load"), plugingui_load_cb,
-							current_sess, NULL, FRF_ADDFOLDER);
+							current_sess,
+							"Plugins and Scripts\0*.dll;*.lua;*.pl;*.py;*.tcl\0"
+							"All files\0*.*\0\0", 0);
 }
 
 static void
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/fe-gtk/rawlog.c xchat-wdk/src/fe-gtk/rawlog.c
--- xchat-wdk.orig/src/fe-gtk/rawlog.c	2010-05-16 05:20:22 +0200
+++ xchat-wdk/src/fe-gtk/rawlog.c	2010-10-09 12:53:27 +0200
@@ -19,7 +19,6 @@
 #include <stdio.h>
 #include <string.h>
 #include <fcntl.h>
-#include <unistd.h>
 #include <stdlib.h>
 
 #include "fe-gtk.h"
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/fe-gtk/search.c xchat-wdk/src/fe-gtk/search.c
--- xchat-wdk.orig/src/fe-gtk/search.c	2010-05-16 05:20:22 +0200
+++ xchat-wdk/src/fe-gtk/search.c	2010-10-09 12:53:27 +0200
@@ -153,7 +153,7 @@
 								_("_Find"));
 	g_object_set_data (G_OBJECT (wid), "e", entry);
 
-	g_signal_connect (G_OBJECT (win), "key-press-event", G_CALLBACK (search_key_cb), win);
+	g_signal_connect (G_OBJECT (win), "key_press_event", G_CALLBACK (search_key_cb), win);
 
 	gtk_widget_show (win);
 }
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/fe-gtk/servlistgui.c xchat-wdk/src/fe-gtk/servlistgui.c
--- xchat-wdk.orig/src/fe-gtk/servlistgui.c	2010-08-07 09:14:45 +0200
+++ xchat-wdk/src/fe-gtk/servlistgui.c	2010-10-09 12:53:27 +0200
@@ -1782,7 +1782,7 @@
 	gtk_container_add (GTK_CONTAINER (hbox), checkbutton_fav);
 	g_signal_connect (G_OBJECT (checkbutton_fav), "toggled",
 							G_CALLBACK (fav_servlist), 0);
-	gtk_widget_show (checkbutton_fav);
+	/* gtk_widget_show (checkbutton_fav); don't show this until it's completed */
 
 	vbuttonbox2 = gtk_vbutton_box_new ();
 	gtk_box_set_spacing (GTK_BOX (vbuttonbox2), 3);
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/fe-gtk/setup.c xchat-wdk/src/fe-gtk/setup.c
--- xchat-wdk.orig/src/fe-gtk/setup.c	2008-02-08 10:04:45 +0100
+++ xchat-wdk/src/fe-gtk/setup.c	2010-11-08 11:03:31 +0100
@@ -109,13 +109,13 @@
 					N_("Give each person on IRC a different color"),0,0},
 	{ST_TOGGLR, N_("Indent nick names"), P_OFFINTNL(indent_nicks),
 					N_("Make nick names right-justified"),0,0},
-	{ST_TOGGLE, N_("Transparent background"), P_OFFINTNL(transparent),0,0,0},
-	{ST_TOGGLR, N_("Show marker line"), P_OFFINTNL(show_marker),
+	/* {ST_TOGGLE, N_("Transparent background"), P_OFFINTNL(transparent),0,0,0}, */
+	{ST_TOGGLE, N_("Show marker line"), P_OFFINTNL(show_marker),
 					N_("Insert a red line after the last read text."),0,0},
-	{ST_HEADER, N_("Transparency Settings"), 0,0,0},
+	/* {ST_HEADER, N_("Transparency Settings"), 0,0,0},
 	{ST_HSCALE, N_("Red:"), P_OFFINTNL(tint_red),0,0,0},
 	{ST_HSCALE, N_("Green:"), P_OFFINTNL(tint_green),0,0,0},
-	{ST_HSCALE, N_("Blue:"), P_OFFINTNL(tint_blue),0,0,0},
+	{ST_HSCALE, N_("Blue:"), P_OFFINTNL(tint_blue),0,0,0}, */
 
 	{ST_HEADER,	N_("Time Stamps"),0,0,0},
 	{ST_TOGGLE, N_("Enable time stamps"), P_OFFINTNL(timestamp),0,0,2},
@@ -363,7 +363,6 @@
 	{ST_END, 0, 0, 0, 0, 0}
 };
 
-#if 0
 static const setting advanced_settings[] =
 {
 	{ST_HEADER,	N_("Advanced Settings"),0,0,0},
@@ -378,7 +377,6 @@
 
 	{ST_END, 0, 0, 0, 0, 0}
 };
-#endif
 
 static const setting logging_settings[] =
 {
@@ -1708,7 +1706,7 @@
 		N_("General"),
 		N_("Logging"),
 		N_("Sound"),
-/*		N_("Advanced"),*/
+		N_("Advanced"),
 		NULL,
 	N_("Network"),
 		N_("Network setup"),
@@ -1733,6 +1731,7 @@
 	setup_add_page (cata[9], book, setup_create_page (general_settings));
 	setup_add_page (cata[10], book, setup_create_page (logging_settings));
 	setup_add_page (cata[11], book, setup_create_sound_page ());
+	setup_add_page (cata[12], book, setup_create_page (advanced_settings));
 	setup_add_page (cata[14], book, setup_create_page (network_settings));
 	setup_add_page (cata[15], book, setup_create_page (filexfer_settings));
 
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/fe-gtk/sexy-spell-entry.c xchat-wdk/src/fe-gtk/sexy-spell-entry.c
--- xchat-wdk.orig/src/fe-gtk/sexy-spell-entry.c	2006-07-17 07:51:02 +0200
+++ xchat-wdk/src/fe-gtk/sexy-spell-entry.c	2010-10-09 12:53:27 +0200
@@ -31,6 +31,8 @@
 /*#include "gtkspell-iso-codes.h"
 #include "sexy-marshal.h"*/
 
+#include "typedef.h"
+
 /*
  * Bunch of poop to make enchant into a runtime dependency rather than a
  * compile-time dependency.  This makes it so I don't have to hear the
@@ -134,12 +136,10 @@
 	GModule *enchant;
 	gpointer funcptr;
 
-	enchant = g_module_open("libenchant", 0);
+	enchant = g_module_open("libenchant.dll", 0);
 	if (enchant == NULL)
 	{
-		enchant = g_module_open("libenchant.so.1", 0);
-		if (enchant == NULL)
-			return;
+		return;
 	}
 
 	have_enchant = TRUE;
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/fe-gtk/xtext.c xchat-wdk/src/fe-gtk/xtext.c
--- xchat-wdk.orig/src/fe-gtk/xtext.c	2008-08-29 13:24:17 +0200
+++ xchat-wdk/src/fe-gtk/xtext.c	2010-10-09 12:53:27 +0200
@@ -42,7 +42,6 @@
 #include <ctype.h>
 #include <stdlib.h>
 #include <time.h>
-#include <unistd.h>
 #include <gtk/gtkmain.h>
 #include <gtk/gtksignal.h>
 #include <gtk/gtkselection.h>
@@ -3834,7 +3833,7 @@
 	PaintDesktop (hdc);
 	ReleaseDC (hwnd, hdc);
 
-	gdk_window_get_size (GTK_WIDGET (xtext)->window, &width, &height);
+	gdk_drawable_get_size (GTK_WIDGET (xtext)->window, &width, &height);
 	img = gdk_image_get (GTK_WIDGET (xtext)->window, 0, 0, width+128, height);
 	xtext->pixmap = win32_tint (xtext, img, img->width, img->height);
 
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/fe-text/fe-text.c xchat-wdk/src/fe-text/fe-text.c
--- xchat-wdk.orig/src/fe-text/fe-text.c	2008-08-29 13:24:17 +0200
+++ xchat-wdk/src/fe-text/fe-text.c	2010-10-09 12:53:27 +0200
@@ -22,9 +22,13 @@
 #ifdef HAVE_STRINGS_H
 #include <strings.h>
 #endif
+#ifdef WIN32
+#define STDIN_FILENO 0
+#define STDOUT_FILENO 1
+#else
 #include <sys/time.h>
+#endif
 #include <sys/types.h>
-#include <unistd.h>
 #include <ctype.h>
 #include "../common/xchat.h"
 #include "../common/xchatc.h"
@@ -339,7 +343,11 @@
 	te->callback = callback;
 	te->userdata = userdata;
 
-	gettimeofday (&now, NULL);
+#ifdef WIN32
+		g_get_current_time (&now);
+#else
+		gettimeofday (&now, NULL);
+#endif
 	te->next_call = now.tv_sec * 1000 + (now.tv_usec / 1000) + te->interval;
 
 	tmr_list = g_slist_prepend (tmr_list, te);
@@ -417,7 +425,12 @@
 void
 fe_main (void)
 {
-	struct timeval timeout, now;
+	struct timeval timeout;
+#ifdef WIN32
+	GTimeVal now;
+#else
+	struct timeval now;
+#endif
 	socketevent *se;
 	timerevent *te;
 	fd_set rd, wd, ex;
@@ -428,7 +441,7 @@
 		new_ircwindow (NULL, NULL, SESS_SERVER, 0);
 
 #ifdef ENABLE_NLS
-	bindtextdomain (GETTEXT_PACKAGE, PREFIX"/share/locale");
+	bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
 	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
 	textdomain (GETTEXT_PACKAGE);
 #endif
@@ -464,7 +477,11 @@
 				shortest = te->next_call;
 			list = list->next;
 		}
+#ifdef WIN32
+		g_get_current_time (&now);
+#else
 		gettimeofday (&now, NULL);
+#endif
 		delay = shortest - ((now.tv_sec * 1000) + (now.tv_usec / 1000));
 		timeout.tv_sec = delay / 1000;
 		timeout.tv_usec = (delay % 1000) * 1000;
@@ -514,7 +531,11 @@
 		}
 
 		/* now check our list of timeout events, some might need to be called! */
+#ifdef WIN32
+		g_get_current_time (&now);
+#else
 		gettimeofday (&now, NULL);
+#endif
 		list = tmr_list;
 		while (list)
 		{