summary refs log tree commit diff stats
path: root/share
AgeCommit message (Expand)Author
2013-05-03Add Italian GenericNameTingPing
2013-05-03Fix desktop translationsTingPing
2013-04-28Install a pkgconfig .pc file. This allows external plugins to findChristoph J. Thompson
2013-04-27Get rid of bundled beepBerke Viktor
2013-04-20fix install errorTingPing
2013-04-18Add english generic nameTingPing
2013-04-18Fix a typo.Christoph J. Thompson
2013-04-18Add GTK and IRCClient to Categories. This is Based on:Christoph J. Thompson
2013-04-18Translate Comment in french, german, italian and norwegian bokmålChristoph J. Thompson
2013-04-18Change "no" to "nb" for Norsk Bokmål. In norway there is not onlyChristoph J. Thompson
2013-04-18Change most Comment lines to be GenericName. GenericName should beChristoph J. Thompson
2013-04-17beep sound is gtk onlyTingPing
2013-04-17Install sound file on unixTingPing
2013-04-16Move beep to proper placeBerke Viktor
2013-04-14G_FILE_COPY_TARGET_DEFAULT_PERMS requires GLib 2.20+Berke Viktor
2013-04-09cosmeticsBerke Viktor
2013-04-09readme cleanupBerke Viktor
2013-04-03gtk_show_uri() requires GTK+ 2.14Berke Viktor
2013-04-01Merge pull request #484 from Phr33d0m/masterTingPing
2013-03-31GLib 2.14 is requiredBerke Viktor
2013-03-31MAKE: don't include icons and desktop file for non-gtk buildshasufell
2013-03-28Update links to docsTingPing
2013-03-23It's just HexChatTingPing
2013-03-23Remove spec fileTingPing
2013-03-23Cleanup, docs are online now, these are either irrelevant or outdatedBerke Viktor
2013-02-25update readme link to building docsTingPing
2013-02-18add gnome's UsesNotifications to the desktop fileTingPing
2013-01-01Don't error on icon cache update failureTingPing
2012-12-23fix incorrect FSF addressDan Mashal
2012-12-16Put hexchat png in icons/hicolor/48x48/appsRichardHitt
2012-12-16Install hicolor svg; move the files Makefile.am to their subdirectoriesRichardHitt
2012-12-03Update share/doc/faq.mdTingPing
2012-11-24Update share/doc/faq.mdTingPing
2012-11-20Update faqTingPing
2012-11-11Fix dateBerke Viktor
2012-11-11Update changelogBerke Viktor
2012-11-10Update changelogBerke Viktor
2012-11-09Add notes about testing translationsBerke Viktor
2012-11-04Use configdir instead of *xchatdir*Berke Viktor
2012-11-04Merge pull request #226 from TingPing/masterbviktor
2012-11-04Updated get_list docsTingPing
2012-11-04Updated python get_info docsTingPing
2012-11-04ReadMe cosmeticsBerke Viktor
2012-11-03Update FAQ according to recent icon file name changesBerke Viktor
2012-11-03Relocate hexchat.png and hexchat.ico and some more varname cleanupBerke Viktor
2012-11-03Relocate hexchat.desktopBerke Viktor
2012-10-30Some quickfixesBerke Viktor
2012-10-30Initial conversion of the Perl interface docs to MarkdownBerke Viktor
2012-10-30Python docs cosmeticsBerke Viktor
2012-10-30Plugin doc fixesBerke Viktor
48 +0100 committer Berke Viktor <bviktor@hexchat.org> 2012-10-30 08:42:48 +0100 Rebranding for the rest of plugin*' href='/git-repos/torxchat.git/commit/plugins/hextray/hexchat.cpp?h=feature/flexible-cert&id=e681eafa78262d0c177832d67900687f2c938081'>e681eafa ^
d03d6e60 ^


e681eafa ^
d03d6e60 ^
e681eafa ^
d03d6e60 ^

e681eafa ^

d03d6e60 ^
e681eafa ^


d03d6e60 ^


e681eafa ^
d03d6e60 ^




e681eafa ^
d03d6e60 ^
e681eafa ^
d03d6e60 ^
e681eafa ^
d03d6e60 ^











e681eafa ^
d03d6e60 ^






e681eafa ^
d03d6e60 ^
e681eafa ^
d03d6e60 ^

e681eafa ^

d03d6e60 ^
e681eafa ^

d03d6e60 ^
e681eafa ^


d03d6e60 ^














e681eafa ^
d03d6e60 ^
e681eafa ^
d03d6e60 ^


e681eafa ^
d03d6e60 ^








e681eafa ^
d03d6e60 ^




e681eafa ^
d03d6e60 ^
e681eafa ^

d03d6e60 ^




e681eafa ^
d03d6e60 ^
e681eafa ^
d03d6e60 ^






e681eafa ^
d03d6e60 ^
e681eafa ^
d03d6e60 ^




e681eafa ^
d03d6e60 ^



e681eafa ^
d03d6e60 ^
e681eafa ^

b0437782 ^
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














                                                                                                     
                                                                             






                     
 

                            
                      
                     

                     
                                                                                  
                                       




























































































































                                                                                                                      
                                           






                                                             
                              

  
                                  






                                             
                                                   

  
                             


                                        
                                                             


               
                                                 
                  
                                                                                               

                                                

                                                                                      
                          


                                                                                                                 


                          
                                           




          
                    
  
                                         
          
                                             











                                        
                                                             






                                                                         
                                                 
                  
                                                                                               

                                                 

                                                                                      
                          

                                                                                                                 
 


                                                                                                 














                                                                                                            
                                                                          
                                          
                                                                                                                                  


                                             
                                                                                                                                                                                                         








                                               
                                           




                      
                                                          
  

                                                             




                             
                                         
          
                                                     






                                       
                                                                                     
                         
                                                   




                                   
                                   



                     
                                 
  

                                                                       
  
/* X-Tray
 * Copyright (C) 1998, 2005 Peter Zelezny, Michael Hotaling <Mike.Hotaling@SinisterDevelopments.com>
 *
 * X-Tray is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * X-Tray is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with X-Tray; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */

#include <windows.h>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <tchar.h>

#include "hexchat-plugin.h"
#include "hextray.h"
#include "resource.h"
#include "hexchat.h"
#include "utility.h"

// from util.c of HexChat source code ( slightly modified to fit HexTray Syntax )
char *hexchat_strip_color (char *text)
{
	int nc	= 0;
	int i	= 0;
	int col	= 0;
	int len	= strlen(text);
	char *new_str = (char *)malloc(len + 2);

	while (len > 0)
	{
		if ((col && isdigit(*text) && (nc < 2)) || (col && isdigit(*(text+1)) && (nc < 3) && (*text == ',')))
		{
			nc++;

			if(*text == ',')
			{
				nc = 0;
			}
		}
		else
		{
			col = 0;

			switch (*text)
			{
			case '\003':			  /*ATTR_COLOR: */
				{
					col = 1;
					nc = 0;
				}
				break;
			case '\007':			  /*ATTR_BEEP: */
			case '\017':			  /*ATTR_RESET: */
			case '\026':			  /*ATTR_REVERSE: */
			case '\002':			  /*ATTR_BOLD: */
			case '\037':			  /*ATTR_UNDERLINE: */
				break;
			default:
				{
					new_str[i] = *text;
					i++;
				}
				break;
			}
		}

		text++;
		len--;
	}

	new_str[i] = 0;

	return new_str;
}

void check_special_chars (char *cmd)
{
	int occur	= 0;
	int len		= strlen (cmd);
	int i = 0, j = 0;
	char *buf;

	if (!len)
		return;

	buf = (char *)malloc (len + 1);

	if (buf)
	{
		while (cmd[j])
		{
			switch (cmd[j])
			{
			case '%':
				{
					occur++;

					switch (cmd[j + 1])
					{
					case 'R':
						buf[i] = '\026';
						break;
					case 'U':
						buf[i] = '\037';
						break;
					case 'B':
						buf[i] = '\002';
						break;
					case 'C':
						buf[i] = '\003';
						break;
					case 'O':
						buf[i] = '\017';
						break;
					case '%':
						buf[i] = '%';
						break;
					default:
						buf[i] = '%';
						j--;
						break;
					}

					j++;
				}
				break;
			default:
				{
					buf[i] = cmd[j];
				}
				break;
			}

			j++;
			i++;
		}

		buf[i] = 0;

		if (occur)
			strcpy (cmd, buf);

		free (buf);
	}
}

void hexchat_globally_away(TCHAR *tszAway)
{
	char szTemp[512];
	char szAway[512];

	ConvertString(tszAway, szAway, 512);
	_snprintf(szTemp, 512, "ALLSERV AWAY %s\0", szAway);
	check_special_chars(szTemp);
	hexchat_exec(szTemp);
}

void hexchat_away(TCHAR *tszAway)
{
	char szTemp[512];
	char szAway[512];

	ConvertString(tszAway, szAway, 512);
	_snprintf(szTemp, 512, szAway);
	check_special_chars(szTemp);
	hexchat_commandf(ph, "AWAY %s\0", szTemp);
}

void hexchat_globally_back()
{
	std::vector<int> xs;
	std::vector<int>::iterator xsi;
	hexchat_list *xl = hexchat_list_get(ph, "channels");

	if(xl)
	{
		while(hexchat_list_next(ph, xl))
		{
			xsi = std::find(xs.begin(), xs.end(), hexchat_list_int(ph, xl, "id"));

			if((xsi == xs.end()) &&
				((strlen(hexchat_list_str(ph, xl, "server")) > 0) || 
				(strlen(hexchat_list_str(ph, xl, "channel")) > 0)))
			{
				xs.push_back(hexchat_list_int(ph, xl, "id"));
				hexchat_set_context(ph, (hexchat_context *)hexchat_list_str(ph, xl, "context"));
				hexchat_back();
			}
		}

		hexchat_list_free(ph, xl);
	}
}



void hexchat_back()
{
	if(hexchat_get_info(ph, "away"))
	{
		hexchat_command(ph, "BACK");
	}
}

HMENU setServerMenu()
{
	HMENU sTemp = CreateMenu();
	TCHAR wszServer[128];
	TCHAR wszNick[128];
	TCHAR wszMenuEntry[256];

	std::vector<int> xs;
	std::vector<int>::iterator xsi;
	hexchat_list *xl = hexchat_list_get(ph, "channels");

	AppendMenu(sTemp, MF_STRING, ACT_AWAY, _T("Set Globally Away"));
	AppendMenu(sTemp, MF_STRING, ACT_BACK, _T("Set Globally Back"));
	AppendMenu(sTemp, MF_SEPARATOR, 0, NULL);

	if(xl)
	{
		while(hexchat_list_next(ph, xl))
		{
			xsi = std::find(xs.begin(), xs.end(), hexchat_list_int(ph, xl, "id"));

			if( (xsi == xs.end()) &&
				((strlen(hexchat_list_str(ph, xl, "server")) > 0) || 
				(strlen(hexchat_list_str(ph, xl, "channel")) > 0)))
			{
				hexchat_set_context(ph, (hexchat_context *)hexchat_list_str(ph, xl, "context"));
				xs.push_back(hexchat_list_int(ph, xl, "id"));

				char *network	= _strdup(hexchat_list_str(ph, xl, "network"));
				char *server	= _strdup(hexchat_list_str(ph, xl, "server"));
				char *nick		= _strdup(hexchat_get_info(ph, "nick"));

				if(network != NULL)
				{
					ConvertString(network, wszServer, 128);
				}
				else
				{
					ConvertString(server, wszServer, 128);
				}

				if(server != NULL)
				{
					ConvertString(nick, wszNick, 128);
					_sntprintf(wszMenuEntry, 256, _T("%s @ %s\0"), wszNick, wszServer);

					if(!hexchat_get_info(ph, "away"))
					{
						AppendMenu(sTemp, MF_STRING, (hexchat_list_int(ph, xl, "id") + 1), wszMenuEntry);
					}
					else
					{
						AppendMenu(sTemp, (MF_CHECKED | MF_STRING), (hexchat_list_int(ph, xl, "id") + 1), wszMenuEntry);							
					}
				}

				free(network);
				free(server);
				free(nick);
			}
		}

		hexchat_list_free(ph, xl);
	}

	return sTemp;
}

struct _hexchat_context *hexchat_find_server(int find_id)
{
	hexchat_context *xc;
	hexchat_list *xl = hexchat_list_get(ph, "channels");
	int id;

	if(!xl)
		return NULL;

	while(hexchat_list_next(ph, xl))
	{
		id = hexchat_list_int(ph, xl, "id");
		
		if(id == -1)
		{
			return NULL;
		}
		else if(id == find_id)
		{
			xc = (hexchat_context *)hexchat_list_str(ph, xl, "context");
			
			hexchat_list_free(ph, xl);

			return xc;
		}
	}

	hexchat_list_free(ph, xl);

	return NULL;
}

void hexchat_exec(char *command)
{
	hexchat_set_context(ph, hexchat_find_context(ph, NULL, NULL));
	hexchat_command(ph, command);
}