kexi

kexiprojectconnectiondata.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2003 Lucijan Busch <lucijan@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#include <sys/types.h>
21#include <unistd.h>
22
23#include <tqdom.h>
24#include <tqdir.h>
25#include <tqfile.h>
26#include <tqregexp.h>
27
28#include <tdeglobal.h>
29#include <kstandarddirs.h>
30#include <kdebug.h>
31#include <tdeio/netaccess.h>
32#include <kurl.h>
33#include <tdelocale.h>
34#include <tdemessagebox.h>
35
36#include <kexidb/connectiondata.h>
37#include <kexidb/drivermanager.h>
38#include "kexiprojectconnectiondata.h"
39
40KexiProjectConnectionData::KexiProjectConnectionData(): KexiDB::ConnectionData()
41{
42}
43
44KexiProjectConnectionData::KexiProjectConnectionData(const TQString& driverName, const TQString& databaseName, const TQString &host,
45 unsigned short int rport, const TQString& user, const TQString &pass, const TQString& file):KexiDB::ConnectionData()
46{
47 m_driverName=driverName;
48 m_databaseName=databaseName;
49 hostName=host;
50 port=rport;
51 userName=user;
52 password=pass;
53 setFileName(file);
54}
55
56KexiProjectConnectionData::KexiProjectConnectionData(const TQString &driverName, const TQString &fileName)
57 : KexiDB::ConnectionData()
58{
59 m_driverName=driverName;
61}
62
63const TQString &
64KexiProjectConnectionData::generateTmpName()
65{
66 return TQString();
67}
68
70KexiProjectConnectionData::loadInfo(TQDomElement &rootElement)
71{
72 TQDomElement engineElement = rootElement.namedItem("engine").toElement();
73 TQDomElement hostElement = rootElement.namedItem("host").toElement();
74 TQDomElement portElement = rootElement.namedItem("port").toElement();
75 TQDomElement nameElement = rootElement.namedItem("name").toElement();
76 TQDomElement userElement = rootElement.namedItem("user").toElement();
77 TQDomElement passElement = rootElement.namedItem("password").toElement();
78 TQDomElement persElement = rootElement.namedItem("persistant").toElement();
79 TQDomElement encodingElement = rootElement.namedItem("encoding").toElement();
80
81 KexiProjectConnectionData *tmp=new KexiProjectConnectionData(
82 engineElement.text(), nameElement.text(),hostElement.text(),portElement.text().toInt(),
83 userElement.text(),passElement.text(),"");
84
85 return tmp;
86}
87
88void KexiProjectConnectionData::setDriverName(const TQString &driverName) {
89 m_driverName=driverName;
90}
91
92void KexiProjectConnectionData::setDatabaseName(const TQString &databaseName) {
93 m_databaseName=databaseName;
94}
95
97 return m_driverName;
98}
99
100TQString KexiProjectConnectionData::databaseName() const {
101 return m_databaseName;
102}
103
104
105void
106KexiProjectConnectionData::writeInfo(TQDomDocument &domDoc)
107{
108 TQDomElement connectionElement = domDoc.createElement("KexiDBConnection");
109 domDoc.documentElement().appendChild(connectionElement);
110
111//DB ENGINE
112 TQDomElement engineElement = domDoc.createElement("engine");
113 connectionElement.appendChild(engineElement);
114
115 TQDomText tEngine = domDoc.createTextNode(m_driverName);
116 engineElement.appendChild(tEngine);
117
118//HOST
119 TQDomElement hostElement = domDoc.createElement("host");
120 connectionElement.appendChild(hostElement);
121
122 TQDomText tHost = domDoc.createTextNode(hostName);
123 hostElement.appendChild(tHost);
124
125//DATABASE NAME
126 TQDomElement nameElement = domDoc.createElement("name");
127 connectionElement.appendChild(nameElement);
128
129 TQDomText tName = domDoc.createTextNode(m_databaseName);
130 nameElement.appendChild(tName);
131
132//USER
133 TQDomElement userElement = domDoc.createElement("user");
134 connectionElement.appendChild(userElement);
135
136 TQDomText tUser = domDoc.createTextNode(userName);
137 userElement.appendChild(tUser);
138
139//PASSWORD STUFF
140 TQDomElement passElement = domDoc.createElement("password");
141 connectionElement.appendChild(passElement);
142
143 TQDomText tPass=domDoc.createTextNode(password);
144 passElement.appendChild(tPass);
145
146}
147
148
149
150KexiProjectConnectionData::~KexiProjectConnectionData()
151{
152}
TQString userName
Username used for the connection.
TQString password
Password used for the connection.
TQString driverName
the name of the driver that should be used to create a connection
TQString hostName
Host name used for the remote connection.
void setFileName(const TQString &fn)
Set the filename used by the connection.
TQString fileName() const
Get the filename used by the connection.
This class aims to provide methods to store/load database settings especially for file based engines.
High-level database connectivity library with database backend drivers.