void AuthDlg::send() { Licq::UserId userId = myUserId; if (!userId.isValid()) userId = Licq::UserId(myOwnerCombo->currentOwnerId(), myAccountIdEdit->text().toUtf8().constData()); if (userId.isValid()) { QByteArray messageText = myMessageEdit->toPlainText().toUtf8(); switch (myType) { default: case RequestAuth: gProtocolManager.requestAuthorization(userId, messageText.constData()); break; case GrantAuth: gProtocolManager.authorizeReply(userId, true, messageText.constData()); break; case RefuseAuth: gProtocolManager.authorizeReply(userId, false, messageText.constData()); break; } close(); } }
CMSNDataEvent::CMSNDataEvent(unsigned long _nEvent, unsigned long _nSessionId, unsigned long _nBaseId, const Licq::UserId& userId, const string &_strFromId, const string &_strCallId, CMSN *p) { m_pMSN = p; m_nSocketDesc = -1; m_nEvent = _nEvent; m_strId = userId.accountId(); m_eState = STATE_WAITING_ACK; m_nFileDesc = -1; { Licq::UserReadGuard u(userId); m_strFileName = u->pictureFileName(); } m_nFilePos = 0; m_nBytesTransferred = 0; m_nStartTime = 0; m_nSessionId = _nSessionId; m_nBaseId = _nBaseId; m_nDataSize[0] = 0; m_nDataSize[1] = 0; m_strFromId = _strFromId; m_strCallId = _strCallId; }
OwnerEditDlg::OwnerEditDlg(const Licq::UserId& ownerId, unsigned setStatus, const QString& autoMessage, QWidget* parent) : QDialog(parent), myOwnerId(ownerId), myPpid(ownerId.protocolId()), myNewOwner(false), mySetStatus(setStatus), myAutoMessage(autoMessage) { init(); { Licq::OwnerReadGuard o(myOwnerId); if (!o.isLocked()) { close(); return; } edtId->setText(o->accountId().c_str()); edtId->setEnabled(false); edtPassword->setText(QString::fromLocal8Bit(o->password().c_str())); chkSave->setChecked(o->SavePassword()); myHostEdit->setText(QString::fromLocal8Bit(o->serverHost().c_str())); myPortSpin->setValue(o->serverPort()); } show(); }
UserEventCommon::UserEventCommon(const Licq::UserId& userId, QWidget* parent, const char* name) : QWidget(parent), myPpid(userId.protocolId()), myHighestEventId(-1) { Support::setWidgetProps(this, name); setAttribute(Qt::WA_DeleteOnClose, true); myUsers.push_back(userId); // Find out what's supported for the protocol mySendFuncs = 0; Licq::ProtocolPlugin::Ptr protocol = Licq::gPluginManager.getProtocolPlugin(myPpid); if (protocol.get() != NULL) mySendFuncs = protocol->capabilities(); myIsOwner = myUsers.front().isOwner(); myDeleteUser = false; myConvoId = 0; myTophLayout = new QHBoxLayout(this); myTopLayout = new QVBoxLayout(); myTophLayout->addLayout(myTopLayout); myTophLayout->setStretchFactor(myTopLayout, 1); QHBoxLayout* layt = new QHBoxLayout(); myTopLayout->addLayout(layt); myToolBar = new QToolBar(); myToolBar->setIconSize(QSize(16, 16)); layt->addWidget(myToolBar); layt->addStretch(1); myTimezone = new InfoField(true); myTimezone->setToolTip(tr("User's current local time")); int timezoneWidth = qMax(myTimezone->fontMetrics().width("88:88:88"), myTimezone->fontMetrics().width(tr("Unknown"))) + 10; myTimezone->setFixedWidth(timezoneWidth); myTimezone->setAlignment(Qt::AlignCenter); myTimezone->setFocusPolicy(Qt::ClickFocus); layt->addWidget(myTimezone); myMenu = myToolBar->addAction(tr("Menu"), this, SLOT(showUserMenu())); myMenu->setMenu(gUserMenu); if (myIsOwner) myMenu->setEnabled(false); myHistory = myToolBar->addAction(tr("History..."), this, SLOT(showHistory())); myInfo = myToolBar->addAction(tr("User Info..."), this, SLOT(showUserInfo())); myEncodingsMenu = new QMenu(this); myEncoding = myToolBar->addAction(tr("Encoding"), this, SLOT(showEncodingsMenu())); myEncoding->setMenu(myEncodingsMenu); if (!(mySendFuncs & Licq::ProtocolPlugin::CanVaryEncoding)) myEncoding->setVisible(false); myToolBar->addSeparator(); mySecure = myToolBar->addAction(tr("Secure Channel"), this, SLOT(switchSecurity())); if (!(mySendFuncs & Licq::ProtocolPlugin::CanSendSecure)) mySecure->setEnabled(false); myTimeTimer = NULL; QString userEncoding; { Licq::UserReadGuard u(myUsers.front()); if (u.isLocked()) { if (u->NewMessages() == 0) setWindowIcon(IconManager::instance()->iconForUser(*u)); else { setWindowIcon(IconManager::instance()->iconForEvent(Licq::UserEvent::TypeMessage)); flashTaskbar(); } updateWidgetInfo(*u); // restore prefered encoding userEncoding = u->userEncoding().c_str(); setTyping(u->isTyping()); } else { userEncoding = Licq::gUserManager.defaultUserEncoding().c_str(); } } myEncodingsGroup = new QActionGroup(this); connect(myEncodingsGroup, SIGNAL(triggered(QAction*)), SLOT(setEncoding(QAction*))); // populate the popup menu for (int i = 0; UserCodec::m_encodings[i].encoding != NULL; ++i) { UserCodec::encoding_t* it = &UserCodec::m_encodings[i]; bool currentCodec = it->encoding == userEncoding; if (!currentCodec && !Config::Chat::instance()->showAllEncodings() && !it->isMinimal) continue; QAction* a = new QAction(UserCodec::nameForEncoding(i), myEncodingsGroup); a->setCheckable(true); a->setData(i); if (currentCodec) a->setChecked(true); if (currentCodec && !Config::Chat::instance()->showAllEncodings() && !it->isMinimal) { // if the current encoding does not appear in the minimal list myEncodingsMenu->insertSeparator(myEncodingsMenu->actions()[0]); myEncodingsMenu->insertAction(myEncodingsMenu->actions()[0], a); } else { myEncodingsMenu->addAction(a); } } myPopupNextMessage = new QAction("Popup Next Message", this); addAction(myPopupNextMessage); connect(myPopupNextMessage, SIGNAL(triggered()), gLicqGui, SLOT(showNextEvent())); // We might be called from a slot so connect the signal only after all the // existing signals are handled. QTimer::singleShot(0, this, SLOT(connectSignal())); myMainWidget = new QVBoxLayout(); myMainWidget->setContentsMargins(0, 0, 0, 0); myTopLayout->addLayout(myMainWidget); updateIcons(); updateShortcuts(); connect(IconManager::instance(), SIGNAL(generalIconsChanged()), SLOT(updateIcons())); connect(Config::Shortcuts::instance(), SIGNAL(shortcutsChanged()), SLOT(updateShortcuts())); // Check if we want the window sticky if (!Config::Chat::instance()->tabbedChatting() && Config::Chat::instance()->msgWinSticky()) QTimer::singleShot(100, this, SLOT(setMsgWinSticky())); }
AuthDlg::AuthDlg(enum AuthDlgType type, const Licq::UserId& userId, QWidget* parent) : QDialog(parent), myType(type), myUserId(userId) { Support::setWidgetProps(this, "AuthDialog"); setAttribute(Qt::WA_DeleteOnClose, true); QString messageTitle; switch (myType) { default: case RequestAuth: setWindowTitle(tr("Licq - Request Authorization")); messageTitle = tr("Request"); break; case GrantAuth: setWindowTitle(tr("Licq - Grant Authorization")); messageTitle = tr("Response"); break; case RefuseAuth: setWindowTitle(tr("Licq - Refuse Authorization")); messageTitle = tr("Response"); break; } QVBoxLayout* dialogLayout = new QVBoxLayout(this); QHBoxLayout* userIdLayout = new QHBoxLayout(); QLabel* ownerLabel = new QLabel(this); ownerLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter); ownerLabel->setText(tr("&Account:")); myOwnerCombo = new OwnerComboBox(); ownerLabel->setBuddy(myOwnerCombo); userIdLayout->addWidget(ownerLabel); userIdLayout->addWidget(myOwnerCombo); QLabel* accountIdLabel = new QLabel(this); accountIdLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter); accountIdLabel->setText(tr("&User ID:")); myAccountIdEdit = new QLineEdit(this); myAccountIdEdit->setMinimumWidth(90); accountIdLabel->setBuddy(myAccountIdEdit); connect(myAccountIdEdit, SIGNAL(returnPressed()), SLOT(send()) ); userIdLayout->addWidget(accountIdLabel); userIdLayout->addWidget(myAccountIdEdit); dialogLayout->addLayout(userIdLayout); dialogLayout->addSpacing(6); QGroupBox* messageBox = new QGroupBox(messageTitle, this); dialogLayout->addWidget(messageBox); dialogLayout->setStretchFactor(messageBox, 2); QVBoxLayout* messageLayout = new QVBoxLayout(messageBox); myMessageEdit = new MLEdit(true); myMessageEdit->setSizeHintLines(5); messageLayout->addWidget(myMessageEdit); QDialogButtonBox* buttons = new QDialogButtonBox(); QPushButton* okButton = buttons->addButton(QDialogButtonBox::Ok); QPushButton* cancelButton = buttons->addButton(QDialogButtonBox::Cancel); connect(myMessageEdit, SIGNAL(ctrlEnterPressed()), this, SLOT(send())); connect(okButton, SIGNAL(clicked()), SLOT(send()) ); connect(cancelButton, SIGNAL(clicked()), SLOT(close()) ); dialogLayout->addWidget(buttons); if (userId.isValid()) { myOwnerCombo->setCurrentOwnerId(userId.ownerId()); myOwnerCombo->setEnabled(false); myAccountIdEdit->setText(userId.accountId().c_str()); myAccountIdEdit->setEnabled(false); myMessageEdit->setFocus(); } else { myOwnerCombo->setFocus(); } show(); }
void MMSendDlg::SendNext() { if (mmv->contacts().empty()) { accept(); return; } Licq::UserId userId = *mmv->contacts().begin(); if (!userId.isValid()) return; switch (myEventType) { case Licq::UserEvent::TypeMessage: { { Licq::UserReadGuard u(userId); if (!u.isLocked()) return; grpSending->setTitle(tr("Sending mass message to %1...") .arg(QString::fromUtf8(u->getAlias().c_str()))); } // create initial strings (implicit copying, no allocation impact :) QByteArray wholeMessageRaw(Licq::gTranslator.returnToDos(s1.toUtf8().data()).c_str()); int wholeMessagePos = 0; bool needsSplitting = false; // If we send through server (= have message limit), and we've crossed the limit if ((wholeMessageRaw.length() - wholeMessagePos) > CICQDaemon::MaxMessageSize) { needsSplitting = true; } QString message; QByteArray messageRaw; while (wholeMessageRaw.length() > wholeMessagePos) { if (needsSplitting) { // This is a bit ugly but adds safety. We don't simply search // for a whitespace to cut at in the encoded text (since we don't // really know how spaces are represented in its encoding), so // we take the maximum length, then convert back to a Unicode string // and then search for Unicode whitespaces. messageRaw = Licq::gTranslator.returnToUnix(wholeMessageRaw.mid(wholeMessagePos, CICQDaemon::MaxMessageSize).data()).c_str(); message = QString::fromUtf8(messageRaw); if ((wholeMessageRaw.length() - wholeMessagePos) > CICQDaemon::MaxMessageSize) { // We try to find the optimal place to cut // (according to our narrow-minded Latin1 idea of optimal :) // prefer keeping sentences intact 1st int foundIndex = message.lastIndexOf(QRegExp("[\\.\\n]")); // slicing at 0 position would be useless if (foundIndex <= 0) foundIndex = message.lastIndexOf(QRegExp("\\s")); if (foundIndex > 0) { message.truncate(foundIndex); messageRaw = message.toUtf8(); } } } else { messageRaw = s1.toUtf8(); } icqEventTag = gProtocolManager.sendMessage(userId, messageRaw.data(), Licq::ProtocolSignal::SendToMultiple); wholeMessagePos += Licq::gTranslator.returnToDos(messageRaw.constData()).size(); } break; } case Licq::UserEvent::TypeUrl: { { Licq::UserReadGuard u(userId); if (!u.isLocked()) return; grpSending->setTitle(tr("Sending mass URL to %1...") .arg(QString::fromUtf8(u->getAlias().c_str()))); } icqEventTag = gProtocolManager.sendUrl(userId, s2.toUtf8().constData(), s1.toUtf8().constData(), Licq::ProtocolSignal::SendToMultiple); break; } case Licq::UserEvent::TypeContactList: { { Licq::UserReadGuard u(userId); if (!u.isLocked()) return; grpSending->setTitle(tr("Sending mass list to %1...") .arg(QString::fromUtf8(u->getAlias().c_str()))); } icqEventTag = gLicqDaemon->icqSendContactList(userId, *myUsers); break; } } if (icqEventTag == 0) slot_done(NULL); }