Example #1
0
void ICQClient::snac_login(unsigned short type, unsigned short)
{
    unsigned long newUin;
    switch (type){
    case ICQ_SNACxLOGIN_ERROR:
        m_reconnect = NO_RECONNECT;
        m_socket->error_state(I18N_NOOP("Login error"), AuthError);
        break;
    case ICQ_SNACxLOGIN_REGISTER:
        if (data.owner.Uin.value){
            m_socket->error_state(I18N_NOOP("Registered in no register state"));
            break;
        }
        m_socket->readBuffer.incReadPos(0x2E);
        m_socket->readBuffer.unpack(newUin);
        log(L_DEBUG, "Register %u %08lX", newUin, newUin);
        setUin(newUin);
        setState(Connecting);
        m_socket->connect(getServer(), getPort(), this);
        break;
    case ICQ_SNACxLOGIN_AUTHxKEYxRESPONSE:
        if (data.owner.Screen.ptr){
            string md5_key;
            m_socket->readBuffer.unpackStr(md5_key);
            snac(ICQ_SNACxFAM_LOGIN, ICQ_SNACxLOGIN_MD5xLOGIN, false, false);
            m_socket->writeBuffer.tlv(0x0001, data.owner.Screen.ptr);
            MD5_CTX c;
            MD5_Init(&c);
            unsigned char md[MD5_DIGEST_LENGTH];
            MD5_Update(&c, md5_key.c_str(), md5_key.length());
            string pswd = getContacts()->fromUnicode(NULL, getPassword());
            MD5_Update(&c, pswd.c_str(), pswd.length());
            pswd = "AOL Instant Messenger (SM)";
            MD5_Update(&c, pswd.c_str(), pswd.length());
            MD5_Final(md, &c);

            m_socket->writeBuffer.tlv(0x0025, (char*)&md, sizeof(md));
            m_socket->writeBuffer.tlv(0x0003, "AOL Instant Messenger, version 5.1.3036/WIN32");
            m_socket->writeBuffer.tlv(0x0016, (unsigned short)0x0109);
            m_socket->writeBuffer.tlv(0x0017, (unsigned short)0x0005);
            m_socket->writeBuffer.tlv(0x0018, (unsigned short)0x0001);
            m_socket->writeBuffer.tlv(0x0019, (unsigned short)0x0000);
            m_socket->writeBuffer.tlv(0x001A, (unsigned short)0x0BDC);
            m_socket->writeBuffer.tlv(0x0014, 0x000000D2L);
            m_socket->writeBuffer.tlv(0x000F, "en");
            m_socket->writeBuffer.tlv(0x000E, "us");
            m_socket->writeBuffer.tlv(0x004A, "\x01");
            sendPacket();
        }
        break;
    case ICQ_SNACxLOGIN_LOGINxREPLY:
        chn_close();
        break;
    default:
        log(L_WARN, "Unknown login family type %04X", type);
    }
}
Example #2
0
bool MsgEdit::load(std::istream &s, string &part)
{
    ConfigArray::load(s, part);
    setUin(Uin);
    ICQUser *u = pClient->getUser(Uin);
    if (u == NULL) return false;
    action(mnuAction);
    return true;
}
Example #3
0
void ICQClient::snac_login(unsigned short type, unsigned short)
{
    unsigned long newUin;
    switch (type){
    case ICQ_SNACxLOGIN_ERROR:
        if (data.owner.Uin.value){
            m_reconnect = NO_RECONNECT;
            m_socket->error_state(I18N_NOOP("Login error"), AuthError);
            break;
        }
        // in the process of registering;
        // it seems that we need to request bot protection picture;
        // reconnecting to send the request.
        log(L_DEBUG, "Verification required, reconnecting");
        m_bVerifying = true;
        m_socket->close();
        m_socket->connect(getServer(), getPort(), this);
        break;
    case ICQ_SNACxLOGIN_REGISTER:
        if (data.owner.Uin.value){
            m_socket->error_state(I18N_NOOP("Registered in no register state"));
            break;
        }
        m_socket->readBuffer.incReadPos(0x2E);
        m_socket->readBuffer.unpack(newUin);
        log(L_DEBUG, "Register %lu %08lX", newUin, newUin);
        setUin(newUin);
        setState(Connecting);
        m_socket->connect(getServer(), getPort(), this);
        break;
    case ICQ_SNACxLOGIN_AUTHxKEYxRESPONSE:
        log(L_DEBUG, "Sending MD5 key");
        if (data.owner.Screen.ptr || data.owner.Uin.value){
            string md5_key;
            m_socket->readBuffer.unpackStr(md5_key);
            snac(ICQ_SNACxFAM_LOGIN, ICQ_SNACxLOGIN_MD5xLOGIN, false, false);
	    if (data.owner.Uin.value){
                char uin[20];
                sprintf(uin, "%lu", data.owner.Uin.value);
                m_socket->writeBuffer.tlv(0x0001, uin);
	    }else{
                m_socket->writeBuffer.tlv(0x0001, data.owner.Screen.ptr);
	    }
            string md = md5_key;
            md += getContacts()->fromUnicode(NULL, getPassword());
            md += "AOL Instant Messenger (SM)";
            md = md5(md.c_str());
            m_socket->writeBuffer.tlv(0x0025, md.c_str(), md.length());
	    if (data.owner.Uin.value){
		m_socket->writeBuffer.tlv(0x0003, "ICQ Inc. - Product of ICQ (TM).2003b.5.56.1.3916.85");
		m_socket->writeBuffer.tlv(0x0016, 0x010A);
		m_socket->writeBuffer.tlv(0x0017, 0x0002);
		m_socket->writeBuffer.tlv(0x0018, 0x0038);
		m_socket->writeBuffer.tlv(0x0019, 0x0001);
		m_socket->writeBuffer.tlv(0x001A, 0x0F4C);
		m_socket->writeBuffer.tlv(0x0014, 0x00000055L);
		m_socket->writeBuffer.tlv(0x000f, "en");
		m_socket->writeBuffer.tlv(0x000e, "us");
	    }else{
		m_socket->writeBuffer.tlv(0x0003, "AOL Instant Messenger, version 5.1.3036/WIN32");
		m_socket->writeBuffer.tlv(0x0016, (unsigned short)0x0109);
		m_socket->writeBuffer.tlv(0x0017, (unsigned short)0x0005);
		m_socket->writeBuffer.tlv(0x0018, (unsigned short)0x0001);
		m_socket->writeBuffer.tlv(0x0019, (unsigned short)0x0000);
		m_socket->writeBuffer.tlv(0x001A, (unsigned short)0x0BDC);
		m_socket->writeBuffer.tlv(0x0014, 0x000000D2L);
		m_socket->writeBuffer.tlv(0x000F, "en");
		m_socket->writeBuffer.tlv(0x000E, "us");
		m_socket->writeBuffer.tlv(0x004A, "\x01");
	    }
            sendPacket(true);
        }
        break;
    case ICQ_SNACxLOGIN_LOGINxREPLY:
        chn_close();
        break;
    case ICQ_SNACxLOGIN_REGISTERxSEND_IMG: {
        m_bVerifying = false;
        TlvList tlv(m_socket->readBuffer);
        // currently there are 2 TLVs in SNAC(17,0D):
        // type = 1: the value contains the mime type of the image (image/jpeg); ignored
        // type = 2: the value contains the image itself in the binary form
        Tlv* tlvImage = tlv(2);
        if (!tlvImage)
            break;
        log(L_DEBUG, "Image length: %d bytes", tlvImage->Size());
        uchar* buf = new uchar[tlvImage->Size()];
        memcpy(buf, *tlvImage, tlvImage->Size());
        QPixmap pict;
        if (!pict.loadFromData(buf, tlvImage->Size()))
        {
            delete[] buf;
            break;
        }
        delete[] buf;
        log(L_DEBUG, "Received verification image");
        VerifyDlg verdlg(qApp->activeWindow(), pict);
        if (verdlg.exec() == QDialog::Accepted) // what to do if the user has cancelled the dialog?
        {
            QString verifyStr = verdlg.getVerifyString();
            log(L_DEBUG, "User input: %s", verifyStr.latin1());
            snac(ICQ_SNACxFAM_LOGIN, ICQ_SNACxLOGIN_REGISTERxREQ);
            Buffer msg;
            msg
            << 0x00000000L << 0x28000300L << 0x00000000L
            << 0x00000000L << 0x94680000L << 0x94680000L
            << 0x00000000L << 0x00000000L << 0x00000000L
            << 0x00000000L;
            string pswd = getContacts()->fromUnicode(NULL, getPassword());
            unsigned short len = (unsigned short)(pswd.length() + 1);
            msg.pack(len);
            msg.pack(pswd.c_str(), len);
            msg << 0x94680000L << 0x00000602L;
            m_socket->writeBuffer.tlv(0x0001, msg);
            m_socket->writeBuffer.tlv(0x0009, verifyStr.latin1(), verifyStr.length());
            sendPacket(true);            
        }
        break;
        }
    default:
        log(L_WARN, "Unknown login family type %04X", type);
    }
}
Example #4
0
MsgEdit::MsgEdit(QWidget *p, unsigned long uin)
        : QFrame(p),
        Uin(this, "Uin")
{
    Uin = uin;
    msg = NULL;
    tabId = -1;
    tab = NULL;
    sendEvent = NULL;
    mHistory = NULL;
    bMultiply = false;
    setWFlags(WDestructiveClose);
    QVBoxLayout *lay = new QVBoxLayout(this);
    boxSend = new QVGroupBox(this);
    lay->addWidget(boxSend);
    QFrame *frmHead = new QFrame(boxSend);
    QHBoxLayout *hLay = new QHBoxLayout(frmHead);
    btnBgColor = new CPushButton(frmHead);
    btnBgColor->setTip(i18n("Background color"));
    btnBgColor->setPixmap(Pict("bgcolor"));
    connect(btnBgColor, SIGNAL(clicked()), this, SLOT(setMsgBackgroundColor()));
    btnBgColor->hide();
    hLay->addWidget(btnBgColor);
    btnReply = new QPushButton(i18n("&Reply"), frmHead);
    btnReply->hide();
    hLay->addWidget(btnReply);
    connect(btnReply, SIGNAL(clicked()), this, SLOT(replyClick()));
    btnGrant = new QPushButton(i18n("&Grant"), frmHead);
    btnGrant->hide();
    hLay->addWidget(btnGrant);
    connect(btnGrant, SIGNAL(clicked()), this, SLOT(grantClick()));
    btnAccept = new QPushButton(i18n("&Accept"), frmHead);
    btnAccept->hide();
    hLay->addWidget(btnAccept);
    connect(btnAccept, SIGNAL(clicked()), this, SLOT(acceptMessage()));
    btnFgColor = new CPushButton(frmHead);
    btnFgColor->setTip(i18n("Text color"));
    btnFgColor->setPixmap(Pict("fgcolor"));
    connect(btnFgColor, SIGNAL(clicked()), this, SLOT(setMsgForegroundColor()));
    hLay->addSpacing(2);
    btnFgColor->hide();
    hLay->addWidget(btnFgColor);
    btnQuote = new QPushButton(i18n("&Quote"), frmHead);
    btnQuote->hide();
    hLay->addWidget(btnQuote);
    connect(btnQuote, SIGNAL(clicked()), this, SLOT(quoteClick()));
    btnRefuse = new QPushButton(i18n("&Refuse"), frmHead);
    btnRefuse->hide();
    hLay->addWidget(btnRefuse);
    declineMenu = new QPopupMenu(this);
    connect(btnRefuse, SIGNAL(clicked()), this, SLOT(refuseClick()));
    connect(declineMenu, SIGNAL(activated(int)), this, SLOT(declineMessage(int)));
    declineMenu->insertItem(reason_string(DECLINE_WITHOUT_REASON), DECLINE_WITHOUT_REASON);
    declineMenu->insertItem(reason_string(DECLINE_REASON_BUSY), DECLINE_REASON_BUSY);
    declineMenu->insertItem(reason_string(DECLINE_REASON_LATER), DECLINE_REASON_LATER);
    declineMenu->insertItem(reason_string(DECLINE_REASON_INPUT), DECLINE_REASON_INPUT);
    btnDecline = new QPushButton(i18n("&Decline"), frmHead);
    btnDecline->hide();
    btnDecline->setPopup(declineMenu);
    hLay->addWidget(btnDecline);
    btnBold = new CPushButton(frmHead);
    btnBold->setTip(i18n("Bold"));
    btnBold->setPixmap(Pict("text_bold"));
    btnBold->setToggleButton(true);
    connect(btnBold, SIGNAL(toggled(bool)), this, SLOT(setBold(bool)));
    hLay->addSpacing(2);
    btnBold->hide();
    hLay->addWidget(btnBold);
    btnForward = new QPushButton(i18n("&Forward"), frmHead);
    connect(btnForward, SIGNAL(clicked()), this, SLOT(forwardClick()));
    btnForward->hide();
    hLay->addWidget(btnForward);
    btnItalic = new CPushButton(frmHead);
    btnItalic->setTip(i18n("Italic"));
    btnItalic->setPixmap(Pict("text_italic"));
    btnItalic->setToggleButton(true);
    connect(btnItalic, SIGNAL(toggled(bool)), this, SLOT(setItalic(bool)));
    hLay->addSpacing(2);
    btnItalic->hide();
    hLay->addWidget(btnItalic);
    btnUnder = new CPushButton(frmHead);
    btnUnder->setTip(i18n("Underline"));
    btnUnder->setPixmap(Pict("text_under"));
    btnUnder->setToggleButton(true);
    connect(btnUnder, SIGNAL(toggled(bool)), this, SLOT(setUnder(bool)));
    hLay->addSpacing(2);
    btnUnder->hide();
    hLay->addWidget(btnUnder);
    btnFont = new CPushButton(frmHead);
    btnFont->setTip(i18n("Text font"));
    btnFont->setPixmap(Pict("text"));
    connect(btnFont, SIGNAL(clicked()), this, SLOT(setFont()));
    hLay->addSpacing(2);
    btnFont->hide();
    hLay->addWidget(btnFont);
#ifdef USE_SPELL
    btnSpell = new CPushButton(frmHead);
    btnSpell->setTip(i18n("Spell check"));
    btnSpell->setPixmap(Pict("spellcheck"));
    connect(btnSpell, SIGNAL(clicked()), this, SLOT(spell()));
    hLay->addSpacing(2);
    btnSpell->hide();
    hLay->addWidget(btnSpell);
#endif
    hLay->addSpacing(2);
    hLay->addStretch();
    chkClose = new QCheckBox(i18n("C&lose after send"), frmHead);
    chkClose->setChecked(pMain->CloseAfterSend());
    connect(chkClose, SIGNAL(toggled(bool)), this, SLOT(closeToggle(bool)));
    hLay->addWidget(chkClose);
    btnSend = new QPushButton(frmHead);
    connect(btnSend, SIGNAL(clicked()), this, SLOT(sendClick()));
    hLay->addWidget(btnSend);
    btnNext = new PictPushButton(frmHead);
    connect(btnNext, SIGNAL(clicked()), this, SLOT(nextClick()));
    btnNext->hide();
    hLay->addWidget(btnNext);
    phone = new QFrame(boxSend);
    phone->hide();
    QHBoxLayout *hlay = new QHBoxLayout(phone);
    QLabel *title = new QLabel(i18n("Phone:"), phone);
    hlay->addWidget(title);
    phoneEdit = new QComboBox(phone);
    phoneEdit->setEditable(true);
    phoneEdit->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
    hlay->addWidget(phoneEdit);
    connect(phoneEdit, SIGNAL(textChanged(const QString&)), this, SLOT(textChanged(const QString&)));
    url   = new QFrame(boxSend);
    url->hide();
    hlay = new QHBoxLayout(url);
    title = new QLabel(i18n("URL:"), url);
    hlay->addWidget(title);
    urlEdit = new QLineEdit(url);
    hlay->addWidget(urlEdit);
    connect(urlEdit, SIGNAL(textChanged(const QString&)), this, SLOT(textChanged(const QString&)));
    file = new QFrame(boxSend);
    file->hide();
    hlay = new QHBoxLayout(file);
    title = new QLabel(i18n("File:"), file);
    hlay->addWidget(title);
    fileEdit = new EditFile(file);
    hlay->addWidget(fileEdit);
    connect(fileEdit, SIGNAL(textChanged(const QString&)), this, SLOT(textChanged(const QString&)));
    btnMultiply = new CPushButton(frmHead);
    btnMultiply->setTip(i18n("Multiply send"));
    btnMultiply->setPixmap(Pict("1rightarrow"));
    connect(btnMultiply, SIGNAL(clicked()), this, SLOT(toggleMultiply()));
    hLay->addSpacing(2);
    hLay->addWidget(btnMultiply);
    lblUsers = new QLabel(i18n("Drag users here"), boxSend);
    edit  = new EditSpell(this);
    edit->hide();
    lay->addWidget(edit);
    users = new UserTbl(this);
    users->hide();
    lay->addWidget(users);
    view  = new TextShow(this);
    view->hide();
    lay->addWidget(view);
    connect(edit, SIGNAL(textChanged()), this, SLOT(editTextChanged()));
    connect(edit, SIGNAL(currentFontChanged(const QFont&)), this, SLOT(editFontChanged(const QFont&)));
    connect(edit, SIGNAL(ctrlEnterPressed()), this, SLOT(sendClick()));
    connect(users, SIGNAL(changed()), this, SLOT(textChanged()));
    connect(pClient, SIGNAL(messageReceived(ICQMessage*)), this, SLOT(messageReceived(ICQMessage*)));
    connect(pClient, SIGNAL(event(ICQEvent*)), this, SLOT(processEvent(ICQEvent*)));
    connect(pMain, SIGNAL(chatChanged()), this, SLOT(chatChanged()));
    connect(pMain, SIGNAL(ftChanged()), this, SLOT(ftChanged()));
    setState();
    setUin(uin);
}