User::User(const UserId& id, bool temporary) : myId(id), m_bNotInList(temporary), myPrivate(new Private(this, id)) { LICQ_D(); // Cache protocol capabilities as a convenience Licq::ProtocolPlugin::Ptr protocol = Licq::gPluginManager.getProtocolPlugin(myId.protocolId()); myProtocolCapabilities = (protocol.get() != NULL ? protocol->capabilities() : 0); myProtocolStatuses = (protocol.get() != NULL ? protocol->statuses() : 0); myServerGroup = 0; if ((myProtocolCapabilities & ProtocolPlugin::CanSingleGroup) == 0) // Protocol handles multiple groups or no groups at all myServerGroup = -1; d->Init(); // Start building filename for user files string filename = "users/" + IniFile::sanitizeName(myId.ownerId().accountId()) + "." + Licq::protocolId_toString(myId.protocolId()); // Create owner specific dir if needed string dirname = gDaemon.baseDir() + filename.c_str(); if (mkdir(dirname.c_str(), 0700) < 0 && errno != EEXIST) gLog.error(tr("Failed to create directory %s: %s"), dirname.c_str(), strerror(errno)); // Add final parts to get filenames filename += "/" + IniFile::sanitizeName(myId.accountId()); d->myConf.setFilename(filename + ".conf"); d->myHistory.setFile(gDaemon.baseDir() + filename + ".history"); myPictureFileName = gDaemon.baseDir() + filename + ".picture"; if (m_bNotInList) { d->setDefaults(); return; } // Make sure we have a file so load won't fail if (!d->myConf.loadFile()) { d->myConf.setSection("user"); if (!d->myConf.writeFile()) gLog.error(tr("Error opening '%s' for writing."), d->myConf.filename().c_str()); d->setDefaults(); } else { d->myConf.setSection("user"); } d->loadUserInfo(); d->loadPictureInfo(); d->loadLicqInfo(); }
QWidget* UserPages::Owner::createPageSettings(QWidget* parent) { QGroupBox* accountBox = new QGroupBox(tr("Account")); QGridLayout* accountLayout = new QGridLayout(accountBox); QLabel* idLabel = new QLabel(tr("User ID:")); accountLayout->addWidget(idLabel, 0, 0); myAccountEdit = new QLineEdit(); myAccountEdit->setEnabled(false); accountLayout->addWidget(myAccountEdit, 0, 1); SkinnableLabel* protocolLabel = new SkinnableLabel(); accountLayout->addWidget(protocolLabel, 0, 2); QLabel* passwordLabel = new QLabel(tr("Password:"******"Save")); accountLayout->addWidget(mySavePwdCheck, 1, 2); QLabel* serverLabel = new QLabel(tr("Server:")); accountLayout->addWidget(serverLabel, 2, 0); myServerHostEdit = new QLineEdit(); #if (QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)) myServerHostEdit->setPlaceholderText(tr("Protocol default")); #endif myServerHostEdit->setToolTip(tr("Host name or IP address of server to connect to. " "Leave blank to use protocol default.")); accountLayout->addWidget(myServerHostEdit, 2, 1); myServerPortSpin = new SpecialSpinBox(0, 0xFFFF, tr("Auto")); myServerPortSpin->setToolTip(tr("Port number for server. \"Auto\" will use protocol default.")); accountLayout->addWidget(myServerPortSpin, 2, 2); QLabel* statusLabel = new QLabel(tr("Startup status:")); accountLayout->addWidget(statusLabel, 3, 0); myAutoLogonCombo = new QComboBox(); myAutoLogonCombo->setToolTip(tr("Automatically log on when first starting up.")); accountLayout->addWidget(myAutoLogonCombo, 3, 1); #define ADD_STATUS(status, cond) \ if (cond) \ myAutoLogonCombo->addItem(User::statusToString(status).c_str(), status); ADD_STATUS(User::OfflineStatus, true); ADD_STATUS(User::OnlineStatus, true); ADD_STATUS(User::OnlineStatus | User::AwayStatus, true); ADD_STATUS(User::OnlineStatus | User::NotAvailableStatus, myProtocolId != MSN_PPID); ADD_STATUS(User::OnlineStatus | User::OccupiedStatus, myProtocolId != JABBER_PPID); ADD_STATUS(User::OnlineStatus | User::DoNotDisturbStatus, myProtocolId != MSN_PPID); ADD_STATUS(User::OnlineStatus | User::FreeForChatStatus, myProtocolId != MSN_PPID); #undef ADD_STATUS myAutoLogonInvisibleCheck = new QCheckBox(tr("Invisible")); if (myProtocolId == JABBER_PPID) myAutoLogonInvisibleCheck->setEnabled(false); accountLayout->addWidget(myAutoLogonInvisibleCheck, 3, 2); QGroupBox* icqBox = NULL; if (myProtocolId == ICQ_PPID) { icqBox = new QGroupBox(tr("ICQ")); QGridLayout* icqLayout = new QGridLayout(icqBox); mySSListCheck = new QCheckBox(tr("Use server side contact list")); mySSListCheck->setToolTip(tr("Store your contacts on the server so they are accessible from different locations and/or programs")); icqLayout->addWidget(mySSListCheck, 0, 0); myReconnectAfterUinClashCheck = new QCheckBox(tr("Reconnect after Uin clash")); myReconnectAfterUinClashCheck->setToolTip(tr("Licq can reconnect you when you got " "disconnected because your Uin was used " "from another location. Check this if you " "want Licq to reconnect automatically.")); icqLayout->addWidget(myReconnectAfterUinClashCheck, 1, 0); myAutoUpdateInfoCheck = new QCheckBox(tr("Auto update contact information")); myAutoUpdateInfoCheck->setToolTip(tr("Automatically update users' server stored information.")); icqLayout->addWidget(myAutoUpdateInfoCheck, 0, 1); myAutoUpdateInfoPluginsCheck = new QCheckBox(tr("Auto update info plugins")); myAutoUpdateInfoPluginsCheck->setToolTip(tr("Automatically update users' Phone Book and Picture.")); icqLayout->addWidget(myAutoUpdateInfoPluginsCheck, 1, 1); myAutoUpdateStatusPluginsCheck = new QCheckBox(tr("Auto update status plugins")); myAutoUpdateStatusPluginsCheck->setToolTip(tr("Automatically update users' Phone \"Follow Me\", File Server and ICQphone status.")); icqLayout->addWidget(myAutoUpdateStatusPluginsCheck, 2, 1); } Licq::ProtocolPlugin::Ptr protocol = Licq::gPluginManager.getProtocolPlugin(myProtocolId); if (protocol.get() != NULL) { protocolLabel->setText(QString::fromLocal8Bit(protocol->name().c_str())); protocolLabel->setPrependPixmap(IconManager::instance()->iconForProtocol(myProtocolId)); } QWidget* w = new QWidget(parent); QVBoxLayout* mainLayout = new QVBoxLayout(w); mainLayout->setContentsMargins(0, 0, 0, 0); mainLayout->addWidget(accountBox); if (icqBox != NULL) mainLayout->addWidget(icqBox); mainLayout->addStretch(1); return w; }
UserEventCommon::UserEventCommon(const Licq::UserId& userId, QWidget* parent, const char* name) : QWidget(parent), myHighestEventId(-1) { Support::setWidgetProps(this, name); setAttribute(Qt::WA_DeleteOnClose, true); myUsers.push_back(userId); { Licq::UserReadGuard user(userId); if (user.isLocked()) { myId = user->accountId().c_str(); myPpid = user->protocolId(); } } // 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 = Licq::gUserManager.isOwner(myUsers.front()); 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; myTypingTimer = 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())); }
void OwnerEditDlg::init() { Support::setWidgetProps(this, "OwnerEdit"); setAttribute(Qt::WA_DeleteOnClose, true); setWindowTitle(tr("Edit Account")); QGridLayout* lay = new QGridLayout(this); lay->setColumnStretch(2, 2); lay->setColumnMinimumWidth(1, 8); SkinnableLabel* protocolName = new SkinnableLabel(); edtId = new QLineEdit(); connect(edtId, SIGNAL(returnPressed()), SLOT(slot_ok())); edtPassword = new QLineEdit(); edtPassword->setEchoMode(QLineEdit::Password); connect(edtPassword, SIGNAL(returnPressed()), SLOT(slot_ok())); myHostEdit = new QLineEdit(); #if (QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)) myHostEdit->setPlaceholderText(tr("Protocol default")); #endif myPortSpin = new SpecialSpinBox(0, 0xffff, tr("Auto")); myPortSpin->setValue(0); int i = 0; QLabel* lbl; #define ADDWIDGET(name, widget) \ lbl = new QLabel(name); \ lbl->setBuddy(widget); \ lay->addWidget(lbl, i, 0); \ lay->addWidget(widget, i++, 2) ADDWIDGET(tr("Protocol:"), protocolName); ADDWIDGET(tr("&User ID:"), edtId); ADDWIDGET(tr("&Password:"******"&Save Password")); lay->addWidget(chkSave, i++, 0, 1, 3); ADDWIDGET(tr("S&erver:"), myHostEdit); ADDWIDGET(tr("P&ort:"), myPortSpin); #undef ADDWIDGET lay->setRowStretch(i++, 2); QDialogButtonBox* buttons = new QDialogButtonBox(); buttons->addButton(QDialogButtonBox::Ok); buttons->addButton(QDialogButtonBox::Cancel); connect(buttons, SIGNAL(accepted()), SLOT(slot_ok())); connect(buttons, SIGNAL(rejected()), SLOT(close())); lay->addWidget(buttons, i++, 0, 1, 3); Licq::ProtocolPlugin::Ptr protocol = Licq::gPluginManager.getProtocolPlugin(myPpid); if (protocol.get() != NULL) protocolName->setText(protocol->name().c_str()); protocolName->setPrependPixmap(IconManager::instance()->iconForProtocol(myPpid)); }