1
1
/* **************************************************************************
2
2
sanewconnection.h
3
- Dialogue box for defining new connections to a SQL Anywhere database
3
+ Dialogue box for defining new connections to a SQL Anywhere database
4
4
-------------------
5
5
begin : Dec 2010
6
6
copyright : (C) 2010 by iAnywhere Solutions, Inc.
7
- author : David DeHaan
7
+ author : David DeHaan
8
8
email : ddehaan at sybase dot com
9
9
10
10
***************************************************************************
@@ -47,12 +47,12 @@ SaNewConnection::SaNewConnection( QWidget *parent, const QString& connName, Qt::
47
47
txtDatabase->setText ( settings.value ( key + " /database" ).toString () );
48
48
txtParameters->setText ( settings.value ( key + " /parameters" ).toString () );
49
49
50
- if ( settings.value ( key + " /saveUsername" , true ).toBool () )
50
+ if ( settings.value ( key + " /saveUsername" , true ).toBool () )
51
51
{
52
- txtUsername->setText ( settings.value ( key + " /username" ).toString () );
53
- chkStoreUsername->setChecked ( true );
52
+ txtUsername->setText ( settings.value ( key + " /username" ).toString () );
53
+ chkStoreUsername->setChecked ( true );
54
54
}
55
- if ( settings.value ( key + " /savePassword" , false ).toBool () )
55
+ if ( settings.value ( key + " /savePassword" , false ).toBool () )
56
56
{
57
57
txtPassword->setText ( settings.value ( key + " /password" ).toString () );
58
58
chkStorePassword->setChecked ( true );
@@ -61,7 +61,7 @@ SaNewConnection::SaNewConnection( QWidget *parent, const QString& connName, Qt::
61
61
chkEstimateMetadata->setChecked ( settings.value ( key + " /estimateMetadata" , false ).toBool () );
62
62
chkOtherSchemas->setChecked ( settings.value ( key + " /otherSchemas" , false ).toBool () );
63
63
64
- }
64
+ }
65
65
}
66
66
67
67
SaNewConnection::~SaNewConnection ()
@@ -116,49 +116,55 @@ void SaNewConnection::on_btnConnect_clicked()
116
116
117
117
void SaNewConnection::testConnection ()
118
118
{
119
- char errbuf[SACAPI_ERROR_SIZE];
120
- sacapi_i32 code;
121
- SqlAnyConnection *conn;
122
-
123
- // load the SQL Anywhere interface
124
- if ( !SqlAnyConnection::initApi () ) {
125
- QMessageBox::information ( this ,
126
- tr (" Failed to load interface" ),
127
- tr ( SqlAnyConnection::failedInitMsg () ) );
128
- return ;
119
+ char errbuf[SACAPI_ERROR_SIZE];
120
+ sacapi_i32 code;
121
+ SqlAnyConnection *conn;
122
+
123
+ // load the SQL Anywhere interface
124
+ if ( !SqlAnyConnection::initApi () )
125
+ {
126
+ QMessageBox::information ( this ,
127
+ tr ( " Failed to load interface" ),
128
+ tr ( SqlAnyConnection::failedInitMsg () ) );
129
+ return ;
130
+ }
131
+
132
+ // establish read-only connection to the database
133
+ conn = SqlAnyConnection::connect ( txtName->text ()
134
+ , txtHost->text (), txtPort->text (), txtServer->text ()
135
+ , txtDatabase->text (), txtParameters->text (), txtUsername->text ()
136
+ , txtPassword->text (), chkSimpleEncryption->isChecked ()
137
+ , chkEstimateMetadata->isChecked (), true
138
+ , code, errbuf, sizeof ( errbuf ) );
139
+ if ( conn )
140
+ {
141
+ // retrieve the username and password, in case the user adjusted them
142
+ QgsDataSourceURI theUri ( conn->uri () );
143
+ if ( chkStoreUsername->isChecked () )
144
+ {
145
+ txtUsername->setText ( theUri.username () );
129
146
}
130
-
131
- // establish read-only connection to the database
132
- conn = SqlAnyConnection::connect ( txtName->text ()
133
- , txtHost->text (), txtPort->text (), txtServer->text ()
134
- , txtDatabase->text (), txtParameters->text (), txtUsername->text ()
135
- , txtPassword->text (), chkSimpleEncryption->isChecked ()
136
- , chkEstimateMetadata->isChecked (), true
137
- , code, errbuf, sizeof ( errbuf ) );
138
- if ( conn ) {
139
- // retrieve the username and password, in case the user adjusted them
140
- QgsDataSourceURI theUri ( conn->uri () );
141
- if ( chkStoreUsername->isChecked () ) {
142
- txtUsername->setText ( theUri.username () );
143
- }
144
- if ( chkStorePassword->isChecked () ) {
145
- txtPassword->setText ( theUri.password () );
146
- }
147
- conn->release ();
148
-
149
- QMessageBox::information ( this ,
147
+ if ( chkStorePassword->isChecked () )
148
+ {
149
+ txtPassword->setText ( theUri.password () );
150
+ }
151
+ conn->release ();
152
+
153
+ QMessageBox::information ( this ,
150
154
tr ( " Test connection" ),
151
155
tr ( " Connection to %1 was successful" )
152
- .arg ( txtDatabase->text () ) );
153
- } else {
154
- QMessageBox::information ( this ,
156
+ .arg ( txtDatabase->text () ) );
157
+ }
158
+ else
159
+ {
160
+ QMessageBox::information ( this ,
155
161
tr ( " Test connection" ),
156
162
tr ( " Connection failed. "
157
- " Check settings and try again.\n\n "
158
- " SQL Anywhere error code: %1\n "
159
- " Description: %2" )
160
- .arg ( code )
161
- .arg ( errbuf ) );
162
- }
163
- SqlAnyConnection::releaseApi ();
163
+ " Check settings and try again.\n\n "
164
+ " SQL Anywhere error code: %1\n "
165
+ " Description: %2" )
166
+ .arg ( code )
167
+ .arg ( errbuf ) );
168
+ }
169
+ SqlAnyConnection::releaseApi ();
164
170
}
0 commit comments