1 /* 2 * defs.h 3 * 4 * Copyright 2008 David Vachulka <arch_dvx@users.sourceforge.net> 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 19 * MA 02110-1301, USA. 20 */ 21 22 #ifndef DEFS_H_ 23 #define DEFS_H_ 24 25 #include <fx.h> 26 #include <fxkeys.h> 27 #include <FXArray.h> 28 #include <new> 29 #include <iostream> 30 #include <map> 31 #ifndef DXTEXT_H 32 #include "dxtext.h" 33 #endif 34 35 #define LUA_HELP_PATH "http://www.dxirc.org/dxirc-lua.html" 36 #define TAB (FXString)"\t" 37 38 class IrcEngine; 39 class DccEngine; 40 struct lua_State; 41 42 enum TYPE { 43 SERVER, 44 CHANNEL, 45 QUERY, 46 OTHER, 47 DCC, 48 BOATS 49 }; 50 51 enum DCCTYPE { 52 DCC_NONE, 53 DCC_CHATIN, //connect to someone for chat 54 DCC_CHATOUT, //someone connect to me for chat 55 DCC_IN, //connect to someone for file receive 56 DCC_OUT, //someone connect to me for file send 57 DCC_PIN, //someone connect to me for file receive (PSEND) 58 DCC_POUT //connect to someone for file send (PSEND) 59 }; 60 61 enum IrcEventType { 62 IRC_CONNECT, 63 IRC_DISCONNECT, //send at closeconnection w/o reconnection 64 IRC_RECONNECT, //send at closeconnection with reconnection 65 IRC_RECONNECTALL, //send at menu "Reconnect all" 66 IRC_ERROR, 67 IRC_NEWCHANNEL, 68 IRC_QUERY, 69 IRC_PRIVMSG, 70 IRC_ACTION, 71 IRC_CTCPREPLY, 72 IRC_CTCPREQUEST, 73 IRC_DCCCHAT, 74 IRC_DCCMSG, 75 IRC_DCCACTION, 76 IRC_DCCSERVER, 77 IRC_DCCIN, 78 IRC_DCCOUT, 79 IRC_DCCPIN, 80 IRC_DCCPOUT, 81 IRC_DCCTOKEN, 82 IRC_DCCMYTOKEN, 83 IRC_DCCPOSITION, 84 IRC_DCCRESUME, 85 IRC_DCCPRESUME, 86 IRC_DCCACCEPT, 87 IRC_DCCPACCEPT, 88 IRC_BOATS, 89 IRC_BOATSINVITE, 90 IRC_BOATSACCEPT, 91 IRC_BOATSDECLINE, 92 IRC_BOATSNEWGAME, 93 IRC_BOATSREADY, 94 IRC_BOATSLEFT, 95 IRC_BOATSDESTROYED, 96 IRC_BOATSWIN, 97 IRC_JOIN, 98 IRC_PART, 99 IRC_QUIT, 100 IRC_UNKNOWN, 101 IRC_TOPIC, 102 IRC_NICK, 103 IRC_MODE, 104 IRC_UMODE, 105 IRC_CHMODE, 106 IRC_SERVERREPLY, //command 001,002,.... 107 IRC_SERVERERROR, //command 400~599 108 IRC_301, //RPL_AWAY 109 IRC_305, //RPL_UNAWAY 110 IRC_306, //RPL_NOWAWAY 111 IRC_323, //RPL_LISTEND 112 IRC_331, //RPL_NOTOPIC 113 IRC_332, //RPL_TOPIC 114 IRC_333, //RPL_TOPICSETBY 115 IRC_353, //RPL_NAMREPLY 116 IRC_366, //RPL_ENDOFNAMES 117 IRC_372, //RPL_MOTD 118 IRC_401, //ERR_NOSUCHNICK (for Boats) 119 IRC_KICK, 120 IRC_NOTICE, 121 IRC_CHNOTICE, 122 IRC_INVITE, 123 IRC_AWAY, 124 IRC_ENDMOTD, 125 IRC_RAW 126 }; 127 128 enum LuaCommands { 129 LUA_LOAD, 130 LUA_UNLOAD, 131 LUA_COMMAND, 132 LUA_LIST 133 }; 134 135 enum UserMode { 136 OWNER = 0, 137 ADMIN, 138 OP, 139 VOICE, 140 HALFOP, 141 NONE 142 }; 143 144 enum dxircID { 145 dxirc_QUIT = FXMainWindow::ID_LAST, 146 dxirc_RESTART, 147 dxirc_SERVERS, 148 dxirc_CONNECT, 149 dxirc_DISCONNECT, 150 dxirc_RECONNECT, 151 dxirc_CLOSETAB, 152 dxirc_SELECTTAB, 153 dxirc_NEXTTAB, 154 dxirc_MOVETAB, 155 dxirc_NEXTUNREAD, 156 dxirc_CLEAR, 157 dxirc_CLEARALL, 158 dxirc_USERS, 159 dxirc_STATUS, 160 dxirc_OPTIONS, 161 dxirc_HELP, 162 dxirc_ABOUT, 163 dxirc_TABS, 164 dxirc_ALIAS, 165 dxirc_TRAY, 166 dxirc_LOG, 167 dxirc_SCRIPTS, 168 dxirc_STIMEOUT, //timeout for status change 169 dxirc_TRANSFERS, 170 dxirc_SPELL, 171 dxirc_FORCEFOCUS, 172 dxirc_LIST, 173 dxirc_AWAYTIMEOUT, //timeout for checking away on channels 174 dxirc_VERSION, //menuitem for check new dxirc version 175 dxirc_VERSIONSOCKET, //socket for check new dxirc version 176 dxirc_NOTIFYHIDE, 177 AboutDialog_LINK, 178 AliasDialog_ADD, 179 AliasDialog_MODIFY, 180 AliasDialog_DELETE, 181 AliasDialog_TABLE, 182 AliasDialog_SAVECLOSE, 183 AliasDialog_CANCEL, 184 ConfigDialog_ADDCOMMAND, 185 ConfigDialog_DELETECOMMAND, 186 ConfigDialog_ADDUSER, 187 ConfigDialog_MODIFYUSER, 188 ConfigDialog_DELETEUSER, 189 ConfigDialog_ADDFRIEND, 190 ConfigDialog_MODIFYFRIEND, 191 ConfigDialog_DELETEFRIEND, 192 ConfigDialog_ADDICONS, 193 ConfigDialog_DELETEICONS, 194 ConfigDialog_COMMAND, 195 ConfigDialog_USER, 196 ConfigDialog_FRIEND, 197 ConfigDialog_IRCCOLORS, 198 ConfigDialog_IRCFONT, 199 ConfigDialog_COLORS, 200 ConfigDialog_TABCOLORS, 201 ConfigDialog_THEME, 202 ConfigDialog_FONT, 203 ConfigDialog_CLOSE, 204 ConfigDialog_ICONS, 205 ConfigDialog_LOG, 206 ConfigDialog_LOGPATH, 207 ConfigDialog_TRAY, 208 ConfigDialog_NICK, 209 ConfigDialog_RECONNECT, 210 ConfigDialog_TABPOS, 211 ConfigDialog_AUTOLOAD, 212 ConfigDialog_AUTOLOADPATH, 213 ConfigDialog_DCCPATH, 214 ConfigDialog_DCCPORTD, 215 ConfigDialog_DCCPORTH, 216 ConfigDialog_DCCTIMEOUT, 217 ConfigDialog_SOUNDS, 218 ConfigDialog_SOUNDCONNECT, 219 ConfigDialog_SOUNDDISCONNECT, 220 ConfigDialog_SOUNDMESSAGE, 221 ConfigDialog_PLAYCONNECT, 222 ConfigDialog_PLAYDISCONNECT, 223 ConfigDialog_PLAYMESSAGE, 224 ConfigDialog_NOTIFY, 225 ConfigDialog_SHOWNOTIFY, 226 ConfigDialog_SELECTCONNECT, 227 ConfigDialog_SELECTDISCONNECT, 228 ConfigDialog_SELECTMESSAGE, 229 ConfigDialog_USESMILEYS, 230 ConfigDialog_ADDSMILEY, 231 ConfigDialog_MODIFYSMILEY, 232 ConfigDialog_DELETESMILEY, 233 ConfigDialog_SMILEY, 234 ConfigDialog_IMPORTSMILEY, 235 ConfigDialog_EXPORTSMILEY, 236 ConfigDialog_NOTIFYPOS, 237 ConfigDialog_LOADLOG, 238 ConfigDialog_TABS, 239 ConfigDialog_MODIFYBINDINGS, 240 ConfigDialog_REFRESHBINDINGS, 241 SmileyDialog_ACCEPT, 242 SmileyDialog_CANCEL, 243 SmileyDialog_PATH, 244 dxTabItem_TEXT, 245 dxTabItem_OPENLINK, 246 dxTabItem_COPYLINK, 247 DccDialog_CLOSE, 248 DccDialog_CLEAR, 249 DccDialog_CANCELED, 250 DccDialog_UTIME, 251 DccDialog_POPUPCANCEL, 252 DccDialog_DCCCANCEL, 253 DccDialog_TABLE, 254 DccEngine_SOCKET, 255 DccEngine_DCC, 256 DccEngine_CTIME, //timeout for check and disconnect offered connection 257 DccEngine_PTIME, //dccfile position 258 DccTabItem_COMMANDLINE, 259 DccTabItem_PTIME, 260 DccTabItem_SPELL, 261 DccTabItem_OWNMSG, 262 DccTabItem_COMMAND, 263 DccTabItem_SOCKET, 264 DccTabItem_CTIME, //timeout for check and disconnect offered connection 265 DccTabItem_LUA, 266 DccTabItem_NEWTETRIS, 267 DccTabItem_NEWMSG, 268 DccTabItem_SHOWLOG, 269 IrcEngine_DXSOCKET, 270 IrcEngine_SERVER, 271 IrcEngine_RTIME, //reconnect 272 IrcEngine_TATIME, //try again timeout 273 IrcEngine_PTIME, //ping timeout 274 IrcEngine_JDTIME, //join delay 275 DccSendDialog_SEND, 276 DccSendDialog_CANCEL, 277 DccSendDialog_FILE, 278 IrcTabItem_COMMANDLINE, 279 IrcTabItem_CDIALOG, 280 IrcTabItem_CQUIT, 281 IrcTabItem_PTIME, 282 IrcTabItem_ETIME, 283 IrcTabItem_USERS, 284 IrcTabItem_NEWQUERY, 285 IrcTabItem_WHOIS, 286 IrcTabItem_OP, 287 IrcTabItem_DEOP, 288 IrcTabItem_VOICE, 289 IrcTabItem_DEVOICE, 290 IrcTabItem_KICK, 291 IrcTabItem_BAN, 292 IrcTabItem_KICKBAN, 293 IrcTabItem_IGNORE, 294 IrcTabItem_TOPIC, 295 IrcTabItem_CSERVER, 296 IrcTabItem_NEWMSG, 297 IrcTabItem_LUA, 298 IrcTabItem_COMMAND, 299 IrcTabItem_OWNMSG, 300 IrcTabItem_NEWTETRIS, 301 IrcTabItem_DCCCHAT, //dcc chat on right click 302 IrcTabItem_DCCSEND, //dcc sending on right click 303 IrcTabItem_ADDICOMMAND, //for handle /ignore addcmd 304 IrcTabItem_RMICOMMAND, //for handle /ignore rmcmd 305 IrcTabItem_ADDIUSER, //for handle /ignore addusr 306 IrcTabItem_RMIUSER, //for handle /ignore rmusr 307 IrcTabItem_AWAY, //set away on right click 308 IrcTabItem_DEAWAY, //remove away on right click 309 IrcTabItem_SPELL, 310 IrcTabItem_SHOWLOG, 311 BoatsTabItem_GAMECANVAS, 312 BoatsTabItem_NEWGAME, 313 LogThread_LIST, 314 LogThread_LINES, 315 LogViewer_ADD, 316 LogViewer_CLOSE, 317 LogViewer_TREE, 318 LogViewer_RESET, 319 LogViewer_ALL, 320 LogViewer_NETWORK, 321 LogViewer_CHANNEL, 322 LogViewer_FILE, 323 LogViewer_SEARCH, 324 LogViewer_SEARCHNEXT, 325 LogViewer_PACK, 326 LogViewer_UNPACK, 327 LogViewer_DELETEITEM, 328 LogViewer_TEXT, 329 LogViewer_OPENLINK, 330 LogViewer_COPYLINK, 331 LogViewer_STIMEOUT, //timeout for status change 332 ScriptDialog_LIST, 333 ScriptDialog_LOAD, 334 ScriptDialog_VIEW, 335 ScriptDialog_VIEWNEW, 336 ScriptDialog_UNLOAD, 337 ScriptDialog_CLOSE, 338 ServerDialog_JOIN, 339 ServerDialog_LIST, 340 ServerDialog_CANCEL, 341 ServerDialog_ADD, 342 ServerDialog_MODIFY, 343 ServerDialog_DELETE, 344 ServerDialog_SAVECLOSE, 345 TetrisTabItem_GAMECANVAS, 346 TetrisTabItem_NEXTCANVAS, 347 TetrisTabItem_TETRISTIMEOUT, 348 TetrisTabItem_NEW, 349 TetrisTabItem_PAUSE, 350 HelpDialog_VIEWLICENSE, 351 KeybindingsDialog_CANCEL, 352 KeybindingsDialog_SAVECLOSE, 353 KeybindingsDialog_LIST, 354 KeybindingsDialog_SORTBYACTION, 355 KeybindingsDialog_SORTBYKB, 356 ListDialog_JOIN, 357 ListDialog_CLOSE, 358 ListDialog_TABLE, 359 ListDialog_SEARCH 360 }; 361 362 struct NickInfo { 363 FXString nick; 364 FXString user; 365 FXString real; 366 FXString host; 367 FXbool away; 368 }; 369 370 //used for ignoreuser, tracking friends 371 struct UserInfo { 372 FXString nick; 373 FXString channel; 374 FXString network; 375 }; 376 377 struct ServerInfo { 378 FXString name; 379 FXString hostname; 380 FXint port; 381 FXString nick; 382 FXString realname; 383 FXString passwd; 384 FXString channels; 385 FXString commands; 386 FXbool autoConnect; 387 FXbool useSsl; 388 }; 389 390 struct IrcColor { 391 FXColor text; 392 FXColor back; 393 FXColor user; 394 FXColor action; 395 FXColor notice; 396 FXColor error; 397 FXColor hilight; 398 FXColor link; 399 FXColor mymsg; 400 FXColor log; 401 }; 402 403 struct ColorTheme { 404 const FXchar* name; 405 FXColor base; 406 FXColor border; 407 FXColor back; 408 FXColor fore; 409 FXColor selback; 410 FXColor selfore; 411 FXColor tipback; 412 FXColor tipfore; 413 FXColor menuback; 414 FXColor menufore; 415 FXColor notifyback; 416 FXColor notifyfore; 417 FXColor shadow; 418 FXColor hilite; 419 bool operator==(const ColorTheme &theme) const 420 { 421 return base==theme.base && border==theme.border && back==theme.back && fore==theme.fore 422 && selback==theme.selback && selfore==theme.selfore && tipback==theme.tipback 423 && tipfore==theme.tipfore && menuback==theme.menuback && menufore==theme.menufore 424 && notifyback==theme.notifyback && notifyfore==theme.notifyfore 425 && shadow==theme.shadow && hilite==theme.hilite; 426 } 427 }; 428 429 struct LuaRequest { 430 LuaCommands type; 431 FXString text; 432 }; 433 434 struct LuaScript { 435 FXString path; 436 FXString name; 437 FXString version; 438 FXString description; 439 lua_State *L; 440 }; 441 442 struct LuaScriptCommand { 443 FXString name; //command name 444 FXString funcname; 445 FXString helptext; 446 FXString script; //script name 447 }; 448 449 struct LuaScriptEvent { 450 FXString name; //eventname, e.g. PRIVMSG, JOIN or ALL etc. 451 FXString funcname; 452 FXString script; //script name 453 }; 454 455 struct DccFile { 456 FXString path; 457 DCCTYPE type; 458 FXulong currentPosition; 459 FXulong speed; 460 FXulong size; 461 FXbool started; 462 FXbool canceled; 463 FXbool finished; 464 FXulong finishedPosition; //used in sending for handle user position 465 FXint token; //token passive send 466 FXString ip; //ip address 467 FXint port; 468 FXString nick; //usefull for resume 469 bool operator==(const DccFile& file) const 470 { 471 return path==file.path && type==file.type && ip==file.ip && port==file.port && token==file.token && nick==file.nick; 472 } 473 }; 474 475 struct IrcEvent { 476 IrcEventType eventType; 477 FXString param1, param2, param3, param4; 478 DccFile dccFile; 479 FXTime time; //for stored events 480 }; 481 482 typedef FXArray<IrcEngine*> dxIrcEnginesArray; 483 typedef FXArray<DccEngine*> dxDccEnginesArray; 484 typedef FXArray<FXObject*> dxTargetsArray; 485 typedef FXArray<FXString> dxStringArray; 486 typedef FXArray<NickInfo> dxNickInfoArray; 487 typedef FXArray<ServerInfo> dxServerInfoArray; 488 typedef FXArray<UserInfo> dxUserInfoArray; 489 typedef FXArray<LuaScript> dxScriptsArray; 490 typedef FXArray<LuaScriptCommand> dxScriptCommandsArray; 491 typedef FXArray<LuaScriptEvent> dxScriptEventsArray; 492 typedef FXArray<DccFile> dxDccFilesArray; 493 typedef FXArray<IrcEvent> dxIrcEventsArray; 494 typedef FXArray<dxHiliteStyle> dxHiliteArray; 495 typedef std::map<FXString,FXString> dxStringMap; 496 typedef std::pair<FXString,FXString> StringPair; 497 typedef std::map<FXString, FXString>::iterator StringIt; 498 499 #endif /* DEFS_H_ */ 500