remove native sqlite3.h bits from Connection idl

This commit is contained in:
vladimir%pobox.com 2004-10-09 14:33:01 +00:00
Родитель 5601db241c
Коммит c5c2f4a92e
6 изменённых файлов: 24 добавлений и 34 удалений

Просмотреть файл

@ -38,16 +38,10 @@
#include "nsISupports.idl"
%{C++
#include <sqlite3.h>
%}
interface mozIStorageFunction;
interface mozIStorageStatement;
interface nsIFile;
[ptr] native sqlite3ptr(sqlite3);
[scriptable, uuid(623b8b2e-c9f9-4cc3-b15a-f3c96df2cc1c)]
interface mozIStorageConnection : nsISupports {
/*
@ -182,9 +176,4 @@ interface mozIStorageConnection : nsISupports {
in string aParameters);
void removeTrigger (in string aTriggerName);
/*
* native support
*/
[noscript] readonly attribute sqlite3ptr sqliteHandle;
};

Просмотреть файл

@ -415,16 +415,6 @@ mozStorageConnection::RemoveTrigger(const char *aTriggerName)
return NS_ERROR_NOT_IMPLEMENTED;
}
/**
** Native support
**/
NS_IMETHODIMP
mozStorageConnection::GetSqliteHandle(sqlite3 **aSqliteHandle)
{
*aSqliteHandle = mDBConn;
return NS_OK;
}
/**
** Other bits
**/

Просмотреть файл

@ -39,6 +39,8 @@
#ifndef _MOZSTORAGECONNECTION_H_
#define _MOZSTORAGECONNECTION_H_
#include "nsCOMPtr.h"
#include "nsString.h"
#include "mozIStorageConnection.h"
@ -60,6 +62,9 @@ public:
NS_DECL_ISUPPORTS
NS_DECL_MOZISTORAGECONNECTION
// fetch the native handle
sqlite3 *GetNativeConnection() { return mDBConn; }
private:
~mozStorageConnection();

Просмотреть файл

@ -73,8 +73,9 @@ mozStorageService::GetProfileStorage(const char *aStorageKey, mozIStorageConnect
return rv;
}
nsCOMPtr<mozStorageConnection> conn = new mozStorageConnection();
rv = conn->Initialize (storageFile);
mozStorageConnection *msc = new mozStorageConnection();
nsCOMPtr<mozIStorageConnection> conn = msc;
rv = msc->Initialize (storageFile);
if (NS_FAILED(rv)) return rv;
*_retval = conn;
@ -88,8 +89,9 @@ mozStorageService::OpenDatabase(nsIFile *aDatabaseFile, mozIStorageConnection **
{
nsresult rv;
nsCOMPtr<mozStorageConnection> conn = new mozStorageConnection();
rv = conn->Initialize (aDatabaseFile);
mozStorageConnection *msc = new mozStorageConnection();
nsCOMPtr<mozIStorageConnection> conn = msc;
rv = msc->Initialize (aDatabaseFile);
if (NS_FAILED(rv)) return rv;
*_retval = conn;

Просмотреть файл

@ -41,6 +41,7 @@
#include "nsError.h"
#include "nsISimpleEnumerator.h"
#include "mozStorageConnection.h"
#include "mozStorageStatement.h"
#include "mozStorageValueArray.h"
@ -163,8 +164,11 @@ mozStorageStatement::Initialize(mozIStorageConnection *aDBConnection, const nsAC
nsresult rv;
sqlite3 *db = nsnull;
rv = aDBConnection->GetSqliteHandle(&db);
NS_ENSURE_SUCCESS(rv, rv);
// XXX - need to implement a private iid to QI for here, to make sure
// we have a real mozStorageConnection
mozStorageConnection *msc = NS_STATIC_CAST(mozStorageConnection*, aDBConnection);
db = msc->GetNativeConnection();
NS_ENSURE_TRUE(db != nsnull, NS_ERROR_NULL_POINTER);
srv = sqlite3_prepare (db, nsPromiseFlatCString(aSQLStatement).get(), aSQLStatement.Length(), &mDBStatement, NULL);
if (srv != SQLITE_OK) {
@ -358,9 +362,9 @@ mozStorageStatement::Execute()
int srv = sqlite3_step (mDBStatement);
if (srv == SQLITE_MISUSE || srv == SQLITE_ERROR) {
#ifdef PR_LOGGING
sqlite3 *sqh;
mDBConnection->GetSqliteHandle(&sqh);
PR_LOG(gStorageLog, PR_LOG_DEBUG, ("mozStorageStatement::Execute error: %s", sqlite3_errmsg(sqh)));
nsCAutoString errStr;
mDBConnection->GetLastErrorString(errStr);
PR_LOG(gStorageLog, PR_LOG_DEBUG, ("mozStorageStatement::Execute error: %s", errStr.get()));
#endif
return NS_ERROR_FAILURE; // XXX error code
}
@ -391,9 +395,9 @@ mozStorageStatement::ExecuteStep(PRBool *_retval)
#ifdef PR_LOGGING
if (srv != SQLITE_ROW && srv != SQLITE_DONE) {
sqlite3 *sqh;
mDBConnection->GetSqliteHandle(&sqh);
PR_LOG(gStorageLog, PR_LOG_DEBUG, ("mozStorageStatement::ExecuteStep error: %s", sqlite3_errmsg(sqh)));
nsCAutoString errStr;
mDBConnection->GetLastErrorString(errStr);
PR_LOG(gStorageLog, PR_LOG_DEBUG, ("mozStorageStatement::ExecuteStep error: %s", errStr.get()));
}
#endif

Просмотреть файл

@ -11,7 +11,7 @@
#include "mozIStorageService.h"
#include "mozIStorageConnection.h"
#include "mozIStorageValue.h"
#include "mozIStorageValueArray.h"
#include "mozIStorageStatement.h"
#include "mozIStorageFunction.h"