aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/General/notifier
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2015-04-30 18:49:36 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2015-04-30 18:49:36 +0000
commit5a0075ed95704f293829d9f7671bbc39e777b924 (patch)
tree28c59552caf857e7075b02224b7a76ce37511fde /src/plugins/General/notifier
parentf6470d2e3b0a07714e2c81be72fa86a9aa8b6ec4 (diff)
downloadqmmp-5a0075ed95704f293829d9f7671bbc39e777b924.tar.gz
qmmp-5a0075ed95704f293829d9f7671bbc39e777b924.tar.bz2
qmmp-5a0075ed95704f293829d9f7671bbc39e777b924.zip
fixed Russian translation
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@4883 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/General/notifier')
0 files changed, 0 insertions, 0 deletions
83ea149b6e91'>9783fa786
895ae02ef
7a8026a4a
6ba4fc48f
bc28f1332
3be88d8c0
b2576ddc1
245d0ac0c
2d622fd9b
24af8da3f
2d622fd9b
9783fa786
c9cb0def7
420e30ba9
f082aa310
7a8026a4a
2d622fd9b

2d622fd9b
aa3f57c02
2d622fd9b
f91f63b99
2d622fd9b
9783fa786
f082aa310
9783fa786
646e72f41
3be88d8c0
9783fa786
3be88d8c0
9783fa786

2d622fd9b

b2576ddc1






df8a183c7
b2576ddc1







646e72f41

b2576ddc1
















df8a183c7
b2576ddc1







df8a183c7
646e72f41
df8a183c7
b2576ddc1
df8a183c7
b2576ddc1






3be88d8c0
420e30ba9
9783fa786
f91f63b99
420e30ba9


d797b6af7
f91f63b99
24af8da3f
420e30ba9
c9cb0def7
f91f63b99




9783fa786







f91f63b99
9783fa786
f91f63b99
9783fa786

f91f63b99
9783fa786
420e30ba9
9783fa786


f91f63b99
9783fa786
f91f63b99
9783fa786

420e30ba9



9783fa786







2d622fd9b

2d622fd9b

24af8da3f
9783fa786

24af8da3f
9783fa786







261ba8213
9783fa786
261ba8213

157b69f61
b2576ddc1
24af8da3f
b2576ddc1
9783fa786
b2576ddc1





9783fa786
b2576ddc1
9783fa786
b2576ddc1











24af8da3f
9783fa786







24af8da3f


15921e6ff
24af8da3f
9783fa786
2d622fd9b

15921e6ff
2d622fd9b
9783fa786
2d622fd9b

b2576ddc1













f082aa310
b2576ddc1



3be88d8c0
15921e6ff
3be88d8c0
15921e6ff

3be88d8c0
15921e6ff
9783fa786
3be88d8c0

261ba8213

895ae02ef
261ba8213
3be88d8c0
9783fa786





f082aa310
9783fa786
3be88d8c0
15921e6ff

2d622fd9b

420e30ba9
24af8da3f
261ba8213
2d622fd9b
c9cb0def7



























f91f63b99







aa167f22d
f91f63b99





1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
                                                                            
                                                                            
                                                                            













                                                                            
                                                                            
                                                                             
 
                                 
                  
                    
               
                       
                         
                           
                         
                           
                          
 
                                                         
 
                                                                       
                                            
                       
                                 
                                                         

 
                         
  
 
                                                                                              
 
                                  
                                                                                                            
 
                                       
     
                                               
     

                         

 






                                                                                                     
                                                                                                      







                                                                

                                                                                       
















                                                                          
                                                                                                       







                                                                
                                               
                                                                                       
                                    
 
                                                                                          






                            
                                                                     
 
                                  
                             


                                                                 
                                                   
 
                              
     
                                                                   




                                                                                







                               
                                                                         
         
                                                       

                                                   
                                 
         
     


                         
                                                   
                                               
                             

     



                                                     







                                                           

 

                      
                       

                         
     







                         
                                         
                         

                                        
 
                           
         
                                 
 





                                                                      
             
                                             
             











                                                                            
         







                             


     
                                         
 
                                     

 
                                              
 
                     

 













                                                                        
                                                                                       



                                 
                                                                  
 
                                          

 
                                                                       
 
                   

                                 

                             
                                                     
                             
     





                                                               
                                                                                       
     
                                 

 

                         
                      
           
                    
 



























                                                                        







                                                                                                     
                                                





                                     
/***************************************************************************
 *   Copyright (C) 2006-2018 by Ilya Kotov                                 *
 *   forkotov02@ya.ru                                                      *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
 ***************************************************************************/

#include <qmmp/metadatamanager.h>
#include <QRegExp>
#include <QMetaType>
#include <QDir>
#include <QApplication>
#include "fileloader_p.h"
#include "qmmpuisettings.h"
#include "playlistitem.h"
#include "playlistparser.h"
#include "playlisttrack.h"

FileLoader::FileLoader(QObject *parent) : QThread(parent)
{
    qRegisterMetaType<QList<PlayListTrack*> >("QList<PlayListTrack*>");
    m_settings = QmmpUiSettings::instance();
    m_finished = false;
    m_parts = TrackInfo::NoParts;
    connect(qApp, SIGNAL(aboutToQuit()), SLOT(finish()));
}

FileLoader::~FileLoader()
{}

QList<PlayListTrack *> FileLoader::processFile(const QString &path, QStringList *ignoredPaths)
{
    QList<PlayListTrack *> tracks;
    QList <TrackInfo *> infoList = MetaDataManager::instance()->createPlayList(path, m_parts, ignoredPaths);

    foreach (TrackInfo *info, infoList)
    {
        tracks.append(new PlayListTrack(info));
    }
    qDeleteAll(infoList);
    return tracks;
}

void FileLoader::insertPlayList(const QString &fmt, const QByteArray &contents, PlayListItem *before)
{
    QList<PlayListTrack *> tracks = PlayListParser::loadPlaylist(fmt, contents);

    while (!tracks.isEmpty() && !m_finished)
    {
        PlayListTrack *t = tracks.takeFirst();
        QList<TrackInfo *> infoList = MetaDataManager::instance()->createPlayList(t->path(), m_parts);
        if(infoList.count() != 1) //invalid or unsupported track
        {
            qDeleteAll(infoList);
            infoList.clear();
            delete t;
            continue;
        }

        TrackInfo *info = infoList.first();
        if(!info->value(Qmmp::ALBUM).isEmpty() && !info->value(Qmmp::ARTIST).isEmpty())
            t->updateMetaData(infoList.first());

        emit newTracksToInsert(before, QList<PlayListTrack *>() << t);
        delete info;
    }
    //clear remaining tracks
    qDeleteAll(tracks);
    tracks.clear();
}

void FileLoader::insertPlayList(const QString &path, PlayListItem *before)
{
    QList<PlayListTrack *> tracks = PlayListParser::loadPlaylist(path);

    while (!tracks.isEmpty() && !m_finished)
    {
        PlayListTrack *t = tracks.takeFirst();
        QList <TrackInfo *> infoList = MetaDataManager::instance()->createPlayList(t->path(), m_parts);
        if(infoList.count() != 1) //invalid or unsupported track
        {
            qDeleteAll(infoList);
            infoList.clear();
            delete t;
            continue;
        }

        TrackInfo *info = infoList.takeFirst();
        if(!info->value(Qmmp::ALBUM).isEmpty() && !info->value(Qmmp::ARTIST).isEmpty())
            t->updateMetaData(info);

        emit newTracksToInsert(before, QList<PlayListTrack *>() << t); //TODO optimization
        delete info;
    }
    //clear remaining tracks
    qDeleteAll(tracks);
    tracks.clear();
}

void FileLoader::addDirectory(const QString& s, PlayListItem *before)
{
    QList<PlayListTrack *> tracks;
    QStringList ignoredPaths;
    QDir dir(s);
    dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
    dir.setSorting(QDir::Name);
    QFileInfoList l = dir.entryInfoList(m_filters);

    foreach(QFileInfo info, l)
    {
        if(checkRestrictFilters(info) && checkExcludeFilters(info))
        {
            QStringList paths;
            tracks.append(processFile(info.absoluteFilePath (), &ignoredPaths));
            ignoredPaths.append(paths);
        }

        if (m_finished)
        {
            qDeleteAll(tracks);
            tracks.clear();
            return;
        }

        if(tracks.count() > 30) //do not send more than 30 tracks at once
        {
            removeIgnoredTracks(&tracks, ignoredPaths);
            emit newTracksToInsert(before, tracks);
            tracks.clear();
            ignoredPaths.clear();
        }
    }

    if(!tracks.isEmpty())
    {
        removeIgnoredTracks(&tracks, ignoredPaths);
        emit newTracksToInsert(before, tracks);
        ignoredPaths.clear();
    }

    dir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
    dir.setSorting(QDir::Name);
    l.clear();
    l = dir.entryInfoList();

    for (int i = 0; i < l.size(); ++i)
    {
        QFileInfo fileInfo = l.at(i);
        addDirectory(fileInfo.absoluteFilePath (), before);
        if (m_finished)
            return;
    }
}

void FileLoader::run()
{
    m_finished = false;
    m_mutex.lock();
    if(m_tasks.isEmpty())
    {
        m_mutex.unlock();
        return;
    }
    m_mutex.unlock();

    while(!m_finished)
    {
        m_mutex.lock();
        LoaderTask i = m_tasks.dequeue();
        m_mutex.unlock();
        PlayListItem *before = i.before;
        QString path = i.path;

        if(!path.isEmpty())
        {
            QFileInfo info(path);

            if(info.isDir())
            {
                addDirectory(path, before);

            }
            else if(info.isFile() && PlayListParser::isPlayList(path))
            {
                insertPlayList(path, before);
            }
            else if(info.isFile() || path.contains("://"))
            {
                QList<PlayListTrack *> tracks = processFile(path);
                if(!tracks.isEmpty())
                {
                    emit newTracksToInsert(before, tracks);
                }
            }
        }
        else if(!i.playListContent.isEmpty() && !i.playListFormat.isEmpty())
        {
            insertPlayList(i.playListFormat, i.playListContent, before);
        }

        m_mutex.lock();
        if(m_tasks.isEmpty())
        {
            m_mutex.unlock();
            break;
        }
        m_mutex.unlock();
    }
}

void FileLoader::add(const QString &path)
{
    insert(0, QStringList() << path);
}

void FileLoader::add(const QStringList &paths)
{
    insert(0, paths);
}

void FileLoader::addPlayList(const QString &fmt, const QByteArray &data)
{
    m_mutex.lock();
    LoaderTask task;
    task.before = 0;
    task.playListFormat = fmt;
    task.playListContent = data;
    m_tasks.append(task);
    m_mutex.unlock();
    if(!isRunning())
    {
        MetaDataManager::instance()->prepareForAnotherThread();
        PlayListParser::loadFormats();
        m_filters = MetaDataManager::instance()->nameFilters();
        m_parts = m_settings->useMetadata() ? TrackInfo::AllParts : TrackInfo::NoParts;
    }
    start(QThread::IdlePriority);
}

void FileLoader::insert(PlayListItem *before, const QString &path)
{
    insert(before, QStringList() << path);
}

void FileLoader::insert(PlayListItem *before, const QStringList &paths)
{
    m_mutex.lock();
    foreach (QString path, paths)
    {
        LoaderTask task;
        task.before = before;
        task.path = QDir::fromNativeSeparators(path);
        m_tasks.append(task);
    }
    m_mutex.unlock();

    if(!isRunning())
    {
        MetaDataManager::instance()->prepareForAnotherThread();
        m_filters = MetaDataManager::instance()->nameFilters();
        m_parts = m_settings->useMetadata() ? TrackInfo::AllParts : TrackInfo::NoParts;
    }
    start(QThread::IdlePriority);
}

void FileLoader::finish()
{
    m_finished = true;