void CoreHighlightSettingsPage::load() { emptyHighlightTable(); emptyIgnoredTable(); auto ruleManager = Client::highlightRuleManager(); if (ruleManager) { for (auto &rule : ruleManager->highlightRuleList()) { if (rule.isInverse) { addNewIgnoredRow(rule.isEnabled, rule.id, rule.name, rule.isRegEx, rule.isCaseSensitive, rule.sender, rule.chanName); } else { addNewHighlightRow(rule.isEnabled, rule.id, rule.name, rule.isRegEx, rule.isCaseSensitive, rule.sender, rule.chanName); } } int highlightNickType = ruleManager->highlightNick(); ui.highlightNicksComboBox->setCurrentIndex(ui.highlightNicksComboBox->findData(QVariant(highlightNickType))); // Trigger the initial update of nicksCaseSensitive being enabled or not highlightNicksChanged(ui.highlightNicksComboBox->currentIndex()); ui.nicksCaseSensitive->setChecked(ruleManager->nicksCaseSensitive()); setChangedState(false); _initialized = true; } else { defaults(); } }
parseResult * ChannelParser::parseINFOTopic(QString string) { int found = 0; string.remove(0, 4); // Remove the leading *T* and space //kdDebug(5008) << "Topic parser: " << string << endl; // Topic for #boo: this is a nice test QRegExp rx( "Topic for (\\S+): (.*)" ); if(rx.search( string ) != -1){ QString channel = rx.cap(1); QString topic = rx.cap(2); topic.replace( QRegExp( "~~" ), "~" ); /* * check where it's going. * topic's maybe for other channels since they have no channel routing * information, so route it to the right place if need be. * If we're not on the channnel just fall through and display it * on our channel, maybe the user asked for a topic of a different channel */ if(channel.lower() != top->channelInfo().channel().lower()){ if(top->ksircProcess()->mrList()[channel.lower()]){ KSircTopLevel *t = dynamic_cast<KSircTopLevel *>(top->ksircProcess()->mrList()[channel.lower()]); if(t) t->setTopic(topic); } } else { //kdDebug(5008) << "New topic: " << topic << endl; top->setTopic( topic ); } found = 1; } rx.setPattern("(\\S+) has changed the topic on channel (\\S+) to (.+)"); if(found == 0 && rx.search(string) != -1){ QString nick = rx.cap(1); QString channel = rx.cap(2); //kdDebug(5008) << "Channel: " << channel << endl; if(top->channelInfo().channel().lower() == channel.lower()){ QString topic = rx.cap(3); //kdDebug(5008) << "Topic: " << topic << endl; topic.replace(QRegExp("~~"), "~"); /* * topic is in double quotes, so remove them */ top->setTopic( topic.mid(1, topic.length()-2) ); QString cmd = "/eval &dostatus();\n"; top->sirc_write(cmd); } highlightNick(string, nick); } return new parseSucc(" " + string, ksopts->infoColor, "user|topic"); }
parseResult * ChannelParser::parseINFOJoin(QString string) { string.remove(0, 4); // strip *>* to save a few compares // You have joined channel #Linux QRegExp rx("You have joined channel (\\S+)"); if(rx.search(string) != -1){ //QString channel = rx.cap(1).lower(); QString channel = rx.cap(1); //kdDebug(5008) << "Channel: " << channel << endl; if(top->channelInfo().channel() != channel) { KSircChannel ci(top->channelInfo().server(), channel); kdDebug(5008) << "Warning: we got a channel join yet me don't belong to it!!! Assuming no key!" << endl; kdDebug(5008) << "String was: " << string << endl; kdDebug(5008) << "We think the channel is: " << channel << " we are: " << top->channelInfo().channel()<< endl; emit top->open_toplevel(ci); } return new parseJoinPart(" " + string, ksopts->channelColor, "user|join"); } // reef-diddy ([email protected]) has joined channel #aquaria rx.setPattern("(\\S+) .+ has joined channel (\\S+)"); if(rx.search(string) != -1){ QString nick = rx.cap(1); QString channel = rx.cap(2).lower(); //kdDebug(5008) << "Channel: " << channel << " nick: " << nick << endl; if(top->channelInfo().channel().lower() != channel){ return new parseWrongChannel(" " + string, ksopts->errorColor, "user|join"); } // nicks->insertItem(s3, 0); // add the sucker top->nicks->inSort(nick); top->addCompleteNick(nick); highlightNick(string, nick); return new parseJoinPart(" " + string, ksopts->channelColor, "user|join"); } return 0; // ?? }
parseResult * ChannelParser::parseINFOChangeNick(QString string) { //char old_nick[101], new_nick[101]; QString old_nick, new_nick; string.remove(0, 4); // Remove the leading *N* and space /* * *N* asj_ is now known as bleh */ //kdDebug(5008) << "Nick change: " << string << endl; QRegExp rx("(\\S+) is now known as (\\S+)"); if(rx.search(string) == -1){ if(string.contains("already taken")){ return new parseSucc(" " + string, ksopts->errorColor, "user|error"); } return new parseError(i18n("Unable to parse: %1").arg(string), i18n("Unable to parse change nick code")); } old_nick = rx.cap(1); new_nick = rx.cap(2); // If we have a window open talking to the nick // Change the nick to the new one. if((top->channelInfo().channel()[0] != '#' || top->channelInfo().channel()[0] != '&') && (top->channelInfo().channel() == old_nick)){ if(!top->ksircProcess()->mrList()[new_nick.lower()]){ top->control_message(CHANGE_CHANNEL, new_nick.lower()); } } highlightNick(string, old_nick); highlightNick(string, new_nick); // search the list for the nick and remove it // since the list is source we should do a binary search... int found = top->nicks->findNick(old_nick); if(found >= 0){ // If the nick's in the nick list, change it and display the change // save current selection int selection = top->nicks->currentItem(); // Get the old item, and create a new one nickListItem *it = top->nicks->item(found); nickListItem *irc = new nickListItem(*it); irc->setText(new_nick); top->nicks->removeItem(found); // remove old nick top->nicks->inSort(irc); top->changeCompleteNick(old_nick, new_nick); top->nicks->setCurrentItem(selection); top->nicks->repaint(TRUE); // We're done, so let's finish up return new parseSucc(" " + string, ksopts->channelColor, "user|join"); } else { if(top->channelInfo().channel() == new_nick || top->channelInfo().channel() == old_nick) return new parseSucc(" " + string, ksopts->channelColor, "user|elipsis"); else return new parseSucc(QString::null); } // warning("Toplevel-N: nick change search failed on %s", s3.data()); // return new parseSucc(QString::null); }
parseResult * ChannelParser::parseINFOPart(QString string) { bool foundNick = false; QString pixname = "user|kick"; QString nick(""); string.remove(0, 4); // clear junk // Multiple type of parts, a signoff or a /part // Each get's get nick in a diffrent localtion // Set we search and find the nick and the remove it from the nick list // 1. /quit, signoff, nick after "^Singoff: " // 2. /part, leave the channek, nick after "has left \w+$" // 3. /kick, kicked off the channel, nick after "kicked off \w+$" // // Signoff: looser QRegExp rx("Signoff: (\\S+)"); if(rx.search(string) != -1) { nick = rx.cap(1); foundNick = true; pixname = "user|X"; highlightNick(string, nick); } /* * Check for "You" before everyone else or else the next * case will match it * You have left channel <channel> */ rx.setPattern("You have left channel (\\S+)"); if((foundNick == false) && (rx.search(string) != -1)) { QString channel = rx.cap(1); if(top->channelInfo().channel().lower() == channel.lower()) { QApplication::postEvent(top, new QCloseEvent()); // WE'RE DEAD return new parseSucc(QString::null); } pixname = "user|part"; } /* * Same as above, check your own state first * You have been kicked off channel <channel> */ rx.setPattern("You have been kicked off channel (\\S+)"); if((foundNick == false) && (rx.search(string) != -1)) { QString channel = rx.cap(1); if(top->channelInfo().channel().lower() != channel.lower()) return new parseWrongChannel(string, ksopts->errorColor, "user|kick"); if (ksopts->autoRejoin == TRUE) { QString str = QString("/join %1\n").arg(top->channelInfo().channel()); emit top->outputUnicodeLine(str); /* if(top->ticker) top->ticker->show(); else*/ top->show(); } else { if(top->KickWinOpen != false) return new parseError(" " + string, i18n("Kick window open")); top->KickWinOpen = true; int result = KMessageBox::questionYesNo(top, string, i18n("You Have Been Kicked"), i18n("Rejoin"), i18n("Leave")); if (result == KMessageBox::Yes) { QString str = QString("/join %1\n").arg(top->channelInfo().channel()); emit top->outputUnicodeLine(str); /* if(top->ticker) * top->ticker->show(); * else*/ top->show(); return new parseJoinPart(" " + string, ksopts->channelColor, "user|kick"); } else { // WE'RE DEAD QApplication::postEvent(top, new QCloseEvent()); top->KickWinOpen = false; } } pixname = "user|kick"; } /* * <nick> has left channel <channel> */ rx.setPattern("(\\S+) has left channel (\\S+)"); if((foundNick == false) && (rx.search(string) != -1)) { nick = rx.cap(1); QString channel = rx.cap(2); // kdDebug(5008) << "Nick: " << nick << " Channel: " << channel << " top: " << top->channelInfo().channel() << endl; if(top->channelInfo().channel().lower() == channel.lower()) { foundNick = true; } else{ return new parseWrongChannel(QString::null); } pixname = "user|part"; highlightNick(string, nick); } /* * "<nick> has been kicked off channel <channel>" */ rx.setPattern("(\\S+) has been kicked off channel (\\S+)"); if((foundNick == false) && (rx.search(string) != -1)) { nick = rx.cap(1); QString channel = rx.cap(2); if(top->channelInfo().channel().lower() == channel.lower()) { foundNick = true; } else { return new parseWrongChannel(QString::null); } highlightNick(string, nick); pixname = "user|kick"; } if (foundNick) { top->removeCompleteNick(nick); int index = top->nicks->findNick(nick); if(index >= 0){ top->nicks->removeItem(index); return new parseJoinPart(" " + string, ksopts->channelColor, pixname); } else { return new parseJoinPart(QString::null); } } else { return new parseError(" " + string, i18n("Failed to parse part/kick/leave/quit message")); } return 0; }