contentstorage/caclient/src/caservice.cpp
changeset 104 9b022b1f357c
parent 103 b99b84bcd2d1
child 115 3ab5c078b490
equal deleted inserted replaced
103:b99b84bcd2d1 104:9b022b1f357c
   821 
   821 
   822 /*!
   822 /*!
   823  Execute command.
   823  Execute command.
   824  \param entryId id of an entry.
   824  \param entryId id of an entry.
   825  \param command command.
   825  \param command command.
   826  \retval true if operation was successful.
   826  \retval 0 if operation was successful.
   827 
   827 
   828  \example
   828  \example
   829  \code
   829  \code
   830  ...
   830  ...
   831  CaEntry itemExecute;
   831  CaEntry itemExecute;
   832  itemExecute.setText("Application");
   832  itemExecute.setText("Application");
   833  itemExecute.setTypeName("application");
   833  itemExecute.setTypeName("application");
   834  itemExecute.setAttribute("application:uid", "0x12345678");
   834  itemExecute.setAttribute("application:uid", "0x12345678");
   835  CaEntry * entryExecute = service->createEntry(itemExecute->id());
   835  CaEntry * entryExecute = service->createEntry(itemExecute->id());
   836  bool result = service->executeCommand(entryExecute->id(), "remove");
   836  int result = service->executeCommand(entryExecute->id(), "remove");
   837  ...
   837  ...
   838  \b Output:
   838  \b Output:
   839  result == true
   839  result == 0
   840  \endcode
   840  \endcode
   841  */
   841  */
   842 bool CaService::executeCommand(int entryId, const QString &command) const
   842 int CaService::executeCommand(int entryId, const QString &command) const
   843 {
   843 {
   844     bool result = false;
   844     int result = -19;
   845     
   845     
   846     const QSharedPointer<CaEntry> temporaryEntry = getEntry(entryId);
   846     const QSharedPointer<CaEntry> temporaryEntry = getEntry(entryId);
   847     
   847     
   848     if (!temporaryEntry.isNull()) {
   848     if (!temporaryEntry.isNull()) {
   849         result = executeCommand(*temporaryEntry, command);
   849         result = executeCommand(*temporaryEntry, command);
   853 
   853 
   854 /*!
   854 /*!
   855  Execute command.
   855  Execute command.
   856  \param entry entry.
   856  \param entry entry.
   857  \param command command.
   857  \param command command.
   858  \retval true if operation was successful.
   858  \retval 0 if operation was successful.
   859 
   859 
   860  \example
   860  \example
   861  \code
   861  \code
   862  ...
   862  ...
   863  CaEntry itemExecute;
   863  CaEntry itemExecute;
   864  itemExecute.setText("URL");
   864  itemExecute.setText("URL");
   865  itemExecute.setTypeName("url");
   865  itemExecute.setTypeName("url");
   866  itemExecute.setAttribute("url", "http://www.nokia.com");
   866  itemExecute.setAttribute("url", "http://www.nokia.com");
   867  CaEntry * entryExecute = service->createEntry(itemExecute->id());
   867  CaEntry * entryExecute = service->createEntry(itemExecute->id());
   868  bool result = service->executeCommand(*entryExecute, "open");
   868  int result = service->executeCommand(*entryExecute, "open");
   869  ...
   869  ...
   870  \b Output:
   870  \b Output:
   871  result == true
   871  result == 0
   872  \endcode
   872  \endcode
   873  */
   873  */
   874 bool CaService::executeCommand(const CaEntry &entry, const QString &command) const
   874 int CaService::executeCommand(const CaEntry &entry, const QString &command) const
   875 {
   875 {
   876     return m_d->executeCommand(entry, command);
   876     return m_d->executeCommand(entry, command);
   877 }
   877 }
   878 
   878 
   879 /*!
   879 /*!
  1327 
  1327 
  1328 /*!
  1328 /*!
  1329  Executes command on entry (fe. "open", "remove")
  1329  Executes command on entry (fe. "open", "remove")
  1330  \param const reference to an entry on which command will be issued
  1330  \param const reference to an entry on which command will be issued
  1331  \param string containing a command
  1331  \param string containing a command
  1332  \retval boolean which is used as an error code return value, true means positive result
  1332  \retval int which is used as an error code return value, 0 means no errors
  1333  */
  1333  */
  1334 bool CaServicePrivate::executeCommand(const CaEntry &entry,
  1334 int CaServicePrivate::executeCommand(const CaEntry &entry,
  1335                                       const QString &command)
  1335                                       const QString &command)
  1336 {
  1336 {
  1337     qDebug() << "CaServicePrivate::executeCommand"
  1337     qDebug() << "CaServicePrivate::executeCommand"
  1338              << "entry id:" << entry.id() << "command:" << command;
  1338              << "entry id:" << entry.id() << "command:" << command;
  1339 
  1339 
  1340     CACLIENTTEST_FUNC_ENTRY("CaServicePrivate::executeCommand");
  1340     CACLIENTTEST_FUNC_ENTRY("CaServicePrivate::executeCommand");
  1341 
  1341 
  1342     if (entry.flags() & UninstallEntryFlag) {
  1342     if (entry.flags() & UninstallEntryFlag) {
  1343         return false;
  1343         return 0;
  1344     }    
  1344     }    
  1345     
  1345     
  1346     if (command == caCmdOpen) {
  1346     if (command == caCmdOpen) {
  1347         touch(entry);
  1347         touch(entry);
  1348     }
  1348     }
  1349 
  1349 
  1350     mErrorCode = mCommandHandler->execute(entry, command);
  1350     int errorCode = mCommandHandler->execute(entry, command);
       
  1351     mErrorCode = CaObjectAdapter::convertErrorCode(errorCode);
       
  1352     
  1351 
  1353 
  1352     qDebug() << "CaServicePrivate::executeCommand mErrorCode on return:"
  1354     qDebug() << "CaServicePrivate::executeCommand mErrorCode on return:"
  1353              << mErrorCode;
  1355              << mErrorCode;
  1354 
  1356 
  1355     CACLIENTTEST_FUNC_EXIT("CaServicePrivate::executeCommand");
  1357     CACLIENTTEST_FUNC_EXIT("CaServicePrivate::executeCommand");
  1356 
  1358 
  1357     return (mErrorCode == NoErrorCode);
  1359     return errorCode;
  1358 }
  1360 }
  1359 
  1361 
  1360 /*!
  1362 /*!
  1361  Creates new notifier. Factory class
  1363  Creates new notifier. Factory class
  1362  \param CaNotifierFilter which is used be new notifier
  1364  \param CaNotifierFilter which is used be new notifier