kexi

kexiprojectconnectiondata.cpp

00001 /* This file is part of the KDE project
00002    Copyright (C) 2003 Lucijan Busch <lucijan@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include <sys/types.h>
00021 #include <unistd.h>
00022 
00023 #include <qdom.h>
00024 #include <qdir.h>
00025 #include <qfile.h>
00026 #include <qregexp.h>
00027 
00028 #include <kglobal.h>
00029 #include <kstandarddirs.h>
00030 #include <kdebug.h>
00031 #include <kio/netaccess.h>
00032 #include <kurl.h>
00033 #include <klocale.h>
00034 #include <kmessagebox.h>
00035 
00036 #include <kexidb/connectiondata.h>
00037 #include <kexidb/drivermanager.h>
00038 #include "kexiprojectconnectiondata.h"
00039 
00040 KexiProjectConnectionData::KexiProjectConnectionData(): KexiDB::ConnectionData()
00041 {
00042 }
00043 
00044 KexiProjectConnectionData::KexiProjectConnectionData(const QString& driverName, const QString& databaseName, const QString &host, 
00045         unsigned short int rport, const QString& user, const QString &pass, const QString& file):KexiDB::ConnectionData()
00046 {
00047     m_driverName=driverName;
00048     m_databaseName=databaseName;
00049     hostName=host;
00050     port=rport;
00051     userName=user;
00052     password=pass;
00053     setFileName(file);
00054 }
00055 
00056 KexiProjectConnectionData::KexiProjectConnectionData(const QString &driverName, const QString &fileName)
00057  : KexiDB::ConnectionData()
00058 {
00059     m_driverName=driverName;
00060     setFileName(fileName);
00061 }
00062 
00063 const QString &
00064 KexiProjectConnectionData::generateTmpName()
00065 {
00066     return QString::null;
00067 }
00068 
00069 KexiProjectConnectionData*
00070 KexiProjectConnectionData::loadInfo(QDomElement &rootElement)
00071 {
00072     QDomElement engineElement = rootElement.namedItem("engine").toElement();
00073     QDomElement hostElement = rootElement.namedItem("host").toElement();
00074     QDomElement portElement = rootElement.namedItem("port").toElement();
00075     QDomElement nameElement = rootElement.namedItem("name").toElement();
00076     QDomElement userElement = rootElement.namedItem("user").toElement();
00077     QDomElement passElement = rootElement.namedItem("password").toElement();
00078     QDomElement persElement = rootElement.namedItem("persistant").toElement();
00079     QDomElement encodingElement = rootElement.namedItem("encoding").toElement();
00080 
00081     KexiProjectConnectionData *tmp=new KexiProjectConnectionData(
00082         engineElement.text(), nameElement.text(),hostElement.text(),portElement.text().toInt(),
00083         userElement.text(),passElement.text(),"");  
00084 
00085     return tmp;
00086 }
00087 
00088 void    KexiProjectConnectionData::setDriverName(const QString &driverName) {
00089     m_driverName=driverName;
00090 }
00091 
00092 void KexiProjectConnectionData::setDatabaseName(const QString &databaseName) {
00093     m_databaseName=databaseName;
00094 }
00095 
00096 QString KexiProjectConnectionData::driverName() const {
00097     return m_driverName;
00098 }
00099 
00100 QString KexiProjectConnectionData::databaseName() const {
00101     return m_databaseName;
00102 }
00103 
00104 
00105 void
00106 KexiProjectConnectionData::writeInfo(QDomDocument &domDoc)
00107 {
00108     QDomElement connectionElement = domDoc.createElement("KexiDBConnection");
00109     domDoc.documentElement().appendChild(connectionElement);
00110 
00111 //DB ENGINE
00112     QDomElement engineElement = domDoc.createElement("engine");
00113     connectionElement.appendChild(engineElement);
00114 
00115     QDomText tEngine = domDoc.createTextNode(m_driverName);
00116     engineElement.appendChild(tEngine);
00117 
00118 //HOST
00119     QDomElement hostElement = domDoc.createElement("host");
00120     connectionElement.appendChild(hostElement);
00121 
00122     QDomText tHost = domDoc.createTextNode(hostName);
00123     hostElement.appendChild(tHost);
00124 
00125 //DATABASE NAME
00126     QDomElement nameElement = domDoc.createElement("name");
00127     connectionElement.appendChild(nameElement);
00128 
00129     QDomText tName = domDoc.createTextNode(m_databaseName);
00130     nameElement.appendChild(tName);
00131 
00132 //USER
00133     QDomElement userElement = domDoc.createElement("user");
00134     connectionElement.appendChild(userElement);
00135 
00136     QDomText tUser = domDoc.createTextNode(userName);
00137     userElement.appendChild(tUser);
00138 
00139 //PASSWORD STUFF
00140     QDomElement passElement = domDoc.createElement("password");
00141     connectionElement.appendChild(passElement);
00142 
00143     QDomText tPass=domDoc.createTextNode(password);
00144     passElement.appendChild(tPass);
00145 
00146 }
00147 
00148 
00149 
00150 KexiProjectConnectionData::~KexiProjectConnectionData()
00151 {
00152 }
KDE Home | KDE Accessibility Home | Description of Access Keys