Пример #1
0
void
WAssert(bool test, const char *message, int line, const char *file, const char *date)
{
	if (!test)
	{
		QString out = qApp->translate("Debug",
			"Send this message to [email protected]! "
			"This message has also been dumped to 'assert.txt'."
			"\n\n%1\n\nLine %2\nFile %3\nDate: %4").arg(qApp->translate("Debug",
				message)).arg(line).arg(file).arg(date);
		WFile f;
		if (f.Open(L"assert.txt", QIODevice::WriteOnly))
		{
			QByteArray tmp = out.toUtf8();
			f.WriteBlock(tmp, tmp.length());
			f.Close();
		}
		WPopup(out);
	}
}
Пример #2
0
void mailr() {
  mailrec m, m1;
  filestatusrec fsr;

  WFile *pFileEmail = OpenEmailFile(false);
  WWIV_ASSERT(pFileEmail);
  if (pFileEmail->IsOpen()) {
    int nRecordNumber = pFileEmail->GetLength() / sizeof(mailrec) - 1;
    char c = ' ';
    while (nRecordNumber >= 0 && c != 'Q' && !hangup) {
      pFileEmail->Seek(nRecordNumber * sizeof(mailrec), WFile::seekBegin);
      pFileEmail->Read(&m, sizeof(mailrec));
      if (m.touser != 0) {
        pFileEmail->Close();
        do {
          WUser user;
          GetApplication()->GetUserManager()->ReadUser(&user, m.touser);
          GetSession()->bout << "|#1  To|#7: |#" << GetSession()->GetMessageColor() << user.GetUserNameAndNumber(
                               m.touser) << wwiv::endl;
          int tp = 80;
          int nn = 0;
          if (m.status & status_source_verified) {
            tp -= 2;
          }
          if (m.status & status_new_net) {
            tp -= 1;
            if (wwiv::strings::GetStringLength(m.title) <= tp) {
              nn = m.title[tp + 1];
            } else {
              nn = 0;
            }
          } else {
            nn = 0;
          }
          set_net_num(nn);
          GetSession()->bout << "|#1Subj|#7: |#" << GetSession()->GetMessageColor() << m.title << wwiv::endl;
          if (m.status & status_file) {
            WFile attachDat(syscfg.datadir, ATTACH_DAT);
            if (attachDat.Open(WFile::modeReadOnly | WFile::modeBinary, WFile::shareUnknown, WFile::permReadWrite)) {
              bool found = false;
              long lAttachFileSize = attachDat.Read(&fsr, sizeof(fsr));
              while (lAttachFileSize > 0 && !found) {
                if (m.daten == static_cast<unsigned long>(fsr.id)) {
                  GetSession()->bout << "|#1Filename|#0.... |#2" << fsr.filename << " (" << fsr.numbytes << " bytes)|#0\r\n";
                  found = true;
                }
                if (!found) {
                  lAttachFileSize = attachDat.Read(&fsr, sizeof(fsr));
                }
              }
              if (!found) {
                GetSession()->bout << "|#1Filename|#0.... |#2File : Unknown or Missing|#0\r\n";
              }
              attachDat.Close();
            } else {
              GetSession()->bout << "|#1Filename|#0.... |#2|#2File : Unknown or Missing|#0\r\n";
            }
          }
          bool next;
          read_message1(&(m.msg), (char)(m.anony & 0x0f), true, &next, "email", m.fromsys, m.fromuser);
          GetSession()->bout << "|#2R,D,Q,<space>  : ";
          if (next) {
            c = ' ';
          } else {
            c = onek("QRD ");
          }
          if (c == 'D') {
            pFileEmail = OpenEmailFile(true);
            pFileEmail->Seek(nRecordNumber * sizeof(mailrec), WFile::seekBegin);
            pFileEmail->Read(&m1, sizeof(mailrec));
            if (memcmp(&m, &m1, sizeof(mailrec)) == 0) {
              delmail(pFileEmail, nRecordNumber);
              bool found = false;
              if (m.status & status_file) {
                WFile attachFile(syscfg.datadir, ATTACH_DAT);
                if (attachFile.Open(WFile::modeReadWrite | WFile::modeBinary)) {
                  long lAttachFileSize = attachFile.Read(&fsr, sizeof(fsr));
                  while (lAttachFileSize > 0 && !found) {
                    if (m.daten == static_cast<unsigned long>(fsr.id)) {
                      found = true;
                      fsr.id = 0;
                      attachFile.Seek(static_cast<long>(sizeof(filestatusrec)) * -1L, WFile::seekCurrent);
                      attachFile.Write(&fsr, sizeof(filestatusrec));
                      WFile::Remove(GetApplication()->GetAttachmentDirectory().c_str(), fsr.filename);
                    } else {
                      attachFile.Read(&fsr, sizeof(filestatusrec));
                    }
                  }
                  attachFile.Close();
                }
              }
            } else {
              GetSession()->bout << "Mail file changed; try again.\r\n";
            }
            pFileEmail->Close();
            if (!GetSession()->IsUserOnline() && m.touser == 1 && m.tosys == 0) {
              GetSession()->GetCurrentUser()->SetNumMailWaiting(GetSession()->GetCurrentUser()->GetNumMailWaiting() - 1);
            }
          }
          GetSession()->bout.NewLine(2);
        } while ((c == 'R') && (!hangup));

        pFileEmail = OpenEmailFile(false);
        WWIV_ASSERT(pFileEmail);
        if (!pFileEmail->IsOpen()) {
          break;
        }
      }
      nRecordNumber -= 1;
    }
    pFileEmail->Close();
  }
  delete pFileEmail;
}
Пример #3
0
void close_sub() {
  if (fileSub.IsOpen()) {
    fileSub.Close();
  }
}