Bool CreateAccount(char *name,char *password,int type,int *account_id) { char buf[ENCRYPT_LEN+1]; account_node *a; if (GetAccountByName(name) != NULL) return False; a = (account_node *)AllocateMemory(MALLOC_ID_ACCOUNT,sizeof(account_node)); a->account_id = next_account_id++; a->name = (char *)AllocateMemory(MALLOC_ID_ACCOUNT,strlen(name)+1); strcpy(a->name,name); MDString(password,(unsigned char *) buf); buf[ENCRYPT_LEN] = 0; a->password = (char *)AllocateMemory(MALLOC_ID_ACCOUNT,strlen(buf)+1); strcpy(a->password,buf); a->type = type; a->last_login_time = 0; a->suspend_time = 0; a->credits = 100*ConfigInt(CREDIT_INIT); InsertAccount(a); *account_id = a->account_id; return True; }
void DeliciousService::getReplyFinished () { QNetworkReply *reply = qobject_cast<QNetworkReply*> (sender ()); if (!reply) { qWarning () << Q_FUNC_INFO << sender () << "isn't a QNetworkReply"; return; } if (Reply2Request_ [reply].Type_ == OTDownload) { DeliciousAccount *account = GetAccountByName (Reply2Request_ [reply].Login_); if (account) { const QVariantList& downloadedBookmarks = DeliciousApi_-> ParseDownloadReply (Account2ReplyContent_ [account]); if (!downloadedBookmarks.isEmpty ()) { account->AppendDownloadedBookmarks (downloadedBookmarks); account->SetLastDownloadDateTime (QDateTime::currentDateTime ()); emit gotBookmarks (account, downloadedBookmarks); } } } reply->deleteLater (); }
void DeleteAccountFromBuffer(char *buf) { char *line; char *version,*name; account_node *a; version = name = NULL; line = strtok(buf,"\r\n"); while (line != NULL) { if (ConfigBool(DEBUG_SMTP)) { dprintf(": %i %s\n",strlen(line),line); Sleep(500); } if (strcmp(line,"VERSION:") == 0) version = strtok(NULL,"\r\n"); if (strcmp(line,"NAME:") == 0) name = strtok(NULL,"\r\n"); line = strtok(NULL,"\r\n"); } if (version == NULL) { eprintf("DeleteAccountFromBuffer got no version\n"); return; } if (strcmp(version,"1") != 0) { eprintf("DeleteAccountFromBuffer got version != 1 (%s)\n",version); return; } if (name == NULL) { eprintf("DeleteAccountFromBuffer got email w/o name\n"); return; } EnterServerLock(); a = GetAccountByName(name); if (a == NULL) eprintf("DeleteAccountFromBuffer got email w/name that's not a valid account %s\n",name); else PostThreadMessage(main_thread_id,WM_BLAK_MAIN_DELETE_ACCOUNT,0,a->account_id); LeaveServerLock(); }
void DeliciousService::readyReadReply () { QNetworkReply *reply = qobject_cast<QNetworkReply*> (sender ()); if (!reply) { qWarning () << Q_FUNC_INFO << sender () << "isn't a QNetworkReply"; return; } QByteArray result = reply->readAll (); Entity e; Priority priority = PInfo_; QString msg; switch (Reply2Request_ [reply].Type_) { case OTAuth: if (DeliciousApi_->ParseAuthReply (result)) { DeliciousAccount *account = new DeliciousAccount (Reply2Request_ [reply].Login_, this); account->SetPassword (Reply2Request_ [reply].Password_); Accounts_ << account; saveAccounts (); emit accountAdded (QObjectList () << account->GetQObject ()); msg = tr ("Authentication successfull."); priority = LeechCraft::PInfo_; } else { msg = tr ("Invalid login or password."); priority = LeechCraft::PWarning_; } e = Util::MakeNotification ("OnlineBookmarks", msg, priority); break; case OTUpload: if (DeliciousApi_->ParseUploadReply (result)) { if (Reply2Request_ [reply].Count_ == Reply2Request_ [reply].Current_ + 1) { msg = tr ("Bookmarks were sent to Del.icio.us."); priority = LeechCraft::PInfo_; DeliciousAccount *account = GetAccountByName (Reply2Request_ [reply].Login_); if (account) account->SetLastUploadDateTime (QDateTime::currentDateTime ()); emit bookmarksUploaded (); } } else { msg = tr ("Error sending bookmarks to Del.icio.us."); priority = LeechCraft::PWarning_; } e = Util::MakeNotification ("OnlineBookmarks", msg, priority); break; case OTDownload: Account2ReplyContent_ [GetAccountByName (Reply2Request_ [reply].Login_)] .append (result); break; } if (!msg.isEmpty ()) emit gotEntity (e); }