contentstorage/caclient/src/caservice.cpp
changeset 116 305818acdca4
parent 112 dbfb5e38438b
child 125 26079c1bb561
equal deleted inserted replaced
112:dbfb5e38438b 116:305818acdca4
    81 /*!
    81 /*!
    82  \var CaServicePrivate::mNotifierProxy
    82  \var CaServicePrivate::mNotifierProxy
    83  Proxy to client notifier.
    83  Proxy to client notifier.
    84  */
    84  */
    85 
    85 
       
    86 namespace Hs {
       
    87     const char packageTypeName[] = "package";
       
    88 }
       
    89 
    86 // Initialization of a static member variable.
    90 // Initialization of a static member variable.
    87 QWeakPointer<CaService> CaService::m_instance = QWeakPointer<CaService>();
    91 QWeakPointer<CaService> CaService::m_instance = QWeakPointer<CaService>();
    88 /*!
    92 /*!
    89  Constructor.
    93  Constructor.
    90  \param parent pointer to a parent. It defaults to NULL.
    94  \param parent pointer to a parent. It defaults to NULL.
   363  result == true
   367  result == true
   364  \endcode
   368  \endcode
   365  */
   369  */
   366 bool CaService::touch(const CaEntry &entry) const
   370 bool CaService::touch(const CaEntry &entry) const
   367 {
   371 {
   368     return m_d->touch(entry);
   372     if (entry.flags() & RemovableEntryFlag &&
       
   373         (entry.flags() & UsedEntryFlag) == 0 &&
       
   374         entry.role() == ItemEntryRole &&
       
   375         entry.entryTypeName() != QString(Hs::packageTypeName)) {
       
   376         return m_d->touch(entry);
       
   377     } else {
       
   378     	return true;
       
   379     }
   369 }
   380 }
   370 
   381 
   371 /*!
   382 /*!
   372  Insert entry into a given group.
   383  Insert entry into a given group.
   373  \param groupId id of a group.
   384  \param groupId id of a group.
   825 
   836 
   826 /*!
   837 /*!
   827  Execute command.
   838  Execute command.
   828  \param entryId id of an entry.
   839  \param entryId id of an entry.
   829  \param command command.
   840  \param command command.
       
   841  \param receiver QObject class with slot.
       
   842  \param member Slot from QObject class.
   830  \retval 0 if operation was successful.
   843  \retval 0 if operation was successful.
   831 
   844 
   832  \example
   845  \example
   833  \code
   846  \code
   834  ...
   847  ...
   841  ...
   854  ...
   842  \b Output:
   855  \b Output:
   843  result == 0
   856  result == 0
   844  \endcode
   857  \endcode
   845  */
   858  */
   846 int CaService::executeCommand(int entryId, const QString &command) const
   859 int CaService::executeCommand(int entryId, const QString &command, 
       
   860         QObject* receiver, const char* member) const
   847 {
   861 {
   848     int result = -19;
   862     int result = -19;
   849     
   863     
   850     const QSharedPointer<CaEntry> temporaryEntry = getEntry(entryId);
   864     const QSharedPointer<CaEntry> temporaryEntry = getEntry(entryId);
   851     
   865     
   852     if (!temporaryEntry.isNull()) {
   866     if (!temporaryEntry.isNull()) {
   853         result = executeCommand(*temporaryEntry, command);
   867         result = executeCommand(*temporaryEntry, command, receiver, member);
   854     }
   868     }
   855     return result;
   869     return result;
   856 }
   870 }
   857 
   871 
   858 /*!
   872 /*!
   859  Execute command.
   873  Execute command.
   860  \param entry entry.
   874  \param entry entry.
   861  \param command command.
   875  \param command command.
       
   876  \param receiver QObject class with slot.
       
   877  \param member Slot from QObject class.
   862  \retval 0 if operation was successful.
   878  \retval 0 if operation was successful.
   863 
   879 
   864  \example
   880  \example
   865  \code
   881  \code
   866  ...
   882  ...
   873  ...
   889  ...
   874  \b Output:
   890  \b Output:
   875  result == 0
   891  result == 0
   876  \endcode
   892  \endcode
   877  */
   893  */
   878 int CaService::executeCommand(const CaEntry &entry, const QString &command) const
   894 int CaService::executeCommand(const CaEntry &entry, const QString &command, 
   879 {
   895         QObject* receiver, const char* member) const
   880     return m_d->executeCommand(entry, command);
   896 {
       
   897     return m_d->executeCommand(entry, command, receiver, member);
   881 }
   898 }
   882 
   899 
   883 /*!
   900 /*!
   884  Creates notifier.
   901  Creates notifier.
   885  \param const reference to CaNotifierFilter.
   902  \param const reference to CaNotifierFilter.
  1331 
  1348 
  1332 /*!
  1349 /*!
  1333  Executes command on entry (fe. "open", "remove")
  1350  Executes command on entry (fe. "open", "remove")
  1334  \param const reference to an entry on which command will be issued
  1351  \param const reference to an entry on which command will be issued
  1335  \param string containing a command
  1352  \param string containing a command
       
  1353  \param receiver QObject with slot
       
  1354  \param member slot from QObject
  1336  \retval int which is used as an error code return value, 0 means no errors
  1355  \retval int which is used as an error code return value, 0 means no errors
  1337  */
  1356  */
  1338 int CaServicePrivate::executeCommand(const CaEntry &entry,
  1357 int CaServicePrivate::executeCommand(const CaEntry &entry,
  1339                                       const QString &command)
  1358                                       const QString &command,
       
  1359                                       QObject* receiver, 
       
  1360                                       const char* member)
  1340 {
  1361 {
  1341     qDebug() << "CaServicePrivate::executeCommand"
  1362     qDebug() << "CaServicePrivate::executeCommand"
  1342              << "entry id:" << entry.id() << "command:" << command;
  1363              << "entry id:" << entry.id() << "command:" << command;
  1343 
  1364 
  1344     CACLIENTTEST_FUNC_ENTRY("CaServicePrivate::executeCommand");
  1365     CACLIENTTEST_FUNC_ENTRY("CaServicePrivate::executeCommand");
  1349     
  1370     
  1350     if (command == caCmdOpen) {
  1371     if (command == caCmdOpen) {
  1351         touch(entry);
  1372         touch(entry);
  1352     }
  1373     }
  1353 
  1374 
  1354     int errorCode = mCommandHandler->execute(entry, command);
  1375     int errorCode = mCommandHandler->execute(entry, 
       
  1376             command, receiver, member);
  1355     mErrorCode = CaObjectAdapter::convertErrorCode(errorCode);
  1377     mErrorCode = CaObjectAdapter::convertErrorCode(errorCode);
  1356     
  1378     
  1357 
  1379 
  1358     qDebug() << "CaServicePrivate::executeCommand mErrorCode on return:"
  1380     qDebug() << "CaServicePrivate::executeCommand mErrorCode on return:"
  1359              << mErrorCode;
  1381              << mErrorCode;