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., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#include "integratordlg.h"
#include <tqfile.h>
#include <tqdir.h>
#include <tqlayout.h>
#include <tqcombobox.h>
#include <tqregexp.h>
#include <tqtextstream.h>
#include <tqcheckbox.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, TQWidget *parent, const char *name)
:IntegratorDlgBase(parent, name), m_integrator(integrator)
{
TQFile cvspass(TQDir::homeDirPath() + "/.cvspass");
if (cvspass.open(IO_ReadOnly))
{
TQTextStream stream(&cvspass);
while (!stream.atEnd())
{
TQString line = stream.readLine();
TQStringList recs = TQStringList::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 TQVBoxLayout(dlg.plainPage(), 0, 0))->setAutoAdd(true);
InitDlg *initDlg = new InitDlg(dlg.plainPage());
initDlg->show();
initDlg->location->setFocus();
initDlg->location->setMode(KFile::Directory);
TQRegExp localrep(":local:(.*)");
if (localrep.search(repository->currentText()) != -1)
initDlg->location->setURL(localrep.cap(1));
if (dlg.exec() == TQDialog::Accepted)
{
TQString 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(TQString(":local:%1").arg(url));
repository->setCurrentText(TQString(":local:%1").arg(url));
}
}
}
void IntegratorDlg::login_clicked()
{
TQCString appId;
TQString error;
if (KApplication::startServiceByDesktopName("cvsservice",
TQStringList(), &error, &appId))
{
TQString 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" << TQString("\"%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);
TQString 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);
}
/* TQCString appId;
TQString error;
if (KApplication::startServiceByDesktopName("cvsservice",
TQStringList(), &error, &appId))
{
TQString 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()
{
}
TQWidget *IntegratorDlg::self()
{
return const_cast<IntegratorDlg*>(this);
}
void IntegratorDlg::init(const TQString &projectName, const TQString &projectLocation)
{
if( m_projectName != projectName )
module->setText(projectName);
m_projectName = projectName;
m_projectLocation = projectLocation;
}
#include "integratordlg.moc"
|