~ubuntu-branches/ubuntu/intrepid/kdesdk/intrepid-updates

« back to all changes in this revision

Viewing changes to kbugbuster/backend/bugsystem.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2008-05-28 10:11:43 UTC
  • mto: This revision was merged to the branch mainline in revision 37.
  • Revision ID: james.westby@ubuntu.com-20080528101143-gzc3styjz1b70zxu
Tags: upstream-4.0.80
ImportĀ upstreamĀ versionĀ 4.0.80

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
 
1
/* This file is part of kdesdk / KBugBuster.
 
2
 
 
3
   Copyright 2008  KBugBuster Authors <kde-ev-board@kde.org>
 
4
 
 
5
   This program is free software; you can redistribute it and/or
 
6
   modify it under the terms of the GNU General Public License as
 
7
   published by the Free Software Foundation; either version 2 of
 
8
   the License or (at your option) version 3 or any later version
 
9
   accepted by the membership of KDE e.V. (or its successor approved
 
10
   by the membership of KDE e.V.), which shall act as a proxy 
 
11
   defined in Section 14 of version 3 of the license.
 
12
 
 
13
   This program is distributed in the hope that it will be useful,
 
14
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
   GNU General Public License for more details.
 
17
 
 
18
   You should have received a copy of the GNU General Public License
 
19
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
20
*/
2
21
#include "bugsystem.h"
 
22
 
3
23
#include "packagelistjob.h"
4
24
#include "buglistjob.h"
5
25
#include "bugmybugsjob.h"
6
26
#include "bugdetailsjob.h"
7
27
#include "bugcommand.h"
8
28
 
9
 
#include <kstaticdeleter.h>
 
29
#include <k3staticdeleter.h>
10
30
#include <kdebug.h>
11
31
#include <klocale.h>
12
32
#include <kemailsettings.h>
13
33
#include <kstandarddirs.h>
14
 
#include <ksimpleconfig.h>
15
34
#include <kconfig.h>
16
35
 
17
36
#include "packageimpl.h"
23
42
#include "bugserverconfig.h"
24
43
#include "bugcache.h"
25
44
 
26
 
KStaticDeleter<BugSystem> bssd;
 
45
K3StaticDeleter<BugSystem> bssd;
27
46
 
28
47
BugSystem *BugSystem::s_self = 0;
29
48
 
45
64
 
46
65
BugSystem::~BugSystem()
47
66
{
48
 
    QValueList<BugServer *>::ConstIterator it;
 
67
    QList<BugServer *>::ConstIterator it;
49
68
    for( it = mServerList.begin(); it != mServerList.end(); ++it ) {
50
69
        delete *it;
51
70
    }
97
116
 
98
117
void BugSystem::retrieveBugList( const Package &pkg, const QString &component )
99
118
{
100
 
    kdDebug() << "BugSystem::retrieveBugList(): " << pkg.name() << endl;
 
119
    kDebug() << "BugSystem::retrieveBugList(): " << pkg.name();
101
120
 
102
121
    if ( pkg.isNull() )
103
122
        return;
116
135
 
117
136
        if ( !m_disconnected )
118
137
        {
119
 
            kdDebug() << "BugSystem::retrieveBugList() starting job" << endl;
 
138
            kDebug() << "BugSystem::retrieveBugList() starting job";
120
139
            emit bugListLoading( pkg, component );
121
140
 
122
141
            BugListJob *job = new BugListJob( mServer );
137
156
 
138
157
void BugSystem::retrieveMyBugsList()
139
158
{
140
 
    kdDebug() << k_funcinfo << endl;
 
159
    kDebug() ;
141
160
 
142
161
    if ( m_disconnected )
143
162
    {
146
165
    }
147
166
    else
148
167
    {
149
 
        kdDebug() << k_funcinfo << "Starting job" << endl;
 
168
        kDebug() << "Starting job";
150
169
 
151
170
        emit bugListLoading( i18n( "Retrieving My Bugs list..." ) );
152
171
 
169
188
    if ( bug.isNull() )
170
189
        return;
171
190
 
172
 
    kdDebug() << "BugSystem::retrieveBugDetails(): " << bug.number() << endl;
 
191
    kDebug() << "BugSystem::retrieveBugDetails(): " << bug.number();
173
192
 
174
193
    mServer->setBugDetails( bug, mServer->cache()->loadBugDetails( bug ) );
175
194
 
176
195
    if ( !mServer->bugDetails( bug ).isNull() ) {
177
 
//        kdDebug() << "Found in cache." << endl;
 
196
//        kDebug() << "Found in cache.";
178
197
        emit bugDetailsAvailable( bug, mServer->bugDetails( bug ) );
179
198
    } else {
180
 
//        kdDebug() << "Not found in cache." << endl;
 
199
//        kDebug() << "Not found in cache.";
181
200
        emit bugDetailsCacheMiss( bug );
182
201
 
183
202
        if ( !m_disconnected ) {
296
315
    mServer->sendCommands( mailer, senderName, senderEmail, sendBCC, recipient );
297
316
}
298
317
 
299
 
void BugSystem::setServerList( const QValueList<BugServerConfig> &servers )
 
318
void BugSystem::setServerList( const QList<BugServerConfig> &servers )
300
319
{
301
320
    if ( servers.isEmpty() ) return;
302
321
 
306
325
 
307
326
    killAllJobs();
308
327
 
309
 
    QValueList<BugServer *>::ConstIterator serverIt;
 
328
    QList<BugServer *>::ConstIterator serverIt;
310
329
    for( serverIt = mServerList.begin(); serverIt != mServerList.end();
311
330
         ++serverIt ) {
312
331
        delete *serverIt;
313
332
    }
314
333
    mServerList.clear();
315
334
 
316
 
    QValueList<BugServerConfig>::ConstIterator cfgIt;
 
335
    QList<BugServerConfig>::ConstIterator cfgIt;
317
336
    for( cfgIt = servers.begin(); cfgIt != servers.end(); ++cfgIt ) {
318
337
        mServerList.append( new BugServer( *cfgIt ) );
319
338
    }
321
340
    setCurrentServer( currentServer );
322
341
}
323
342
 
324
 
QValueList<BugServer *> BugSystem::serverList()
 
343
QList<BugServer *> BugSystem::serverList()
325
344
{
326
345
    return mServerList;
327
346
}
334
353
    if ( server ) {
335
354
        mServer = server;
336
355
    } else {
337
 
        kdError() << "Server '" << name << "' not known." << endl;
 
356
        kError() << "Server '" << name << "' not known." << endl;
338
357
        if ( mServerList.isEmpty() ) {
339
 
            kdError() << "Fatal error: server list empty." << endl;
 
358
            kError() << "Fatal error: server list empty." << endl;
340
359
        } else {
341
360
            mServer = mServerList.first();
342
361
        }
349
368
 
350
369
BugServer *BugSystem::findServer( const QString &name )
351
370
{
352
 
    QValueList<BugServer *>::ConstIterator serverIt;
 
371
    QList<BugServer *>::ConstIterator serverIt;
353
372
    for( serverIt = mServerList.begin(); serverIt != mServerList.end();
354
373
         ++serverIt ) {
355
374
        if ( (*serverIt)->serverConfig().name() == name ) return *serverIt;
357
376
    return 0;
358
377
}
359
378
 
360
 
void BugSystem::saveQuery( const KURL &url )
 
379
void BugSystem::saveQuery( const KUrl &url )
361
380
{
362
381
  mLastResponse = "Query: " + url.url();
363
382
  mLastResponse += "\n\n";
375
394
 
376
395
void BugSystem::readConfig( KConfig *config )
377
396
{
378
 
  config->setGroup("Servers");
379
 
  QStringList servers = config->readListEntry( "Servers" );
 
397
  KConfigGroup group = config->group("Servers");
 
398
  QStringList servers = group.readEntry( "Servers" , QStringList() );
380
399
 
381
 
  QValueList<BugServerConfig> serverList;
 
400
  QList<BugServerConfig> serverList;
382
401
 
383
402
  if ( servers.isEmpty() ) {
384
403
    serverList.append( BugServerConfig() );
396
415
 
397
416
void BugSystem::writeConfig( KConfig *config )
398
417
{
399
 
  QValueList<BugServer *>::ConstIterator itServer;
 
418
  QList<BugServer *>::ConstIterator itServer;
400
419
  QStringList servers;
401
 
  QValueList<BugServer *> serverList = BugSystem::self()->serverList();
 
420
  QList<BugServer *> serverList = BugSystem::self()->serverList();
402
421
  for( itServer = serverList.begin(); itServer != serverList.end();
403
422
       ++itServer ) {
404
423
    BugServerConfig serverConfig = (*itServer)->serverConfig();
406
425
    serverConfig.writeConfig( config );
407
426
  }
408
427
 
409
 
  config->setGroup("Servers");
410
 
  config->writeEntry( "Servers", servers );
 
428
  KConfigGroup group = config->group("Servers");
 
429
  group.writeEntry( "Servers", servers );
411
430
}
412
431
 
413
432
void BugSystem::registerJob( BugJob *job )