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 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883
|
/*!
* \file
*
* \author Peter Harvey <pharvey@peterharvey.org>
* \author \sa AUTHORS file
* \version 2
* \date 2007
* \license Copyright unixODBC Project 2007-2008, LGPL
*/
#include <ini.h>
#include <QtGui>
#include "CDriverList.h"
#include "CPropertiesDialog.h"
#define ODBC_HELP_DRIVER_NAME "*Unique* driver name."
#define ODBC_HELP_DRIVER_DESC "Driver description."
#define ODBC_HELP_DRIVER_DRIVER "The driver. Its a share library and the filename will probably have odbc in it and it will probably end with *.so."
#define ODBC_HELP_DRIVER_DRIVER64 "The driver for 64 bit environments. Its a share library and the filename will probably have odbc in it and it will probably end with *.so."
#define ODBC_HELP_DRIVER_SETUP "The setup routines. Its a share library used to provide this program with DSN properties which can be presented to the user to edit. This library filename usually ends with a *S.so."
#define ODBC_HELP_DRIVER_SETUP64 "The setup routines for 64 bit environments. Its a share library used to provide this program with DSN properties which can be presented to the user to edit. This library filename usually ends with a *S.so."
#define ODBC_HELP_DRIVER_USAGECOUNT "The number of installs that use this driver. This driver entry should be removed when < 1."
#define ODBC_HELP_DRIVER_CPTIMEOUT "Number of seconds before a connection timesout when in a Connection Pool. Leave this value blank to disable Connection Pooling. 0-n (0=default)."
#define ODBC_HELP_DRIVER_CPTIMETOLIVE "Max number of seconds a pooled connection may be used. 0-n (0=default)."
#define ODBC_HELP_DRIVER_CPREUSE "The maximum number of times a connection can be reused in a Connection Pool. Set to a lower number when dealing with drivers which have stability issues or memory leaks."
#define ODBC_HELP_DRIVER_CPPROBE "A simple, benign, SQL statement which can be used to verify that the connection is still valid. Text (empty=default)."
#define ODBC_HELP_DRIVER_DGF "Enable/Disable use of SQLGetFunctions by DM. 0-1 (0=default)."
#define ODBC_HELP_DRIVER_DLCLOSE "Enable to tell DM to skip explicit unload request of driver. 0-1 (1=default)."
#define ODBC_HELP_DRIVER_FETCHMAP "Enable/Disable SQLFetch -> SQLExtendedFetch mapping. 0-1 (1=default)."
#define ODBC_HELP_DRIVER_THREADING "Thread level: 0-3 (3=default)."
#define ODBC_HELP_DRIVER_FAKEUNICODE "Fake UNICODE: 0-1 (0=default)."
#define ODBC_HELP_DRIVER_ICONV "Iconv option. Default is set at build time and is usually 'auto-search'."
#define ODBC_HELP_DRIVER_TRACE "Turn trace on/off. 0-1 (0=default)."
#define ODBC_HELP_DRIVER_TRACEFILE "Place to write trace output (/tmp/Trace.txt=default)."
#define ODBC_HELP_DRIVER_TRACELIBRARY "Library to create trace output (odbctrac=default)."
#define ODBC_HELP_DRIVER_UNKNOWN "No help for this driver specific property. Please check with the vendor of the driver... perhaps their web site"
CDriverList::CDriverList( QWidget* pwidgetParent )
: QTableWidget( pwidgetParent )
{
setToolTip( tr( "list of registered drivers" ) );
setWhatsThis( tr( "This is a list of registered drivers. Registered drivers are drivers which the Driver Manager knows about. A well behaved driver installer will automatically register a driver - but not all driver installers do this last step. If you know your driver is installed but is not registered here then it can be registered manually providing you knwo the file names." ) );
QStringList stringlistHeaderLabels;
setColumnCount( 4 );
setHorizontalHeaderLabels( stringlistHeaderLabels << tr( "Name" ) << tr( "Description" ) << tr( "Driver" ) << tr( "Setup" ) );
setSelectionBehavior( QAbstractItemView::SelectRows );
setSelectionMode( QAbstractItemView::SingleSelection );
verticalHeader()->setVisible( false );
connect( this, SIGNAL(itemDoubleClicked( QTableWidgetItem * )), this, SLOT(slotDoubleClick( QTableWidgetItem * )));
slotLoad();
}
CDriverList::~CDriverList()
{
}
QString CDriverList::getFriendlyName()
{
QList<QTableWidgetItem*> listSelectedItems = selectedItems();
if ( !listSelectedItems.count() )
return QString::null;
return item( row( listSelectedItems.at( 0 ) ), 0 )->text();
}
QString CDriverList::getDescription()
{
QList<QTableWidgetItem*> listSelectedItems = selectedItems();
if ( !listSelectedItems.count() )
return QString::null;
return item( row( listSelectedItems.at( 0 ) ), 1 )->text();
}
QString CDriverList::getDriver()
{
QList<QTableWidgetItem*> listSelectedItems = selectedItems();
if ( !listSelectedItems.count() )
return QString::null;
return item( row( listSelectedItems.at( 0 ) ), 2 )->text();
}
QString CDriverList::getSetup()
{
QList<QTableWidgetItem*> listSelectedItems = selectedItems();
if ( !listSelectedItems.count() )
return QString::null;
return item( row( listSelectedItems.at( 0 ) ), 3 )->text();
}
void CDriverList::slotAdd()
{
HODBCINSTPROPERTY hFirstProperty = NULL;
HODBCINSTPROPERTY hCurProperty = NULL;
HODBCINSTPROPERTY hLastProperty;
// SET UP PROPERTIES LIST
hFirstProperty = (HODBCINSTPROPERTY)malloc( sizeof(ODBCINSTPROPERTY) );
memset( hFirstProperty, 0, sizeof(ODBCINSTPROPERTY) );
hFirstProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
hFirstProperty->pNext = NULL;
hFirstProperty->bRefresh = 0;
hFirstProperty->hDLL = NULL;
hFirstProperty->pWidget = NULL;
hFirstProperty->pszHelp = strdup( ODBC_HELP_DRIVER_NAME );
hFirstProperty->aPromptData = NULL;
strncpy( hFirstProperty->szName, "Name", INI_MAX_PROPERTY_NAME );
strcpy( hFirstProperty->szValue, "" );
hLastProperty = hFirstProperty;
hLastProperty->pNext = (HODBCINSTPROPERTY)malloc( sizeof(ODBCINSTPROPERTY) );
hLastProperty = hLastProperty->pNext;
memset( hLastProperty, 0, sizeof(ODBCINSTPROPERTY) );
hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
hLastProperty->pNext = NULL;
hLastProperty->bRefresh = 0;
hLastProperty->hDLL = NULL;
hLastProperty->pWidget = NULL;
hLastProperty->pszHelp = strdup( ODBC_HELP_DRIVER_DESC );
hLastProperty->aPromptData = NULL;
strncpy( hLastProperty->szName, "Description", INI_MAX_PROPERTY_NAME );
strcpy( hLastProperty->szValue, "" );
/*
* Don't have a deflib for 64 bit, the user may not want a driver entry, just a driver64
*/
#ifdef PLATFORM64
#undef DEFLIB_PATH
#endif
hLastProperty->pNext = (HODBCINSTPROPERTY)malloc( sizeof(ODBCINSTPROPERTY) );
hLastProperty = hLastProperty->pNext;
memset( hLastProperty, 0, sizeof(ODBCINSTPROPERTY) );
hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_FILENAME;
hLastProperty->pszHelp = strdup( ODBC_HELP_DRIVER_DRIVER );
strncpy( hLastProperty->szName, "Driver", INI_MAX_PROPERTY_NAME );
#ifdef DEFLIB_PATH
strncpy( hLastProperty->szValue, DEFLIB_PATH, INI_MAX_PROPERTY_VALUE );
#else
strncpy( hLastProperty->szValue, "", INI_MAX_PROPERTY_VALUE );
#endif
hLastProperty->pNext = (HODBCINSTPROPERTY)malloc( sizeof(ODBCINSTPROPERTY) );
hLastProperty = hLastProperty->pNext;
memset( hLastProperty, 0, sizeof(ODBCINSTPROPERTY) );
hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_FILENAME;
hLastProperty->pszHelp = strdup( ODBC_HELP_DRIVER_DRIVER64 );
strncpy( hLastProperty->szName, "Driver64", INI_MAX_PROPERTY_NAME );
#ifdef DEFLIB_PATH
strncpy( hLastProperty->szValue, DEFLIB_PATH, INI_MAX_PROPERTY_VALUE );
#else
strncpy( hLastProperty->szValue, "", INI_MAX_PROPERTY_VALUE );
#endif
hLastProperty->pNext = (HODBCINSTPROPERTY)malloc( sizeof(ODBCINSTPROPERTY) );
hLastProperty = hLastProperty->pNext;
memset( hLastProperty, 0, sizeof(ODBCINSTPROPERTY) );
hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_FILENAME;
hLastProperty->pszHelp = strdup( ODBC_HELP_DRIVER_SETUP );
strncpy( hLastProperty->szName, "Setup", INI_MAX_PROPERTY_NAME );
#ifdef DEFLIB_PATH
strncpy( hLastProperty->szValue, DEFLIB_PATH, INI_MAX_PROPERTY_VALUE );
#else
strncpy( hLastProperty->szValue, "", INI_MAX_PROPERTY_VALUE );
#endif
hLastProperty->pNext = (HODBCINSTPROPERTY)malloc( sizeof(ODBCINSTPROPERTY) );
hLastProperty = hLastProperty->pNext;
memset( hLastProperty, 0, sizeof(ODBCINSTPROPERTY) );
hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_FILENAME;
hLastProperty->pszHelp = strdup( ODBC_HELP_DRIVER_SETUP64 );
strncpy( hLastProperty->szName, "Setup64", INI_MAX_PROPERTY_NAME );
#ifdef DEFLIB_PATH
strncpy( hLastProperty->szValue, DEFLIB_PATH, INI_MAX_PROPERTY_VALUE );
#else
strncpy( hLastProperty->szValue, "", INI_MAX_PROPERTY_VALUE );
#endif
hLastProperty->pNext = (HODBCINSTPROPERTY)malloc( sizeof(ODBCINSTPROPERTY) );
hLastProperty = hLastProperty->pNext;
memset( hLastProperty, 0, sizeof(ODBCINSTPROPERTY) );
hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
hLastProperty->pNext = NULL;
hLastProperty->bRefresh = 0;
hLastProperty->hDLL = NULL;
hLastProperty->pWidget = NULL;
hLastProperty->pszHelp = strdup( ODBC_HELP_DRIVER_USAGECOUNT );
hLastProperty->aPromptData = NULL;
strncpy( hLastProperty->szName, "UsageCount", INI_MAX_PROPERTY_NAME );
strcpy( hLastProperty->szValue, "1" );
hLastProperty->pNext = (HODBCINSTPROPERTY)malloc( sizeof(ODBCINSTPROPERTY) );
hLastProperty = hLastProperty->pNext;
memset( hLastProperty, 0, sizeof(ODBCINSTPROPERTY) );
hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
hLastProperty->pNext = NULL;
hLastProperty->bRefresh = 0;
hLastProperty->hDLL = NULL;
hLastProperty->pWidget = NULL;
hLastProperty->pszHelp = strdup( ODBC_HELP_DRIVER_CPTIMEOUT );
hLastProperty->aPromptData = NULL;
strncpy( hLastProperty->szName, "CPTimeout", INI_MAX_PROPERTY_NAME );
strcpy( hLastProperty->szValue, "0" );
hLastProperty->pNext = (HODBCINSTPROPERTY)malloc( sizeof(ODBCINSTPROPERTY) );
hLastProperty = hLastProperty->pNext;
memset( hLastProperty, 0, sizeof(ODBCINSTPROPERTY) );
hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
hLastProperty->pNext = NULL;
hLastProperty->bRefresh = 0;
hLastProperty->hDLL = NULL;
hLastProperty->pWidget = NULL;
hLastProperty->pszHelp = strdup( ODBC_HELP_DRIVER_CPTIMETOLIVE );
hLastProperty->aPromptData = NULL;
strncpy( hLastProperty->szName, "CPTimeToLive", INI_MAX_PROPERTY_NAME );
strcpy( hLastProperty->szValue, "0" );
hLastProperty->pNext = (HODBCINSTPROPERTY)malloc( sizeof(ODBCINSTPROPERTY) );
hLastProperty = hLastProperty->pNext;
memset( hLastProperty, 0, sizeof(ODBCINSTPROPERTY) );
hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
hLastProperty->pNext = NULL;
hLastProperty->bRefresh = 0;
hLastProperty->hDLL = NULL;
hLastProperty->pWidget = NULL;
hLastProperty->pszHelp = strdup( ODBC_HELP_DRIVER_CPPROBE );
hLastProperty->aPromptData = NULL;
strncpy( hLastProperty->szName, "CPProbe", INI_MAX_PROPERTY_NAME );
hLastProperty->pNext = (HODBCINSTPROPERTY)malloc( sizeof(ODBCINSTPROPERTY) );
hLastProperty = hLastProperty->pNext;
memset( hLastProperty, 0, sizeof(ODBCINSTPROPERTY) );
hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
hLastProperty->pNext = NULL;
hLastProperty->bRefresh = 0;
hLastProperty->hDLL = NULL;
hLastProperty->pWidget = NULL;
hLastProperty->pszHelp = strdup( ODBC_HELP_DRIVER_DGF );
hLastProperty->aPromptData = NULL;
strncpy( hLastProperty->szName, "DisableGetFunctions", INI_MAX_PROPERTY_NAME );
strcpy( hLastProperty->szValue, "0" );
hLastProperty->pNext = (HODBCINSTPROPERTY)malloc( sizeof(ODBCINSTPROPERTY) );
hLastProperty = hLastProperty->pNext;
memset( hLastProperty, 0, sizeof(ODBCINSTPROPERTY) );
hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
hLastProperty->pNext = NULL;
hLastProperty->bRefresh = 0;
hLastProperty->hDLL = NULL;
hLastProperty->pWidget = NULL;
hLastProperty->pszHelp = strdup( ODBC_HELP_DRIVER_DLCLOSE );
hLastProperty->aPromptData = NULL;
strncpy( hLastProperty->szName, "DontDLCLose", INI_MAX_PROPERTY_NAME );
strcpy( hLastProperty->szValue, "1" );
hLastProperty->pNext = (HODBCINSTPROPERTY)malloc( sizeof(ODBCINSTPROPERTY) );
hLastProperty = hLastProperty->pNext;
memset( hLastProperty, 0, sizeof(ODBCINSTPROPERTY) );
hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
hLastProperty->pNext = NULL;
hLastProperty->bRefresh = 0;
hLastProperty->hDLL = NULL;
hLastProperty->pWidget = NULL;
hLastProperty->pszHelp = strdup( ODBC_HELP_DRIVER_FETCHMAP );
hLastProperty->aPromptData = NULL;
strncpy( hLastProperty->szName, "ExFetchMapping", INI_MAX_PROPERTY_NAME );
strcpy( hLastProperty->szValue, "1" );
hLastProperty->pNext = (HODBCINSTPROPERTY)malloc( sizeof(ODBCINSTPROPERTY) );
hLastProperty = hLastProperty->pNext;
memset( hLastProperty, 0, sizeof(ODBCINSTPROPERTY) );
hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
hLastProperty->pNext = NULL;
hLastProperty->bRefresh = 0;
hLastProperty->hDLL = NULL;
hLastProperty->pWidget = NULL;
hLastProperty->pszHelp = strdup( ODBC_HELP_DRIVER_THREADING );
hLastProperty->aPromptData = NULL;
strncpy( hLastProperty->szName, "Threading", INI_MAX_PROPERTY_NAME );
strcpy( hLastProperty->szValue, "3" );
hLastProperty->pNext = (HODBCINSTPROPERTY)malloc( sizeof(ODBCINSTPROPERTY) );
hLastProperty = hLastProperty->pNext;
memset( hLastProperty, 0, sizeof(ODBCINSTPROPERTY) );
hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
hLastProperty->pNext = NULL;
hLastProperty->bRefresh = 0;
hLastProperty->hDLL = NULL;
hLastProperty->pWidget = NULL;
hLastProperty->pszHelp = strdup( ODBC_HELP_DRIVER_FAKEUNICODE );
hLastProperty->aPromptData = NULL;
strncpy( hLastProperty->szName, "FakeUnicode", INI_MAX_PROPERTY_NAME );
strcpy( hLastProperty->szValue, "0" );
hLastProperty->pNext = (HODBCINSTPROPERTY)malloc( sizeof(ODBCINSTPROPERTY) );
hLastProperty = hLastProperty->pNext;
memset( hLastProperty, 0, sizeof(ODBCINSTPROPERTY) );
hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
hLastProperty->pNext = NULL;
hLastProperty->bRefresh = 0;
hLastProperty->hDLL = NULL;
hLastProperty->pWidget = NULL;
hLastProperty->pszHelp = strdup( ODBC_HELP_DRIVER_ICONV );
hLastProperty->aPromptData = NULL;
strncpy( hLastProperty->szName, "IconvEncoding", INI_MAX_PROPERTY_NAME );
hLastProperty->pNext = (HODBCINSTPROPERTY)malloc( sizeof(ODBCINSTPROPERTY) );
hLastProperty = hLastProperty->pNext;
memset( hLastProperty, 0, sizeof(ODBCINSTPROPERTY) );
hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
hLastProperty->pNext = NULL;
hLastProperty->bRefresh = 0;
hLastProperty->hDLL = NULL;
hLastProperty->pWidget = NULL;
hLastProperty->pszHelp = strdup( ODBC_HELP_DRIVER_TRACE );
hLastProperty->aPromptData = NULL;
strncpy( hLastProperty->szName, "Trace", INI_MAX_PROPERTY_NAME );
hLastProperty->pNext = (HODBCINSTPROPERTY)malloc( sizeof(ODBCINSTPROPERTY) );
hLastProperty = hLastProperty->pNext;
memset( hLastProperty, 0, sizeof(ODBCINSTPROPERTY) );
hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
hLastProperty->pNext = NULL;
hLastProperty->bRefresh = 0;
hLastProperty->hDLL = NULL;
hLastProperty->pWidget = NULL;
hLastProperty->pszHelp = strdup( ODBC_HELP_DRIVER_TRACEFILE );
hLastProperty->aPromptData = NULL;
strncpy( hLastProperty->szName, "TraceFile", INI_MAX_PROPERTY_NAME );
hLastProperty->pNext = (HODBCINSTPROPERTY)malloc( sizeof(ODBCINSTPROPERTY) );
hLastProperty = hLastProperty->pNext;
memset( hLastProperty, 0, sizeof(ODBCINSTPROPERTY) );
hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
hLastProperty->pNext = NULL;
hLastProperty->bRefresh = 0;
hLastProperty->hDLL = NULL;
hLastProperty->pWidget = NULL;
hLastProperty->pszHelp = strdup( ODBC_HELP_DRIVER_TRACELIBRARY );
hLastProperty->aPromptData = NULL;
strncpy( hLastProperty->szName, "TraceLibrary", INI_MAX_PROPERTY_NAME );
// present properties for editing...
{
CPropertiesDialog propertiesdialog( this, hFirstProperty );
propertiesdialog.setWindowTitle( tr( "Driver Properties (new)" ) );
if ( !propertiesdialog.exec() )
{
ODBCINSTDestructProperties( &hFirstProperty );
return;
}
}
// save changes...
{
// get our ini file
char szINI[FILENAME_MAX+1];
char b1[ 256 ], b2[ 256 ];
sprintf( szINI, "%s/%s", odbcinst_system_file_path( b1 ), odbcinst_system_file_name( b1 ) );
// ensure section does not exist...
if ( SQLWritePrivateProfileString( hFirstProperty->szValue, NULL, NULL, szINI ) == FALSE )
{
ODBCINSTDestructProperties( &hFirstProperty );
CODBCInst::showErrors( this, QString( "Could not write to (%1)\nYou probably need to do this while logged in as root." ).arg( szINI ) );
return;
}
// create section (first call) and add key/value pairs...
for ( hCurProperty = hFirstProperty->pNext; hCurProperty != NULL; hCurProperty = hCurProperty->pNext )
{
SQLWritePrivateProfileString( hFirstProperty->szValue, hCurProperty->szName, hCurProperty->szValue, szINI );
}
// free mem used by properties...
ODBCINSTDestructProperties( &hFirstProperty );
// announce that we have revised driver information...
emit signalChanged();
}
// reload to pickup any changes (including any we may not know about)...
slotLoad();
}
void CDriverList::slotEdit()
{
QString stringName = "";
CPropertiesDialog * pProperties;
HODBCINSTPROPERTY hFirstProperty = NULL;
HODBCINSTPROPERTY hCurProperty = NULL;
HODBCINSTPROPERTY hLastProperty;
HINI hIni;
char szINI[FILENAME_MAX+1];
char b1[ 256 ], b2[ 256 ];
sprintf( szINI, "%s/%s", odbcinst_system_file_path( b1 ), odbcinst_system_file_name( b1 ) );
QList<QTableWidgetItem*> listSelectedItems = selectedItems();
if ( listSelectedItems.count() )
stringName = item( row( listSelectedItems.at( 0 ) ), 0 )->text();
else
{
QMessageBox::warning( this, tr( "ODBC Administrator" ), "Please select a Driver from the list first." );
return;
}
// SET UP PROPERTIES LIST STARTING WITH MANDATORY PROPERTIES
hFirstProperty = (HODBCINSTPROPERTY)malloc( sizeof(ODBCINSTPROPERTY) );
memset( hFirstProperty, 0, sizeof(ODBCINSTPROPERTY) );
hFirstProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
hFirstProperty->pNext = NULL;
hFirstProperty->bRefresh = 0;
hFirstProperty->hDLL = NULL;
hFirstProperty->pWidget = NULL;
hFirstProperty->pszHelp = strdup( ODBC_HELP_DRIVER_NAME );
hFirstProperty->aPromptData = NULL;
strncpy( hFirstProperty->szName, "Name", INI_MAX_PROPERTY_NAME );
strcpy( hFirstProperty->szValue, stringName.toAscii().data() );
hLastProperty = hFirstProperty;
hLastProperty->pNext = (HODBCINSTPROPERTY)malloc( sizeof(ODBCINSTPROPERTY) );
hLastProperty = hLastProperty->pNext;
memset( hLastProperty, 0, sizeof(ODBCINSTPROPERTY) );
hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
hLastProperty->pNext = NULL;
hLastProperty->bRefresh = 0;
hLastProperty->hDLL = NULL;
hLastProperty->pWidget = NULL;
hLastProperty->pszHelp = strdup( ODBC_HELP_DRIVER_DESC );
hLastProperty->aPromptData = NULL;
strncpy( hLastProperty->szName, "Description", INI_MAX_PROPERTY_NAME );
strcpy( hLastProperty->szValue, "" );
SQLGetPrivateProfileString( stringName.toAscii().data(), hLastProperty->szName, "", hLastProperty->szValue, sizeof(hLastProperty->szValue)-1, szINI );
hLastProperty->pNext = (HODBCINSTPROPERTY)malloc( sizeof(ODBCINSTPROPERTY) );
hLastProperty = hLastProperty->pNext;
memset( hLastProperty, 0, sizeof(ODBCINSTPROPERTY) );
hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_FILENAME;
hLastProperty->pszHelp = strdup( ODBC_HELP_DRIVER_DRIVER );
strncpy( hLastProperty->szName, "Driver", INI_MAX_PROPERTY_NAME );
strncpy( hLastProperty->szValue, "", INI_MAX_PROPERTY_VALUE );
SQLGetPrivateProfileString( stringName.toAscii().data(), hLastProperty->szName, "", hLastProperty->szValue, sizeof(hLastProperty->szValue)-1, szINI );
hLastProperty->pNext = (HODBCINSTPROPERTY)malloc( sizeof(ODBCINSTPROPERTY) );
hLastProperty = hLastProperty->pNext;
memset( hLastProperty, 0, sizeof(ODBCINSTPROPERTY) );
hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_FILENAME;
hLastProperty->pszHelp = strdup( ODBC_HELP_DRIVER_DRIVER64 );
strncpy( hLastProperty->szName, "Driver64", INI_MAX_PROPERTY_NAME );
strncpy( hLastProperty->szValue, "", INI_MAX_PROPERTY_VALUE );
SQLGetPrivateProfileString( stringName.toAscii().data(), hLastProperty->szName, "", hLastProperty->szValue, sizeof(hLastProperty->szValue)-1, szINI );
hLastProperty->pNext = (HODBCINSTPROPERTY)malloc( sizeof(ODBCINSTPROPERTY) );
hLastProperty = hLastProperty->pNext;
memset( hLastProperty, 0, sizeof(ODBCINSTPROPERTY) );
hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_FILENAME;
hLastProperty->pszHelp = strdup( ODBC_HELP_DRIVER_SETUP );
strncpy( hLastProperty->szName, "Setup", INI_MAX_PROPERTY_NAME );
strncpy( hLastProperty->szValue, "", INI_MAX_PROPERTY_VALUE );
SQLGetPrivateProfileString( stringName.toAscii().data(), hLastProperty->szName, "", hLastProperty->szValue, sizeof(hLastProperty->szValue)-1, szINI );
hLastProperty->pNext = (HODBCINSTPROPERTY)malloc( sizeof(ODBCINSTPROPERTY) );
hLastProperty = hLastProperty->pNext;
memset( hLastProperty, 0, sizeof(ODBCINSTPROPERTY) );
hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_FILENAME;
hLastProperty->pszHelp = strdup( ODBC_HELP_DRIVER_SETUP64 );
strncpy( hLastProperty->szName, "Setup64", INI_MAX_PROPERTY_NAME );
strncpy( hLastProperty->szValue, "", INI_MAX_PROPERTY_VALUE );
SQLGetPrivateProfileString( stringName.toAscii().data(), hLastProperty->szName, "", hLastProperty->szValue, sizeof(hLastProperty->szValue)-1, szINI );
hLastProperty->pNext = (HODBCINSTPROPERTY)malloc( sizeof(ODBCINSTPROPERTY) );
hLastProperty = hLastProperty->pNext;
memset( hLastProperty, 0, sizeof(ODBCINSTPROPERTY) );
hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
hLastProperty->pNext = NULL;
hLastProperty->bRefresh = 0;
hLastProperty->hDLL = NULL;
hLastProperty->pWidget = NULL;
hLastProperty->aPromptData = NULL;
hLastProperty->pszHelp = strdup( ODBC_HELP_DRIVER_USAGECOUNT );
strncpy( hLastProperty->szName, "UsageCount", INI_MAX_PROPERTY_NAME );
strcpy( hLastProperty->szValue, "1" );
SQLGetPrivateProfileString( stringName.toAscii().data(), hLastProperty->szName, "", hLastProperty->szValue, sizeof(hLastProperty->szValue)-1, szINI );
hLastProperty->pNext = (HODBCINSTPROPERTY)malloc( sizeof(ODBCINSTPROPERTY) );
hLastProperty = hLastProperty->pNext;
memset( hLastProperty, 0, sizeof(ODBCINSTPROPERTY) );
hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
hLastProperty->pNext = NULL;
hLastProperty->bRefresh = 0;
hLastProperty->hDLL = NULL;
hLastProperty->pWidget = NULL;
hLastProperty->pszHelp = strdup( ODBC_HELP_DRIVER_CPTIMEOUT );
hLastProperty->aPromptData = NULL;
strncpy( hLastProperty->szName, "CPTimeout", INI_MAX_PROPERTY_NAME );
strcpy( hLastProperty->szValue, "0" );
SQLGetPrivateProfileString( stringName.toAscii().data(), hLastProperty->szName, "", hLastProperty->szValue, sizeof(hLastProperty->szValue)-1, szINI );
hLastProperty->pNext = (HODBCINSTPROPERTY)malloc( sizeof(ODBCINSTPROPERTY) );
hLastProperty = hLastProperty->pNext;
memset( hLastProperty, 0, sizeof(ODBCINSTPROPERTY) );
hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
hLastProperty->pNext = NULL;
hLastProperty->bRefresh = 0;
hLastProperty->hDLL = NULL;
hLastProperty->pWidget = NULL;
hLastProperty->pszHelp = strdup( ODBC_HELP_DRIVER_CPTIMETOLIVE );
hLastProperty->aPromptData = NULL;
strncpy( hLastProperty->szName, "CPTimeToLive", INI_MAX_PROPERTY_NAME );
strcpy( hLastProperty->szValue, "0" );
SQLGetPrivateProfileString( stringName.toAscii().data(), hLastProperty->szName, "", hLastProperty->szValue, sizeof(hLastProperty->szValue)-1, szINI );
/*
hLastProperty->pNext = (HODBCINSTPROPERTY)malloc( sizeof(ODBCINSTPROPERTY) );
hLastProperty = hLastProperty->pNext;
memset( hLastProperty, 0, sizeof(ODBCINSTPROPERTY) );
hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
hLastProperty->pNext = NULL;
hLastProperty->bRefresh = 0;
hLastProperty->hDLL = NULL;
hLastProperty->pWidget = NULL;
hLastProperty->pszHelp = strdup( ODBC_HELP_DRIVER_CPREUSE );
hLastProperty->aPromptData = NULL;
strncpy( hLastProperty->szName, "CPReuse", INI_MAX_PROPERTY_NAME );
strcpy( hLastProperty->szValue, "0" );
SQLGetPrivateProfileString( stringName.toAscii().data(), hLastProperty->szName, "", hLastProperty->szValue, sizeof(hLastProperty->szValue)-1, szINI );
*/
hLastProperty->pNext = (HODBCINSTPROPERTY)malloc( sizeof(ODBCINSTPROPERTY) );
hLastProperty = hLastProperty->pNext;
memset( hLastProperty, 0, sizeof(ODBCINSTPROPERTY) );
hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
hLastProperty->pNext = NULL;
hLastProperty->bRefresh = 0;
hLastProperty->hDLL = NULL;
hLastProperty->pWidget = NULL;
hLastProperty->pszHelp = strdup( ODBC_HELP_DRIVER_DGF );
hLastProperty->aPromptData = NULL;
strncpy( hLastProperty->szName, "DisableGetFunctions", INI_MAX_PROPERTY_NAME );
strcpy( hLastProperty->szValue, "0" );
SQLGetPrivateProfileString( stringName.toAscii().data(), hLastProperty->szName, "", hLastProperty->szValue, sizeof(hLastProperty->szValue)-1, szINI );
hLastProperty->pNext = (HODBCINSTPROPERTY)malloc( sizeof(ODBCINSTPROPERTY) );
hLastProperty = hLastProperty->pNext;
memset( hLastProperty, 0, sizeof(ODBCINSTPROPERTY) );
hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
hLastProperty->pNext = NULL;
hLastProperty->bRefresh = 0;
hLastProperty->hDLL = NULL;
hLastProperty->pWidget = NULL;
hLastProperty->pszHelp = strdup( ODBC_HELP_DRIVER_DLCLOSE );
hLastProperty->aPromptData = NULL;
strncpy( hLastProperty->szName, "DontDLCLose", INI_MAX_PROPERTY_NAME );
strcpy( hLastProperty->szValue, "1" );
SQLGetPrivateProfileString( stringName.toAscii().data(), hLastProperty->szName, "", hLastProperty->szValue, sizeof(hLastProperty->szValue)-1, szINI );
hLastProperty->pNext = (HODBCINSTPROPERTY)malloc( sizeof(ODBCINSTPROPERTY) );
hLastProperty = hLastProperty->pNext;
memset( hLastProperty, 0, sizeof(ODBCINSTPROPERTY) );
hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
hLastProperty->pNext = NULL;
hLastProperty->bRefresh = 0;
hLastProperty->hDLL = NULL;
hLastProperty->pWidget = NULL;
hLastProperty->pszHelp = strdup( ODBC_HELP_DRIVER_FETCHMAP );
hLastProperty->aPromptData = NULL;
strncpy( hLastProperty->szName, "ExFetchMapping", INI_MAX_PROPERTY_NAME );
strcpy( hLastProperty->szValue, "1" );
SQLGetPrivateProfileString( stringName.toAscii().data(), hLastProperty->szName, "", hLastProperty->szValue, sizeof(hLastProperty->szValue)-1, szINI );
hLastProperty->pNext = (HODBCINSTPROPERTY)malloc( sizeof(ODBCINSTPROPERTY) );
hLastProperty = hLastProperty->pNext;
memset( hLastProperty, 0, sizeof(ODBCINSTPROPERTY) );
hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
hLastProperty->pNext = NULL;
hLastProperty->bRefresh = 0;
hLastProperty->hDLL = NULL;
hLastProperty->pWidget = NULL;
hLastProperty->pszHelp = strdup( ODBC_HELP_DRIVER_THREADING );
hLastProperty->aPromptData = NULL;
strncpy( hLastProperty->szName, "Threading", INI_MAX_PROPERTY_NAME );
strcpy( hLastProperty->szValue, "3" );
SQLGetPrivateProfileString( stringName.toAscii().data(), hLastProperty->szName, "", hLastProperty->szValue, sizeof(hLastProperty->szValue)-1, szINI );
hLastProperty->pNext = (HODBCINSTPROPERTY)malloc( sizeof(ODBCINSTPROPERTY) );
hLastProperty = hLastProperty->pNext;
memset( hLastProperty, 0, sizeof(ODBCINSTPROPERTY) );
hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
hLastProperty->pNext = NULL;
hLastProperty->bRefresh = 0;
hLastProperty->hDLL = NULL;
hLastProperty->pWidget = NULL;
hLastProperty->pszHelp = strdup( ODBC_HELP_DRIVER_FAKEUNICODE );
hLastProperty->aPromptData = NULL;
strncpy( hLastProperty->szName, "FakeUnicode", INI_MAX_PROPERTY_NAME );
strcpy( hLastProperty->szValue, "0" );
SQLGetPrivateProfileString( stringName.toAscii().data(), hLastProperty->szName, "", hLastProperty->szValue, sizeof(hLastProperty->szValue)-1, szINI );
hLastProperty->pNext = (HODBCINSTPROPERTY)malloc( sizeof(ODBCINSTPROPERTY) );
hLastProperty = hLastProperty->pNext;
memset( hLastProperty, 0, sizeof(ODBCINSTPROPERTY) );
hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
hLastProperty->pNext = NULL;
hLastProperty->bRefresh = 0;
hLastProperty->hDLL = NULL;
hLastProperty->pWidget = NULL;
hLastProperty->pszHelp = strdup( ODBC_HELP_DRIVER_ICONV );
hLastProperty->aPromptData = NULL;
strncpy( hLastProperty->szName, "IconvEncoding", INI_MAX_PROPERTY_NAME );
SQLGetPrivateProfileString( stringName.toAscii().data(), hLastProperty->szName, "", hLastProperty->szValue, sizeof(hLastProperty->szValue)-1, szINI );
hLastProperty->pNext = (HODBCINSTPROPERTY)malloc( sizeof(ODBCINSTPROPERTY) );
hLastProperty = hLastProperty->pNext;
memset( hLastProperty, 0, sizeof(ODBCINSTPROPERTY) );
hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
hLastProperty->pNext = NULL;
hLastProperty->bRefresh = 0;
hLastProperty->hDLL = NULL;
hLastProperty->pWidget = NULL;
hLastProperty->pszHelp = strdup( ODBC_HELP_DRIVER_TRACE );
hLastProperty->aPromptData = NULL;
strncpy( hLastProperty->szName, "Trace", INI_MAX_PROPERTY_NAME );
SQLGetPrivateProfileString( stringName.toAscii().data(), hLastProperty->szName, "", hLastProperty->szValue, sizeof(hLastProperty->szValue)-1, szINI );
hLastProperty->pNext = (HODBCINSTPROPERTY)malloc( sizeof(ODBCINSTPROPERTY) );
hLastProperty = hLastProperty->pNext;
memset( hLastProperty, 0, sizeof(ODBCINSTPROPERTY) );
hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
hLastProperty->pNext = NULL;
hLastProperty->bRefresh = 0;
hLastProperty->hDLL = NULL;
hLastProperty->pWidget = NULL;
hLastProperty->pszHelp = strdup( ODBC_HELP_DRIVER_TRACEFILE );
hLastProperty->aPromptData = NULL;
strncpy( hLastProperty->szName, "TraceFile", INI_MAX_PROPERTY_NAME );
SQLGetPrivateProfileString( stringName.toAscii().data(), hLastProperty->szName, "", hLastProperty->szValue, sizeof(hLastProperty->szValue)-1, szINI );
hLastProperty->pNext = (HODBCINSTPROPERTY)malloc( sizeof(ODBCINSTPROPERTY) );
hLastProperty = hLastProperty->pNext;
memset( hLastProperty, 0, sizeof(ODBCINSTPROPERTY) );
hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
hLastProperty->pNext = NULL;
hLastProperty->bRefresh = 0;
hLastProperty->hDLL = NULL;
hLastProperty->pWidget = NULL;
hLastProperty->pszHelp = strdup( ODBC_HELP_DRIVER_TRACELIBRARY );
hLastProperty->aPromptData = NULL;
strncpy( hLastProperty->szName, "TraceLibrary", INI_MAX_PROPERTY_NAME );
SQLGetPrivateProfileString( stringName.toAscii().data(), hLastProperty->szName, "", hLastProperty->szValue, sizeof(hLastProperty->szValue)-1, szINI );
// ACCEPT ANY DRIVER SPECIFIC PROPERTIES THAT HAVE BEEN TYPED IN MANUALLY OR INSTALLED
// NOTE: This is a quick enhancement. Much room to optimize this func.
{
char szDriverName[INI_MAX_OBJECT_NAME+1];
char szPropertyName[INI_MAX_PROPERTY_NAME+1];
char szPropertyNameUpper[INI_MAX_PROPERTY_NAME+1];
char szPropertyValue[INI_MAX_PROPERTY_VALUE+1];
strcpy( szDriverName, stringName.toAscii().data() );
if ( iniOpen( &hIni, szINI, (char*)"#;", '[', ']', '=', TRUE ) != INI_ERROR )
{
if ( iniObjectSeek( hIni, szDriverName ) == INI_SUCCESS )
{
while ( iniPropertyEOL( hIni ) == FALSE )
{
iniProperty( hIni, szPropertyName );
iniProperty( hIni, szPropertyNameUpper );
iniToUpper( szPropertyNameUpper );
if ( strncmp( szPropertyNameUpper, "NAME", INI_MAX_PROPERTY_NAME ) != 0 &&
strncmp( szPropertyNameUpper, "DESCRIPTION", INI_MAX_PROPERTY_NAME ) != 0 &&
strncmp( szPropertyNameUpper, "DRIVER", INI_MAX_PROPERTY_NAME ) != 0 &&
strncmp( szPropertyNameUpper, "DRIVER64", INI_MAX_PROPERTY_NAME ) != 0 &&
strncmp( szPropertyNameUpper, "SETUP", INI_MAX_PROPERTY_NAME ) != 0 &&
strncmp( szPropertyNameUpper, "SETUP64", INI_MAX_PROPERTY_NAME ) != 0 &&
strncmp( szPropertyNameUpper, "USAGECOUNT", INI_MAX_PROPERTY_NAME ) != 0 &&
strncmp( szPropertyNameUpper, "CPTIMEOUT", INI_MAX_PROPERTY_NAME ) != 0 &&
/* strncmp( szPropertyNameUpper, "CPREUSE", INI_MAX_PROPERTY_NAME ) != 0 && */
strncmp( szPropertyNameUpper, "CPTIMETOLIVE", INI_MAX_PROPERTY_NAME ) != 0 &&
strncmp( szPropertyNameUpper, "CPPROBE", INI_MAX_PROPERTY_NAME ) != 0 &&
strncmp( szPropertyNameUpper, "DISABLEGETFUNCTIONS", INI_MAX_PROPERTY_NAME ) != 0 &&
strncmp( szPropertyNameUpper, "DONTDLCLOSE", INI_MAX_PROPERTY_NAME ) != 0 &&
strncmp( szPropertyNameUpper, "EXFETCHMAPPING", INI_MAX_PROPERTY_NAME ) != 0 &&
strncmp( szPropertyNameUpper, "THREADING", INI_MAX_PROPERTY_NAME ) != 0 &&
strncmp( szPropertyNameUpper, "FAKEUNICODE", INI_MAX_PROPERTY_NAME ) != 0 &&
strncmp( szPropertyNameUpper, "ICONVENCODING", INI_MAX_PROPERTY_NAME ) != 0 &&
strncmp( szPropertyNameUpper, "TRACE", INI_MAX_PROPERTY_NAME ) != 0 &&
strncmp( szPropertyNameUpper, "TRACEFILE", INI_MAX_PROPERTY_NAME ) != 0 &&
strncmp( szPropertyNameUpper, "TRACELIBRARY", INI_MAX_PROPERTY_NAME ) != 0 )
{
iniValue( hIni, szPropertyValue );
hLastProperty->pNext = (HODBCINSTPROPERTY)malloc( sizeof(ODBCINSTPROPERTY) );
hLastProperty = hLastProperty->pNext;
memset( hLastProperty, 0, sizeof(ODBCINSTPROPERTY) );
hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
hLastProperty->pNext = NULL;
hLastProperty->bRefresh = 0;
hLastProperty->hDLL = NULL;
hLastProperty->pWidget = NULL;
hLastProperty->pszHelp = strdup( ODBC_HELP_DRIVER_UNKNOWN );
hLastProperty->aPromptData = NULL;
strncpy( hLastProperty->szName, szPropertyName, INI_MAX_PROPERTY_NAME );
strncpy( hLastProperty->szValue, szPropertyValue, sizeof(hLastProperty->szValue)-1 );
}
iniPropertyNext( hIni );
}
}
iniClose( hIni );
}
}
// ALLOW USER TO EDIT
pProperties = new CPropertiesDialog( this, hFirstProperty );
pProperties->setWindowTitle( tr( "Driver Properties (edit)" ) );
if ( pProperties->exec() )
{
/* DELETE ENTIRE SECTION IF IT EXISTS (no entry given) */
if ( SQLWritePrivateProfileString( stringName.toAscii().data(), NULL, NULL, szINI ) == FALSE )
{
delete pProperties;
ODBCINSTDestructProperties( &hFirstProperty );
CODBCInst::showErrors( this, QString( "Could not write to (%1).\nYou probably need to do this while logged in as root." ).arg( szINI ) );
return;
}
/* ADD ENTRIES; SECTION CREATED ON FIRST CALL */
for ( hCurProperty = hFirstProperty->pNext; hCurProperty != NULL; hCurProperty = hCurProperty->pNext )
{
SQLWritePrivateProfileString( hFirstProperty->szValue, hCurProperty->szName, hCurProperty->szValue, szINI );
}
emit signalChanged();
}
delete pProperties;
ODBCINSTDestructProperties( &hFirstProperty );
// RELOAD (slow but safe)
slotLoad();
}
void CDriverList::slotDelete()
{
HINI hIni;
char szINI[FILENAME_MAX+1];
QString stringName;
char b1[ 256 ], b2[ 256 ];
sprintf( szINI, "%s/%s", odbcinst_system_file_path( b1 ), odbcinst_system_file_name( b1 ) );
// GET SELECT DATA SOURCE NAME
QList<QTableWidgetItem*> listSelectedItems = selectedItems();
if ( listSelectedItems.count() )
stringName = item( row( listSelectedItems.at( 0 ) ), 0 )->text();
else
{
QMessageBox::warning( this, tr( "ODBC Administrator" ), "Please select a Driver from the list first" );
return;
}
// DELETE ENTIRE SECTION IF IT EXISTS (given NULL entry)
if ( SQLWritePrivateProfileString( stringName.toAscii().data(), NULL, NULL, szINI ) == FALSE )
CODBCInst::showErrors( this, QString( "Could not write property list for (%1)" ).arg( stringName ) );
emit signalChanged();
// RELOAD (slow but safe)
slotLoad();
}
void CDriverList::slotLoad()
{
HINI hIni;
char szINI[FILENAME_MAX+1];
char szDriverName[INI_MAX_OBJECT_NAME+1];
char szPropertyName[INI_MAX_PROPERTY_NAME+1];
char szDescription[INI_MAX_PROPERTY_VALUE+1];
char szDriver[INI_MAX_PROPERTY_VALUE+1];
char szDriver64[INI_MAX_PROPERTY_VALUE+1];
char szSetup[INI_MAX_PROPERTY_VALUE+1];
char szSetup64[INI_MAX_PROPERTY_VALUE+1];
int nRow = 0;
char b1[ 256 ], b2[ 256 ];
setRowCount( 0 );
sprintf( szINI, "%s/%s", odbcinst_system_file_path( b1 ), odbcinst_system_file_name( b1 ) );
if ( iniOpen( &hIni, szINI, (char*)"#;", '[', ']', '=', TRUE ) != INI_ERROR )
{
iniObjectFirst( hIni );
while ( iniObjectEOL( hIni ) == FALSE )
{
*szDriverName = '\0';
*szDescription = '\0';
*szDriver = '\0';
*szDriver64 = '\0';
*szSetup64 = '\0';
*szSetup = '\0';
iniObject( hIni, szDriverName );
iniPropertyFirst( hIni );
if ( strcmp( szDriverName, "ODBC" ) == 0 )
{
iniObjectNext( hIni );
continue;
}
while ( iniPropertyEOL( hIni ) == FALSE )
{
iniProperty( hIni, szPropertyName );
iniToUpper( szPropertyName );
if ( strncmp( szPropertyName, "DESCRIPTION", INI_MAX_PROPERTY_NAME ) == 0 )
iniValue( hIni, szDescription );
#ifdef PLATFORM64
if ( strncmp( szPropertyName, "DRIVER64", INI_MAX_PROPERTY_NAME ) == 0 )
iniValue( hIni, szDriver64 );
if ( strncmp( szPropertyName, "DRIVER", INI_MAX_PROPERTY_NAME ) == 0 )
iniValue( hIni, szDriver );
if ( strncmp( szPropertyName, "SETUP64", INI_MAX_PROPERTY_NAME ) == 0 )
iniValue( hIni, szSetup64 );
if ( strncmp( szPropertyName, "SETUP", INI_MAX_PROPERTY_NAME ) == 0 )
iniValue( hIni, szSetup );
#else
if ( strncmp( szPropertyName, "DRIVER", INI_MAX_PROPERTY_NAME ) == 0 )
iniValue( hIni, szDriver );
if ( strncmp( szPropertyName, "SETUP", INI_MAX_PROPERTY_NAME ) == 0 )
iniValue( hIni, szSetup );
#endif
iniPropertyNext( hIni );
}
#ifdef PLATFORM64
if ( szDriver64[ 0 ] != '\0' )
strcpy( szDriver, szDriver64 );
if ( szSetup64[ 0 ] != '\0' )
strcpy( szSetup, szSetup64 );
#endif
QTableWidgetItem *ptablewidgetitem;
setRowCount( nRow + 1 );
ptablewidgetitem = new QTableWidgetItem( szDriverName );
ptablewidgetitem->setFlags( Qt::ItemIsSelectable );
setItem( nRow, 0, ptablewidgetitem );
ptablewidgetitem = new QTableWidgetItem( szDescription );
ptablewidgetitem->setFlags( Qt::ItemIsSelectable );
setItem( nRow, 1, ptablewidgetitem );
ptablewidgetitem = new QTableWidgetItem( szDriver );
ptablewidgetitem->setFlags( Qt::ItemIsSelectable );
setItem( nRow, 2, ptablewidgetitem );
ptablewidgetitem = new QTableWidgetItem( szSetup );
ptablewidgetitem->setFlags( Qt::ItemIsSelectable );
setItem( nRow, 3, ptablewidgetitem );
nRow++;
iniObjectNext( hIni );
}
iniClose( hIni );
}
else
CODBCInst::showErrors( this, QString( "Could not open system file at %1" ).arg( szINI ) );
}
void CDriverList::slotDoubleClick( QTableWidgetItem * )
{
slotEdit();
}
|