List:Commits« Previous MessageNext Message »
From:pharvey Date:April 17 2006 5:54am
Subject:Connector/ODBC 5 commit: r77 - in MYODBCIns: MYODBCInsLib include
View as plain text  
Modified:
   MYODBCIns/MYODBCInsLib/MYODBCIns.cpp
   MYODBCIns/include/MYODBCIns.h
Log:


Modified: MYODBCIns/MYODBCInsLib/MYODBCIns.cpp
===================================================================
--- MYODBCIns/MYODBCInsLib/MYODBCIns.cpp	2006-04-17 00:52:25 UTC (rev 76)
+++ MYODBCIns/MYODBCInsLib/MYODBCIns.cpp	2006-04-17 05:54:30 UTC (rev 77)
@@ -28,11 +28,17 @@
 */
 #include "MYODBCInsInternal.h"
 
-RETCODE MYODBCIns::setError( const QString &stringMessage, DWORD nErrorCode )
+bool MYODBCIns::setError( const QString &stringError, DWORD nError )
 {
     MYODBCDbgEnter();
 
-    MYODBCDbgReturn( SQLPostInstallerError( nErrorCode, stringMessage.utf16() ) );
+    if ( stringError.isNull() )
+        MYODBCDbgReturn3( "%d", false );
+
+    if ( !SQL_SUCCEEDED( SQLPostInstallerError( (DWORD)nError, stringError.utf16() ) ) )
+        MYODBCDbgReturn3( "%d", false );
+
+    MYODBCDbgReturn3( "%d", true );
 }
 
 
@@ -72,9 +78,7 @@
     for ( nChar = 0; nChar < nChars; nChar++ )
     {
         if ( szBuffer[nChar] )
-        {
             stringFriendlyName += szBuffer[nChar];
-        }
         else
         {
             if ( !stringFriendlyName.isEmpty() )
@@ -202,35 +206,97 @@
     MYODBCDbgReturn3( "%s", stringlistErrors );
 }
 
-bool MYODBCIns::doRegisterDriver( const QString &stringName, const QString
&stringAttributes )
+bool MYODBCIns::doRegisterDriver( const QString &stringName, const QString
&stringAttributes, DWORD *pnUsageCount )
 {
-    return true;
+    MYODBCDbgEnter();
+
+    if ( stringName.isNull() )
+    {
+        setError( QString( "[%1][%2][ERROR] Driver name NULL." ).arg( __FILE__ ).arg(
__LINE__ ) );
+        MYODBCDbgReturn3( "%d", false );
+    }
+
+    if ( stringAttributes.isNull() )
+    {
+        setError( QString( "[%1][%2][ERROR] Driver attributes NULL." ).arg( __FILE__
).arg( __LINE__ ) );
+        MYODBCDbgReturn3( "%d", false );
+    }
+
+    QString     stringNameAttributes    = stringName + ";" + stringAttributes + " "; //
extra space at end needed to expand buffer for extra null term
+    QChar *     pData                   = stringNameAttributes.data();
+    QChar *     pChar;
+    SQLWCHAR    sLocation[FILENAME_MAX];
+    WORD        nLocationLength;
+    DWORD       nUsageCount = -1;
+    QChar       cNull( '\0' );
+    QChar       cSemi( ';' );
+
+    if ( !pnUsageCount )
+        pnUsageCount = &nUsageCount;
+
+    // Replace ';' with '\0' and ensure extra '\0' is at end.
+    for ( pChar = pData; *pChar != cNull; pChar++ )
+    {
+        if ( *pChar == cSemi || pChar[1] == cNull )
+            *pChar = cNull;
+    }
+
+    /*! \todo throwing pData down the pipe like this may be asking for trouble? */
+    if ( !SQLInstallDriverEx( stringNameAttributes.utf16(), 0, sLocation, FILENAME_MAX,
&nLocationLength, ODBC_INSTALL_COMPLETE, &nUsageCount ) )
+        MYODBCDbgReturn3( "%d", false );
+
+    MYODBCDbgReturn3( "%d", true );
 }
 
-bool MYODBCIns::doDeregisterDriver( const QString &stringName )
+bool MYODBCIns::doDeregisterDriver( const QString &stringName, bool bRemoveDSNs,
DWORD *pnUsageCount  )
 {
-    // SQLRemoveDriver 
-    return true;
+    MYODBCDbgEnter();
+
+    DWORD nUsageCount = -1;
+
+    if ( stringName.isNull() )
+    {
+        setError( QString( "[%1][%2][ERROR] Driver name NULL." ).arg( __FILE__ ).arg(
__LINE__ ) );
+        MYODBCDbgReturn3( "%d", false );
+    }
+
+    if ( !pnUsageCount )
+        pnUsageCount = &nUsageCount;
+
+    if ( !SQLRemoveDriver( stringName.utf16(), bRemoveDSNs, pnUsageCount ) )
+        MYODBCDbgReturn3( "%d", false );
+
+    MYODBCDbgReturn3( "%d", true );
 }
 
 bool MYODBCIns::doInsertDataSource( const QString &stringName, const QString
&stringAttributes, MYODBC_INS_DATASOURCE_SCOPE nScope )
 {
-    return true;
+    MYODBCDbgEnter();
+
+    MYODBCDbgReturn3( "%d", true );
 }
 
 bool MYODBCIns::doUpdateDataSource( const QString &stringName, const QString
&stringAttributes, MYODBC_INS_DATASOURCE_SCOPE nScope )
 {
-    return true;
+    MYODBCDbgEnter();
+
+    MYODBCDbgReturn3( "%d", true );
 }
 
 bool MYODBCIns::doDeleteDataSource( const QString &stringName,
MYODBC_INS_DATASOURCE_SCOPE nScope )
 {
-    return true;
+    MYODBCDbgEnter();
+
+    MYODBCDbgReturn3( "%d", true );
 }
 
 bool MYODBCIns::isError()
 {
-    return SQL_SUCCEEDED( SQLInstallerError( 0, NULL, NULL, 0, NULL ) );
+    MYODBCDbgEnter();
+
+    bool bReturn = SQL_SUCCEEDED( SQLInstallerError( 0, NULL, NULL, 0, NULL ) );
+
+    MYODBCDbgReturn3( "%d", bReturn );
 }
 
 bool MYODBCIns::isExistsDataSourceName( const QString &stringName,
MYODBC_INS_DATASOURCE_SCOPE nScope )

Modified: MYODBCIns/include/MYODBCIns.h
===================================================================
--- MYODBCIns/include/MYODBCIns.h	2006-04-17 00:52:25 UTC (rev 76)
+++ MYODBCIns/include/MYODBCIns.h	2006-04-17 05:54:30 UTC (rev 77)
@@ -8,7 +8,7 @@
 class MYODBCIns
 {
 public:
-    static RETCODE setError( const QString &stringMessage, DWORD nErrorCode =
ODBC_ERROR_GENERAL_ERR );
+    static bool setError( const QString &stringMessage, DWORD nErrorCode =
ODBC_ERROR_GENERAL_ERR );
 
     static QStringList getDriverNames();
     static QStringList getDataSourceNames( MYODBC_INS_DATASOURCE_SCOPE nScope );
@@ -17,8 +17,8 @@
     static QString getError( WORD nError );
     static QStringList getErrors();
 
-    static bool doRegisterDriver( const QString &stringName, const QString
&stringAttributes );
-    static bool doDeregisterDriver( const QString &stringName );
+    static bool doRegisterDriver( const QString &stringName, const QString
&stringAttributes, DWORD *pnUsageCount = NULL );
+    static bool doDeregisterDriver( const QString &stringName, bool bRemoveDSNs =
false, DWORD *pnUsageCount = NULL );
     static bool doInsertDataSource( const QString &stringName, const QString
&stringAttributes, MYODBC_INS_DATASOURCE_SCOPE nScope );
     static bool doUpdateDataSource( const QString &stringName, const QString
&stringAttributes, MYODBC_INS_DATASOURCE_SCOPE nScope );
     static bool doDeleteDataSource( const QString &stringName,
MYODBC_INS_DATASOURCE_SCOPE nScope );

Thread
Connector/ODBC 5 commit: r77 - in MYODBCIns: MYODBCInsLib includepharvey17 Apr