1 #ifndef _KVI_CHANNEL_H_ 2 #define _KVI_CHANNEL_H_ 3 //============================================================================= 4 // 5 // File : KviChannelWindow.h 6 // Creation date : Tue Aug 1 2000 01:42:00 by Szymon Stefanek 7 // 8 // This file is part of the KVIrc IRC client distribution 9 // Copyright (C) 2000-2011 Szymon Stefanek (pragma at kvirc dot net) 10 // 11 // This program is FREE software. You can redistribute it and/or 12 // modify it under the terms of the GNU General Public License 13 // as published by the Free Software Foundation; either version 2 14 // of the License, or (at your option) any later version. 15 // 16 // This program is distributed in the HOPE that it will be USEFUL, 17 // but WITHOUT ANY WARRANTY; without even the implied warranty of 18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 19 // See the GNU General Public License for more details. 20 // 21 // You should have received a copy of the GNU General Public License 22 // along with this program. If not, write to the Free Software Foundation, 23 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 24 // 25 //============================================================================= 26 27 /** 28 * \file KviChannelWindow.h 29 * \author Szymon Stefanek 30 * \brief Channel widget: abstraction of an IRC channel 31 */ 32 33 #include "kvi_settings.h" 34 #include "KviConsoleWindow.h" 35 #include "KviWindow.h" 36 #include "KviIrcUserDataBase.h" 37 #include "KviPixmap.h" 38 #include "KviUserListView.h" 39 #include "KviTimeUtils.h" 40 #include "KviModeWidget.h" 41 42 #include <QDateTime> 43 #include <QList> 44 #include <QString> 45 #include <QStringList> 46 #include <QToolButton> 47 48 #include <map> 49 #include <vector> 50 51 class KviConsoleWindow; 52 class KviIrcMask; 53 class KviMaskEditor; 54 class KviModeEditor; 55 class KviTalHBox; 56 class KviThemedLabel; 57 class KviTopicWidget; 58 59 #ifdef COMPILE_ON_WINDOWS 60 // windows compiler wants this instead of the forward decl 61 #include "KviMaskEditor.h" 62 #else 63 struct KviMaskEntry; // KviMaskEditor.h 64 #endif 65 66 /** 67 * \def KVI_CHANNEL_AVERAGE_USERS The average channel users of a channel 68 * \def KVI_CHANNEL_ACTION_HISTORY_MAX_COUNT Maximum actions count we keep in memory 69 * \def KVI_CHANNEL_ACTION_HISTORY_MAX_TIMESPAN Timespan of the oldest action we keep in memory (600 secs = 10 mins) 70 */ 71 #define KVI_CHANNEL_ACTION_HISTORY_MAX_COUNT 40 72 #define KVI_CHANNEL_ACTION_HISTORY_MAX_TIMESPAN 600 73 74 #ifndef KVI_CHANNEL_AVERAGE_USERS 75 #define KVI_CHANNEL_AVERAGE_USERS 101 76 #endif 77 78 /** 79 * \struct _KviChannelAction 80 * \brief A struct which holds the channel actions 81 */ 82 struct KviChannelAction 83 { 84 QString szNick; // action source nick 85 unsigned int uActionType; // type of the action 86 kvi_time_t tTime; // time of the action 87 int iTemperature; // temperature of the action 88 }; 89 90 /** 91 * \struct _KviChannelActivityStats 92 * \brief A struct which holds the activity stats 93 */ 94 struct KviChannelActivityStats 95 { 96 unsigned int uActionCount; // number of actions in the history 97 bool bStatsInaccurate; // the stats are inaccurate because we have just joined the chan 98 unsigned int uLastActionTimeSpan; // the timespan between the last action and now 99 unsigned int uFirstActionTimeSpan; // the time span between the first and the last action 100 double dActionsPerMinute; // average number of actions per minute in the lastActionTimeSpan 101 unsigned int uActionsInTheLastMinute; // number of actions in the last minute 102 int iAverageActionTemperature; // the average chan temperature 103 unsigned int uHotActionCount; 104 unsigned int uHotActionPercent; 105 QStringList lTalkingUsers; // users that seem to be talking NOW 106 QStringList lWereTalkingUsers; 107 }; 108 109 /** 110 * \class KviChannelWindow 111 * \brief The class which manages a channel 112 */ 113 class KVIRC_API KviChannelWindow : public KviWindow 114 { 115 Q_OBJECT 116 public: 117 /** 118 * \enum StateFlag 119 * \brief Holds the state flags of the channel 120 */ 121 enum StateFlag 122 { 123 HaveAllNames = 1, /**< Flag for "have all names" */ 124 HaveWhoList = (1 << 2), /**< Flag for "have WHO list" */ 125 DeadChan = (1 << 3), /**< Flag for "dead channel" */ 126 SentWhoRequest = (1 << 4), /**< Flag to set WHO request */ 127 SentPart = (1 << 5), /**< Flag to set PART request */ 128 Synchronized = (1 << 6), /**< Flag to set SYNC request */ 129 NoCloseOnPart = (1 << 7), /**< Flag to set no close on part */ 130 SentSyncWhoRequest = (1 << 8) /**< Flag for SYNC request */ 131 }; 132 133 /** 134 * \enum ActivityLimit 135 * \brief Holds the limits of the activity in a channel 136 */ 137 enum ActivityLimit 138 { 139 Ice = 5, /**< The limit to be "ice" */ 140 VeryCold = 10, /**< The limit to be "very cold" */ 141 Cold = 20, /**< The limit to be "cold" */ 142 Undefined = 30, /**< The limit to be "undefined" */ 143 Hot = 50, /**< The limit to be "hot" */ 144 VeryHot = 70 /**< The limit to be "very hot" */ 145 }; 146 147 /** 148 * \brief Constructs the channel object 149 * \param lpConsole The console of the context 150 * \param szName The name of the channel 151 * \return KviChannelWindow 152 */ 153 KviChannelWindow(KviConsoleWindow * lpConsole, const QString & szName); 154 155 /** 156 * \brief Destroys the channel object 157 */ 158 ~KviChannelWindow(); 159 160 protected: 161 KviTalSplitter * m_pTopSplitter; 162 KviTalSplitter * m_pVertSplitter; 163 QToolButton * m_pDoubleViewButton; 164 KviWindowToolPageButton * m_pListViewButton; 165 KviWindowToolPageButton * m_pModeEditorButton; 166 std::map<char, KviWindowToolPageButton *> m_ListEditorButtons; 167 std::map<char, KviMaskEditor *> m_ListEditors; 168 KviModeEditor * m_pModeEditor; 169 KviIrcView * m_pMessageView; 170 KviTopicWidget * m_pTopicWidget; 171 KviUserListView * m_pUserListView; 172 KviModeWidget * m_pModeWidget; 173 int m_iStateFlags; 174 QString m_szSentModeRequests; 175 QString m_szChannelMode; 176 std::map<char, QString> m_szChannelParameterModes; 177 std::map<char, std::vector<KviMaskEntry *>> m_ModeLists; 178 KviPixmap m_privateBackground; 179 QDateTime m_joinTime; 180 QString m_szNameWithUserFlag; 181 QStringList * m_pTmpHighLighted; 182 unsigned int m_uActionHistoryHotActionCount; 183 QList<KviChannelAction *> m_lActionHistory; 184 kvi_time_t m_tLastReceivedWhoReply; 185 QList<int> m_VertSplitterSizesList; 186 QList<int> m_SplitterSizesList; 187 KviTalHBox * m_pButtonContainer; 188 189 public: 190 /** 191 * \brief Returns the user listview object 192 * \return KviUserListView * 193 */ userListView()194 KviUserListView * userListView() { return m_pUserListView; }; 195 196 /** 197 * \brief Returns the topic widget object 198 * \return KviTopicWidget * 199 */ topicWidget()200 KviTopicWidget * topicWidget() { return m_pTopicWidget; }; 201 202 /** 203 * \brief Returns the irc view object 204 * \return KviIrcView * 205 */ messageView()206 KviIrcView * messageView() const { return m_pMessageView; }; 207 208 /** 209 * \brief Returns the button container object 210 * \return QFrame * 211 */ buttonContainer()212 QFrame * buttonContainer() override { return (QFrame *)m_pButtonContainer; } 213 214 /** 215 * \brief Returns a list of masks for a specific mode 216 * \return const std::vector<KviMaskEntry *> & 217 */ modeMasks(char cMode)218 const std::vector<KviMaskEntry *> & modeMasks(char cMode) const 219 { 220 static const std::vector<KviMaskEntry *> EMPTY_VECTOR; 221 const auto it = m_ModeLists.find(cMode); 222 if(it != m_ModeLists.end()) 223 return it->second; 224 return EMPTY_VECTOR; 225 }; 226 227 /** 228 * \brief Returns the first selected nickname in the userlist 229 * \return QString * 230 */ firstSelectedNickname()231 QString * firstSelectedNickname() { return m_pUserListView->firstSelectedNickname(); }; 232 233 /** 234 * \brief Returns the next selected nickname in the userlist 235 * \return QString * 236 */ nextSelectedNickname()237 QString * nextSelectedNickname() { return m_pUserListView->nextSelectedNickname(); }; 238 239 /** 240 * \brief Returns the name of the channel 241 * \return const QString & 242 */ target()243 const QString & target() override { return windowName(); } 244 245 /** 246 * \brief Returns the name of the channel with user flags 247 * \return const QString & 248 */ nameWithUserFlag()249 const QString & nameWithUserFlag() { return m_szNameWithUserFlag; }; 250 251 /** 252 * \brief Gets the channel activity stats and put them in the buffer 253 * \param pStats The buffer where to store the data 254 * \return void 255 */ 256 void getChannelActivityStats(KviChannelActivityStats * pStats); 257 258 /** 259 * \brief Returns the number of selected users 260 * \return int 261 */ selectedCount()262 int selectedCount() { return m_pUserListView->selectedCount(); }; 263 264 /** 265 * \brief Returns the number of users with chanowner status 266 * \return int 267 */ chanOwnerCount()268 int chanOwnerCount() { return m_pUserListView->chanOwnerCount(); }; 269 270 /** 271 * \brief Returns the number of users with chanadmin status 272 * \return int 273 */ chanAdminCount()274 int chanAdminCount() { return m_pUserListView->chanAdminCount(); }; 275 276 /** 277 * \brief Returns the number of users with op status 278 * \return int 279 */ opCount()280 int opCount() { return m_pUserListView->opCount(); }; 281 282 /** 283 * \brief Returns the number of users with halfop status 284 * \return int 285 */ halfOpCount()286 int halfOpCount() { return m_pUserListView->halfOpCount(); }; 287 288 /** 289 * \brief Returns the number of users with voice status 290 * \return int 291 */ voiceCount()292 int voiceCount() { return m_pUserListView->voiceCount(); }; 293 294 /** 295 * \brief Returns the number of users with userop status 296 * \return int 297 */ userOpCount()298 int userOpCount() { return m_pUserListView->userOpCount(); }; 299 300 /** 301 * \brief Returns the number of users 302 * \return unsigned int 303 */ count()304 unsigned int count() { return m_pUserListView->count(); }; 305 306 /** 307 * \brief Returns the number of masks is a channel mode list 308 * \return size_t 309 */ maskCount(char cMode)310 size_t maskCount(char cMode) const { return this->modeMasks(cMode).size(); }; 311 312 /** 313 * \brief Called when someone sets a channel mode that is stored in a list; these modes require a parameter that is tipically a mask 314 * 315 * Examples: 316 * - b: ban with mask 317 * - e: ban exception with mask 318 * - I: invite exception with mask 319 * - q: channel owner with nick (unreal) or quiet ban (ircd-seven) 320 * - g: spam filter word (inspircd) 321 * \param cMode The type of the mask 322 * \param szMask The mask set (more generically, the parameter) 323 * \param bAdd Whether to add or remove the mask 324 * \param szSetBy Who set the mask 325 * \param uSetAt The datetime when the mask was set 326 * \param szChangeMask If bAdd is false and this string is set, the mask will be updated instead that removed 327 * \return void 328 */ 329 void setModeInList(char cMode, const QString & szMask, bool bAdd, const QString & szSetBy, unsigned int uSetAt, QString szChangeMask = QString()); 330 331 /** 332 * \brief Returns the time of the last received WHO reply 333 * \return kvi_time_t 334 */ lastReceivedWhoReply()335 kvi_time_t lastReceivedWhoReply() { return m_tLastReceivedWhoReply; }; 336 337 /** 338 * \brief Sets the time of the last received WHO reply 339 * \param tTime The source time 340 * \return void 341 */ setLastReceivedWhoReply(kvi_time_t tTime)342 void setLastReceivedWhoReply(kvi_time_t tTime) { m_tLastReceivedWhoReply = tTime; }; 343 344 /** 345 * \brief Returns true if we have sent the sync WHO request 346 * \return bool 347 */ sentSyncWhoRequest()348 bool sentSyncWhoRequest() { return (m_iStateFlags & SentSyncWhoRequest); }; 349 350 /** 351 * \brief Sets the sync WHO request flag 352 * \return void 353 */ setSentSyncWhoRequest()354 void setSentSyncWhoRequest() { m_iStateFlags |= SentSyncWhoRequest; }; 355 356 /** 357 * \brief Clears the sync WHO request flag 358 * \return void 359 */ clearSentSyncWhoRequest()360 void clearSentSyncWhoRequest() { m_iStateFlags ^= SentSyncWhoRequest; }; 361 362 /** 363 * \brief Returns true if we have sent the WHO request 364 * \return bool 365 */ sentWhoRequest()366 bool sentWhoRequest() { return (m_iStateFlags & SentWhoRequest); }; 367 368 /** 369 * \brief Sets the WHO request flag 370 * \return void 371 */ setSentWhoRequest()372 void setSentWhoRequest() { m_iStateFlags |= SentWhoRequest; }; 373 374 /** 375 * \brief Returns true if we have sent a list request for a specific channel mode 376 * \return bool 377 */ sentListRequest(char cMode)378 bool sentListRequest(char cMode) { return m_szSentModeRequests.contains(cMode); }; 379 380 /** 381 * \brief Sets the "sent request" flag for a specific channel mode 382 * \return void 383 */ setSentListRequest(char cMode)384 void setSentListRequest(char cMode) { m_szSentModeRequests.append(cMode); }; 385 386 /** 387 * \brief Clears the "sent request" flag for a specific chanel mode 388 * \return void 389 */ setListRequestDone(char cMode)390 void setListRequestDone(char cMode) 391 { 392 m_szSentModeRequests.remove(cMode); 393 checkChannelSync(); 394 }; 395 396 /** 397 * \brief Returns true if the channel has all names 398 * \return bool 399 */ hasAllNames()400 bool hasAllNames() { return (m_iStateFlags & HaveAllNames); }; 401 402 /** 403 * \brief Sets the existence of all names 404 * \return void 405 */ setHasAllNames()406 void setHasAllNames() 407 { 408 m_iStateFlags |= HaveAllNames; 409 checkChannelSync(); 410 }; 411 412 /** 413 * \brief Returns true if the channel has an invite list 414 * \return bool 415 */ hasInviteList()416 bool hasInviteList() { return m_ModeLists.count('I'); }; 417 418 /** 419 * \brief Returns true if the channel has a WHO list 420 * \return bool 421 */ hasWhoList()422 bool hasWhoList() { return (m_iStateFlags & HaveWhoList); }; 423 424 /** 425 * \brief Sets the existence of the WHO list 426 * \return void 427 */ setHasWhoList()428 void setHasWhoList() 429 { 430 m_iStateFlags |= HaveWhoList; 431 checkChannelSync(); 432 }; 433 434 /** 435 * \brief Returns true if the channel has a ban list 436 * \return bool 437 */ hasBanList()438 bool hasBanList() { return m_ModeLists.count('b'); }; 439 440 /** 441 * \brief Returns true if the channel has a ban exception list 442 * \return bool 443 */ hasBanExceptionList()444 bool hasBanExceptionList() { return m_ModeLists.count('e'); }; 445 446 /** 447 * \brief Returns true if the channel has a quiet ban list 448 * \return bool 449 */ hasQuietBanList()450 bool hasQuietBanList() { return m_ModeLists.count('q'); }; 451 452 /** 453 * \brief Returns true if the channel has to be closed on part 454 * \return bool 455 */ closeOnPart()456 bool closeOnPart() { return !(m_iStateFlags & NoCloseOnPart); }; 457 458 /** 459 * \brief Called when we want to part a channel 460 * \param bCloseOnPart Whether to leave channel open after part 461 * \param bShowMessage Whether to show part message 462 * \return void 463 */ 464 void partMessageSent(bool bCloseOnPart = true, bool bShowMessage = true); 465 466 /** 467 * \brief Colors the icon who tells how much activity there is 468 * \param puActivityValue The value of the activity 469 * \param puActivityTemperature The temperature of the activity 470 * \return bool 471 */ 472 bool activityMeter(unsigned int * puActivityValue, unsigned int * puActivityTemperature) override; 473 474 /** 475 * \brief Sets the channel as dead 476 * \return void 477 */ 478 void setDeadChan(); 479 480 /** 481 * \brief Returns true if the channel is dead 482 * \return bool 483 */ isDeadChan()484 bool isDeadChan() { return (m_iStateFlags & DeadChan); }; 485 486 /** 487 * \brief Sets the channel as alive 488 * \return void 489 */ 490 void setAliveChan(); 491 492 /** 493 * \brief Prepends the user flag to the nickname 494 * \param szNick The nickname of the user 495 * \param szBuffer The buffer :) 496 * \return void 497 */ prependUserFlag(const QString & szNick,QString & szBuffer)498 void prependUserFlag(const QString & szNick, QString & szBuffer) { m_pUserListView->prependUserFlag(szNick, szBuffer); }; 499 500 /** 501 * \brief Returns the flag of a user 502 * \param szNick The nick of the user 503 * \return char 504 */ getUserFlag(const QString & szNick)505 char getUserFlag(const QString & szNick) { return m_pUserListView->getUserFlag(szNick); }; 506 507 /** 508 * \brief Returns the size of the channel 509 * \return QSize 510 */ 511 QSize sizeHint() const override; 512 513 /** 514 * \brief Enables or disable the userlist updates 515 * \param bEnable Whether to enable the updates 516 * \return void 517 */ enableUserListUpdates(bool bEnable)518 void enableUserListUpdates(bool bEnable) { m_pUserListView->enableUpdates(bEnable); }; 519 520 /** 521 * \brief Called when a user joins the channel 522 * \param szNick The nickname of the user 523 * \param szUser The username of the user 524 * \param szHost The hostname of the user 525 * \param iFlags The flags of the user 526 * \return KviUserListEntry * 527 */ 528 KviUserListEntry * join(const QString & szNick, const QString & szUser = QString(), const QString & szHost = QString(), int iFlags = 0) { return m_pUserListView->join(szNick, szUser, szHost, iFlags); }; 529 530 /** 531 * \brief Returns true if the avatar of a user is changed 532 * \param szNick The nickname of the user 533 * \return bool 534 */ avatarChanged(const QString & szNick)535 bool avatarChanged(const QString & szNick) { return m_pUserListView->avatarChanged(szNick); }; 536 537 /** 538 * \brief Sets the chan owner mode 539 * \param szNick The nick to set the mode on 540 * \param bChanOwner Whether to set or unset the mode on the user 541 * \return bool 542 */ setChanOwner(const QString & szNick,bool bChanOwner)543 bool setChanOwner(const QString & szNick, bool bChanOwner) { return m_pUserListView->setChanOwner(szNick, bChanOwner); }; 544 545 /** 546 * \brief Sets the chan admin mode 547 * \param szNick The nick to set the mode on 548 * \param bChanAdmin Whether to set or unset the mode on the user 549 * \return bool 550 */ setChanAdmin(const QString & szNick,bool bChanAdmin)551 bool setChanAdmin(const QString & szNick, bool bChanAdmin) { return m_pUserListView->setChanAdmin(szNick, bChanAdmin); }; 552 553 /** 554 * \brief Sets the operator mode 555 * \param szNick The nick to set the mode on 556 * \param bOp Whether to set or unset the mode on the user 557 * \param bIsMe Whether the user opped is us 558 * \return bool 559 */ 560 bool setOp(const QString & szNick, bool bOp, bool bIsMe); 561 562 /** 563 * \brief Sets the half operator mode 564 * \param szNick The nick to set the mode on 565 * \param bHalfOp Whether to set or unset the mode on the user 566 * \return bool 567 */ setHalfOp(const QString & szNick,bool bHalfOp,bool)568 bool setHalfOp(const QString & szNick, bool bHalfOp, bool) { return m_pUserListView->setHalfOp(szNick, bHalfOp); }; 569 570 /** 571 * \brief Sets the voice mode 572 * \param szNick The nick to set the mode on 573 * \param bVoice Whether to set or unset the mode on the user 574 * \return bool 575 */ setVoice(const QString & szNick,bool bVoice,bool)576 bool setVoice(const QString & szNick, bool bVoice, bool) { return m_pUserListView->setVoice(szNick, bVoice); }; 577 578 /** 579 * \brief Sets the user operator mode 580 * \param szNick The nick to set the mode on 581 * \param bUserOp Whether to set or unset the mode on the user 582 * \return bool 583 */ setUserOp(const QString & szNick,bool bUserOp,bool)584 bool setUserOp(const QString & szNick, bool bUserOp, bool) { return m_pUserListView->setUserOp(szNick, bUserOp); }; 585 586 /** 587 * \brief Returns true if the user is a chan owner 588 * \param szNick The nickname of the user to check 589 * \param bAtLeast Whether the user is at least a chan owner 590 * \return bool 591 */ 592 bool isChanOwner(const QString & szNick, bool bAtLeast = false) { return m_pUserListView->isChanOwner(szNick, bAtLeast); }; 593 594 /** 595 * \brief Returns true if the user is a chan admin 596 * \param szNick The nickname of the user to check 597 * \param bAtLeast Whether the user is at least a chan admin 598 * \return bool 599 */ 600 bool isChanAdmin(const QString & szNick, bool bAtLeast = false) { return m_pUserListView->isChanAdmin(szNick, bAtLeast); }; 601 602 /** 603 * \brief Returns true if the user is an operator 604 * \param szNick The nickname of the user to check 605 * \param bAtLeast Whether the user is at least an operator 606 * \return bool 607 */ 608 bool isOp(const QString & szNick, bool bAtLeast = false) { return m_pUserListView->isOp(szNick, bAtLeast); }; 609 610 /** 611 * \brief Returns true if the user is a half operator 612 * \param szNick The nickname of the user to check 613 * \param bAtLeast Whether the user is at least a half operator 614 * \return bool 615 */ 616 bool isHalfOp(const QString & szNick, bool bAtLeast = false) { return m_pUserListView->isHalfOp(szNick, bAtLeast); }; 617 618 /** 619 * \brief Returns true if the user is a voice 620 * \param szNick The nickname of the user to check 621 * \param bAtLeast Whether the user is at least a voice 622 * \return bool 623 */ 624 bool isVoice(const QString & szNick, bool bAtLeast = false) { return m_pUserListView->isVoice(szNick, bAtLeast); }; 625 626 /** 627 * \brief Returns true if the user is a user operator 628 * \param szNick The nickname of the user to check 629 * \param bAtLeast Whether the user is at least a user operator 630 * \return bool 631 */ 632 bool isUserOp(const QString & szNick, bool bAtLeast = false) { return m_pUserListView->isUserOp(szNick, bAtLeast); }; 633 634 /** 635 * \brief Returns true if we are an ircop 636 * \param bAtLeast Whether we are at least an ircop 637 * \return bool 638 */ 639 bool isMeIrcOp(bool bAtLeast = false); 640 641 /** 642 * \brief Returns true if we are a chan owner 643 * \param bAtLeast Whether we are at least a chan owner 644 * \return bool 645 */ 646 bool isMeChanOwner(bool bAtLeast = false); 647 648 /** 649 * \brief Returns true if we are a chan admin 650 * \param bAtLeast Whether we are at least a chan admin 651 * \return bool 652 */ 653 bool isMeChanAdmin(bool bAtLeast = false); 654 655 /** 656 * \brief Returns true if we are an operator 657 * \param bAtLeast Whether we are at least an operator 658 * \return bool 659 */ 660 bool isMeOp(bool bAtLeast = false); 661 662 /** 663 * \brief Returns true if we are a half operator 664 * \param bAtLeast Whether we are at least a half operator 665 * \return bool 666 */ 667 bool isMeHalfOp(bool bAtLeast = false); 668 669 /** 670 * \brief Returns true if we are a voice 671 * \param bAtLeast Whether we are at least a voice 672 * \return bool 673 */ 674 bool isMeVoice(bool bAtLeast = false); 675 676 /** 677 * \brief Returns true if we are a user operator 678 * \param bAtLeast Whether we are at least a user operator 679 * \return bool 680 */ 681 bool isMeUserOp(bool bAtLeast = false); 682 683 /** 684 * \brief Perform a user action in the channel 685 * \param user The user who made the action 686 * \param uActionType The type of the action 687 * \return void 688 */ 689 void userAction(KviIrcMask * user, unsigned int uActionType); 690 691 /** 692 * \brief Perform a user action in the channel 693 * \param szNick The nickname of the user who made the action 694 * \param uActionType The type of the action 695 * \return void 696 */ 697 void userAction(const QString & szNick, unsigned int uActionType); 698 699 /** 700 * \brief Perform a user action in the channel 701 * \param szNick The nickname of the user who made the action 702 * \param szUser The username of the user who made the action 703 * \param szHost The hostname of the user who made the action 704 * \param uActionType The type of the action 705 * \return void 706 */ 707 void userAction(const QString & szNick, const QString & szUser, const QString & szHost, unsigned int uActionType); 708 709 /** 710 * \brief Called when someone perform an action in the channel 711 * \param szNick The nickname of the user who made the action 712 * \param uActionType The type of the action 713 * \param iTemperature The temperature of the action 714 * \return void 715 */ 716 void channelAction(const QString & szNick, unsigned int uActionType, int iTemperature); 717 718 /** 719 * \brief Called when someone changes his nick 720 * \param szOldNick The old nickname of the user 721 * \param szNewNick The new nickname of the user 722 * \return bool 723 */ 724 bool nickChange(const QString & szOldNick, const QString & szNewNick); 725 726 /** 727 * \brief Called when someone parts the channel 728 * \param szNick The nickname of the user who parts 729 * \return bool 730 */ 731 bool part(const QString & szNick); 732 733 /** 734 * \brief Returns true if the user is on the channel 735 * \param szNick The nickname of the user 736 * \return bool 737 */ isOn(const QString & szNick)738 bool isOn(const QString & szNick) { return (m_pUserListView->findEntry(szNick) != 0); }; 739 740 /** 741 * \brief Searches for a user in the userlist 742 * \param szNick The nickname of the user to find 743 * \return KviUserListEntry * 744 */ findEntry(const QString & szNick)745 KviUserListEntry * findEntry(const QString & szNick) { return m_pUserListView->findEntry(szNick); }; 746 747 /** 748 * \brief Returns our flags 749 * \return int 750 */ 751 int myFlags(); 752 753 /** 754 * \brief Updates the tooltip over the channel modes 755 * \return void 756 */ 757 void updateModeLabel(); 758 759 /** 760 * \brief Outputs a message to the channel window 761 * \param iMsgType The type of the message 762 * \param szMsg The message :) 763 * \return void 764 */ 765 virtual void outputMessage(int iMsgType, const QString & szMsg, const QDateTime & datetime = QDateTime()); 766 767 /** 768 * \brief Called when we send a message 769 * \param szBuffer The buffer :) 770 * \param bUserFeedback Whether to display the echo feedback to the user 771 * \return void 772 */ 773 void ownMessage(const QString & szBuffer, bool bUserFeedback = true) override; 774 775 /** 776 * \brief Called when we perform an action 777 * \param szBuffer The buffer :) 778 * \return void 779 */ 780 void ownAction(const QString & szBuffer) override; 781 782 /** 783 * \brief Sets a plain (parameter-less) channel mode, (eg: +m) 784 * \param cMode The mode to set 785 * \param bAdd Whether to add or remove the mode 786 * \return void 787 */ 788 void setChannelMode(char cMode, bool bAdd); 789 790 /** 791 * \brief Returns only the plain (parameter-less) channel modes (eg: mi) 792 * \return QString 793 */ plainChannelMode()794 QString plainChannelMode() { return m_szChannelMode; }; 795 796 /** 797 * \brief Fills szBuffer with all set channel modes, but without any parameters (eg: lkmi) 798 * \param szBuffer The buffer :) 799 * \return void 800 */ 801 void getChannelModeString(QString & szBuffer); 802 803 /** 804 * \brief Fills szBuffer with all set channel modes and any parameters (eg: mi l:10 k:password) 805 * \param szBuffer The buffer :) 806 * \return void 807 */ 808 QString getChannelModeStringWithEmbeddedParams(); 809 810 /** 811 * \brief Sets a channel mode with a parameter; an empty parameter unsets the mode (eg: +k password) 812 * \param cMode The mode 813 * \param szParam The parameter for the mode 814 * \return void 815 */ 816 void setChannelModeWithParam(char cMode, QString & szParam); 817 818 /** 819 * \brief Returns true if the channel has a mode with parameter set (eg. mode k) 820 * \param cMode The mode 821 * \return bool 822 */ hasChannelMode(char cMode)823 bool hasChannelMode(char cMode) { return m_szChannelParameterModes.count(cMode); }; 824 825 /** 826 * \brief Returns the value (parameter) for a channel mode (eg. the password for mode k) 827 * \param cMode The mode 828 * \return QString 829 */ channelModeParam(char cMode)830 QString channelModeParam(char cMode) const 831 { 832 const auto it = m_szChannelParameterModes.find(cMode); 833 if(it != m_szChannelParameterModes.end()) 834 return it->second; 835 return QString(); 836 }; 837 838 /** 839 * \brief Adds a user to the highlight list 840 * \param szNick The nickname of the user 841 * \return void 842 */ 843 void addHighlightedUser(const QString & szNick); 844 845 /** 846 * \brief Removes a user from the highlight list 847 * \param szNick The nickname of the user 848 * \return void 849 */ 850 void removeHighlightedUser(const QString & szNick); 851 852 /** 853 * \brief Returns true if the user is highlighted 854 * \param szNick The nickname of the user 855 * \return bool 856 */ isHighlightedUser(const QString & szNick)857 bool isHighlightedUser(const QString & szNick) { return m_pTmpHighLighted->contains(szNick, Qt::CaseInsensitive); }; 858 859 /** 860 * \brief Called when the channel losts the focus by the user 861 * \return void 862 */ 863 void lostUserFocus() override; 864 865 /** 866 * \brief Creates the tooltip over the channel treeview 867 * \param szBuffer The buffer where to store the data 868 * \return void 869 */ 870 void getWindowListTipText(QString & szBuffer) override; 871 872 /** 873 * \brief Unhighlights the windowlist item 874 * \return void 875 */ 876 void unhighlight(); 877 878 /** 879 * \brief Gets the KviIrcConnectionServerInfo structure associated to the current connection 880 * \return KviIrcConnectionServerInfo* 881 */ 882 KviIrcConnectionServerInfo * serverInfo(); 883 884 /** 885 * \brief Checks the channel synchronization time 886 * \return void 887 */ 888 void checkChannelSync(); 889 890 /** 891 * \brief Returns the KviIrcView that was last clicked in this window 892 * 893 * Acts as view() except for split view windows 894 * See also: view() 895 * \return KviIrcView * 896 */ 897 KviIrcView * lastClickedView() const override; 898 899 protected: 900 /** 901 * \brief Filters the events 902 * \param pObject The object 903 * \param pEvent The event 904 * \return bool 905 */ 906 bool eventFilter(QObject * pObject, QEvent * pEvent) override; 907 908 /** 909 * \brief Returns the correct icon for the channel 910 * \return QPixmap * 911 */ 912 QPixmap * myIconPtr() override; 913 914 /** 915 * \brief Fills in the caption buffers 916 * \return void 917 */ 918 void fillCaptionBuffers() override; 919 920 /** 921 * \brief Gets the group name 922 * \param szBuffer The buffer where to save the data 923 * \return void 924 */ 925 void getConfigGroupName(QString & szBuffer) override; 926 927 /** 928 * \brief Saves the properties to file 929 * \param pCfg The config file 930 * \return void 931 */ 932 void saveProperties(KviConfigurationFile * pCfg) override; 933 934 /** 935 * \brief Loads the properties from file 936 * \param pCfg The config file 937 * \return void 938 */ 939 void loadProperties(KviConfigurationFile * pCfg) override; 940 941 /** 942 * \brief Applies the options 943 * \return void 944 */ 945 void applyOptions() override; 946 947 /** 948 * \brief Gets the base name for log file 949 * \param szBuffer The buffer where to save data 950 * \return void 951 */ 952 void getBaseLogFileName(QString & szBuffer) override; 953 954 /** 955 * \brief Trigger the OnChannelWindowCreated event 956 * \return void 957 */ 958 void triggerCreationEvents() override; 959 960 /** 961 * \brief Called when someone sets a mask in the channel's lists 962 * \param szMask The mask set 963 * \param bAdd Whether to add or remove the mask 964 * \param szSetBy Who set the mask 965 * \param uSetAt The datetime when the mask was set 966 * \param l The list of masks in the channel lists 967 * \param ppEd The mask editor window 968 * \param szChangeMask If bAdd is false and this string is set, the mask will be updated instead that removed 969 * \return void 970 */ 971 void internalMask(const QString & szMask, bool bAdd, const QString & szSetBy, unsigned int uSetAt, std::vector<KviMaskEntry *> & l, KviMaskEditor ** ppEd, QString & szChangeMask); 972 973 /** 974 * \brief Splits the channel view into two views 975 * 976 * The upper one will be used to show all system messages like join, 977 * parts, quits, topics and so on, while the lower one will be used to 978 * show the users messages. 979 * \param bShow Whether to show the double view 980 * \return void 981 */ 982 void showDoubleView(bool bShow); 983 984 /** 985 * \brief Fixes the action history 986 * \return void 987 */ 988 void fixActionHistory(); 989 990 /** 991 * \brief Gets the talking user stats to fill in the tooltip 992 * \param szBuffer The buffer where to store the data 993 * \param list The list of talking users 994 * \param bPast Whether the activity is recent or in the past 995 * \return void 996 */ 997 void getTalkingUsersStats(QString & szBuffer, QStringList & list, bool bPast); 998 999 /** 1000 * \brief Preprocess message stripping control bytes 1001 * \param szMessage The message :) 1002 * \return void 1003 */ 1004 void preprocessMessage(QString & szMessage) override; 1005 1006 void resizeEvent(QResizeEvent *) override; 1007 void closeEvent(QCloseEvent * pEvent) override; 1008 public slots: 1009 /** 1010 * \brief Toggles the double view mode 1011 * \return void 1012 */ 1013 void toggleDoubleView(); 1014 1015 private slots: 1016 /** 1017 * \brief Toggles the userlist view 1018 * \return void 1019 */ 1020 void toggleListView(); 1021 1022 /** 1023 * \brief Toggles a list mode editor 1024 * \return void 1025 */ 1026 void toggleListModeEditor(); 1027 1028 /** 1029 * \brief Toggles the mode editor 1030 * \return void 1031 */ 1032 void toggleModeEditor(); 1033 1034 /** 1035 * \brief Called when we close the mode editor 1036 */ 1037 void modeSelectorDone(); 1038 1039 /** 1040 * \brief Called when we select the topic 1041 * \param szTopic The topic :) 1042 * \return void 1043 */ 1044 void topicSelected(const QString & szTopic); 1045 1046 /** 1047 * \brief Called when we select the modes from the mode editor 1048 * \param szMode The modes selected, including any plus/minus sign and parameters 1049 * \return void 1050 */ 1051 void setMode(const QString & szMode); 1052 1053 /** 1054 * \brief Called when we right-click the irc view. 1055 * 1056 * Trigger the OnChannelPopupRequest event 1057 * \return void 1058 */ 1059 void textViewRightClicked(); 1060 1061 /** 1062 * \brief Removes the masks from the mask editor window 1063 * \param pEd The mask editor 1064 * \param pList The list of masks to remove 1065 * \return void 1066 */ 1067 void removeMasks(KviMaskEditor * pEd, const std::vector<KviMaskEntry *> & pList); 1068 1069 /** 1070 * \brief Toggles tool buttons widget over the listview 1071 * \return void 1072 */ 1073 void toggleToolButtons(); 1074 1075 signals: 1076 /** 1077 * \brief Emitted when our op status change 1078 * \return void 1079 */ 1080 void opStatusChanged(); 1081 }; 1082 1083 #endif //_KVI_CHANNEL_H_ 1084