예제 #1
0
	bool Run(wxWindow* parent, const wxString& m_local_dir, int count_files, int count_dirs)
	{
		if (!Load(parent, _T("ID_SEARCH_DOWNLOAD")))
			return false;

		wxString desc;
		if (!count_dirs)
			desc.Printf(wxPLURAL("Selected %d file for transfer.", "Selected %d files for transfer.", count_files), count_files);
		else if (!count_files)
			desc.Printf(wxPLURAL("Selected %d directory with its contents for transfer.", "Selected %d directories with their contents for transfer.", count_dirs), count_dirs);
		else
		{
			wxString files = wxString::Format(wxPLURAL("%d file", "%d files", count_files), count_files);
			wxString dirs = wxString::Format(wxPLURAL("%d directory with its contents", "%d directories with their contents", count_dirs), count_dirs);
			desc.Printf(_("Selected %s and %s for transfer."), files.c_str(), dirs.c_str());
		}
		XRCCTRL(*this, "ID_DESC", wxStaticText)->SetLabel(desc);

		XRCCTRL(*this, "ID_LOCALPATH", wxTextCtrl)->ChangeValue(m_local_dir);

		if (ShowModal() != wxID_OK)
			return false;

		return true;
	}
예제 #2
0
파일: search.cpp 프로젝트: robotenok/MILF
void CSearchDialog::OnDelete(wxCommandEvent& event)
{
    if (!m_pState->IsRemoteIdle())
        return;

    // Find all selected files and directories
    std::list<CServerPath> selected_dirs;
    std::list<int> selected_files;
    ProcessSelection(selected_files, selected_dirs);

    if (selected_files.empty() && selected_dirs.empty())
        return;

    if (selected_dirs.size() > 1)
    {
        wxMessageBox(_("Deleting multiple unrelated directories is not yet supported"), _("Deleting directories"), wxICON_EXCLAMATION);
        return;
    }

    wxString question;
    if (selected_dirs.empty())
        question.Printf(wxPLURAL("Really delete %d file from the server?", "Really delete %d files from the server?", selected_files.size()), selected_files.size());
    else if (selected_files.empty())
        question.Printf(wxPLURAL("Really delete %d directory with its contents from the server?", "Really delete %d directories with their contents from the server?", selected_dirs.size()), selected_dirs.size());
    else
    {
        wxString files = wxString::Format(wxPLURAL("%d file", "%d files", selected_files.size()), selected_files.size());
        wxString dirs = wxString::Format(wxPLURAL("%d directory with its contents", "%d directories with their contents", selected_dirs.size()), selected_dirs.size());
        question.Printf(_("Really delete %s and %s from the server?"), files.c_str(), dirs.c_str());
    }

    if (wxMessageBox(question, _("Confirm deletion"), wxICON_QUESTION | wxYES_NO) != wxYES)
        return;

    for (std::list<int>::const_iterator iter = selected_files.begin(); iter != selected_files.end(); ++iter)
    {
        const CDirentry& entry = m_results->m_fileData[*iter].entry;
        std::list<wxString> files_to_delete;
        files_to_delete.push_back(entry.name);
        m_pState->m_pCommandQueue->ProcessCommand(new CDeleteCommand(m_results->m_fileData[*iter].path, files_to_delete));
    }

    for (std::list<CServerPath>::const_iterator iter = selected_dirs.begin(); iter != selected_dirs.end(); ++iter)
    {
        CServerPath path = *iter;
        if (!path.HasParent())
            m_pState->GetRecursiveOperationHandler()->AddDirectoryToVisit(path, _T(""));
        else
        {
            m_pState->GetRecursiveOperationHandler()->AddDirectoryToVisit(path.GetParent(), path.GetLastSegment());
            path = path.GetParent();
        }

        std::list<CFilter> filters; // Empty, recurse into everything
        m_pState->GetRecursiveOperationHandler()->StartRecursiveOperation(CRecursiveOperation::recursive_delete, path, filters, !path.HasParent(), m_original_dir);
    }
}
예제 #3
0
void CCommentDialogLst::UpdateList()
{
	int count = 0;
	ClearList();

	FileRatingList list;
	m_file->GetRatingAndComments(list);
	for (FileRatingList::const_iterator it = list.begin(); it != list.end(); ++it) {
		if (!thePrefs::IsCommentFiltered(it->Comment)) {
			m_list->InsertItem(count, it->UserName);
			m_list->SetItem(count, 1, it->FileName);
			m_list->SetItem(count, 2, (it->Rating != -1) ? GetRateString(it->Rating) : wxString(wxT("on")));
			m_list->SetItem(count, 3, it->Comment);
			m_list->SetItemPtrData(count, reinterpret_cast<wxUIntPtr>(new SFileRating(*it)));
			++count;
		}
	}

	wxString info;
	if (count == 0) {
		info = _("No comments");
	} else {
		info = CFormat(wxPLURAL("%u comment", "%u comments", count)) % count;
	}

	FindWindow(IDC_CMSTATUS)->SetLabel(info);
	FindWindow(IDC_CMSTATUS)->GetParent()->Layout();

	m_file->UpdateFileRatingCommentAvail();
}
예제 #4
0
wxString wxFileData::GetHint() const
{
    wxString s = m_filePath;
    s += wxT("  ");

    if (IsDir())
        s += _("<DIR>");
    else if (IsLink())
        s += _("<LINK>");
    else if (IsDrive())
        s += _("<DRIVE>");
    else // plain file
        s += wxString::Format(wxPLURAL("%ld byte", "%ld bytes", m_size),
                              wxLongLong(m_size).ToString().c_str());

    s += wxT(' ');

    if ( !IsDrive() )
    {
        s << GetModificationTime()
          << wxT("  ")
          << m_permissions;
    }

    return s;
}
예제 #5
0
wxLog::~wxLog()
{
    // Flush() must be called before destroying the object as otherwise some
    // messages could be lost
    if ( gs_prevLog.numRepeated )
    {
        wxMessageOutputDebug().Printf
        (
#if wxUSE_INTL
            wxPLURAL
            (
                "Last repeated message (\"%s\", %lu time) wasn't output",
                "Last repeated message (\"%s\", %lu times) wasn't output",
                gs_prevLog.numRepeated
            ),
#else
            wxS("Last repeated message (\"%s\", %lu time(s)) wasn't output"),
#endif
            gs_prevLog.msg,
            gs_prevLog.numRepeated
        );
    }

    delete m_formatter;
}
예제 #6
0
unsigned wxLog::LogLastRepeatIfNeeded()
{
    const unsigned count = gs_prevLog.numRepeated;

    if ( gs_prevLog.numRepeated )
    {
        wxString msg;
#if wxUSE_INTL
        if ( gs_prevLog.numRepeated == 1 )
        {
            // We use a separate message for this case as "repeated 1 time"
            // looks somewhat strange.
            msg = _("The previous message repeated once.");
        }
        else
        {
            // Notice that we still use wxPLURAL() to ensure that multiple
            // numbers of times are correctly formatted, even though we never
            // actually use the singular string.
            msg.Printf(wxPLURAL("The previous message repeated %lu time.",
                                "The previous message repeated %lu times.",
                                gs_prevLog.numRepeated),
                       gs_prevLog.numRepeated);
        }
#else
        msg.Printf(wxS("The previous message was repeated %lu time(s)."),
                   gs_prevLog.numRepeated);
#endif
        gs_prevLog.numRepeated = 0;
        gs_prevLog.msg.clear();
        DoLogRecord(gs_prevLog.level, msg, gs_prevLog.info);
    }

    return count;
}
예제 #7
0
bool CVerifyCertDialog::DisplayCert(wxDialogEx* pDlg, const CCertificate& cert)
{
	bool warning = false;
	if (cert.GetActivationTime().IsValid()) {
		if (cert.GetActivationTime() > wxDateTime::Now()) {
			pDlg->SetChildLabel(XRCID("ID_ACTIVATION_TIME"), wxString::Format(_("%s - Not yet valid!"), cert.GetActivationTime().FormatDate()));
			warning = true;
		}
		else
			pDlg->SetChildLabel(XRCID("ID_ACTIVATION_TIME"), cert.GetActivationTime().FormatDate());
	}
	else {
		warning = true;
		pDlg->SetChildLabel(XRCID("ID_ACTIVATION_TIME"), _("Invalid date"));
	}

	if (cert.GetExpirationTime().IsValid()) {
		if (cert.GetExpirationTime() < wxDateTime::Now()) {
			pDlg->SetChildLabel(XRCID("ID_EXPIRATION_TIME"), wxString::Format(_("%s - Certificate expired!"), cert.GetExpirationTime().FormatDate()));
			warning = true;
		}
		else
			pDlg->SetChildLabel(XRCID("ID_EXPIRATION_TIME"), cert.GetExpirationTime().FormatDate());
	}
	else {
		warning = true;
		pDlg->SetChildLabel(XRCID("ID_EXPIRATION_TIME"), _("Invalid date"));
	}

	if (!cert.GetSerial().empty())
		pDlg->SetChildLabel(XRCID("ID_SERIAL"), cert.GetSerial());
	else
		pDlg->SetChildLabel(XRCID("ID_SERIAL"), _("None"));

	pDlg->SetChildLabel(XRCID("ID_PKALGO"), wxString::Format(_("%s with %d bits"), cert.GetPkAlgoName(), cert.GetPkAlgoBits()));
	pDlg->SetChildLabel(XRCID("ID_SIGNALGO"), cert.GetSignatureAlgorithm());

	wxString const& sha256 = cert.GetFingerPrintSHA256();
	pDlg->SetChildLabel(XRCID("ID_FINGERPRINT_SHA256"), sha256.Left(sha256.size() / 2 + 1) + _T("\n") + sha256.Mid(sha256.size() / 2 + 1));
	pDlg->SetChildLabel(XRCID("ID_FINGERPRINT_SHA1"), cert.GetFingerPrintSHA1());

	ParseDN(XRCCTRL(*pDlg, "ID_ISSUER_BOX", wxStaticBox), cert.GetIssuer(), m_pIssuerSizer);

	auto subjectBox = XRCCTRL(*pDlg, "ID_SUBJECT_BOX", wxStaticBox);
	ParseDN(subjectBox, cert.GetSubject(), m_pSubjectSizer);

	auto const& altNames = cert.GetAltSubjectNames();
	if (!altNames.empty()) {
		wxString str;
		for (auto const& altName : altNames) {
			str += altName + _T("\n");
		}
		str.RemoveLast();
		m_pSubjectSizer->Add(new wxStaticText(subjectBox, wxID_ANY, wxPLURAL("Alternative name:", "Alternative names:", altNames.size())));
		m_pSubjectSizer->Add(new wxStaticText(subjectBox, wxID_ANY, str));
	}

	return warning;
}
예제 #8
0
inline wxString
NotifyAnswer::getAnswerTime(void) const
{
	if (wasAllowed_) {
		switch (timeUnit_) {
		case TIMEUNIT_SECOND:
			return wxString::Format(wxPLURAL(
			    "this message was allowed for %d second.",
			    "this message was allowed for %d seconds.",
			    timeValue_), timeValue_);
		case TIMEUNIT_MINUTE:
			return wxString::Format(wxPLURAL(
			    "this message was allowed for %d minute.",
			    "this message was allowed for %d minutes.",
			    timeValue_), timeValue_);
		case TIMEUNIT_HOUR:
			return wxString::Format(wxPLURAL(
			    "this message was allowed for %d hour.",
			    "this message was allowed for %d hours.",
			    timeValue_), timeValue_);
		case TIMEUNIT_DAY:
			return wxString::Format(wxPLURAL(
			    "this message was allowed for %d day.",
			    "this message was allowed for %d days.",
			    timeValue_), timeValue_);
		}
	} else {
		switch (timeUnit_) {
		case TIMEUNIT_SECOND:
			return wxString::Format(wxPLURAL(
			    "this message was forbidden for %d second.",
			    "this message was forbidden for %d seconds.",
			    timeValue_), timeValue_);
		case TIMEUNIT_MINUTE:
			return wxString::Format(wxPLURAL(
			    "this message was forbidden for %d minute.",
			    "this message was forbidden for %d minutes.",
			    timeValue_), timeValue_);
		case TIMEUNIT_HOUR:
			return wxString::Format(wxPLURAL(
			    "this message was forbidden for %d hour.",
			    "this message was forbidden for %d hours.",
			    timeValue_), timeValue_);
		case TIMEUNIT_DAY:
			return wxString::Format(wxPLURAL(
			    "this message was forbidden for %d day.",
			    "this message was forbidden for %d days.",
			    timeValue_), timeValue_);
		}
	}

	return (wxEmptyString); /* Should never be reached */
}
예제 #9
0
bool slNode::CheckAcksAndContinue(wxFrame *frame)
{
	long l = GetOutstandingAcks();
	if (!l)
		return true;

	wxMessageDialog dlg(frame, wxString::Format(wxPLURAL("There are %ld event acknowledgement outstanding.\nContinue anyway?",
	                    "There are %ld event acknowledgements outstanding.\nContinue anyway?", l), l),
	                    _("Events pending"), wxYES_NO | wxNO_DEFAULT);

	return dlg.ShowModal() == wxID_YES;
}
void mmCustomFieldListDialog::UpdateField()
{
    Model_CustomField::Data *field = Model_CustomField::instance().get(m_field_id);
    if (!field)
        return;

    int UpdateResponse = wxMessageBox(
        wxString::Format(_("This function will massive search & replace for \"%s\" custom field values\n"
            "It will match & replace only complete field value, no partial or middle-value replaces allowed\n"
            "Please consider that there isn't any validation!"),field->DESCRIPTION)
        , _("Confirm Custom Field Content Update")
        , wxYES_NO | wxNO_DEFAULT | wxICON_WARNING);
    if (UpdateResponse != wxYES)
        return;

    const wxString txtSearch = wxGetTextFromUser(_("Find what"), _("Update Custom Field Content"));
    if (txtSearch == "")
    {
        int Response = wxMessageBox(
            _("Do you want to update blank content?\n"
                "Press no if you want to abort replace procedure!")
            , _("Update Custom Field Content")
            , wxYES_NO | wxNO_DEFAULT | wxICON_WARNING);
        if (Response != wxYES)
            return;
    }

    const wxString txtReplace = wxGetTextFromUser(_("Replace with"), _("Update Custom Field Content"));
    if (txtReplace == "")
    {
        int Response = wxMessageBox(
            _("Do you want to update to blank?\n"
                "Press no if you want to abort replace procedure!")
            , _("Update Custom Field Content")
            , wxYES_NO | wxNO_DEFAULT | wxICON_WARNING);
        if (Response != wxYES)
            return;
    }

    auto data = Model_CustomFieldData::instance().find(Model_CustomFieldData::FIELDID(m_field_id),
        Model_CustomFieldData::CONTENT(txtSearch));
    for (auto &d : data)
    {
        d.CONTENT = txtReplace;
    }
    Model_CustomFieldData::instance().save(data);

    wxMessageBox(wxString::Format(wxPLURAL("%zu occurrence founded and replaced!", "%zu occurrences founded and replaced!", data.size()), data.size())
        , _("Update Custom Field Content"), wxOK | wxICON_INFORMATION);
}
예제 #11
0
void CControlSocket::LogTransferResultMessage(int nErrorCode, CFileTransferOpData *pData)
{
	if (m_pTransferStatus && (nErrorCode == FZ_REPLY_OK || m_pTransferStatus->madeProgress))
	{
		int elapsed = wxTimeSpan(wxDateTime::Now() - m_pTransferStatus->started).GetSeconds().GetLo();
		if (elapsed <= 0)
			elapsed = 1;
		wxString time = wxString::Format(
			wxPLURAL("%d second", "%d seconds", elapsed),
			elapsed);

		wxLongLong transferred = m_pTransferStatus->currentOffset - m_pTransferStatus->startOffset;
		wxString size = CSizeFormatBase::Format(m_pEngine->GetOptions(), transferred, true);

		MessageType msgType = MessageType::Error;
		wxString msg;
		if (nErrorCode == FZ_REPLY_OK)
		{
			msgType = MessageType::Status;
			msg = _("File transfer successful, transferred %s in %s");
		}
		else if ((nErrorCode & FZ_REPLY_CANCELED) == FZ_REPLY_CANCELED)
			msg = _("File transfer aborted by user after transferring %s in %s");
		else if ((nErrorCode & FZ_REPLY_CRITICALERROR) == FZ_REPLY_CRITICALERROR)
			msg = _("Critical file transfer error after transferring %s in %s");
		else
			msg = _("File transfer failed after transferring %s in %s");
		LogMessage(msgType, msg, size, time);
	}
	else
	{
		if ((nErrorCode & FZ_REPLY_CANCELED) == FZ_REPLY_CANCELED)
			LogMessage(MessageType::Error, _("File transfer aborted by user"));
		else if (nErrorCode == FZ_REPLY_OK)
		{
			if (pData->transferInitiated)
				LogMessage(MessageType::Status, _("File transfer successful"));
			else
				LogMessage(MessageType::Status, _("File transfer skipped"));
		}
		else if ((nErrorCode & FZ_REPLY_CRITICALERROR) == FZ_REPLY_CRITICALERROR)
			LogMessage(MessageType::Error, _("Critical file transfer error"));
		else
			LogMessage(MessageType::Error, _("File transfer failed"));
	}
}
예제 #12
0
void SjLogDialog::MessagesChanged(long firstNewIndex)
{
	if( m_icon && !m_iconIsInfo )
	{
		wxBitmap bitmap = wxArtProvider::GetIcon(wxART_INFORMATION, wxART_MESSAGE_BOX);
		m_icon->SetBitmap(bitmap);
		m_iconIsInfo = true;
	}

	m_msg->SetLabel(wxString::Format(
	  // TRANSLATORS: %i will be replaced by a number
	  wxPLURAL("%i message", "%i messages", m_logGui->m_aPacked.GetCount()),
	  (int)m_logGui->m_aPacked.GetCount()));
	Layout();

	m_listCtrl->MessagesChanged(firstNewIndex);
}
예제 #13
0
void CControlSocket::LogTransferResultMessage(int nErrorCode, CFileTransferOpData *pData)
{
	bool tmp;

	CTransferStatus const status = engine_.transfer_status_.Get(tmp);
	if (!status.empty() && (nErrorCode == FZ_REPLY_OK || status.madeProgress)) {
		int elapsed = static_cast<int>((fz::datetime::now() - status.started).get_seconds());
		if (elapsed <= 0)
			elapsed = 1;
		wxString time = wxString::Format(
			wxPLURAL("%d second", "%d seconds", elapsed),
			elapsed);

		int64_t transferred = status.currentOffset - status.startOffset;
		wxString size = CSizeFormatBase::Format(&engine_.GetOptions(), transferred, true);

		MessageType msgType = MessageType::Error;
		wxString msg;
		if (nErrorCode == FZ_REPLY_OK) {
			msgType = MessageType::Status;
			msg = _("File transfer successful, transferred %s in %s");
		}
		else if ((nErrorCode & FZ_REPLY_CANCELED) == FZ_REPLY_CANCELED)
			msg = _("File transfer aborted by user after transferring %s in %s");
		else if ((nErrorCode & FZ_REPLY_CRITICALERROR) == FZ_REPLY_CRITICALERROR)
			msg = _("Critical file transfer error after transferring %s in %s");
		else
			msg = _("File transfer failed after transferring %s in %s");
		LogMessage(msgType, msg, size, time);
	}
	else {
		if ((nErrorCode & FZ_REPLY_CANCELED) == FZ_REPLY_CANCELED)
			LogMessage(MessageType::Error, _("File transfer aborted by user"));
		else if (nErrorCode == FZ_REPLY_OK) {
			if (pData->transferInitiated)
				LogMessage(MessageType::Status, _("File transfer successful"));
			else
				LogMessage(MessageType::Status, _("File transfer skipped"));
		}
		else if ((nErrorCode & FZ_REPLY_CRITICALERROR) == FZ_REPLY_CRITICALERROR)
			LogMessage(MessageType::Error, _("Critical file transfer error"));
		else
			LogMessage(MessageType::Error, _("File transfer failed"));
	}
}
예제 #14
0
파일: log.cpp 프로젝트: madnessw/thesnow
unsigned wxLog::LogLastRepeatIfNeededUnlocked()
{
    long retval = ms_prevCounter;
    if ( ms_prevCounter > 0 )
    {
        wxString msg;
#if wxUSE_INTL
        msg.Printf(wxPLURAL("The previous message repeated once.",
                            "The previous message repeated %lu times.",
                            ms_prevCounter),
                   ms_prevCounter);
#else
        msg.Printf(wxT("The previous message was repeated."));
#endif
        ms_prevCounter = 0;
        ms_prevString.clear();
        DoLog(ms_prevLevel, msg.c_str(), ms_prevTimeStamp);
    }
    return retval;
}
예제 #15
0
bool ctlSQLBox::ReplaceAll(const wxString &find, const wxString &replace, bool wholeWord, bool matchCase, bool useRegexps)
{
	// Use DoFind to repeatedly replace text
	int count = 0;
	int initialPos = GetCurrentPos();
	GotoPos(0);

	while(DoFind(find, replace, true, wholeWord, matchCase, useRegexps, false, false))
		count++;

	GotoPos(initialPos);

	wxString msg;
	msg.Printf(wxPLURAL("%d replacement made.", "%d replacements made.", count), count);
	wxMessageBox(msg, _("Replace all"), wxOK | wxICON_INFORMATION);

	if (count)
		return true;
	else
		return false;
}
예제 #16
0
void MyFrame::OnTest2(wxCommandEvent& WXUNUSED(event))
{
    const wxString& title = _("Testing _N() (ngettext)");
    wxTextEntryDialog d(this,
        _("Please enter range for plural forms of \"n files deleted\" phrase"),
        title, "0-10");

    if (d.ShowModal() == wxID_OK)
    {
        int first, last;
        wxSscanf(d.GetValue(), "%d-%d", &first, &last);
        wxString s(title);
        s << "\n";
        for (int n = first; n <= last; ++n)
        {
            s << n << " " <<
                wxPLURAL("file deleted", "files deleted", n) <<
                "\n";
        }
        wxMessageBox(s);
    }
}
예제 #17
0
void CControlSocket::OnTimer(fz::timer_id)
{
	m_timer = 0; // It's a one-shot timer, no need to stop it

	int const timeout = engine_.GetOptions().GetOptionVal(OPTION_TIMEOUT);
	if (timeout > 0) {
		fz::duration elapsed = fz::monotonic_clock::now() - m_lastActivity;

		if ((!m_pCurOpData || !m_pCurOpData->waitForAsyncRequest) && !IsWaitingForLock()) {
			if (elapsed > fz::duration::from_seconds(timeout)) {
				LogMessage(MessageType::Error, wxPLURAL("Connection timed out after %d second of inactivity", "Connection timed out after %d seconds of inactivity", timeout), timeout);
				DoClose(FZ_REPLY_TIMEOUT);
				return;
			}
		}
		else {
			elapsed = fz::duration();
		}

		m_timer = add_timer(fz::duration::from_milliseconds(timeout * 1000) - elapsed, true);
	}
}
예제 #18
0
int CFileZillaEnginePrivate::ContinueConnect()
{
	const CConnectCommand *pConnectCommand = (CConnectCommand *)m_pCurrentCommand;
	const CServer& server = pConnectCommand->GetServer();
	unsigned int delay = GetRemainingReconnectDelay(server);
	if (delay)
	{
		m_pLogging->LogMessage(Status, wxPLURAL("Delaying connection for %d second due to previously failed connection attempt...", "Delaying connection for %d seconds due to previously failed connection attempt...", (delay + 999) / 1000), (delay + 999) / 1000);
		m_retryTimer.Start(delay, true);
		return FZ_REPLY_WOULDBLOCK;
	}

	switch (server.GetProtocol())
	{
	case FTP:
	case FTPS:
	case FTPES:
	case INSECURE_FTP:
		m_pControlSocket = new CFtpControlSocket(this);
		break;
	case SFTP:
		m_pControlSocket = new CSftpControlSocket(this);
		break;
	case HTTP:
	case HTTPS:
		m_pControlSocket = new CHttpControlSocket(this);
		break;
	default:
		m_pLogging->LogMessage(Debug_Warning, _T("Not a valid protocol: %d"), server.GetProtocol());
		return FZ_REPLY_SYNTAXERROR|FZ_REPLY_DISCONNECTED;
	}

	int res = m_pControlSocket->Connect(server);
	if (m_retryTimer.IsRunning())
		return FZ_REPLY_WOULDBLOCK;

	return res;
}
예제 #19
0
파일: log.cpp 프로젝트: madnessw/thesnow
unsigned wxLog::LogLastRepeatIfNeeded()
{
    const unsigned count = gs_prevLog.numRepeated;

    if ( gs_prevLog.numRepeated )
    {
        wxString msg;
#if wxUSE_INTL
        msg.Printf(wxPLURAL("The previous message repeated once.",
                            "The previous message repeated %lu times.",
                            gs_prevLog.numRepeated),
                   gs_prevLog.numRepeated);
#else
        msg.Printf(wxS("The previous message was repeated %lu times."),
                   gs_prevLog.numRepeated);
#endif
        gs_prevLog.numRepeated = 0;
        gs_prevLog.msg.clear();
        DoLogRecord(gs_prevLog.level, msg, gs_prevLog.info);
    }

    return count;
}
예제 #20
0
int pgQueryThread::Execute()
{
	wxMutexLocker lock(m_queriesLock);

	PGresult       *result           = NULL;
	wxMBConv       &conv             = *(m_conn->conv);

	wxString       &query            = m_queries[m_currIndex]->m_query;
	int            &resultToRetrieve = m_queries[m_currIndex]->m_resToRetrieve;
	long           &rowsInserted     = m_queries[m_currIndex]->m_rowsInserted;
	Oid            &insertedOid      = m_queries[m_currIndex]->m_insertedOid;
	// using the alias for the pointer here, in order to save the result back
	// in the pgBatchQuery object
	pgSet         *&dataSet          = m_queries[m_currIndex]->m_resultSet;
	int            &rc               = m_queries[m_currIndex]->m_returnCode;
	pgParamsArray  *params           = m_queries[m_currIndex]->m_params;
	bool            useCallable      = m_queries[m_currIndex]->m_useCallable;
	pgError        &err              = m_queries[m_currIndex]->m_err;

	wxCharBuffer queryBuf = query.mb_str(conv);

	if (PQstatus(m_conn->conn) != CONNECTION_OK)
	{
		rc = pgQueryResultEvent::PGQ_CONN_LOST;
		err.msg_primary = _("Connection to the database server lost");

		return(RaiseEvent(rc));
	}

	if (!queryBuf && !query.IsEmpty())
	{
		rc = pgQueryResultEvent::PGQ_STRING_INVALID;
		m_conn->SetLastResultError(NULL, _("the query could not be converted to the required encoding."));
		err.msg_primary = _("Query string is empty");

		return(RaiseEvent(rc));
	}

	// Honour the parameters (if any)
	if (params && params->GetCount() > 0)
	{
		int    pCount = params->GetCount();
		int    ret    = 0,
		       idx    = 0;

		Oid         *pOids    = (Oid *)malloc(pCount * sizeof(Oid));
		const char **pParams  = (const char **)malloc(pCount * sizeof(const char *));
		int         *pLens    = (int *)malloc(pCount * sizeof(int));
		int         *pFormats = (int *)malloc(pCount * sizeof(int));
		// modes are used only by enterprisedb callable statement
#if defined (__WXMSW__) || (EDB_LIBPQ)
		int         *pModes   = (int *)malloc(pCount * sizeof(int));
#endif

		for (; idx < pCount; idx++)
		{
			pgParam *param = (*params)[idx];

			pOids[idx] = param->m_type;
			pParams[idx] = (const char *)param->m_val;
			pLens[idx] = param->m_len;
			pFormats[idx] = param->GetFormat();
#if defined (__WXMSW__) || (EDB_LIBPQ)
			pModes[idx] = param->m_mode;
#endif
		}

		if (useCallable)
		{
#if defined (__WXMSW__) || (EDB_LIBPQ)
			wxLogInfo(wxString::Format(
			              _("using an enterprisedb callable statement (queryid:%ld, threadid:%ld)"),
			              (long)m_currIndex, (long)GetId()));
			wxString stmt = wxString::Format(wxT("pgQueryThread-%ld-%ld"), this->GetId(), m_currIndex);
			PGresult *res = PQiPrepareOut(m_conn->conn, stmt.mb_str(wxConvUTF8),
			                              queryBuf, pCount, pOids, pModes);

			if( PQresultStatus(res) != PGRES_COMMAND_OK)
			{
				rc = pgQueryResultEvent::PGQ_ERROR_PREPARE_CALLABLE;
				err.SetError(res, &conv);

				PQclear(res);

				goto return_with_error;
			}

			ret = PQiSendQueryPreparedOut(m_conn->conn, stmt.mb_str(wxConvUTF8),
			                              pCount, pParams, pLens, pFormats, 1);

			if (ret != 1)
			{
				rc = pgQueryResultEvent::PGQ_ERROR_EXECUTE_CALLABLE;

				m_conn->SetLastResultError(NULL, _("Failed to run PQsendQuery in pgQueryThread"));
				err.msg_primary = wxString(PQerrorMessage(m_conn->conn), conv);

				PQclear(res);
				res = NULL;

				goto return_with_error;
			}

			PQclear(res);
			res = NULL;
#else
			rc = -1;
			wxASSERT_MSG(false,
			             _("the program execution flow must not reach to this point in pgQueryThread"));

			goto return_with_error;
#endif
		}
		else
		{
			// assumptions: we will need the results in text format only
			ret = PQsendQueryParams(m_conn->conn, queryBuf, pCount, pOids, pParams, pLens, pFormats, 0);

			if (ret != 1)
			{
				rc = pgQueryResultEvent::PGQ_ERROR_SEND_QUERY;

				m_conn->SetLastResultError(NULL,
				                           _("Failed to run PQsendQueryParams in pgQueryThread"));

				err.msg_primary = _("Failed to run PQsendQueryParams in pgQueryThread.\n") +
				                  wxString(PQerrorMessage(m_conn->conn), conv);

				goto return_with_error;
			}
		}
		goto continue_without_error;

return_with_error:
		{
			free(pOids);
			free(pParams);
			free(pLens);
			free(pFormats);
#if defined (__WXMSW__) || (EDB_LIBPQ)
			free(pModes);
#endif
			return (RaiseEvent(rc));
		}
	}
	else
	{
		// use the PQsendQuery api in case, we don't have any parameters to
		// pass to the server
		if (!PQsendQuery(m_conn->conn, queryBuf))
		{
			rc = pgQueryResultEvent::PGQ_ERROR_SEND_QUERY;

			err.msg_primary = _("Failed to run PQsendQueryParams in pgQueryThread.\n") +
			                  wxString(PQerrorMessage(m_conn->conn), conv);

			return(RaiseEvent(rc));
		}
	}

continue_without_error:
	int resultsRetrieved = 0;
	PGresult *lastResult = 0;

	while (true)
	{
		// This is a 'joinable' thread, it is not advisable to call 'delete'
		// function on this.
		// Hence - it does not make sense to use the function 'testdestroy' here.
		// We introduced the 'CancelExecution' function for the same purpose.
		//
		// Also, do not raise event when the query execution is cancelled to
		// avoid the bugs introduced to handle events by the event handler,
		// which is missing or being deleted.
		//
		// It will be responsibility of the compononent, using the object of
		// pgQueryThread, to take the required actions to take care of the
		// issue.
		if (m_cancelled)
		{
			m_conn->CancelExecution();
			rc = pgQueryResultEvent::PGQ_EXECUTION_CANCELLED;

			err.msg_primary = _("Execution Cancelled");

			if (lastResult)
			{
				PQclear(lastResult);
				lastResult = NULL;
			}
			AppendMessage(_("Query-thread execution cancelled...\nthe query is:"));
			AppendMessage(query);

			return rc;
		}

		if ((rc = PQconsumeInput(m_conn->conn)) != 1)
		{
			if (rc == 0)
			{
				err.msg_primary = wxString(PQerrorMessage(m_conn->conn), conv);
			}
			if (PQstatus(m_conn->conn) == CONNECTION_BAD)
			{
				err.msg_primary = _("Connection to the database server lost");
				rc = pgQueryResultEvent::PGQ_CONN_LOST;
			}
			else
			{
				rc = pgQueryResultEvent::PGQ_ERROR_CONSUME_INPUT;
			}

			return(RaiseEvent(rc));
		}

		if (PQisBusy(m_conn->conn))
		{
			Yield();
			this->Sleep(10);

			continue;
		}

		// if resultToRetrieve is given, the nth result will be returned,
		// otherwise the last result set will be returned.
		// all others are discarded
		PGresult *res = PQgetResult(m_conn->conn);

		if (!res)
			break;

		if((PQresultStatus(res) == PGRES_NONFATAL_ERROR) ||
		        (PQresultStatus(res) == PGRES_FATAL_ERROR) ||
		        (PQresultStatus(res) == PGRES_BAD_RESPONSE))
		{
			result = res;
			err.SetError(res, &conv);

			// Wait for the execution to be finished
			// We need to fetch all the results, before sending the error
			// message
			do
			{
				if (PQconsumeInput(m_conn->conn) != 1)
				{
					if (m_cancelled)
					{
						rc = pgQueryResultEvent::PGQ_EXECUTION_CANCELLED;

						// Release the result as the query execution has been cancelled by the
						// user
						if (result)
							PQclear(result);

						return rc;
					}
					goto out_of_consume_input_loop;
				}

				if ((res = PQgetResult(m_conn->conn)) == NULL)
				{
					goto out_of_consume_input_loop;
				}
				// Release the temporary results
				PQclear(res);
				res = NULL;

				if (PQisBusy(m_conn->conn))
				{
					Yield();
					this->Sleep(10);
				}
			}
			while (true);

			break;
		}

#if defined (__WXMSW__) || (EDB_LIBPQ)
		// there should be 2 results in the callable statement - the first is the
		// dummy, the second contains our out params.
		if (useCallable)
		{
			PQclear(res);
			result = PQiGetOutResult(m_conn->conn);
		}
#endif
		if (PQresultStatus(res) == PGRES_COPY_IN)
		{
			rc = PGRES_COPY_IN;
			PQputCopyEnd(m_conn->conn, "not supported by pgadmin");
		}

		if (PQresultStatus(res) == PGRES_COPY_OUT)
		{
			int copyRc;
			char *buf;
			int copyRows = 0;
			int lastCopyRc = 0;

			rc = PGRES_COPY_OUT;

			AppendMessage(_("query returned copy data:\n"));

			while((copyRc = PQgetCopyData(m_conn->conn, &buf, 1)) >= 0)
			{
				if (buf != NULL)
				{
					if (copyRows < 100)
					{
						wxString str(buf, conv);
						wxCriticalSectionLocker cs(m_criticalSection);
						m_queries[m_currIndex]->m_message.Append(str);

					}
					else if (copyRows == 100)
						AppendMessage(_("Query returned more than 100 copy rows, discarding the rest...\n"));

					PQfreemem(buf);
				}
				if (copyRc > 0)
					copyRows++;

				if (m_cancelled)
				{
					m_conn->CancelExecution();
					rc = pgQueryResultEvent::PGQ_EXECUTION_CANCELLED;

					return -1;
				}
				if (lastCopyRc == 0 && copyRc == 0)
				{
					Yield();
					this->Sleep(10);
				}
				if (copyRc == 0)
				{
					if (!PQconsumeInput(m_conn->conn))
					{
						if (PQstatus(m_conn->conn) == CONNECTION_BAD)
						{
							err.msg_primary = _("Connection to the database server lost");
							rc = pgQueryResultEvent::PGQ_CONN_LOST;
						}
						else
						{
							rc = pgQueryResultEvent::PGQ_ERROR_CONSUME_INPUT;

							err.msg_primary = wxString(PQerrorMessage(m_conn->conn), conv);
						}
						return(RaiseEvent(rc));
					}
				}
				lastCopyRc = copyRc;
			}

			res = PQgetResult(m_conn->conn);

			if (!res)
				break;
		}

		resultsRetrieved++;
		if (resultsRetrieved == resultToRetrieve)
		{
			result = res;
			insertedOid = PQoidValue(res);
			if (insertedOid && insertedOid != (Oid) - 1)
				AppendMessage(wxString::Format(_("query inserted one row with oid %d.\n"), insertedOid));
			else
				AppendMessage(wxString::Format(wxPLURAL("query result with %d row will be returned.\n", "query result with %d rows will be returned.\n",
				                                        PQntuples(result)), PQntuples(result)));
			continue;
		}

		if (lastResult)
		{
			if (PQntuples(lastResult))
				AppendMessage(wxString::Format(wxPLURAL("query result with %d row discarded.\n", "query result with %d rows discarded.\n",
				                                        PQntuples(lastResult)), PQntuples(lastResult)));
			PQclear(lastResult);
		}
		lastResult = res;
	}
out_of_consume_input_loop:

	if (!result)
		result = lastResult;

	err.SetError(result, &conv);

	AppendMessage(wxT("\n"));

	rc = PQresultStatus(result);
	if (rc == PGRES_TUPLES_OK)
	{
		dataSet = new pgSet(result, m_conn, conv, m_conn->needColQuoting);
		dataSet->MoveFirst();
	}
	else if (rc == PGRES_COMMAND_OK)
	{
		char *s = PQcmdTuples(result);
		if (*s)
			rowsInserted = atol(s);
	}
	else if (rc == PGRES_FATAL_ERROR ||
	         rc == PGRES_NONFATAL_ERROR ||
	         rc == PGRES_BAD_RESPONSE)
	{
		if (result)
		{
			AppendMessage(wxString(PQresultErrorMessage(result), conv));
			PQclear(result);
			result = NULL;
		}
		else
		{
			AppendMessage(wxString(PQerrorMessage(m_conn->conn), conv));
		}

		return(RaiseEvent(rc));
	}

	insertedOid = PQoidValue(result);
	if (insertedOid == (Oid) - 1)
		insertedOid = 0;

	return(RaiseEvent(1));
}
예제 #21
0
SjLogDialog::SjLogDialog(SjLogGui* logGui,
                         wxWindow *parent,
                         long style,
                         long aIndex)
	: SjDialog(parent, _("Console"),
	           parent? SJ_MODELESS : SJ_MODAL,
	           SJ_RESIZEABLE_IF_POSSIBLE)
{
	m_see = NULL;
	m_logGui = logGui;
	s_dlg = this;

	// create dialog
	m_listCtrl = NULL;
	wxSizer* sizer1 = new wxBoxSizer(wxVERTICAL);
	SetSizer(sizer1);

	m_sizerAddRemoveParent = new wxBoxSizer(wxVERTICAL);
	sizer1->Add(m_sizerAddRemoveParent, 1, wxALL|wxGROW, SJ_DLG_SPACE);

	wxSizer* sizer3 = new wxBoxSizer(wxHORIZONTAL);
	m_sizerAddRemoveParent->Add(sizer3, 0, 0, 0);

	// icon
	m_icon = NULL;
	m_iconIsInfo = false;
	if( (style & wxICON_MASK) )
	{
		wxBitmap bitmap;
		switch ( style & wxICON_MASK )
		{
			case wxICON_INFORMATION:    bitmap = wxArtProvider::GetIcon(wxART_INFORMATION, wxART_MESSAGE_BOX);  m_iconIsInfo = true; break;
			case wxICON_WARNING:        bitmap = wxArtProvider::GetIcon(wxART_WARNING, wxART_MESSAGE_BOX);      break;
			default:                    bitmap = wxArtProvider::GetIcon(wxART_ERROR, wxART_MESSAGE_BOX);        break;
		}
		m_icon = new wxStaticBitmap(this, -1, bitmap);
		sizer3->Add(m_icon, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, SJ_DLG_SPACE);
	}

	// text
	wxString msg;
	if( aIndex < 0 || aIndex >= (long)logGui->m_aPacked.GetCount() )
	{
		msg = wxString::Format(
		  // TRANSLATORS: %i will be replaced by a number
		  wxPLURAL("%i message", "%i messages", m_logGui->m_aPacked.GetCount()),
		  (int)m_logGui->m_aPacked.GetCount());
		m_showingDetails = true;
	}
	else
	{
		unsigned long severity, time;
		wxString scope;
		SjLogGui::ExplodeMessage(logGui->m_aPacked[aIndex], severity, time, msg, scope);
		m_showingDetails = false;
	}

	m_msg = new wxStaticText(this, -1, msg);
	m_msg->Wrap(SJ_MSG_BOX_WRAP);
	sizer3->Add(m_msg, 0, wxALL|wxALIGN_CENTER_VERTICAL, SJ_DLG_SPACE);

	m_sizerDetails = new wxBoxSizer(wxVERTICAL);
	m_sizerAddRemoveParent->Add(m_sizerDetails, 1, wxGROW|wxTOP, SJ_DLG_SPACE);
	m_sizerDetailsAttached = true;

	// list control ( added if needed )
	m_listCtrl = new SjLogListCtrl(logGui, this, IDC_LIST_CTRL, aIndex);
	m_sizerDetails->Add(m_listCtrl, 1, wxGROW|wxTOP, SJ_DLG_SPACE);

	// evaluate etc. ( added if needed )
	wxSizer* sizer4 = new wxBoxSizer(wxHORIZONTAL);
	m_sizerDetails->Add(sizer4, 0, wxGROW|wxTOP, SJ_DLG_SPACE/2);

	#if SJ_USE_SCRIPTS
		m_evalInput = new wxTextCtrl(this, IDC_EVAL_INPUT, wxT(""), wxDefaultPosition, wxSize(300, -1), wxTE_PROCESS_ENTER);
		sizer4->Add(m_evalInput, 1, wxRIGHT|wxALIGN_CENTER_VERTICAL, SJ_DLG_SPACE/2);

		m_evalButton = new wxButton(this, IDC_EVAL_BUTTON, _("Evaluate"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
		sizer4->Add(m_evalButton, 0, wxRIGHT|wxALIGN_CENTER_VERTICAL, SJ_DLG_SPACE/2);
	#endif

	m_clearButton = new wxButton(this, IDC_CLEAR_BUTTON, _("Clear"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
	sizer4->Add(m_clearButton, 0, wxRIGHT|wxALIGN_CENTER_VERTICAL, SJ_DLG_SPACE/2);

	m_saveButton = new wxButton(this, IDC_SAVE_BUTTON, _("Save"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
	sizer4->Add(m_saveButton, 0, wxALIGN_CENTER_VERTICAL, SJ_DLG_SPACE);

	m_autoOpenCheckBox = new wxCheckBox(this, IDC_AUTO_OPEN_CHECKBOX, _("Open console on errors and warnings"));
	m_autoOpenCheckBox->SetValue(SjLogGui::GetAutoOpen());
	m_sizerDetails->Add(m_autoOpenCheckBox, 0, wxTOP, SJ_DLG_SPACE);

	// buttons
	sizer1->Add(CreateButtons(SJ_DLG_MENU|SJ_DLG_OK, _("Close")),
	            0, wxGROW|wxLEFT|wxTOP|wxRIGHT|wxBOTTOM, SJ_DLG_SPACE);

	ShowDetails(m_showingDetails);

	sizer1->SetSizeHints(this);

	FindWindow(wxID_OK)->SetFocus();

	m_listCtrl->SizeChanged();
	CenterOnParent();
}
예제 #22
0
bool frmExport::Export(pgSet *set)
{
	ctlSQLResult *grid=0;
	if (!set)
	{
		wxLogInfo(wxT("Exporting data from the grid"));
		grid = (ctlSQLResult *)parent;
	}
	else
		wxLogInfo(wxT("Exporting data from a resultset"));

    wxFile file(txtFilename->GetValue(), wxFile::write);
    if (!file.IsOpened())
    {
        wxLogError(__("Failed to open file %s."), txtFilename->GetValue().c_str());
        return false;
    }

    wxString line;
    long skipped = 0;
    wxWX2MBbuf buf;

    int colCount, rowCount;

	if (set)
	{
		colCount = set->NumCols();
		rowCount = set->NumRows();
	}
	else
	{
		colCount = grid->GetNumberCols();
		rowCount = grid->NumRows();
	}

    int col;
    if (chkColnames->GetValue())
    {
        for (col=0 ; col < colCount ; col++)
        {
            if (!col)
                line=wxEmptyString;
            else
                line += cbColSeparator->GetValue();
            
            if (rbQuoteStrings->GetValue() || rbQuoteAll->GetValue())
            {
                wxString qc = cbQuoteChar->GetValue();
				
				wxString hdr;
				if (set)
                    hdr = set->ColName(col);
				else
					hdr = grid->OnGetItemText(-1, col+1).BeforeFirst('\n');

                hdr.Replace(qc, qc+qc);
                line += qc + hdr + qc;
            }
            else
			{
				if (set)
                    line += set->ColName(col);
				else
					line += grid->OnGetItemText(-1, col+1).BeforeFirst('\n');
			}
        }
        if (rbCRLF->GetValue())
            line += wxT("\r\n");
        else
            line += wxT("\n");

        if (rbUnicode->GetValue())
            file.Write(line, wxConvUTF8);
        else
        {
            buf = line.mb_str(wxConvLibc);
            if (!buf)
                skipped++;
            else
                file.Write(line, wxConvLibc);
        }
    }


    wxString text;
    OID typOid;

    int row;
    for (row=0 ; row < rowCount ; row++)
    {
        for (col=0 ; col < colCount ; col++)
        {
            if (!col)
                line=wxEmptyString;
            else
                line += cbColSeparator->GetValue();

            bool needQuote=rbQuoteAll->GetValue();

			if (set)
			{
                text = set->GetVal(col);
                typOid = set->ColTypClass(col);
			}
			else
			{
				text = grid->OnGetItemText(row, col+1);
				typOid = grid->colTypClasses[col];
			}

            if (!needQuote && rbQuoteStrings->GetValue())
            {
                // find out if string
                switch (typOid)
                {
                    case PGTYPCLASS_NUMERIC:
                    case PGTYPCLASS_BOOL:
                        break;
                    default:
                        needQuote=true;
                        break;
                }
            }
            if (needQuote)
            {
                wxString qc = cbQuoteChar->GetValue();
                text.Replace(qc, qc+qc);
                line += qc + text + qc;
            }
            else
                line += text;
        }
        if (rbCRLF->GetValue())
            line += wxT("\r\n");
        else
            line += wxT("\n");

        if (rbUnicode->GetValue())
            file.Write(line, wxConvUTF8);
        else
        {
            buf = line.mb_str(wxConvLibc);
            if (!buf)
                skipped++;
            else
                file.Write(line, wxConvLibc);
        }

		if (set)
			set->MoveNext();
    }
    file.Close();

    if (skipped)
        wxLogError(wxPLURAL(
            "Data export incomplete.\n\n%d row contained characters that could not be converted to the local charset.\n\nPlease correct the data or try using UTF8 instead.", 
            "Data export incomplete.\n\n%d rows contained characters that could not be converted to the local charset.\n\nPlease correct the data or try using UTF8 instead.", 
            skipped), skipped);
    else
        wxMessageBox(_("Data export completed successfully."), _("Export data"), wxICON_INFORMATION | wxOK);

    return true;
}
예제 #23
0
int pgQueryThread::execute()
{
	rowsInserted = -1L;

	if (!conn->conn)
		return(raiseEvent(0));

	wxCharBuffer queryBuf = query.mb_str(*conn->conv);
	if (!queryBuf && !query.IsEmpty())
	{
		conn->SetLastResultError(NULL, _("The query could not be converted to the required encoding."));
		return(raiseEvent(0));
	}

	if (!PQsendQuery(conn->conn, queryBuf))
	{
		conn->SetLastResultError(NULL);
		conn->IsAlive();
		return(raiseEvent(0));
	}
	int resultsRetrieved = 0;
	PGresult *lastResult = 0;
	while (true)
	{
		if (TestDestroy())
		{
			if (rc != -3)
			{
				if (!PQrequestCancel(conn->conn)) // could not abort; abort failed.
					return(raiseEvent(-1));

				rc = -3;
			}
		}
		if (!PQconsumeInput(conn->conn))
			return(raiseEvent(0));
		if (PQisBusy(conn->conn))
		{
			Yield();
			this->Sleep(10);
			continue;
		}

		// If resultToRetrieve is given, the nth result will be returned,
		// otherwise the last result set will be returned.
		// all others are discarded
		PGresult *res = PQgetResult(conn->conn);

		if (!res)
			break;

		resultsRetrieved++;
		if (resultsRetrieved == resultToRetrieve)
		{
			result = res;
			insertedOid = PQoidValue(res);
			if (insertedOid && insertedOid != (OID) - 1)
				appendMessage(wxString::Format(_("Query inserted one row with OID %d.\n"), insertedOid));
			else
				appendMessage(wxString::Format(wxPLURAL("Query result with %d row will be returned.\n", "Query result with %d rows will be returned.\n",
				                                        PQntuples(result))));
			continue;
		}
		if (lastResult)
		{
			if (PQntuples(lastResult))
				appendMessage(wxString::Format(wxPLURAL("Query result with %d row discarded.\n", "Query result with %d rows discarded.\n",
				                                        PQntuples(lastResult))));
			PQclear(lastResult);
		}
		lastResult = res;
	}

	if (!result)
		result = lastResult;

	conn->SetLastResultError(result);

	appendMessage(wxT("\n"));
	rc = PQresultStatus(result);
	insertedOid = PQoidValue(result);
	if (insertedOid == (OID) - 1)
		insertedOid = 0;

	if (rc == PGRES_TUPLES_OK)
	{
		dataSet = new pgSet(result, conn, *conn->conv, conn->needColQuoting);
		dataSet->MoveFirst();
	}
	else if (rc == PGRES_COMMAND_OK)
	{
		char *s = PQcmdTuples(result);
		if (*s)
			rowsInserted = atol(s);
	}
	else if (rc == PGRES_FATAL_ERROR)
	{
		appendMessage(conn->GetLastError() + wxT("\n"));
	}
	return(raiseEvent(1));
}
예제 #24
0
void Catalog::ExportToHTML(std::ostream& f)
{
    const bool translated = HasCapability(Catalog::Cap::Translations);

    f << "<!DOCTYPE html>\n"
         "<html>\n"
         "<head>\n"
         "  <title>" << str::to_utf8(m_header.Project) << "</title>\n"
         "  <meta http-equiv='Content-Type' content='text/html; charset=utf-8'>\n"
         "  <style>\n" << CSS_STYLE << "\n"
         "  </style>\n"
         "</head>\n"
         "<body>\n"
         "<div class='container'>\n";

    // Metadata section:

    f << "<table class='metadata'>\n";
    if (!m_header.Project.empty())
        TableRow(f, _("Project:"), m_header.Project);
    if (translated && m_header.Lang.IsValid())
        TableRow(f, _("Language:"), m_header.Lang.DisplayName());
    f << "</table>\n";


    // Statistics:
    if (translated)
    {
        int all = 0;
        int fuzzy = 0;
        int untranslated = 0;
        int unfinished = 0;
        GetStatistics(&all, &fuzzy, nullptr, &untranslated, &unfinished);
        int percent = (all == 0 ) ? 0 : (100 * (all - unfinished) / all);

        f << "<div class='stats'>\n"
          << "  <div class='graph'>\n";
        if (all > unfinished)
          f << "    <div class='percent-done' style='width: " << 100.0 * (all - unfinished) / all << "%'>&nbsp;</div>\n";
        if (fuzzy > 0)
          f << "    <div class='percent-fuzzy' style='width: " << 100.0 * fuzzy / all << "%'>&nbsp;</div>\n";
        if (untranslated > 0)
          f << "    <div class='percent-untrans' style='width: " << 100.0 * untranslated / all << "%'>&nbsp;</div>\n";
        f << "  </div>\n"
          << "  <div class='legend'>";
        f << str::to_utf8(wxString::Format(_("Translated: %d of %d (%d %%)"), all - unfinished, all, percent));
        if (unfinished > 0)
            f << str::to_utf8(L"  •  ") << str::to_utf8(wxString::Format(_("Remaining: %d"), unfinished));
        f << "  </div>\n"
          << "</div>\n";
    }
    else
    {
        int all = (int)items().size();
        f << "<div class='stats'>\n"
          << "  <div class='graph'>\n"
          << "    <div class='percent-untrans' style='width: 100%'>&nbsp;</div>\n"
          << "  </div>\n"
          << "  <div class='legend'>"
          << str::to_utf8(wxString::Format(wxPLURAL("%d entry", "%d entries", all), all))
          << "  </div>\n"
          << "</div>\n";
    }

    // Translations:

    std::string lang_src, lang_tra;
    if (m_sourceLanguage.IsValid())
        lang_src = " lang='" + m_sourceLanguage.RFC3066() + "'";
    if (m_header.Lang.IsValid())
    {
        lang_tra = " lang='" + m_header.Lang.RFC3066() + "'";
        if (m_header.Lang.IsRTL())
            lang_tra += " dir='rtl'";
    }

    auto thead_src = m_sourceLanguage.IsValid()
                     ? (wxString::Format(_(L"Source text — %s"), m_sourceLanguage.DisplayName()))
                     : _("Source text");
    auto thead_tra = wxString::Format(_(L"Translation — %s"),
                                      m_header.Lang.IsValid() ? m_header.Lang.DisplayName() : _("unknown language"));

    f << "<table class='translations'>\n"
         "  <thead>\n"
         "    <tr>\n"
         "      <th>" << str::to_utf8(thead_src) << "</th>\n";
    if (translated)
    {
        f << "      <th>" << str::to_utf8(thead_tra) << "</th>\n";
    }
    f << "    </tr>\n"
         "  </thead>\n"
         "  <tbody>\n";

    for (auto& item: items())
    {
        bool hasComments = item->HasComment() || item->HasExtractedComments();

        std::string klass("i");
        if (!item->IsTranslated())
            klass += " untrans";
        if (item->IsFuzzy())
            klass += " fuzzy";
        if (hasComments)
            klass += " with-comments";
        f << "<tr class='" << klass << "'>\n";

        // Source string:
        f << "<td class='src' " << lang_src << ">\n";
        if (item->HasPlural())
        {
            f << "<ol class='plurals'>\n"
              << "  <li>" << fmt_trans(item->GetString()) << "</li>\n"
              << "  <li>" << fmt_trans(item->GetPluralString()) << "</li>\n"
              << "</ol>\n";
        }
        else
        {
            f << fmt_trans(item->GetString());
        }
        if (item->HasContext())
            f << " <span class='msgctxt'>[" << fmt_trans(item->GetContext()) << "]</span>";
        f << "</td>\n";

        // Translation:
        if (translated)
        {
            f << "<td class='tra' " << lang_tra << ">\n";
            if (item->HasPlural())
            {
                if (item->IsTranslated())
                {
                    f << "<ol class='plurals'>\n";
                    for (auto t: item->GetTranslations())
                        f << "  <li>" << fmt_trans(t) << "</li>\n";
                    f << "</ol>\n";
                }
            }
            else
            {
                f << fmt_trans(item->GetTranslation());
            }
            f << "</td>\n";
        }

        // Notes, if present:
        if (hasComments)
        {
            f << "</tr>\n"
              << "<tr class='comments'>\n"
              << "  <td colspan='" << (translated ? 2 : 1) << "'><div>";
            if (item->HasExtractedComments())
            {
                f << "<p>\n";
                for (auto& n: item->GetExtractedComments())
                    f << fmt_trans(n) << "<br>\n";
                f << "</p>\n";
            }
            if (item->HasComment())
            {
                f << "<p>\n"
                  << fmt_trans(item->GetComment())
                  << "</p>\n";
            }
            f << "</div></td>\n";
        }

        f << "</tr>\n";
    }

    f << "</tbody>\n"
         "</table>\n"
         "</div>\n"
         "</body>\n"
         "</html>\n";
}
예제 #25
0
void StyleDialog::OnReport ( wxCommandEvent& event )
{
	table->DeleteAllItems();
	matchVector.clear();
	status->SetStatusText ( _ ( "Checking document..." ) );

	// update presets
	ruleSetPreset = ruleSetCombo->GetValue();
	filterPreset = filterCombo->GetValue();

	// reconstitute short filenames
	wxString ruleSet, filter;
	ruleSet = ruleSetPreset + _T ( ".xml" );
	ruleSet.Replace ( _(" "), _T("_") );
	filter = filterPreset + _T ( ".xml" );

	wxString separator = wxFileName::GetPathSeparator();

	std::auto_ptr<HouseStyle> hs ( new HouseStyle (
					   (type == ID_TYPE_SPELL) ? HS_TYPE_SPELL : HS_TYPE_STYLE,
	                                   bufferUtf8,
	                                   ruleSetDirectory,
	                                   ruleSet,
	                                   filterDirectory,
	                                   filter,
	                                   separator,
 #ifdef __WXMSW__
	                                   aspellDataPath,
	                                   aspellDictPath,
 #endif
	                                   5 ) );

	status->SetStatusText ( _ ( "Checking document..." ) );
	if ( !hs->createReport() )
	{
		const wxString &error = hs->getLastError();
		status->SetStatusText ( _ ( "Cannot check document: " ) + error );
		return;
	}
	matchVector = hs->getMatchVector();

	vector<ContextMatch>::iterator it;
	std::string prelogUtf8, matchUtf8, postlogUtf8, replaceUtf8, reportUtf8;
	wxString matchNo, prelog, match, postlog, replace, report;
	int i = 0;
	for ( it = matchVector.begin(); it != matchVector.end(); ++it )
	{
		matchNo.Printf ( _T ( "%i" ), i + 1 ); // display numbers from 1
		prelogUtf8 = flatWhiteSpace ( ( *it ).prelog );
		matchUtf8 = flatWhiteSpace ( ( *it ).match );
		postlogUtf8 = flatWhiteSpace ( ( *it ).postlog );
		replaceUtf8 = flatWhiteSpace ( ( *it ).replace );
		reportUtf8 = flatWhiteSpace ( ( *it ).report );
		prelog = wxString ( prelogUtf8.c_str(), wxConvUTF8, ( *it ).prelog.size() );
		match = wxString ( matchUtf8.c_str(), wxConvUTF8, ( *it ).match.size() );
		postlog = wxString ( postlogUtf8.c_str(), wxConvUTF8, ( *it ).postlog.size() );
		replace = wxString ( replaceUtf8.c_str(), wxConvUTF8, ( *it ).replace.size() );
		report = wxString ( reportUtf8.c_str(), wxConvUTF8, ( *it ).report.size() );
		table->InsertItem ( i, matchNo, 0 );
		table->SetItem ( i, 1, prelog );
		table->SetItem ( i, 2, match );
		table->SetItem ( i, 3, postlog );
		table->SetItem ( i, 4, replace );
		table->SetItem ( i, 5, report );
		setIgnore ( i, ( *it ).tentative );
		table->SetItemData ( i, i );
		++i;
	}
	wxString message;
	message.Printf ( wxPLURAL ( "%i error", "%i errors", i ), i );
	status->SetStatusText ( message );
	if ( i )
		table->SetFocus();
}
예제 #26
0
bool CVerifyCertDialog::DisplayCert(wxDialogEx* pDlg, const CCertificate& cert)
{
	bool warning = false;
	if (cert.GetActivationTime().empty()) {
		if (cert.GetActivationTime() > fz::datetime::now()) {
			pDlg->SetChildLabel(XRCID("ID_ACTIVATION_TIME"), wxString::Format(_("%s - Not yet valid!"), CTimeFormat::Format(cert.GetActivationTime())));
			xrc_call(*pDlg, "ID_ACTIVATION_TIME", &wxWindow::SetForegroundColour, wxColour(255, 0, 0));
			warning = true;
		}
		else
			pDlg->SetChildLabel(XRCID("ID_ACTIVATION_TIME"), CTimeFormat::Format(cert.GetActivationTime()));
	}
	else {
		warning = true;
		pDlg->SetChildLabel(XRCID("ID_ACTIVATION_TIME"), _("Invalid date"));
	}

	if (cert.GetExpirationTime().empty()) {
		if (cert.GetExpirationTime() < fz::datetime::now()) {
			pDlg->SetChildLabel(XRCID("ID_EXPIRATION_TIME"), wxString::Format(_("%s - Certificate expired!"), CTimeFormat::Format(cert.GetExpirationTime())));
			xrc_call(*pDlg, "ID_EXPIRATION_TIME", &wxWindow::SetForegroundColour, wxColour(255, 0, 0));
			warning = true;
		}
		else
			pDlg->SetChildLabel(XRCID("ID_EXPIRATION_TIME"), CTimeFormat::Format(cert.GetExpirationTime()));
	}
	else {
		warning = true;
		pDlg->SetChildLabel(XRCID("ID_EXPIRATION_TIME"), _("Invalid date"));
	}

	if (!cert.GetSerial().empty())
		pDlg->SetChildLabel(XRCID("ID_SERIAL"), cert.GetSerial());
	else
		pDlg->SetChildLabel(XRCID("ID_SERIAL"), _("None"));

	pDlg->SetChildLabel(XRCID("ID_PKALGO"), wxString::Format(_("%s with %d bits"), cert.GetPkAlgoName(), cert.GetPkAlgoBits()));
	pDlg->SetChildLabel(XRCID("ID_SIGNALGO"), cert.GetSignatureAlgorithm());

	wxString const& sha256 = cert.GetFingerPrintSHA256();
	pDlg->SetChildLabel(XRCID("ID_FINGERPRINT_SHA256"), sha256.Left(sha256.size() / 2 + 1) + _T("\n") + sha256.Mid(sha256.size() / 2 + 1));
	pDlg->SetChildLabel(XRCID("ID_FINGERPRINT_SHA1"), cert.GetFingerPrintSHA1());

	ParseDN(XRCCTRL(*pDlg, "ID_ISSUER_BOX", wxStaticBox), cert.GetIssuer(), m_pIssuerSizer);

	auto subjectPanel = XRCCTRL(*pDlg, "ID_SUBJECT_PANEL", wxScrolledWindow);
	subjectPanel->Freeze();

	ParseDN(subjectPanel, cert.GetSubject(), m_pSubjectSizer);

	auto const& altNames = cert.GetAltSubjectNames();
	if (!altNames.empty()) {
		wxString str;
		for (auto const& altName : altNames) {
			str += altName + _T("\n");
		}
		str.RemoveLast();
		m_pSubjectSizer->Add(new wxStaticText(subjectPanel, wxID_ANY, wxPLURAL("Alternative name:", "Alternative names:", altNames.size())));
		m_pSubjectSizer->Add(new wxStaticText(subjectPanel, wxID_ANY, str));
	}
	m_pSubjectSizer->Fit(subjectPanel);

	wxSize min = m_pSubjectSizer->CalcMin();
	int const maxHeight = (line_height_ + m_pDlg->ConvertDialogToPixels(wxPoint(0, 1)).y) * 15;
	if (min.y >= maxHeight) {
		min.y = maxHeight;
		min.x += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
	}

	// Add extra safety margin to prevent squishing on OS X.
	min.x += 2;

	subjectPanel->SetMinSize(min);
	subjectPanel->Thaw();

	return warning;
}
예제 #27
0
void WFileList::OnMenuFileExport(wxCommandEvent& WXUNUSED(event))
{
    if (GetSelectedItemCount() == 0)
    {
        return;
    }
    else if (GetSelectedItemCount() == 1)
    {
        long sfid = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);

        wxString suggestname = strSTL2WX(wmain->container.GetSubFileProperty(sfid, "Name"));

        wxFileDialog dlg(this,
                         _("Save SubFile"), wxEmptyString, suggestname,
                         _("Any file (*)|*"),
                         wxFD_SAVE | wxFD_OVERWRITE_PROMPT);

        if (dlg.ShowModal() != wxID_OK) return;

        wxFile outfile(dlg.GetPath(), wxFile::write);
        if (!outfile.IsOpened()) return;

        {
            wxFileOutputStream outstream(outfile);
            wmain->ExportSubFile(sfid, outstream);
        }

        wmain->UpdateStatusBar(wxString::Format(_("Wrote %u bytes from subfile \"%s\" to %s"),
                                                (unsigned int)(outfile.Tell()),
                                                suggestname.c_str(),
                                                dlg.GetPath().c_str()));
    }
    else
    {
        wxString dlgtitle = wxString::Format(_("Select directory to export %u files to."), GetSelectedItemCount());
        wxDirDialog dlg(this, dlgtitle, wxEmptyString, wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST);

        if (dlg.ShowModal() != wxID_OK) return;

        int filesok = 0;

        long sfid = -1;
        while (1)
        {
            sfid = GetNextItem(sfid, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
            if (sfid == -1) break;

            wxString name = strSTL2WX(wmain->container.GetSubFileProperty(sfid, "Name"));

            wxFileName filename(dlg.GetPath(), name);

            if (filename.FileExists())
            {
                wxString overstr = wxString::Format(_("The export filename \"%s\" already exists.\nDo you wish to overwrite the existing file?"), filename.GetFullPath().c_str());

                wxMessageDialog overdlg(this, overstr, _("Overwrite existing file?"),
                                        wxYES_NO | wxNO_DEFAULT);

                if (overdlg.ShowModal() == wxID_NO) continue;
            }

            wxFile outfile(filename.GetFullPath(), wxFile::write);
            if (!outfile.IsOpened()) continue;

            {
                wxFileOutputStream outstream(outfile);
                wmain->ExportSubFile(sfid, outstream);
            }

            filesok++;
        }

        wmain->UpdateStatusBar(wxString::Format(wxPLURAL("Exported %u subfile to %s",
                                                         "Exported %u subfiles to %s", filesok),
                                                filesok, dlg.GetPath().c_str()));
    }
}
예제 #28
0
bool CServerList::LoadServerMet(const CPath& path)
{
	AddLogLineN(CFormat(_("Loading server.met file: %s")) % path);
	
	bool merge = !m_servers.empty();
	
	if (!path.FileExists()) {
		AddLogLineN(_("Server.met file not found!"));
		return false;
	}

	// Try to unpack the file, might be an archive
	const wxChar* mets[] = { wxT("server.met"), NULL };
	// Try to unpack the file, might be an archive
	if (UnpackArchive(path, mets).second != EFT_Met) {
		AddLogLineC(CFormat(_("Failed to load server.met file '%s', unknown format encountered.")) % path);
		return false;
	}	

	CFile servermet(path, CFile::read);
	if ( !servermet.IsOpened() ){ 
		AddLogLineN(_("Failed to open server.met!") );
		return false;
	}

	
	try {
		Notify_ServerFreeze();
		
		byte version = servermet.ReadUInt8();
		
		if (version != 0xE0 && version != MET_HEADER) {
			AddLogLineC(CFormat(_("Server.met file corrupt, found invalid versiontag: 0x%x, size %i")) % version % sizeof(version));
			Notify_ServerThaw();
			return false;
		}

		uint32 fservercount = servermet.ReadUInt32();

		ServerMet_Struct sbuffer;
		uint32 iAddCount = 0;

		for ( uint32 j = 0; j < fservercount; ++j ) {
			sbuffer.ip		= servermet.ReadUInt32();
			sbuffer.port		= servermet.ReadUInt16();
			sbuffer.tagcount	= servermet.ReadUInt32();
			
			CServer* newserver = new CServer(&sbuffer);

			// Load tags
			for ( uint32 i = 0; i < sbuffer.tagcount; ++i ) {
				newserver->AddTagFromFile(&servermet);
			}

			// Server priorities are not in sorted order
			// High = 1, Low = 2, Normal = 0, so we have to check 
			// in a less logical fashion.
			int priority = newserver->GetPreferences();
			if (priority < SRV_PR_MIN || priority > SRV_PR_MAX) {
				newserver->SetPreference(SRV_PR_NORMAL);
			}
			
			// set listname for server
			if ( newserver->GetListName().IsEmpty() ) {
				newserver->SetListName(wxT("Server ") +newserver->GetAddress());
			}
			
			
			if ( !theApp->AddServer(newserver) ) {
				CServer* update = GetServerByAddress(newserver->GetAddress(), newserver->GetPort());
				if(update) {
					update->SetListName( newserver->GetListName());
					if(!newserver->GetDescription().IsEmpty()) {
						update->SetDescription( newserver->GetDescription());
					}
					Notify_ServerRefresh(update);
				}
				delete newserver;
			} else {
				++iAddCount;
			}

		}
		
		Notify_ServerThaw();
    
		if (!merge) {
			AddLogLineC(CFormat(wxPLURAL("%i server in server.met found", "%i servers in server.met found", fservercount)) % fservercount);
		} else {
			AddLogLineC(CFormat(wxPLURAL("%d server added", "%d servers added", iAddCount)) % iAddCount);
		}
	} catch (const CInvalidPacket& err) {
		AddLogLineC(_("Error: the file 'server.met' is corrupted: ") + err.what());
		Notify_ServerThaw();
		return false;
	} catch (const CSafeIOException& err) {
		AddLogLineC(_("IO error while reading 'server.met': ") + err.what());
		Notify_ServerThaw();
		return false;
	}
	
	return true;
}
예제 #29
0
wxString CSizeFormatBase::Format(COptionsBase* pOptions, wxLongLong size, bool add_bytes_suffix, enum CSizeFormatBase::_format format, bool thousands_separator, int num_decimal_places)
{
	wxASSERT(format != formats_count);
	wxASSERT(size >= 0);
	if( size < 0 ) {
		size = 0;
	}

	if (format == bytes) {
		wxString result = FormatNumber(pOptions, size, &thousands_separator);

		if (!add_bytes_suffix)
			return result;
		else
		{
			// wxPLURAL has no support for wxLongLong
			int last;
			if (size > 1000000000)
				last = (1000000000 + (size % 1000000000)).GetLo();
			else
				last = size.GetLo();
			return wxString::Format(wxPLURAL("%s byte", "%s bytes", last), result);
		}
	}

	wxString places;

	int divider;
	if (format == si1000)
		divider = 1000;
	else
		divider = 1024;

	// Exponent (2^(10p) or 10^(3p) depending on option
	int p = 0;

	wxLongLong r = size;
	int remainder = 0;
	bool clipped = false;
	while (r > divider && p < 6) {
		const wxLongLong rr = r / divider;
		if (remainder != 0)
			clipped = true;
		remainder = (r - rr * divider).GetLo();
		r = rr;
		++p;
	}
	if (!num_decimal_places) {
		if (remainder != 0 || clipped)
			++r;
	}
	else if (p) { // Don't add decimal places on exact bytes
		if (format != si1000) {
			// Binary, need to convert 1024 into range from 1-1000
			if (clipped) {
				++remainder;
				clipped = false;
			}
			remainder = (int)ceil((double)remainder * 1000 / 1024);
		}

		int max;
		switch (num_decimal_places)
		{
		default:
			num_decimal_places = 1;
			// Fall-through
		case 1:
			max = 9;
			divider = 100;
			break;
		case 2:
			max = 99;
			divider = 10;
			break;
		case 3:
			max = 999;
			break;
		}

		if (num_decimal_places != 3) {
			if (remainder % divider)
				clipped = true;
			remainder /= divider;
		}

		if (clipped)
			remainder++;
		if (remainder > max) {
			r++;
			remainder = 0;
		}

		places.Printf(_T("%d"), remainder);
		const size_t len = places.Len();
		for (size_t i = len; i < static_cast<size_t>(num_decimal_places); ++i)
			places = _T("0") + places;
	}

	wxString result = r.ToString();
	if (!places.empty()) {
		const wxString& sep = GetRadixSeparator();

		result += sep;
		result += places;
	}
	result += ' ';

	static wxChar byte_unit = 0;
	if (!byte_unit)
	{
		wxString t = _("B <Unit symbol for bytes. Only translate first letter>");
		byte_unit = t[0];
	}

	if (!p)
		return result + byte_unit;

	result += prefix[p];
	if (format == iec)
		result += 'i';

	result += byte_unit;

	return result;
}
예제 #30
0
void CDownloadQueue::LoadMetFiles(const CPath& path)
{
	AddLogLineNS(CFormat(_("Loading temp files from %s.")) % path.GetPrintable());
	
	std::vector<CPath> files;

	// Locate part-files to be loaded
	CDirIterator TempDir(path);
	CPath fileName = TempDir.GetFirstFile(CDirIterator::File, wxT("*.part.met"));
	while (fileName.IsOk()) {
		files.push_back(path.JoinPaths(fileName));

		fileName = TempDir.GetNextFile();
	}

	// Loading in order makes it easier to figure which
	// file is broken in case of crashes, or the like.
	std::sort(files.begin(), files.end());

	// Load part-files	
	for ( size_t i = 0; i < files.size(); i++ ) {
		AddLogLineNS(CFormat(_("Loading PartFile %u of %u")) % (i + 1) % files.size());
		fileName = files[i].GetFullName();
		CPartFile *toadd = new CPartFile();
		bool result = toadd->LoadPartFile(path, fileName) != 0;
		if (!result) {
			// Try from backup
			result = toadd->LoadPartFile(path, fileName, true) != 0;
		}
		if (result && !IsFileExisting(toadd->GetFileHash())) {
			{
				wxMutexLocker lock(m_mutex);
				m_filelist.push_back(toadd);
			}
			NotifyObservers(EventType(EventType::INSERTED, toadd));
			Notify_DownloadCtrlAddFile(toadd);
		} else {
			wxString msg;
			if (result) {
				msg << CFormat(wxT("WARNING: Duplicate partfile with hash '%s' found, skipping: %s"))
					% toadd->GetFileHash().Encode() % fileName;
			} else {
				// If result is false, then reading of both the primary and the backup .met failed
				AddLogLineN(_("ERROR: Failed to load backup file. Search http://forum.amule.org for .part.met recovery solutions."));
				msg << CFormat(wxT("ERROR: Failed to load PartFile '%s'")) % fileName;
			}
			AddLogLineCS(msg);

			// Delete the partfile object in the end.
			delete toadd;
		}
	}
	AddLogLineNS(_("All PartFiles Loaded."));
	
	if ( GetFileCount() == 0 ) {
		AddLogLineN(_("No part files found"));
	} else {
		AddLogLineN(CFormat(wxPLURAL("Found %u part file", "Found %u part files", GetFileCount())) % GetFileCount());

		DoSortByPriority();
		CheckDiskspace( path );
		Notify_ShowUpdateCatTabTitles();
	}
}