Don't keep compiling/run if something failed.
[kdevelopdvcssupport.git] / plugins / subversion / svnjobbase.cpp
blobd213cdfe01fa96c77dffba0d892ad47139dacf90
1 /***************************************************************************
2 * Copyright 2007 Dukju Ahn <dukjuahn@gmail.com> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 ***************************************************************************/
11 #include "svnjobbase.h"
13 #include <QEvent>
15 #include <kpassworddialog.h>
16 #include <klocale.h>
17 #include <kmessagebox.h>
18 #include <kdebug.h>
20 #include "svninternaljobbase.h"
21 #include "svnssldialog.h"
22 #include "kdevsvnplugin.h"
23 #include "svnoutputmodel.h"
25 SvnJobBase::SvnJobBase( KDevSvnPlugin* parent )
26 : VcsJob( parent ), m_part( parent ),
27 m_status( KDevelop::VcsJob::JobNotStarted )
31 SvnJobBase::~SvnJobBase()
35 KDevelop::VcsJob::JobStatus SvnJobBase::status() const
37 return m_status;
41 void SvnJobBase::askForLogin( const QString& realm )
43 kDebug( 9510 ) << "login";
44 KPasswordDialog dlg( 0, KPasswordDialog::ShowUsernameLine | KPasswordDialog::ShowKeepPassword );
45 dlg.setPrompt( i18n("Enter Login for: %1", realm ) );
46 dlg.exec();
47 internalJob()->m_login_username = dlg.username();
48 internalJob()->m_login_password = dlg.password();
49 internalJob()->m_maySave = dlg.keepPassword();
50 internalJob()->m_guiSemaphore.release( 1 );
53 void SvnJobBase::showNotification( const QString& path, const QString& msg )
55 kDebug( 9510 ) << "notification" << path << msg;
56 m_part->outputModel()->appendRow( new SvnOutputItem( path, msg ) );
59 void SvnJobBase::askForCommitMessage()
61 kDebug( 9510 ) << "commit msg";
62 internalJob()->m_guiSemaphore.release( 1 );
65 void SvnJobBase::askForSslServerTrust( const QStringList& failures, const QString& host,
66 const QString& print, const QString& from,
67 const QString& until, const QString& issuer,
68 const QString& realm )
71 kDebug( 9510 ) << "servertrust";
72 SvnSSLTrustDialog dlg;
73 dlg.setCertInfos( host, print, from, until, issuer, realm, failures );
74 if( dlg.exec() == QDialog::Accepted )
76 kDebug(9510) << "accepted with:" << dlg.useTemporarily();
77 if( dlg.useTemporarily() )
79 internalJob()->m_trustAnswer = svn::ContextListener::ACCEPT_TEMPORARILY;
80 }else
82 internalJob()->m_trustAnswer = svn::ContextListener::ACCEPT_PERMANENTLY;
84 }else
86 kDebug(9510) << "didn't accept";
87 internalJob()->m_trustAnswer = svn::ContextListener::DONT_ACCEPT;
89 internalJob()->m_guiSemaphore.release( 1 );
92 void SvnJobBase::askForSslClientCert( const QString& realm )
94 KMessageBox::information( 0, realm );
95 kDebug( 9510 ) << "clientrust";
96 internalJob()->m_guiSemaphore.release( 1 );
99 void SvnJobBase::askForSslClientCertPassword( const QString& )
101 kDebug( 9510 ) << "clientpw";
102 internalJob()->m_guiSemaphore.release( 1 );
105 void SvnJobBase::internalJobStarted( ThreadWeaver::Job* job )
107 if( internalJob() == job )
109 m_status = KDevelop::VcsJob::JobRunning;
113 void SvnJobBase::internalJobDone( ThreadWeaver::Job* job )
115 if( internalJob() == job )
117 kDebug(9510) << "Job is done";
118 m_status = KDevelop::VcsJob::JobSucceeded;
120 emitResult();
123 void SvnJobBase::internalJobFailed( ThreadWeaver::Job* job )
125 if( internalJob() == job )
127 setError( 255 );
128 QString msg = internalJob()->errorMessage();
129 if( !msg.isEmpty() )
130 setErrorText( i18n( "Error executing Job:\n%1", msg ) );
131 kDebug(9510) << "Job failed";
132 m_status = KDevelop::VcsJob::JobFailed;
134 emitResult();
137 KDevelop::IPlugin* SvnJobBase::vcsPlugin() const
139 return m_part;
142 #include "svnjobbase.moc"