Ignore:
Timestamp:
Jan 9, 2017, 11:09:38 AM (2 years ago)
Author:
jrpelegrina
Message:

Update new version: 3.15.02

File:
1 edited

Legend:

Unmodified
Added
Removed
  • filezilla/trunk/fuentes/src/interface/QueueView.cpp

    r130 r3185  
    2222#include <wx/progdlg.h>
    2323#include <wx/sound.h>
    24 #include "local_filesys.h"
    2524#include "statusbar.h"
    2625#include "recursive_operation.h"
     
    3029#if WITH_LIBDBUS
    3130#include "../dbus/desktop_notification.h"
     31#elif defined(__WXGTK__) || defined(__WXMSW__)
     32#include <wx/notifmsg.h>
    3233#endif
     34
     35#include <libfilezilla/local_filesys.hpp>
    3336
    3437#ifdef __WXMSW__
     
    210213END_EVENT_TABLE()
    211214
    212 class CFolderProcessingThread final : public wxThread
     215class CFolderProcessingThread final : public fz::thread
    213216{
    214217        struct t_internalDirPair
     
    219222public:
    220223        CFolderProcessingThread(CQueueView* pOwner, CFolderScanItem* pFolderItem)
    221                 : wxThread(wxTHREAD_JOINABLE) {
     224        {
    222225                m_pOwner = pOwner;
    223226                m_pFolderItem = pFolderItem;
    224 
    225                 m_didSendEvent = false;
    226                 m_threadWaiting = false;
    227                 m_throttleWait = false;
    228                 m_processing_entries = false;
    229227
    230228                t_internalDirPair* pair = new t_internalDirPair;
     
    236234        virtual ~CFolderProcessingThread()
    237235        {
     236                {
     237                        fz::scoped_lock locker(m_sync);
     238                        m_quit = true;
     239                }
     240                join();
    238241                for (auto iter = m_entryList.begin(); iter != m_entryList.end(); ++iter)
    239242                        delete *iter;
     
    245248        {
    246249                wxASSERT(entryList.empty());
    247                 scoped_lock locker(m_sync);
     250                fz::scoped_lock locker(m_sync);
    248251                entryList.swap(m_entryList);
    249252
     
    267270        void ProcessDirectory(const CLocalPath& localPath, CServerPath const& remotePath, const wxString& name)
    268271        {
    269                 scoped_lock locker(m_sync);
     272                fz::scoped_lock locker(m_sync);
    270273
    271274                t_internalDirPair* pair = new t_internalDirPair;
     
    289292        void CheckFinished()
    290293        {
    291                 scoped_lock locker(m_sync);
     294                fz::scoped_lock locker(m_sync);
    292295                wxASSERT(m_processing_entries);
    293296
     
    309312        void AddEntry(CFolderProcessingEntry* entry)
    310313        {
    311                 scoped_lock l(m_sync);
     314                fz::scoped_lock l(m_sync);
    312315                m_entryList.push_back(entry);
    313316
     
    342345        }
    343346
    344         ExitCode Entry()
     347        void entry()
    345348        {
    346349#ifdef __WXDEBUG__
     
    352355                wxASSERT(!m_pFolderItem->Download());
    353356
    354                 CLocalFileSystem localFileSystem;
    355 
    356                 while (!TestDestroy() && !m_pFolderItem->m_remove) {
    357                         scoped_lock l(m_sync);
     357                fz::local_filesys localFileSystem;
     358
     359                while (!m_pFolderItem->m_remove) {
     360                        fz::scoped_lock l(m_sync);
     361                        if (m_quit) {
     362                                break;
     363                        }
    358364                        if (m_dirsToCheck.empty()) {
    359365                                if (!m_didSendEvent && !m_entryList.empty()) {
     
    380386                        l.unlock();
    381387
    382                         if (!localFileSystem.BeginFindFiles(pair->localPath.GetPath(), false)) {
     388                        if (!localFileSystem.begin_find_files(fz::to_native(pair->localPath.GetPath()), false)) {
    383389                                delete pair;
    384390                                continue;
     
    392398                        t_newEntry* entry = new t_newEntry;
    393399
    394                         wxString name;
     400                        fz::native_string name;
    395401                        bool is_link;
    396402                        bool is_dir;
    397                         while (localFileSystem.GetNextFile(name, is_link, is_dir, &entry->size, &entry->time, &entry->attributes)) {
     403                        while (localFileSystem.get_next_file(name, is_link, is_dir, &entry->size, &entry->time, &entry->attributes)) {
    398404                                if (is_link)
    399405                                        continue;
     
    412418
    413419                m_pOwner->QueueEvent(new wxCommandEvent(fzEVT_FOLDERTHREAD_COMPLETE, wxID_ANY));
    414                 return 0;
    415420        }
    416421
     
    423428        CFolderScanItem* m_pFolderItem;
    424429
    425         mutex m_sync;
    426         condition m_condition;
    427         bool m_threadWaiting;
    428         bool m_throttleWait;
    429         bool m_didSendEvent;
    430         bool m_processing_entries;
     430        fz::mutex m_sync;
     431        fz::condition m_condition;
     432        bool m_threadWaiting{};
     433        bool m_throttleWait{};
     434        bool m_didSendEvent{};
     435        bool m_processing_entries{};
     436        bool m_quit{};
    431437};
    432438
     
    446452        m_waitStatusLineUpdate = false;
    447453        m_lastTopItem = -1;
    448         m_pFolderProcessingThread = 0;
    449 
     454       
    450455        m_totalQueueSize = 0;
    451456        m_filesWithUnknownSize = 0;
     
    471476
    472477        m_resize_timer.SetOwner(this);
    473 
    474 #if WITH_LIBDBUS
    475         m_desktop_notification = 0;
    476 #endif
    477478}
    478479
    479480CQueueView::~CQueueView()
    480481{
    481         if (m_pFolderProcessingThread) {
    482                 m_pFolderProcessingThread->Delete(0, wxTHREAD_WAIT_BLOCK);
    483                 delete m_pFolderProcessingThread;
    484         }
     482        delete m_pFolderProcessingThread;
     483        m_pFolderProcessingThread = 0;
    485484
    486485        DeleteEngines();
    487486
    488487        m_resize_timer.Stop();
    489 
    490 #if WITH_LIBDBUS
    491         delete m_desktop_notification;
    492 #endif
    493488}
    494489
     
    16941689void CQueueView::ProcessUploadFolderItems()
    16951690{
    1696         if (m_queuedFolders[1].empty())
    1697         {
     1691        if (m_queuedFolders[1].empty()) {
    16981692                if (m_quit)
    16991693                        m_pMainFrame->Close();
     
    17141708        pItem->m_active = true;
    17151709        m_pFolderProcessingThread = new CFolderProcessingThread(this, pItem);
    1716         m_pFolderProcessingThread->Create();
    1717         m_pFolderProcessingThread->Run();
     1710        m_pFolderProcessingThread->run();
    17181711
    17191712        RefreshListOnly(false);
     
    17291722        wxASSERT(!m_queuedFolders[1].empty());
    17301723        CFolderScanItem* pItem = m_queuedFolders[1].front();
    1731         if (pItem->m_dir_is_empty)
    1732         {
     1724        if (pItem->m_dir_is_empty) {
    17331725                CServerItem* pServerItem = (CServerItem*)pItem->GetTopLevelItem();
    17341726                CFileItem* fileItem = new CFolderItem(pServerItem, pItem->queued(), pItem->m_current_remote_path, _T(""));
     
    17401732        RemoveItem(pItem, true);
    17411733
    1742         m_pFolderProcessingThread->Wait(wxTHREAD_WAIT_BLOCK);
    17431734        delete m_pFolderProcessingThread;
    17441735        m_pFolderProcessingThread = 0;
     
    29222913        // download operation still in progress
    29232914        const std::vector<CState*> *pStates = CContextManager::Get()->GetAllStates();
    2924         for (unsigned int i = 0; i < pStates->size(); i++)
    2925         {
     2915        for (unsigned int i = 0; i < pStates->size(); ++i) {
    29262916                CState *pState = (*pStates)[i];
    29272917                CRecursiveOperation *pRecursiveOperationHandler;
     
    29362926        }
    29372927
     2928        if (!m_pMainFrame->IsActive() && COptions::Get()->GetOptionVal(OPTION_SHOW_NOTIFICATION_BUBBLE) != 0) {
     2929                wxString const title = _("Transfers finished");
     2930                wxString msg;
     2931                int const failed_count = m_pQueue->GetQueueView_Failed()->GetFileCount();
     2932                if (failed_count != 0) {
     2933                        wxString fmt = wxPLURAL("All transfers have finished. %d file could not be transferred.", "All transfers have finished. %d files could not be transferred.", failed_count);
     2934                        msg = wxString::Format(fmt, failed_count);
     2935                }
     2936                else
     2937                        msg = _("All files have been successfully transferred");
     2938
    29382939#if WITH_LIBDBUS
    2939         if (!m_pMainFrame->IsActive())
    2940         {
    29412940                if (!m_desktop_notification)
    2942                         m_desktop_notification = new CDesktopNotification;
    2943                 int failed_count = m_pQueue->GetQueueView_Failed()->GetFileCount();
    2944                 if (failed_count != 0)
    2945                 {
    2946                         wxString fmt = wxPLURAL("All transfers have finished. %d file could not be transferred.", "All transfers have finished. %d files could not be transferred.", failed_count);
    2947                         m_desktop_notification->Notify(_("Transfers finished"), wxString::Format(fmt, failed_count), _T("transfer.error"));
    2948                 }
    2949                 else
    2950                         m_desktop_notification->Notify(_("Transfers finished"), _("All files have been successfully transferred"), _T("transfer.complete"));
    2951         }
     2941                        m_desktop_notification = std::make_unique<CDesktopNotification>();
     2942                m_desktop_notification->Notify(title, msg, (failed_count > 0) ? _T("transfer.error") : _T("transfer.complete"));
     2943#elif defined(__WXGTK__) || defined(__WXMSW__)
     2944                m_desktop_notification = std::make_unique<wxNotificationMessage>();
     2945                m_desktop_notification->SetTitle(title);
     2946                m_desktop_notification->SetMessage(msg);
     2947                m_desktop_notification->Show(5);
    29522948#endif
     2949        }
    29532950
    29542951        switch (m_actionAfterState)
Note: See TracChangeset for help on using the changeset viewer.