diff options
author | Denis Loh <denis.loh@gmail.com> | 2009-10-28 16:55:43 +0100 |
---|---|---|
committer | Denis Loh <denis.loh@gmail.com> | 2009-10-28 16:55:43 +0100 |
commit | a0ea012e9f0a6535695ab1c6efb6cb700d4b57ef (patch) | |
tree | 454d89ef6d37e293c03c1ad224faa363b04b872f /database | |
parent | eb0522f864623adc5ade2475961d7f2f429da8d7 (diff) | |
download | vdr-plugin-upnp-a0ea012e9f0a6535695ab1c6efb6cb700d4b57ef.tar.gz vdr-plugin-upnp-a0ea012e9f0a6535695ab1c6efb6cb700d4b57ef.tar.bz2 |
Another bug with database loading and inserting
Diffstat (limited to 'database')
-rw-r--r-- | database/database.h | 10 | ||||
-rw-r--r-- | database/metadata.cpp | 6 | ||||
-rw-r--r-- | database/resources.cpp | 16 |
3 files changed, 18 insertions, 14 deletions
diff --git a/database/database.h b/database/database.h index 49c208d..cc3ad12 100644 --- a/database/database.h +++ b/database/database.h @@ -734,11 +734,11 @@ "violates foreign key constraint \"" SQLITE_COL_OBJECTID "\"') " \ "END; END;" - /**********************************************\ - * * - * Resources * - * * - \**********************************************/ +/**********************************************\ +* * +* Resources * +* * +\**********************************************/ #define SQLITE_CREATE_TABLE_RESOURCES "CREATE TABLE IF NOT EXISTS "\ SQLITE_TABLE_RESOURCES \ diff --git a/database/metadata.cpp b/database/metadata.cpp index 8ea43dc..4f18009 100644 --- a/database/metadata.cpp +++ b/database/metadata.cpp @@ -129,13 +129,17 @@ int cMediaDatabase::addFastFind(cUPnPClassObject* Object, const char* FastFind){ MESSAGE("Invalid fast find parameters"); return -1; } + + char* escapedFastFind; + escapeSQLite(FastFind, &escapedFastFind); cString Statement = cString::sprintf("INSERT OR REPLACE INTO %s (%s, %s) VALUES ('%s', '%s')", SQLITE_TABLE_ITEMFINDER, SQLITE_COL_OBJECTID, SQLITE_COL_ITEMFINDER, *Object->getID(), - FastFind + escapedFastFind ); + free(escapedFastFind); if(this->mDatabase->execStatement(Statement)){ ERROR("Error while executing statement"); return -1; diff --git a/database/resources.cpp b/database/resources.cpp index bfd9955..e1bfca2 100644 --- a/database/resources.cpp +++ b/database/resources.cpp @@ -204,7 +204,7 @@ cUPnPResource* cUPnPResourceMediator::getResource(unsigned int ResourceID){ cString Column = NULL, Value = NULL; while(Row->fetchColumn(&Column, &Value)){ if(!strcasecmp(SQLITE_COL_OBJECTID, Column)){ - Resource->mObjectID = atoi(Value); + Resource->mObjectID = *Value?atoi(Value):-1; } else if(!strcasecmp(SQLITE_COL_PROTOCOLINFO, Column)){ Resource->mProtocolInfo = Value; @@ -213,25 +213,25 @@ cUPnPResource* cUPnPResourceMediator::getResource(unsigned int ResourceID){ Resource->mResource = Value; } else if(!strcasecmp(SQLITE_COL_SIZE, Column)){ - Resource->mSize = atol(Value); + Resource->mSize = *Value?atol(Value):0; } else if(!strcasecmp(SQLITE_COL_DURATION, Column)){ Resource->mDuration = Value; } else if(!strcasecmp(SQLITE_COL_BITRATE, Column)){ - Resource->mBitrate = atoi(Value); + Resource->mBitrate = *Value?atoi(Value):0; } else if(!strcasecmp(SQLITE_COL_SAMPLEFREQUENCE, Column)){ - Resource->mSampleFrequency = atoi(Value); + Resource->mSampleFrequency = *Value?atoi(Value):0; } else if(!strcasecmp(SQLITE_COL_BITSPERSAMPLE, Column)){ - Resource->mBitsPerSample = atoi(Value); + Resource->mBitsPerSample = *Value?atoi(Value):0; } else if(!strcasecmp(SQLITE_COL_NOAUDIOCHANNELS, Column)){ - Resource->mNrAudioChannels = atoi(Value); + Resource->mNrAudioChannels = *Value?atoi(Value):0; } else if(!strcasecmp(SQLITE_COL_COLORDEPTH, Column)){ - Resource->mColorDepth = atoi(Value); + Resource->mColorDepth = *Value?atoi(Value):0; } else if(!strcasecmp(SQLITE_COL_RESOLUTION, Column)){ Resource->mResolution = Value; @@ -240,7 +240,7 @@ cUPnPResource* cUPnPResourceMediator::getResource(unsigned int ResourceID){ Resource->mContentType = Value; } else if(!strcasecmp(SQLITE_COL_RESOURCETYPE, Column)){ - Resource->mResourceType = atoi(Value); + Resource->mResourceType = *Value?atoi(Value):0; } } return Resource; |