| 117 | | AuthUserDlg::AuthUserDlg(CICQDaemon *s, unsigned long nUin, bool bGrant, |
| 118 | | QWidget *parent) |
| 119 | | : LicqDialog(parent, "AuthUserDialog", false, WDestructiveClose) |
| 120 | | { |
| 121 | | server = s; |
| 122 | | m_nUin = nUin; |
| 123 | | m_bGrant = bGrant; |
| 124 | | m_nPPID = LICQ_PPID; |
| 125 | | char szUin[14]; |
| 126 | | sprintf(szUin, "%lu", nUin); |
| 127 | | m_szId = strdup(szUin); |
| 128 | | |
| 129 | | |
| 130 | | if(bGrant) |
| 131 | | setCaption(tr("Licq - Grant Authorisation")); |
| 132 | | else |
| 133 | | setCaption(tr("Licq - Refuse Authorisation")); |
| 134 | | |
| 135 | | QBoxLayout* toplay = new QVBoxLayout(this, 8, 8); |
| 136 | | |
| 137 | | lblUin = new QLabel(this); |
| 138 | | lblUin->setAlignment(AlignCenter); |
| 139 | | if (m_nUin == 0) |
| 140 | | { |
| 141 | | lblUin->setText(tr("Authorize which user (UIN):")); |
| 142 | | edtUin = new QLineEdit(this); |
| 143 | | edtUin->setMinimumWidth(90); |
| 144 | | edtUin->setValidator(new QIntValidator(10000, 2147483647, edtUin)); |
| 145 | | connect (edtUin, SIGNAL(returnPressed()), SLOT(ok()) ); |
| 146 | | QBoxLayout* lay = new QHBoxLayout(toplay); |
| 147 | | lay->addWidget(lblUin); |
| 148 | | lay->addWidget(edtUin); |
| 149 | | } |
| 150 | | else |
| 151 | | { |
| 152 | | edtUin = NULL; |
| 153 | | toplay->addWidget(lblUin); |
| 154 | | QString userName; |
| 155 | | ICQUser *u = gUserManager.FetchUser(m_nUin, LOCK_R); |
| 156 | | if (u != NULL) { |
| 157 | | //QTextCodec *codec = UserCodec::codecForICQUser(u); |
| 158 | | userName = QString("%1 (%2)").arg(QString::fromUtf8(u->GetAlias())).arg(m_nUin); |
| 159 | | gUserManager.DropUser(u); |
| 160 | | } else { |
| 161 | | userName = QString::number(m_nUin); |
| 162 | | } |
| 163 | | |
| 164 | | if (bGrant) |
| 165 | | lblUin->setText(tr("Grant authorization to %1").arg(userName)); |
| 166 | | else |
| 167 | | lblUin->setText(tr("Refuse authorization to %1").arg(userName)); |
| 168 | | } |
| 169 | | |
| 170 | | toplay->addSpacing(6); |
| 171 | | |
| 172 | | grpResponse = new QVGroupBox(tr("Response"), this); |
| 173 | | toplay->addWidget(grpResponse); |
| 174 | | toplay->setStretchFactor(grpResponse, 2); |
| 175 | | |
| 176 | | mleResponse = new MLEditWrap(true, grpResponse); |
| 177 | | |
| 178 | | QBoxLayout* lay = new QHBoxLayout(toplay); |
| 179 | | lay->addStretch(1); |
| 180 | | btnOk = new QPushButton(tr("&Ok"), this); |
| 181 | | btnOk->setMinimumWidth(75); |
| 182 | | lay->addWidget(btnOk); |
| 183 | | btnCancel = new QPushButton(tr("&Cancel"), this); |
| 184 | | btnCancel->setMinimumWidth(75); |
| 185 | | lay->addWidget(btnCancel); |
| 186 | | connect (mleResponse, SIGNAL(signal_CtrlEnterPressed()), this, SLOT(ok())); |
| 187 | | connect (btnOk, SIGNAL(clicked()), SLOT(ok()) ); |
| 188 | | connect (btnCancel, SIGNAL(clicked()), SLOT(close()) ); |
| 189 | | |
| 190 | | if (m_nUin) |
| 191 | | mleResponse->setFocus(); |
| 192 | | else |
| 193 | | edtUin->setFocus(); |
| 194 | | |
| 195 | | show(); |
| 196 | | } |
| 197 | | |