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
|
/***************************************************************************
* Copyright (C) 2004 by Alexander Dymo *
* adymo@kdevelop.org *
* *
* 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., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "integratordlg.h"
#include <qfile.h>
#include <qdir.h>
#include <qlayout.h>
#include <qcombobox.h>
#include <qregexp.h>
#include <qtextstream.h>
#include <qcheckbox.h>
#include <kapplication.h>
#include <kdialogbase.h>
#include <kurlrequester.h>
#include <kprocess.h>
#include <klocale.h>
#include <kmessagebox.h>
#include <kdebug.h>
#include <klineedit.h>
#include <cvsservice_stub.h>
#include "initdlg.h"
IntegratorDlg::IntegratorDlg(CVSServiceIntegrator *integrator, QWidget *parent, const char *name)
:IntegratorDlgBase(parent, name), m_integrator(integrator)
{
QFile cvspass(QDir::homeDirPath() + "/.cvspass");
if (cvspass.open(IO_ReadOnly))
{
QTextStream stream(&cvspass);
while (!stream.atEnd())
{
QString line = stream.readLine();
QStringList recs = QStringList::split(" ", line, false);
repository->insertItem(recs[1]);
}
cvspass.close();
}
}
void IntegratorDlg::init_clicked()
{
KDialogBase dlg(KDialogBase::Plain, i18n("Init CVS Repository"), KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok);
dlg.plainPage()->setMargin(0);
(new QVBoxLayout(dlg.plainPage(), 0, 0))->setAutoAdd(true);
InitDlg *initDlg = new InitDlg(dlg.plainPage());
initDlg->show();
initDlg->location->setFocus();
initDlg->location->setMode(KFile::Directory);
QRegExp localrep(":local:(.*)");
if (localrep.search(repository->currentText()) != -1)
initDlg->location->setURL(localrep.cap(1));
if (dlg.exec() == QDialog::Accepted)
{
QString url = initDlg->location->url();
KProcess *proc = new KProcess();
*proc << "cvs";
*proc << "-d" << url << "init";
proc->start(KProcess::Block);
if (!proc->normalExit())
KMessageBox::error(this, i18n("cvs init did not exit normally. Please check if cvs is installed and works correctly."), i18n("Init CVS Repository"));
else if (proc->exitStatus() != 0)
KMessageBox::error(this, i18n("cvs init exited with status %1. Please check if the cvs location is correct.").arg(proc->exitStatus()), i18n("Init CVS Repository"));
else
{
repository->insertItem(QString(":local:%1").arg(url));
repository->setCurrentText(QString(":local:%1").arg(url));
}
}
}
void IntegratorDlg::login_clicked()
{
QCString appId;
QString error;
if (KApplication::startServiceByDesktopName("cvsservice",
QStringList(), &error, &appId))
{
QString msg = i18n("Unable to find the Cervisia KPart. \n"
"Cervisia Integration will not be available. Please check your\n"
"Cervisia installation and re-try. Reason was:\n") + error;
KMessageBox::error(this, msg, "DCOP Error");
}
else
{
CvsService_stub *cvsService = new CvsService_stub(appId, "CvsService");
cvsService->login(repository->currentText());
}
}
void IntegratorDlg::accept()
{
if (m_projectLocation.isEmpty())
return;
if (!createModule->isChecked())
return;
KProcess *proc = new KProcess();
proc->setWorkingDirectory(m_projectLocation);
*proc << "cvs";
*proc << "-d" << repository->currentText() << "import"
<< "-m" << QString("\"%1\"").arg(comment->text()) << module->text()
<< vendorTag->text() << releaseTag->text();
proc->start(KProcess::Block);
if (!proc->normalExit())
KMessageBox::error(this, i18n("cvs import did not exit normally. Please check if cvs is installed and works correctly."), i18n("Init CVS Repository"));
else if (proc->exitStatus() != 0)
KMessageBox::error(this, i18n("cvs import exited with status %1. Please check if the cvs location is correct.").arg(proc->exitStatus()), i18n("Init CVS Repository"));
else
{
kdDebug() << "Project is in: " << m_projectLocation << endl;
KURL url = KURL::fromPathOrURL(m_projectLocation);
QString up = url.upURL().path();
kdDebug() << "Up is: " << up << endl;
//delete sources in project dir
KProcess *rmproc = new KProcess();
*rmproc << "rm";
*rmproc << "-f" << "-r" << m_projectLocation;
rmproc->start(KProcess::Block);
//checkout sources from cvs
KProcess *coproc = new KProcess();
coproc->setWorkingDirectory(up);
*coproc << "cvs";
*coproc << "-d" << repository->currentText() << "checkout" << "-d" << m_projectName << module->text();
coproc->start(KProcess::Block);
}
/* QCString appId;
QString error;
if (KApplication::startServiceByDesktopName("cvsservice",
QStringList(), &error, &appId))
{
QString msg = i18n("Unable to find the Cervisia KPart. \n"
"Cervisia Integration will not be available. Please check your\n"
"Cervisia installation and re-try. Reason was:\n") + error;
KMessageBox::error(this, msg, "DCOP Error");
}
else
{
kdDebug() << "!!!!! IMPORT" << endl;
CvsService_stub *cvsService = new CvsService_stub(appId, "CvsService");
cvsService->import(m_projectLocation, repository->currentText(), module->text(),
"", comment->text(), vendorTag->text(), releaseTag->text(), false);
}*/
}
void IntegratorDlg::createModule_clicked()
{
}
QWidget *IntegratorDlg::self()
{
return const_cast<IntegratorDlg*>(this);
}
void IntegratorDlg::init(const QString &projectName, const QString &projectLocation)
{
if( m_projectName != projectName )
module->setText(projectName);
m_projectName = projectName;
m_projectLocation = projectLocation;
}
#include "integratordlg.moc"
|