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
|
/***************************************************************************
** xIrcConnect2.cpp $Revision: 1.14 $ - $Name: V2-0 $
** Class for making the server connections Part 2
**
** Copyright (C) 1995, 1996 Joseph Croft <jcroft@unicomp.net>
**
** This program 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 1, or (at your option)
** any later version.
**
** This program 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 this program; if not, write to the Free Software
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**
***************************************************************************/
#include <pwd.h>
#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>
#include <ctype.h>
#include <time.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <qapp.h>
#include <qkeycode.h>
#include <qmenubar.h>
#include <qsize.h>
#include <qregexp.h>
#include <xApp.h>
#include <xFileDialog.h>
#include <xLineEditQuery.h>
#include <xMessageBox.h>
#include "xIrcChannelQuery.h"
#include "xIrcMsgDispatch.h"
#include "xIrcNickQuery.h"
#include "xIrcDccFile.h"
#include "xIrcDccQuery.h"
#include "xIrcServerQuery.h"
#include "xIrcErrorBox.h"
#include "xIrcInviteBox.h"
#include "xDefaults.h"
#include "xIrcConnect.h"
static int dbg = 0;
extern xApplication *pApp;
extern xDefaults Defaults;
extern xIrcNickQuery *NickQuery;
extern xChannelQuery *ChanQuery;
extern xServerQuery *ServQuery;
extern xLineEditQuery *QuitQuery;
extern xIrcCommands ircResponses;
extern xIrcMsgDispatch Dispatcher;
void xIrcConnect::initiateDCCChat(xIrcDccChatFrame *chatFrame)
{
struct sockaddr_in addr1, addr2;
xIrcMessage msg;
char buf[512];
QString tmpStr, tmpStr1, tmpStr2;
if (pSocket == NULL)
{
xMessageBox::message("Error", "Not Connected to a Server");
return;
}
//
// Point to the port number we're accepting connections from
//
addr1 = chatFrame->socketName();
//
// Then the IP address we're talking to the network on and
// add the port we're accepting connections from
//
addr2 = pSocket->socketName();
addr2.sin_family = AF_INET;
addr2.sin_port = addr1.sin_port;
sprintf(buf, "Initiating DCC Chat (%s)", inet_ntoa(addr2.sin_addr));
pMainWin->pWin->putString(buf);
pMainWin->pWin->putString("\n");
msg.rspCode = ircResponses.code("NOTICE");
msg.dstStr = chatFrame->name();
msg.msgStr = buf;
emit msgOut(&msg);
sprintf(buf, "%cDCC CHAT chat %lu %u%c", '\x01',
ntohl(addr2.sin_addr.s_addr), ntohs(addr2.sin_port), '\x01');
pMainWin->pWin->putString(buf);
pMainWin->pWin->putString("\n");
msg.rspCode = ircResponses.code("PRIVMSG");
msg.dstStr = chatFrame->name();
msg.msgStr = buf;
emit msgOut(&msg);
}
void xIrcConnect::dccChatHandler(xIrcMessage *pMsg)
{
xIrcMessageFrame *pMsgFrame;
xIrcDccChatFrame *pDccChatFrame;
// xIrcDccFile *pDccFileFrame;
char buf[256];
int err;
const char *cp;
if (dbg) fprintf(stdout, "xIrcConnect::dccChatHandler():got response |%s| from query\n",
(const char *)pMsg->srcNick);
if (dbg) fflush(stdout);
if (pMsg->rspCode == xIrcDccQuery::Message)
{
if (dbg) fprintf(stdout, "xIrcConnect::dccChatHandler():Setting up normal chat window!\n");
if (dbg) fflush(stdout);
if ((pMsgFrame = makeNewMsgFrame(NULL, pMsg->srcNick)) != NULL)
pMsgFrame->show();
}
else if (pMsg->rspCode == xIrcDccQuery::Accepted)
{
if (dbg) fprintf(stdout, "xIrcConnect::dccChatHandler():Got Accept from Query, isolating IP from |%s|\n",
(const char *)pMsg->msgStr);
for (cp = pMsg->msgStr; isspace(*cp); cp++);
if (dbg) fprintf(stdout, "xIrcConnect::dccChatHandler():Spaces Skipped, remaining: |%s|\n", cp);
for (; !isspace(*cp); cp++);
if (dbg) fprintf(stdout, "xIrcConnect::dccChatHandler():Setting up DCC Chat to %s @ |%s|!\n",
(const char *)pMsg->srcNick, cp);
if (dbg) fflush(stdout);
if (pMsg->pmsgTyp == ipmDCCChat)
{
pDccChatFrame = new xIrcDccChatFrame(wdtPrv, NULL, pMsg->srcNick);
if (pDccChatFrame != NULL)
{
if ((err = pDccChatFrame->connectTo(cp)) == 0)
{
connect(pDccChatFrame,
SIGNAL(textSelected(xMultiLineTextSelection)),
pNickAction, SLOT(wakeUp(xMultiLineTextSelection)));
pDccChatFrame->show();
}
else
{
sprintf(buf, "Error Making DCC Connection to %s:%s",
(const char *)pMsg->srcNick, strerror(err));
xMessageBox::message("Error", buf);
delete pDccChatFrame;
}
}
}
/*
else if (pMsg->pmsgTyp == ipmDCCSend)
{
int fd;
const char *cp;
QString file;
const char *pDir;
pDir = Resources->get(wdtRes, "dcc.dir", "DCC.Dir");
for (cp = pMsg->msgStr; *(++cp) != ' ';)
file += *cp;
QString s(xFileDialog::getSaveFileName(wdtRes, pDir, file));
if (!s.isEmpty())
{
if ((fd = open(s, O_RDWR | O_CREAT, S_IRWXU | S_IRGRP)) >= 0)
{
pDccFileFrame = new xIrcDccFile(wdtPrv, NULL, pMsg->srcNick);
if (pDccFileFrame != NULL)
{
if ((err = pDccFileFrame->connectTo(cp, fd)) == 0)
pDccFileFrame->show();
else
{
sprintf(buf, "Error Making DCC Connection to %s:%s",
(const char *)pMsg->srcNick, strerror(err));
xMessageBox::message("Error", buf);
delete pDccFileFrame;
}
}
}
else
{
sprintf(buf, "Error Opening file %s:%s",
(const char *)s, strerror(errno));
xMessageBox::message("Error", buf);
delete pDccFileFrame;
}
}
}
*/
}
}
void xIrcConnect::msgQryHandler(xIrcMsgQuery *pMsgQuery)
{
xIrcMessageFrame *pMsgFrame;
xIrcMessageList *pMsgList;
xIrcMessage *pMsg, *pMsg1;
if (dbg) fprintf(stdout, "xIrcConnect::msgQryHandler():got response from query\n");
if (dbg) fflush(stdout);
// if ((msgList = pMsgQuery->getList()) != NULL)
pMsgList = pMsgQuery->getList();
if (pMsgQuery->results() == QDialog::Accepted)
{
if (dbg) fprintf(stdout, "xIrcConnect::msgQryHandler():Creating new message frame\n");
if (dbg) fflush(stdout);
pMsg = pMsgList->first();
pMsg1 = pMsg;
if ((pMsgFrame = makeNewMsgFrame(NULL, pMsg->srcNick)) != NULL)
{
if (dbg) fprintf(stdout, "xIrcConnect::msgQryHandler():Showing message frame\n");
if (dbg) fflush(stdout);
pMsgFrame->show();
for (pMsg = pMsgList->first(); pMsg != NULL; pMsg = pMsgList->next())
{
if (dbg) fprintf(stdout, "xIrcConnect::msgQryHandler():Sending message to frame\n");
if (dbg) fflush(stdout);
pMsgFrame->procServerMsg(pMsg);
}
}
}
if (dbg) fprintf(stdout, "xIrcConnect::msgQryHandler():Removing Query\n");
if (dbg) fflush(stdout);
msgQueryList.remove(pMsgQuery);
if (dbg) fprintf(stdout, "xIrcConnect::msgQryHandler():Exit()\n");
if (dbg) fflush(stdout);
}
void xIrcConnect::acceptInvite(QString strChannel)
{
ChanQuery->setText((const char *)strChannel);
newChannel();
}
void xIrcConnect::gotResponse(xIrcMessage *pMsg)
{
xIrcMessageFrame *pMsgFrame;
xIrcMsgQuery *pMsgQry;
xIrcMessage msg;
char str[120];
int x;
if (dbg) fprintf(stdout, "xIrcConnect::gotResponse():msgTyp = %d\n", (int)pMsg->pmsgTyp);
if (dbg) fprintf(stdout, "xIrcConnect::gotResponse():rspCode = %d\n", (int)pMsg->rspCode);
if (dbg) fprintf(stdout, "xIrcConnect::gotResponse():rspStr = %s\n", (const char *)pMsg->rspStr);
if (dbg) fprintf(stdout, "xIrcConnect::gotResponse():srcNick = %s\n", (const char *)pMsg->srcNick);
if (dbg) fprintf(stdout, "xIrcConnect::gotResponse():srcAddr = %s\n", (const char *)pMsg->srcAddr);
if (dbg) fprintf(stdout, "xIrcConnect::gotResponse():dstStr = %s\n", (const char *)pMsg->dstStr);
if (dbg) fprintf(stdout, "xIrcConnect::gotResponse():msgStr = %s\n", (const char *)pMsg->msgStr);
if (dbg) fprintf(stdout, "xIrcConnect::gotResponse():rawMsg = %s\n", (const char *)pMsg->rawMsg);
if (dbg) fflush(stdout);
pSocketBox->hide();
if (Dispatcher.proccessResponse(pMsg) == TRUE)
return;
if (isMsg(pMsg->rspCode, "NICK"))
{
if (dbg) fprintf(stdout, "xIrcConnect::gotResponse():A Nick is Changing!\n");
if (dbg) fflush(stdout);
if (dbg) fprintf(stdout, "xIrcConnect::gotResponse():Check for any windows w/ the old nick!\n");
if (dbg) fflush(stdout);
for (x = 0, pMsgFrame = pIrcMsgFrames; pMsgFrame; pMsgFrame = pMsgFrame->next())
{
if (dbg) fprintf(stdout, "xIrcConnect::gotResponse():Testing window |%s|\n", (char *)pMsgFrame->name());
if (dbg) fflush(stdout);
if (strlen(pMsgFrame->name()) > 0 &&
pMsgFrame->is((const char *)pMsg->srcNick))
{
if (dbg) fprintf(stdout, "xIrcConnect::gotResponse():Found a Match!!!\n");
if (dbg) fflush(stdout);
pMsgFrame->newName((const char *)pMsg->dstStr);
sprintf(str, "\x02*** %s is now known as %s\n",
(const char *)pMsg->srcNick,
(const char *)pMsg->dstStr);
pMsgFrame->putString(str);
}
}
}
/*
if ((pMsg->rspCode == 352 || pMsg->rspCode == 315) &&
pNotify->gotNotification(pMsg) == TRUE)
{
return;
}
*/
if (isMsg(pMsg->rspCode, "INVITE"))
{
if (dbg) fprintf(stdout, "xIrcConnect::gotResponse():Got invitation!\n");
if (dbg) fflush(stdout);
xIrcInviteBox *pIB = new xIrcInviteBox(wdtPrv, NULL, "Invite", this,
SLOT(acceptInvite(QString)),
pMsg);
pIB->show();
return;
}
if (pIgnore->list()->matches(pMsg))
{
xIrcPeopleEntry *p;
if ((p = pIgnore->list()->entry(pMsg)) != NULL)
{
if (p->flag() != 0)
{
showResponse(pMsg);
return;
}
}
}
for (x = 0, pMsgFrame = pIrcMsgFrames; pMsgFrame; pMsgFrame = pMsgFrame->next())
{
QRegExp regexp( " .*" );
QString tempName((char*)pMsgFrame->name());
tempName.replace( regexp, "");
pMsgFrame->setName((const char *)tempName);
if (dbg) fprintf(stdout, "xIrcConnect::gotResponse():testing window |%s|\n", (char *)pMsgFrame->name());
if (dbg) fflush(stdout);
if (strlen(pMsgFrame->name()) > 0 && pMsgFrame->procServerMsg(pMsg))
{
if (dbg) fprintf(stdout, "xIrcConnect::gotResponse():Matched!!!\n");
if (dbg) fflush(stdout);
x++;
break;
}
if (dbg) fprintf(stdout, "xIrcConnect::gotResponse():Done\n");
if (dbg) fflush(stdout);
}
if (x == 0 & dbg) fprintf(stdout, "xIrcConnect::gotResponse():Testing if new PRIVMSG\n");
if (dbg) fflush(stdout);
if (x == 0 && ((!isMsg(pMsg->rspCode, "PRIVMSG") &&
!isMsg(pMsg->rspCode, "NOTICE")) ||
strlen(pMsg->srcNick) == 0))
{
if (dbg) fprintf(stdout, "xIrcConnect::gotResponse():Not new PRIVMSG\n");
if (dbg) fflush(stdout);
if ((pMsg->rspCode >= IRCRESP_First && pMsg->rspCode <= IRCRESP_Last) ||
(pMsg->rspCode < 400))
showResponse(pMsg);
else
showError(pMsg);
}
else if (x == 0)
{
if (!isMsg(pMsg->rspCode, "NOTICE") ||
strstr((const char *)pMsg->msgStr, "DCC Chat") == NULL)
{
if (dbg) fprintf(stdout, "xIrcConnect::gotResponse():is new PRIVMSG\n");
if (dbg) fflush(stdout);
if (!doSpecialMessage(pMsg))
{
if ((pMsgQry = msgQueryList.find(pMsg)) != NULL)
pMsgQry->add(pMsg);
else
{
if (dbg) fprintf(stdout, "xIrcConnect::gotResponse():Starting New message queryQuery\n");
if (dbg) fflush(stdout);
if ((pMsgQry = new xIrcMsgQuery(wdtPrv)) != NULL)
{
msgQueryList.append(pMsgQry);
connect(pMsgQry, SIGNAL(done(xIrcMsgQuery *)),
this, SLOT(msgQryHandler(xIrcMsgQuery *)));
pMsgQry->add(pMsg);
pMsgQry->show();
}
}
}
}
else if (isMsg(pMsg->rspCode, "NOTICE"))
doSpecialMessage(pMsg);
}
if (dbg) fprintf(stdout, "xIrcConnect::gotResponse():Exit\n");
if (dbg) fflush(stdout);
}
xIrcMessageFrame *xIrcConnect::findMsgFrame(const char *pName)
{
int x;
xIrcMessageFrame *rv;
QString nameTmp1, nameTmp2;
char name[20];
nameTmp1 = pName;
nameTmp1.upper();
if (dbg) fprintf(stdout, "xIrcConnect::findMsgFrame():Looking for %s\n", (const char *)nameTmp1);
if (dbg) fflush(stdout);
for (x = 0, rv = pIrcMsgFrames; rv != NULL; rv = rv->next())
{
nameTmp2 = rv->name();
nameTmp2.upper();
strcpy(name, (const char*)nameTmp2);
if (dbg) fprintf(stdout, "xIrcConnect::findMsgFrame():Testing %s\n", name);
if (dbg) fflush(stdout);
if (strcmp((const char *)nameTmp1, name) == 0)
{
if (dbg) fprintf(stdout, "xIrcConnect::findMsgFrame():Have match!!\n");
if (dbg) fflush(stdout);
break;
}
}
if (dbg) fprintf(stdout, "xIrcConnect::findMsgFrame():Exit(%d)\n", (int)rv);
if (dbg) fflush(stdout);
return(rv);
}
bool xIrcConnect::doSpecialMessage(xIrcMessage *pMsg)
{
xIrcDccQuery *pMsgQry;
xIrcMessage msg;
bool rv = FALSE;
const char *cp;
char str[400], *cp1;
if (dbg) fprintf(stdout, "xIrcConnect::doSpecial():Enter\n");
if (dbg) fflush(stdout);
switch (pMsg->pmsgTyp)
{
case ipmPing:
if (isMsg(pMsg->rspCode, "NOTICE"))
{
long pingTime = time(NULL) - atol(pMsg->msgStr);
long pingMins = pingTime / 60;
long pingSecs = pingTime % 60;
if (pingMins > 0)
sprintf(str, "*** Ping from %s: %ld:%02ld minutes\n",
(const char *)pMsg->srcNick,
pingMins, pingSecs);
else
sprintf(str, "*** Ping from %s: %ld seconds\n",
(const char *)pMsg->srcNick, pingSecs);
pMainWin->pWin->putString(str);
/*
sprintf(str, "*** Ping from %s: %s\n", (const char *)pMsg->srcNick,
(const char *)pMsg->msgStr);
*/
}
else if (isMsg(pMsg->rspCode, "PRIVMSG"))
{
sprintf(str, "*** Pinged by %s\n", (const char *)pMsg->srcNick);
pMainWin->pWin->putString(str);
for (cp = (const char *)pMsg->msgStr, cp1 = str; *cp; cp++)
if (*cp >= ' ')
{
*(cp1++) = *cp;
*cp1 = '\0';
}
msg.rspCode = ircResponses.code("NOTICE");
msg.dstStr = pMsg->srcNick;
msg.msgStr = "\x01";
msg.msgStr += "PING ";
msg.msgStr += str;
msg.msgStr += "\x01";
if (dbg) fprintf(stdout, "xIrcConnect::doSpecial():Sending |%s| to Socket\n",
(const char *)msg.msgStr);
if (dbg) fflush(stdout);
emit msgOut(&msg);
}
rv = TRUE;
break;
case ipmDCCChat:
if (dbg) fprintf(stdout, "xIrcConnect::doSpecial():Got DCC Chat Request!\n");
if (dbg) fflush(stdout);
if ((pMsgQry = new xIrcDccQuery(wdtPrv)) != NULL)
{
connect(pMsgQry, SIGNAL(done(xIrcMessage *)), this, SLOT(dccChatHandler(xIrcMessage *)));
pMsgQry->setupQuery("Chat", pMsg);
}
if (dbg) fprintf(stdout, "xIrcConnect::doSpecial():Waiting Query Response!\n");
if (dbg) fflush(stdout);
rv = TRUE;
break;
case ipmDCCSend:
/*
if (dbg) fprintf(stdout, "xIrcConnect::doSpecial():Got DCC Send Request!\n");
if (dbg) fflush(stdout);
if ((pMsgQry = new xIrcDccQuery(wdtPrv)) != NULL)
{
QString file("Send: ");
const char *cp;
for (cp = pMsg->msgStr; *(++cp) != ' ';)
file += *cp;
connect(pMsgQry, SIGNAL(done(xIrcMessage *)), this, SLOT(dccChatHandler(xIrcMessage *)));
pMsgQry->setupQuery(file, pMsg);
}
if (dbg) fprintf(stdout, "xIrcConnect::doSpecial():Waiting Query Response!\n");
if (dbg) fflush(stdout);
rv = TRUE;
break;
*/
case ipmDCC:
if (dbg) fprintf(stdout, "xIrcConnect::doSpecial():Got DCC Request!\n");
if (dbg) fflush(stdout);
sprintf(str, "* %s %s", (const char *)pMsg->srcNick, (const char *)pMsg->msgStr);
pMainWin->pWin->putString(str);
if (isMsg(pMsg->rspCode, "PRIVMSG"))
{
if (dbg) fprintf(stdout, "xIrcConnect::doSpecial():It's a PRIVMSG DCC message\n");
if (dbg) fflush(stdout);
if ((cp = Defaults.get("DCC_RESPONSE")) != NULL)
{
if (dbg) fprintf(stdout, "xIrcConnect::doSpecial():Found DCC_RESPONSE Default\n");
if (dbg) fflush(stdout);
msg.rspCode = ircResponses.code("PRIVMSG");
msg.dstStr = pMsg->srcNick;
msg.msgStr = cp;
if (dbg) fprintf(stdout, "xIrcConnect::doSpecial():Sending |%s| to Socket\n",
(const char *)msg.msgStr);
if (dbg) fflush(stdout);
emit msgOut(&msg);
if (pMsg->pmsgTyp == ipmDCCSend)
{
if (dbg) fprintf(stdout, "xIrcConnect::doSpecial():Was a DCC Send request!\n");
if (dbg) fflush(stdout);
if ((cp = Defaults.get("DCC_SEND_RESPONSE")) != NULL)
{
msg.rspCode = ircResponses.code("PRIVMSG");
msg.dstStr = pMsg->srcNick;
msg.msgStr = cp;
if (dbg) fprintf(stdout, "xIrcConnect::doSpecial():Sending |%s| to Socket\n",
(const char *)msg.msgStr);
if (dbg) fflush(stdout);
emit msgOut(&msg);
}
}
}
}
rv = TRUE;
break;
case ipmVersion:
if (isMsg(pMsg->rspCode, "PRIVMSG"))
{
msg.rspCode = ircResponses.code("NOTICE");
msg.dstStr = pMsg->srcNick;
msg.msgStr = "\x01";
msg.msgStr += "VERSION xIrc $Name: V2-0 $";
msg.msgStr += "\x01";
emit msgOut(&msg);
}
else
showResponse(pMsg);
rv = TRUE;
break;
case ipmUserInfo:
if (isMsg(pMsg->rspCode, "PRIVMSG"))
{
msg.rspCode = ircResponses.code("NOTICE");
msg.dstStr = pMsg->srcNick;
msg.msgStr = "\x01";
msg.msgStr += "USERINFO ";
if ((cp = Defaults.get("USERINFO")) != NULL)
msg.msgStr += cp;
else
msg.msgStr += "None Available";
msg.msgStr += "\x01";
emit msgOut(&msg);
}
else
showResponse(pMsg);
rv = TRUE;
break;
case ipmSource:
if (isMsg(pMsg->rspCode, "PRIVMSG"))
{
msg.rspCode = ircResponses.code("NOTICE");
msg.dstStr = pMsg->srcNick;
msg.msgStr = "\x01";
msg.msgStr += "SOURCE ";
if ((cp = Defaults.get("SOURCEINFO")) != NULL)
msg.msgStr += cp;
else
msg.msgStr += "sunsite.unc.edu:/pub/linux/X11/system/network/chat/xIrc-X.X.tar.gz xIrc-X.X.lsm or ";
msg.msgStr += "http:www.dfw.net/~croftj";
msg.msgStr += "\x01";
emit msgOut(&msg);
msg.rspCode = ircResponses.code("NOTICE");
msg.dstStr = pMsg->srcNick;
msg.msgStr = "\x01";
msg.msgStr += "SOURCE";
msg.msgStr += "\x01";
emit msgOut(&msg);
}
else
showResponse(pMsg);
rv = TRUE;
break;
case ipmFinger:
if (isMsg(pMsg->rspCode, "PRIVMSG"))
{
msg.rspCode = ircResponses.code("NOTICE");
msg.dstStr = pMsg->srcNick;
msg.msgStr = "\x01";
msg.msgStr += "FINGER ";
sprintf(str, "%s", (const char *)realName);
msg.msgStr += str;
msg.msgStr += "\x01";
emit msgOut(&msg);
}
else
showResponse(pMsg);
rv = TRUE;
break;
case ipmClientInfo:
case ipmErrMsg:
case ipmTime:
showResponse(pMsg);
rv = TRUE;
break;
default:
rv = FALSE;
break;
}
return(rv);
}
xIrcMessageFrame *xIrcConnect::makeNewMsgFrame(QWidget *pParent, const char *pName)
{
xIrcMessageFrame *rv, *pMsg;
rv = NULL;
/*
if (pIrcMsgFrames != NULL)
{
if (dbg) fprintf(stdout, "xIrcConnect::makeNewMsgFrame():Testing for unused Irc Frame\n");
if (dbg) fflush(stdout);
for (rv = pIrcMsgFrames; rv != NULL; rv = rv->next())
{
if (strlen(rv->name()) == 0)
{
if (dbg) fprintf(stdout, "xIrcConnect::makeNewMsgFrame():Found one!!!!\n");
if (dbg) fflush(stdout);
rv->newName((char *)pName);
// rv->reset();
break;
}
}
}
*/
if (rv == NULL && (rv = new xIrcMessageFrame(wdtPrv, pParent, pName)) != NULL)
{
if (pIrcMsgFrames != NULL)
{
if (dbg) fprintf(stdout, "xIrcConnect::makeNewMsgFrame():New Message Frame at %d\n", (int)rv);
if (dbg) fflush(stdout);
for (pMsg = pIrcMsgFrames; pMsg->next() != NULL; pMsg = pMsg->next());
pMsg->link(rv);
}
else
pIrcMsgFrames = rv;
if (dbg) fprintf(stdout, "xIrcConnect::makeNewMsgFrame():Connecting xNickActionQuery Signals/slots\n");
if (dbg) fflush(stdout);
connect(rv, SIGNAL(textSelected(xMultiLineTextSelection)),
pNickAction, SLOT(wakeUp(xMultiLineTextSelection)));
if (dbg) fprintf(stdout, "xIrcConnect::makeNewMsgFrame():Connecting keybord to Socket!\n");
if (dbg) fflush(stdout);
connect(rv, SIGNAL(ircMsgFrameClosing(xIrcMessageFrame*)),
this, SLOT(ircMsgFrameClosing(xIrcMessageFrame*)));
connect(rv, SIGNAL(ircMessageOut(xIrcMessage*)),
this, SLOT(sendMessage(xIrcMessage*)));
connect(rv, SIGNAL(chatRequest()),
this, SLOT(newChannel()));
}
else if (rv == NULL)
fprintf(stderr, "Cannot allocate IRC Message Frame!\n");
if (dbg) fprintf(stdout, "xIrcConnect::makeNewMsgFrame():Exit(%d)\n", (int)rv);
if (dbg) fflush(stdout);
return(rv);
}
void xIrcConnect::ircMsgFrameClosing(xIrcMessageFrame *pMF)
{
if (pIrcMsgFrames == pMF)
pIrcMsgFrames = pMF->next();
disconnect(this, NULL, pMF, NULL);
// disconnect((QObject*)this, NULL, (QObject*)pMF, (char *)NULL);
}
|