diff -r a6d55a2e75be -r 782e3408c2ab contentstorage/caclient/stub/src/caclientproxy.cpp --- a/contentstorage/caclient/stub/src/caclientproxy.cpp Fri Mar 26 13:00:55 2010 +0200 +++ b/contentstorage/caclient/stub/src/caclientproxy.cpp Fri Apr 16 14:45:49 2010 +0300 @@ -32,6 +32,7 @@ #include "canotifier_p.h" #include "canotifiers.h" +#include "caclient_defines.h" #include "hswidgetregistryservice.h" const char *DATABASE_CONNECTION_NAME = "CaService"; @@ -47,7 +48,7 @@ // //---------------------------------------------------------------------------- CaClientProxy::CaClientProxy() : - mWidgetRegistryPath("hsresources/import/widgetregistry") + mWidgetRegistryPath("private/20022F35/import/widgetregistry") { } @@ -278,10 +279,10 @@ qDebug() << "CaClientProxy::removeData" << "entryIdList: " << entryIdList; - QList entryList; + QList< QSharedPointer > entryList; getData(entryIdList, entryList); QList > parentsIds; - foreach(CaEntry *entry, entryList) { + foreach(QSharedPointer entry, entryList) { QList parentIds; GetParentsIds(QList() << entry->id(), parentIds); parentsIds.append(parentIds); @@ -486,7 +487,7 @@ // //---------------------------------------------------------------------------- ErrorCode CaClientProxy::getData(const QList &entryIdList, - QList &sourceList) + QList< QSharedPointer > &sourceList) { qDebug() << "CaClientProxy::getData" << "entryIdList: " << entryIdList; @@ -507,7 +508,7 @@ qDebug() << query.executedQuery(); int role = query.value(query.record().indexOf("EN_ROLE")).toInt(); - CaEntry *entry = new CaEntry((EntryRole) role); + QSharedPointer entry (new CaEntry((EntryRole) role)); CaObjectAdapter::setId(*entry, query.value(query.record().indexOf("ENTRY_ID")).toInt()); entry->setText(query.value( @@ -571,7 +572,7 @@ // //---------------------------------------------------------------------------- ErrorCode CaClientProxy::getData(const CaQuery &query, - QList &sourceList) + QList< QSharedPointer > &sourceList) { QList entryIdList; ErrorCode errorCode = getEntryIds(query, entryIdList); @@ -709,7 +710,12 @@ { qDebug() << "CaClientProxy::executeCommand" << "entry id: " << entry.id() << "command: " << command; - return NoErrorCode; + + ErrorCode result = NoErrorCode; + if (command != caCmdOpen && command != QString("remove")) { + result = UnknownErrorCode; + } + return result; } //---------------------------------------------------------------------------- @@ -717,7 +723,12 @@ //---------------------------------------------------------------------------- ErrorCode CaClientProxy::touch(const CaEntry &entry) { - const int id = entry.id(); + int id = entry.id(); + if (id <= 0) { + const int uid = entry.attribute( + QString(APPLICATION_UID_ATTRIBUTE_NAME)).toInt(); + id = getEntryIdByUid(entry, uid); + } qDebug() << "CaClientProxy::touch" << "id: " << id; @@ -742,11 +753,11 @@ ErrorCode error = NoErrorCode; if (success) { query.exec("commit"); - QList entryList; + QList< QSharedPointer > entryList; if (getData(QList() << id, entryList) == NoErrorCode) { QList parentIds; GetParentsIds(QList() << id, parentIds); - CaNotifiers::Notify(*entryList[0], UpdateChangeType, parentIds); + CaNotifiers::NotifyTouched(id); } } else { query.exec("rollback"); @@ -1018,3 +1029,19 @@ } return success; } + +int CaClientProxy::getEntryIdByUid(const CaEntry &entry, const int uid) +{ + int result = -1; + + QSqlQuery query(dbConnection()); + query.prepare("SELECT ENTRY_ID from CA_ENTRY where EN_UID=?"); + query.addBindValue(uid); + bool success = query.exec(); + + if (success && (query.first())) { + result = query.value(query.record().indexOf("ENTRY_ID")).toInt(); + } + + return result; +}