void UsrPacket::answer(const char *cmd, vector<string> &args) { if (strcmp(cmd, "USR")){ QTimer::singleShot(0, m_client, SLOT(authFailed())); return; } if (args[0] == "OK"){ QTimer::singleShot(0, m_client, SLOT(authOk())); return; } if (args[1] == "S"){ MD5_CTX c; unsigned char md[MD5_DIGEST_LENGTH]; MD5_Init(&c); string user; user = m_client->getLogin().utf8(); MD5_Update(&c, args[2].c_str(),(unsigned long)args[2].length()); string pswd; pswd = m_client->getPassword().utf8(); MD5_Update(&c, pswd.c_str(), pswd.length()); MD5_Final(md, &c); string digest = ""; for (unsigned i = 0; i < MD5_DIGEST_LENGTH; i++){ char b[3]; sprintf(b, "%02x",md[i]); digest += b; } MSNPacket *packet = new UsrPacket(m_client, digest.c_str()); packet->send(); } }
void UsrPacket::answer(vector<string> &args) { if (args[0] == "OK"){ QTimer::singleShot(0, m_client, SLOT(authOk())); return; } if (args[1] == "S"){ m_client->m_authChallenge = args[2].c_str(); m_client->requestLoginHost("https://nexus.passport.com/rdr/pprdr.asp"); } }
bool UsrPacket::answer(const char*, vector<string> &args) { if (args[0] == "OK"){ QTimer::singleShot(0, m_client, SLOT(authOk())); return false;; } if (args[1] == "S"){ m_client->m_authChallenge = args[2].c_str(); m_client->m_fetchId = fetch(m_client, "https://nexus.passport.com/rdr/pprdr.asp"); if (m_client->m_fetchId == 0){ m_client->authFailed(); return false; } m_client->m_state = MSNClient::LoginHost; } return false; }
void YahooClient::process_packet() { Params params; Params::iterator it; for (;;) { string key; string value; if (!m_socket->readBuffer.scan("\xC0\x80", key) || !m_socket->readBuffer.scan("\xC0\x80", value)) break; unsigned key_id = atol(key.c_str()); params.push_back(PARAM(key_id, value)); log(L_DEBUG, "Param: %u %s", key_id, value.c_str()); } switch (m_service) { case YAHOO_SERVICE_VERIFY: if (m_pkt_status != 1) { m_reconnect = NO_RECONNECT; m_socket->error_state(I18N_NOOP("Yahoo! login lock")); return; } addParam(1, getLogin().utf8()); sendPacket(YAHOO_SERVICE_AUTH); break; case YAHOO_SERVICE_AUTH: process_auth(params[13], params[94], params[1]); break; case YAHOO_SERVICE_AUTHRESP: m_pkt_status = 0; if (params[66]) m_pkt_status = atol(params[66]); switch (m_pkt_status) { case YAHOO_LOGIN_OK: authOk(); return; case YAHOO_LOGIN_PASSWD: m_reconnect = NO_RECONNECT; m_socket->error_state(I18N_NOOP("Login failed"), AuthError); return; case YAHOO_LOGIN_LOCK: m_reconnect = NO_RECONNECT; m_socket->error_state(I18N_NOOP("Your account has been locked"), AuthError); return; case YAHOO_LOGIN_DUPL: m_reconnect = NO_RECONNECT; m_socket->error_state(I18N_NOOP("Your account is being used from another location")); return; default: m_socket->error_state(I18N_NOOP("Login failed")); } break; case YAHOO_SERVICE_LIST: authOk(); loadList(params[87]); for (it = params.begin(); it != params.end(); ++it) { if ((*it).first == 59) { string s = (*it).second; string n = getToken(s, ' '); const char *p = s.c_str(); for (; *p; ++p) if (*p != ' ') break; string cookie = p; s = getToken(cookie, ';'); if (n == "Y") setCookieY(s.c_str()); if (n == "T") setCookieT(s.c_str()); } } break; case YAHOO_SERVICE_LOGOFF: if (m_pkt_status == (unsigned long)(-1)) { m_reconnect = NO_RECONNECT; m_socket->error_state(I18N_NOOP("Your account is being used from another location")); return; } case YAHOO_SERVICE_LOGON: if (params[1]) authOk(); case YAHOO_SERVICE_USERSTAT: case YAHOO_SERVICE_ISAWAY: case YAHOO_SERVICE_ISBACK: case YAHOO_SERVICE_GAMELOGON: case YAHOO_SERVICE_GAMELOGOFF: case YAHOO_SERVICE_IDACT: case YAHOO_SERVICE_IDDEACT: if (params[7] && params[13]) processStatus(m_service, params[7], params[10], params[19], params[47], params[137]); break; case YAHOO_SERVICE_IDLE: case YAHOO_SERVICE_MAILSTAT: case YAHOO_SERVICE_CHATINVITE: case YAHOO_SERVICE_CALENDAR: case YAHOO_SERVICE_NEWPERSONALMAIL: case YAHOO_SERVICE_ADDIDENT: case YAHOO_SERVICE_ADDIGNORE: case YAHOO_SERVICE_PING: case YAHOO_SERVICE_GOTGROUPRENAME: case YAHOO_SERVICE_GROUPRENAME: case YAHOO_SERVICE_PASSTHROUGH2: case YAHOO_SERVICE_CHATLOGON: case YAHOO_SERVICE_CHATLOGOFF: case YAHOO_SERVICE_CHATMSG: case YAHOO_SERVICE_REJECTCONTACT: case YAHOO_SERVICE_PEERTOPEER: break; case YAHOO_SERVICE_MESSAGE: if (params[4] && params[14]) process_message(params[4], params[14], params[97]); break; case YAHOO_SERVICE_NOTIFY: if (params[4] && params[49]) notify(params[4], params[49], params[13]); break; case YAHOO_SERVICE_NEWCONTACT: if (params[1]) { contact_added(params[3], params[14]); return; } if (params[7]) { processStatus(m_service, params[7], params[10], params[14], params[47], params[137]); return; } if (m_pkt_status == 7) contact_rejected(params[3], params[14]); break; case YAHOO_SERVICE_P2PFILEXFER: if ((params[49] == NULL) || strcmp(params[49], "FILEXFER")) { log(L_WARN, "Unhandled p2p type %s", params[49]); break; } case YAHOO_SERVICE_FILETRANSFER: if (params[4] && params[27] && params[28] && params[14] && params[20]) process_file(params[4], params[27], params[28], params[14], params[20]); break; default: log(L_WARN, "Unknown service %X", m_service); } }