45 #define SYMBIAN_ENABLE_PUBLIC_PLATFORM_HEADER_SPLIT 56 #include "../../../corelib/kernel/qcore_symbian_p.h" 65 #include <e32capability.h> 180 bool fetchNext(
bool initialFetch);
195 skippedStatus(false),
217 int nCols =
stmt.ColumnCount();
224 for (
int i = 0; i < nCols; ++i) {
226 TInt err =
stmt.ColumnName(i, cName);
228 if (err != KErrNone) {
234 QString colName = qt_TDesC2QString(cName);
238 TSqlColumnType decColType;
239 err =
stmt.DeclaredColumnType(i, decColType);
241 if (err != KErrNone) {
327 TInt res =
d->
stmt.Prepare(
d->
access, qt_QString2TPtrC(query));
329 if (res != KErrNone) {
355 int res =
d->
stmt.Reset();
357 if (res != KErrNone) {
365 while (
d->
stmt.ParamName(paramCount, tmp) == KErrNone)
368 if (paramCount == values.
count()) {
369 for (
int i = 0; i < paramCount; ++i) {
374 res =
d->
stmt.BindNull(i);
376 switch (value.
type()) {
397 res =
d->
stmt.BindText(i, qt_QString2TPtrC(*str));
401 res =
d->
stmt.BindText(i, qt_QString2TPtrC(str));
405 if (res != KErrNone) {
426 if (
d->
stmt.ColumnCount() > 0) {
504 switch (
d->
stmt.ColumnType(idx)) {
508 d->
stmt.ColumnBinary(idx, data);
509 return QByteArray(reinterpret_cast<const char *>(data.Ptr()), data.Length());
532 d->
stmt.ColumnText(idx, res);
533 r =
QVariant(qt_TDesC2QString(res));
542 d->
stmt.ColumnText(idx, res);
543 r =
QVariant(qt_TDesC2QString(res));
552 return d->
stmt.IsNull(i);
563 if (
at() <= -1 || i <
at()) {
615 res =
d->
stmt.Next();
617 }
while (res == KSqlAtRow);
619 if (res != KSqlAtEnd)
679 TCapability cap = ECapability_HardLimit;
681 for (
int i = 0; i < static_cast<int>(ECapability_Limit); i++) {
683 cap =
static_cast<TCapability
>(i);
689 if (cap == ECapability_HardLimit
691 cap = ECapability_None;
702 if (startPos == -1) {
708 if (values.
count() > 0) {
711 const int MaxCapCount = 7;
712 const int VidMaxCount = 3;
713 const int SidMaxCount = 3;
715 TCapability capList[MaxCapCount] = { ECapability_None,ECapability_None,ECapability_None,
716 ECapability_None,ECapability_None,ECapability_None,ECapability_None };
722 int maxAllowed = MaxCapCount;
729 maxAllowed = VidMaxCount;
736 maxAllowed = SidMaxCount;
739 if (values.
count() <= maxAllowed) {
740 bool wasSuccesful =
true;
742 for (
int i = 0; i < values.
count(); i++) {
745 if (capList[i] == ECapability_HardLimit) {
746 wasSuccesful =
false;
759 policy = TSecurityPolicy(vid, capList[0], capList[1], capList[2]);
762 policy = TSecurityPolicy(sid, capList[0], capList[1], capList[2]);
768 policy = TSecurityPolicy(capList[0], capList[1], capList[2], capList[3],
769 capList[4], capList[5], capList[6]);
861 for (
int i = optionList.
count() - 1; i >= 0; i--) {
862 if (!optionList[i].contains(isOurOption)) {
863 symbianList.
append(optionList[i]);
867 QString formatted = optionList[i];
872 optionList[i] = formatted;
878 for (
int i = 0; i < symbianList.
count(); i++) {
879 symbianOpt += symbianList[i];
880 symbianOpt += itemSeparator;
883 TPtrC dbName(qt_QString2TPtrC(db));
885 const TPtrC8 config(reinterpret_cast<const TUint8*>(conOpts8.
constData()), (conOpts8.
length()));
887 TInt res =
d->
access.Open(dbName, &config);
889 if (res == KErrNotFound) {
898 int policyIndex = optionList.
indexOf(findDefault);
900 if (policyIndex != -1) {
901 QString defaultPolicyString = optionList[policyIndex];
904 TSecurityPolicy policyItem;
907 RSqlSecurityPolicy policy;
908 res = policy.Create(policyItem);
910 if (res == KErrNone) {
911 for (
int i = 0; i < optionList.
count(); i++) {
912 QString option = optionList[i];
916 res = policy.SetDbPolicy(RSqlSecurityPolicy::EReadPolicy, policyItem);
920 }
else if (option.
contains(findWrite)) {
922 res = policy.SetDbPolicy(RSqlSecurityPolicy::EWritePolicy, policyItem);
926 }
else if (option.
contains(findSchema)) {
928 res = policy.SetDbPolicy(RSqlSecurityPolicy::ESchemaPolicy, policyItem);
932 }
else if (option.
contains(findTableWrite)) {
936 if (firstComma != -1) {
938 tableOption = tableOption.
mid(firstComma + 1);
941 TPtrC symTableName(qt_QString2TPtrC(tableName));
943 res = policy.SetPolicy(RSqlSecurityPolicy::ETable, symTableName,
944 RSqlSecurityPolicy::EWritePolicy, policyItem);
951 }
else if (option.
contains(findTableRead)) {
955 if (firstComma != -1) {
957 tableOption = tableOption.
mid(firstComma + 1);
960 TPtrC symTableName(qt_QString2TPtrC(tableName));
962 res = policy.SetPolicy(RSqlSecurityPolicy::ETable, symTableName,
963 RSqlSecurityPolicy::EReadPolicy, policyItem);
974 if (res != KErrNone) {
980 if (res == KErrNone) {
981 res =
d->
access.Create(dbName, policy, &config);
996 policyIndex = optionList.
indexOf(isOurOption);
998 if (policyIndex == -1) {
999 res =
d->
access.Create(dbName, &config);
1001 if (res != KErrNone)
1010 if (res == KErrNone) {
1039 TInt err =
d->
access.Exec(_L(
"BEGIN"));
1040 if (err < KErrNone) {
1054 TInt err =
d->
access.Exec(_L(
"COMMIT"));
1055 if (err < KErrNone) {
1069 TInt err =
d->
access.Exec(_L(
"ROLLBACK"));
1070 if (err < KErrNone) {
1089 "UNION ALL SELECT name FROM sqlite_temp_master WHERE %1");
1092 else if (type & QSql::Tables)
1094 else if (type & QSql::Views)
1116 if (indexOfSeparator > -1) {
1117 dbName = tableName.
left(indexOfSeparator +1 );
1118 table = tableName.
mid(indexOfSeparator + 1);
1122 const int NAME_IDX = 1;
1123 const int TYPE_IDX = 2;
1124 const int NOTNULL_IDX = 3;
1125 const int DFLT_VALUE_IDX = 4;
1126 const int PK_IDX = 5;
1131 if (onlyPIndex && !isPk)
1139 fld.setRequired(q.
value(NOTNULL_IDX).
toInt() != 0);
1140 fld.setDefaultValue(q.
value(DFLT_VALUE_IDX));
The QVariant class acts like a union for the most common Qt data types.
The QSqlError class provides SQL database error information.
The QSqlIndex class provides functions to manipulate and describe database indexes.
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QVariant handle() const
Returns the low-level database handle for this result set wrapped in a QVariant or an invalid QVarian...
bool qExtractSecurityPolicyFromString(const QString &string, TSecurityPolicy &policy)
const QSqlDriver * driver() const
Returns the driver associated with the result.
QSymSQLDriver(QObject *parent=0)
static QVariant::Type qGetColumnType(const TSqlColumnType coltype)
bool isActive() const
Returns true if the result has records to be retrieved; otherwise returns false.
#define QT_END_NAMESPACE
This macro expands to.
QVariant qVariantFromValue(const T &)
virtual void setOpen(bool o)
This function sets the open state of the database to open.
int size()
Returns the size of the SELECT result, or -1 if it cannot be determined or if the query is not a SELE...
The QRegExp class provides pattern matching using regular expressions.
DriverFeature
This enum contains a list of features a driver might support.
bool isNull() const
Returns true if this is a NULL variant, false otherwise.
const char qCapabilityNone[]
virtual void setOpenError(bool e)
This function sets the open error state of the database to error.
int count(const T &t) const
Returns the number of occurrences of value in the vector.
void append(const QSqlField &field)
Appends the field field to the list of indexed fields.
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
bool fetchNext(bool initialFetch)
QString & replace(int i, int len, QChar after)
The QByteArray class provides an array of bytes.
QString & prepend(QChar c)
The QSqlQuery class provides a means of executing and manipulating SQL statements.
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
bool fetch(int i)
Positions the result to an arbitrary (zero-based) row index.
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static QSqlError gMakeErrorOpen(const QString &descr, QSqlError::ErrorType type, TInt errorCode)
int count(const T &t) const
Returns the number of occurrences of value in the list.
virtual bool isOpen() const
Returns true if the database connection is open; otherwise returns false.
The QSqlRecord class encapsulates a database record.
bool hasFeature(DriverFeature f) const
Returns true if the driver supports feature feature; otherwise returns false.
QSql::NumericalPrecisionPolicy numericalPrecisionPolicy() const
The QSqlDriver class is an abstract base class for accessing specific SQL databases.
The QString class provides a Unicode character string.
int at() const
Returns the current (zero-based) row position of the result.
const QString fieldSeparator(QLatin1String(","))
The QObject class is the base class of all Qt objects.
bool isNull(int i)
Returns true if the field at position index in the current row is null; otherwise returns false...
int numRowsAffected()
Returns the number of rows affected by the last query executed, or -1 if it cannot be determined or i...
QStringList tables(QSql::TableType) const
Returns a list of the names of the tables in the database.
QString lastQuery() const
Returns the current SQL query text, or an empty string if there isn't one.
void initColumns(QSqlRecord &rec)
virtual void setAt(int at)
This function is provided for derived classes to set the internal (zero-based) row position to index...
static QString translate(const char *context, const char *key, const char *disambiguation=0, Encoding encoding=CodecForTr)
QList< T > mid(int pos, int length=-1) const
Returns a list whose elements are copied from this list, starting at position pos.
QSqlRecord record() const
Returns the current record if the query is active; otherwise returns an empty QSqlRecord.
virtual void setLastError(const QSqlError &e)
This function is provided for derived classes to set the last error to error.
bool isIdentifierEscaped(const QString &identifier, IdentifierType type) const
Returns whether identifier is escaped according to the database rules.
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
bool fetchFirst()
Positions the result to the first record (row 0) in the result.
bool isOpenError() const
Returns true if the there was an error opening the database connection; otherwise returns false...
static QString _q_escapeIdentifier(const QString &identifier)
ErrorType
This enum type describes the context in which the error occurred, e.
QSymSQLResult(const QSymSQLDriver *db)
QSqlRecord record(const QString &tablename) const
Returns a QSqlRecord populated with the names of the fields in table tableName.
void append(const T &t)
Inserts value at the end of the list.
int indexOf(const QRegExp &rx, int from=0) const
Returns the index position of the first exact match of rx in the list, searching forward from index p...
#define QT_BEGIN_NAMESPACE
This macro expands to.
qlonglong toLongLong(bool *ok=0) const
Returns the variant as a long long int if the variant has type() LongLong , Bool , ByteArray , Char , Double , Int , String , UInt , or ULongLong ; otherwise returns 0.
bool fetchLast()
Positions the result to the last record (last row) in the result.
const char * qCapabilityNames[ECapability_Limit]
virtual void setSelect(bool s)
This function is provided for derived classes to indicate whether or not the current statement is a S...
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
int access(const char *, int)
QString trimmed() const Q_REQUIRED_RESULT
Returns a string that has whitespace removed from the start and the end.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
The QStringList class provides a list of strings.
bool exec()
Executes the query, returning true if successful; otherwise returns false.
const QString valueSeparator(QLatin1String("="))
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Type
This enum type defines the types of variable that a QVariant can contain.
QString right(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n rightmost characters of the string.
TCapability qMatchCapStr(QString &str)
Converts capability string to TCapability.
QVariant lastInsertId() const
Returns the object ID of the most recent inserted row if the database supports it.
virtual void virtual_hook(int id, void *data)
QVariant data(int field)
Returns the data for field index in the current row as a QVariant.
void setForwardOnly(bool forward)
Sets forward only mode to forward.
const T & at(int i) const
Returns the item at index position i in the vector.
bool prepare(const QString &query)
Prepares the given query for execution; the query will normally use placeholders so that it can be ex...
bool commitTransaction()
This function is called to commit a transaction.
int length() const
Same as size().
const char * constData() const
Returns a pointer to the data stored in the byte array.
QSqlResult * createResult() const
Creates an empty SQL result on the database.
static QSqlError qMakeError(RSqlDatabase &access, const QString &descr, QSqlError::ErrorType type, int errorCode=-1)
QSqlIndex primaryIndex(const QString &table) const
Returns the primary index for table tableName.
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
bool fetchPrevious()
Positions the result to the previous record (row) in the result.
QString & append(QChar c)
int compare(const QString &s) const
friend class QSymSQLResult
void clear()
Clears the contents of the string and makes it empty.
friend class QSymSQLResultPrivate
int lastIndexOf(QChar c, int from=-1, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Type type() const
Returns the storage type of the value stored in the variant.
QObject * parent() const
Returns a pointer to the parent object.
bool rollbackTransaction()
This function is called to rollback a transaction.
const void * constData() const
QString toLower() const Q_REQUIRED_RESULT
Returns a lowercase copy of the string.
uint toUInt(bool *ok=0, int base=10) const
Returns the string converted to an unsigned int using base base, which is 10 by default and must be b...
QVariant handle() const
Returns the low-level database handle wrapped in a QVariant or an invalid variant if there is no hand...
void append(const QSqlField &field)
Append a copy of field field to the end of the record.
QSqlError lastError() const
Returns the last error associated with the result.
bool isSelect() const
Returns true if the current result is from a SELECT statement; otherwise returns false.
double toDouble(bool *ok=0) const
Returns the variant as a double if the variant has type() Double , QMetaType::Float ...
virtual void setActive(bool a)
This function is provided for derived classes to set the internal active state to active...
virtual bool fetchPrevious()
Positions the result to the previous record (row) in the result.
bool beginTransaction()
This function is called to begin a transaction.
static QSqlIndex qGetTableInfo(QSqlQuery &q, const QString &tableName, bool onlyPIndex=false)
bool isValid() const
Returns true if the result is positioned on a valid record (that is, the result is not positioned bef...
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
The QSqlField class manipulates the fields in SQL database tables and views.
bool reset(const QString &query)
Sets the result to use the SQL statement query for subsequent data retrieval.
bool exec(const QString &query)
Executes the SQL in query.
virtual void setLastError(const QSqlError &e)
This function is used to set the value of the last error, error, that occurred on the database...
QString & remove(int i, int len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
void setAutoValue(bool autoVal)
Marks the field as an auto-generated value if autoVal is true.
QSymSQLResultPrivate(QSymSQLResult *res)
QString stripDelimiters(const QString &identifier, IdentifierType type) const
Returns the identifier with the leading and trailing delimiters removed, identifier can either be a t...
QVector< QVariant > & boundValues() const
Returns a vector of the result's bound values for the current record (row).
QVariant value(int i) const
Returns the value of field index in the current record.
QString escapeIdentifier(const QString &identifier, IdentifierType) const
Returns the identifier escaped according to the database rules.
bool fetchNext()
Positions the result to the next available record (row) in the result.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
bool next()
Retrieves the next record in the result, if available, and positions the query on the retrieved recor...
The QSqlResult class provides an abstract interface for accessing data from specific SQL databases...
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
void close()
Derived classes must reimplement this pure virtual function in order to close the database connection...
IdentifierType
This enum contains a list of SQL identifier types.
bool open(const QString &db, const QString &user, const QString &password, const QString &host, int port, const QString &connOpts)
Derived classes must reimplement this pure virtual function to open a database connection on database...
static QString fromUtf16(const ushort *, int size=-1)
Returns a QString initialized with the first size characters of the Unicode string unicode (ISO-10646...
void virtual_hook(int id, void *data)
void removeAt(int i)
Removes the item at index position i.