/** Default constructor */ PopupChatDialog::PopupChatDialog(std::string id, std::string name, QWidget *parent, Qt::WFlags flags) : QMainWindow(parent, flags), dialogId(id), dialogName(name), lastChatTime(0), lastChatName("") { /* Invoke Qt Designer generated QObject setup routine */ ui.setupUi(this); RshareSettings config; config.loadWidgetInformation(this); loadEmoticons(); last_status_send_time = 0 ; styleHtm = ":/qss/chat/default.htm"; /* Hide Avatar frame */ showAvatarFrame(false); connect(ui.avatarFrameButton, SIGNAL(toggled(bool)), this, SLOT(showAvatarFrame(bool))); connect(ui.actionAvatar, SIGNAL(triggered()),this, SLOT(getAvatar())); connect(ui.chattextEdit, SIGNAL(textChanged ( ) ), this, SLOT(checkChat( ) )); connect(ui.sendButton, SIGNAL(clicked( ) ), this, SLOT(sendChat( ) )); connect(ui.addFileButton, SIGNAL(clicked() ), this , SLOT(addExtraFile())); connect(ui.textboldButton, SIGNAL(clicked()), this, SLOT(setFont())); connect(ui.textunderlineButton, SIGNAL(clicked()), this, SLOT(setFont())); connect(ui.textitalicButton, SIGNAL(clicked()), this, SLOT(setFont())); connect(ui.fontButton, SIGNAL(clicked()), this, SLOT(getFont())); connect(ui.colorButton, SIGNAL(clicked()), this, SLOT(setColor())); connect(ui.emoteiconButton, SIGNAL(clicked()), this, SLOT(smileyWidget())); connect(ui.styleButton, SIGNAL(clicked()), SLOT(changeStyle())); connect(ui.textBrowser, SIGNAL(anchorClicked(const QUrl &)), SLOT(anchorClicked(const QUrl &))); // Create the status bar resetStatusBar() ; ui.textBrowser->setOpenExternalLinks ( false ); ui.textBrowser->setOpenLinks ( false ); QString title = QString::fromStdString(name) + " :" + tr(" RetroShare - Encrypted Chat") ; setWindowTitle(title); //set the default avatar //ui.avatarlabel->setPixmap(QPixmap(":/images/retrosharelogo1.png")); setWindowIcon(QIcon(QString(":/images/rstray3.png"))); ui.textboldButton->setIcon(QIcon(QString(":/images/edit-bold.png"))); ui.textunderlineButton->setIcon(QIcon(QString(":/images/edit-underline.png"))); ui.textitalicButton->setIcon(QIcon(QString(":/images/edit-italic.png"))); ui.fontButton->setIcon(QIcon(QString(":/images/fonts.png"))); ui.emoteiconButton->setIcon(QIcon(QString(":/images/emoticons/kopete/kopete020.png"))); ui.styleButton->setIcon(QIcon(QString(":/images/looknfeel.png"))); ui.textboldButton->setCheckable(true); ui.textunderlineButton->setCheckable(true); ui.textitalicButton->setCheckable(true); setAcceptDrops(true); ui.chattextEdit->setAcceptDrops(false); /*Disabled style Button when will switch chat style RetroShare will crash need to be fix */ //ui.styleButton->setEnabled(false); /*QMenu * fontmenu = new QMenu(); fontmenu->addAction(ui.actionBold); fontmenu->addAction(ui.actionUnderline); fontmenu->addAction(ui.actionItalic); fontmenu->addAction(ui.actionStrike); ui.fontButton->setMenu(fontmenu);*/ mCurrentColor = Qt::black; mCurrentFont = QFont("Comic Sans MS", 10); colorChanged(mCurrentColor); setFont(); updateAvatar() ; updatePeerAvatar(id) ; }
/** Constructor */ PeersDialog::PeersDialog(QWidget *parent) : RsAutoUpdatePage(1000,parent), historyKeeper(Rshare::dataDirectory() + "/his1.xml") { /* Invoke the Qt Designer generated object setup routine */ ui.setupUi(this); connect( ui.peertreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( peertreeWidgetCostumPopupMenu( QPoint ) ) ); connect( ui.peertreeWidget, SIGNAL( itemDoubleClicked ( QTreeWidgetItem *, int)), this, SLOT(chatfriend())); /* hide the Tree +/- */ ui.peertreeWidget -> setRootIsDecorated( false ); /* Set header resize modes and initial section sizes */ QHeaderView * _header = ui.peertreeWidget->header () ; _header->setResizeMode (0, QHeaderView::Custom); _header->setResizeMode (1, QHeaderView::Interactive); _header->setResizeMode (2, QHeaderView::Interactive); /*_header->setResizeMode (3, QHeaderView::Interactive); _header->setResizeMode (4, QHeaderView::Interactive); _header->setResizeMode (5, QHeaderView::Interactive); _header->setResizeMode (6, QHeaderView::Interactive); _header->setResizeMode (7, QHeaderView::Interactive);*/ _header->resizeSection ( 0, 25 ); _header->resizeSection ( 1, 100 ); _header->resizeSection ( 2, 100 ); /*_header->resizeSection ( 3, 120 ); _header->resizeSection ( 4, 100 ); _header->resizeSection ( 5, 230 ); _header->resizeSection ( 6, 120 ); _header->resizeSection ( 7, 220 );*/ // set header text aligment QTreeWidgetItem * headerItem = ui.peertreeWidget->headerItem(); headerItem->setTextAlignment(0, Qt::AlignHCenter | Qt::AlignVCenter); headerItem->setTextAlignment(1, Qt::AlignHCenter | Qt::AlignVCenter); headerItem->setTextAlignment(2, Qt::AlignHCenter | Qt::AlignVCenter); loadEmoticonsgroupchat(); //setWindowIcon(QIcon(QString(":/images/rstray3.png"))); connect(ui.lineEdit, SIGNAL(textChanged ( ) ), this, SLOT(checkChat( ) )); connect(ui.Sendbtn, SIGNAL(clicked()), this, SLOT(sendMsg())); connect(ui.emoticonBtn, SIGNAL(clicked()), this, SLOT(smileyWidgetgroupchat())); //connect( ui.msgSendList, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( msgSendListCostumPopupMenu( QPoint ) ) ); connect( ui.msgText, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayInfoChatMenu(const QPoint&))); connect(ui.textboldChatButton, SIGNAL(clicked()), this, SLOT(setFont())); connect(ui.textunderlineChatButton, SIGNAL(clicked()), this, SLOT(setFont())); connect(ui.textitalicChatButton, SIGNAL(clicked()), this, SLOT(setFont())); connect(ui.fontsButton, SIGNAL(clicked()), this, SLOT(getFont())); connect(ui.colorChatButton, SIGNAL(clicked()), this, SLOT(setColor())); ui.fontsButton->setIcon(QIcon(QString(":/images/fonts.png"))); _currentColor = Qt::black; QPixmap pxm(16,16); pxm.fill(_currentColor); ui.colorChatButton->setIcon(pxm); mCurrentFont = QFont("Comic Sans MS", 12); ui.lineEdit->setFont(mCurrentFont); setChatInfo(tr("Welcome to RetroShare's group chat."), QString::fromUtf8("blue")); QStringList him; historyKeeper.getMessages(him, "", "THIS", 8); foreach(QString mess, him) ui.msgText->append(mess); //setChatInfo(mess, "green"); QMenu * grpchatmenu = new QMenu(); grpchatmenu->addAction(ui.actionClearChat); ui.menuButton->setMenu(grpchatmenu); _underline = false; QTimer *timer = new QTimer(this); timer->connect(timer, SIGNAL(timeout()), this, SLOT(insertChat())); timer->start(500); /* half a second */ ui.peertreeWidget->sortItems( 1, Qt::AscendingOrder ); /* Hide platform specific features */ #ifdef Q_WS_WIN #endif }
void Firewall::filterIncomingMessage(Chat chat, Contact sender, QString &message, time_t time, bool &ignore) { Q_UNUSED(time) Account account = chat.chatAccount(); Protocol *protocol = account.protocolHandler(); if (!protocol) return; // emotikony s± sprawdzane nawet przy ³±czeniu const int min_interval_notify = 2000; if (CheckFloodingEmoticons) { if ((!EmoticonsAllowKnown || sender.ownerBuddy().isAnonymous()) && checkEmoticons(message)) { ignore = true; if (LastNotify.elapsed() > min_interval_notify) { FirewallNotification::notify(chat, sender, tr("flooding DoS attack with emoticons!")); writeLog(sender, message); LastNotify.restart(); } kdebugf2(); return; } } // atak floodem if (checkFlood()) { ignore = true; if (LastNotify.elapsed() > min_interval_notify) { FirewallNotification::notify(chat, sender, tr("flooding DoS attack!")); writeLog(sender, message); LastNotify.restart(); } kdebugf2(); return; } // ochrona przed anonimami if (checkChat(chat, sender, message, ignore)) ignore = true; // ochrona przed konferencjami if (checkConference(chat)) ignore = true; // wiadomosc zatrzymana. zapisz do loga i wyswietl dymek if (ignore) { if (message.length() > 50) FirewallNotification::notify(chat, sender, message.left(50).append("...")); else FirewallNotification::notify(chat, sender, message); writeLog(sender, message); if (WriteInHistory) { if (History::instance()->currentStorage()) { Message msg = Message::create(); msg.setContent(message); msg.setType(Message::TypeReceived); msg.setReceiveDate(QDateTime::currentDateTime()); msg.setSendDate(QDateTime::fromTime_t(time)); History::instance()->currentStorage()->appendMessage(msg); } } } kdebugf2(); }