Corrected handle when using plugins; corrected array size for getpath function; corre...
[profile/ivi/persistence-client-library.git] / src / persistence_client_library_key.c
1 /******************************************************************************
2  * Project         Persistency
3  * (c) copyright   2012
4  * Company         XS Embedded GmbH
5  *****************************************************************************/
6 /******************************************************************************
7  * This Source Code Form is subject to the terms of the
8  * Mozilla Public License, v. 2.0. If a  copy of the MPL was not distributed
9  * with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 ******************************************************************************/
11  /**
12  * @file           persistence_client_library_key.c
13  * @ingroup        Persistence client library
14  * @author         Ingo Huerner
15  * @brief          Implementation of the persistence client library.
16  *                 Library provides an API to access persistent data
17  * @see            
18  */
19
20 #include "persistence_client_library_key.h"
21
22 #include "../include_protected/persistence_client_library_db_access.h"
23 #include "../include_protected/persistence_client_library_rc_table.h"
24 #include "../include_protected/crc32.h"
25
26 #include "persistence_client_library_handle.h"
27 #include "persistence_client_library_pas_interface.h"
28 #include "persistence_client_library_prct_access.h"
29 #include "persistence_client_library_custom_loader.h"
30
31
32 // function declaration
33 int handleRegNotifyOnChange(int key_handle, pclChangeNotifyCallback_t callback, PersNotifyRegPolicy_e regPolicy);
34 int regNotifyOnChange(unsigned int ldbid, const char* resource_id, unsigned int user_no, unsigned int seat_no,
35                       pclChangeNotifyCallback_t callback, PersNotifyRegPolicy_e regPolicy);
36
37 // ----------------------------------------------------------------------------
38 // ----------------------------------------------------------------------------
39 // function with handle
40 // ----------------------------------------------------------------------------
41 // ----------------------------------------------------------------------------
42
43 int pclKeyHandleOpen(unsigned int ldbid, const char* resource_id, unsigned int user_no, unsigned int seat_no)
44 {
45    int handle = EPERS_NOT_INITIALIZED;
46
47    if(gPclInitialized >= PCLinitialized)
48    {
49       PersistenceInfo_s dbContext;
50
51       char dbKey[DbKeyMaxLen]   = {0};      // database key
52       char dbPath[DbPathMaxLen] = {0};    // database location
53
54       //DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclKeyHandleOpen: "), DLT_INT(ldbid), DLT_STRING(resource_id) );
55       dbContext.context.ldbid   = ldbid;
56       dbContext.context.seat_no = seat_no;
57       dbContext.context.user_no = user_no;
58
59       // get database context: database path and database key
60       handle = get_db_context(&dbContext, resource_id, ResIsNoFile, dbKey, dbPath);
61       if(   (handle >= 0)
62          && (dbContext.configKey.type == PersistenceResourceType_key) )          // check if type matches
63       {
64          if(dbContext.configKey.storage < PersistenceStorage_LastEntry)    // check if store policy is valid
65          {
66             if(PersistenceStorage_custom ==  dbContext.configKey.storage)
67             {
68                int idx =  custom_client_name_to_id(dbPath, 1);
69                char workaroundPath[128];  // workaround, because /sys/ can not be accessed on host!!!!
70                snprintf(workaroundPath, 128, "%s%s", "/Data", dbPath  );
71
72                if( (idx < PersCustomLib_LastEntry) && (gPersCustomFuncs[idx].custom_plugin_handle_open != NULL) )
73                {
74                   int flag = 0, mode = 0;
75                   gPersCustomFuncs[idx].custom_plugin_handle_open(workaroundPath, flag, mode);
76                }
77                else
78                {
79                   handle = EPERS_NOPLUGINFUNCT;
80                }
81             }
82
83             // generate handle for custom and for normal key
84             handle = get_persistence_handle_idx();
85
86             if((handle < MaxPersHandle) && (0 <= handle))
87             {
88                // remember data in handle array
89                strncpy(gKeyHandleArray[handle].dbPath, dbPath, DbPathMaxLen);
90                strncpy(gKeyHandleArray[handle].dbKey,  dbKey,  DbKeyMaxLen);
91                strncpy(gKeyHandleArray[handle].resourceID,  resource_id,  DbResIDMaxLen);
92                gKeyHandleArray[handle].dbPath[DbPathMaxLen-1] = '\0'; // Ensures 0-Termination
93                gKeyHandleArray[handle].dbKey[ DbPathMaxLen-1] = '\0'; // Ensures 0-Termination
94                gKeyHandleArray[handle].info = dbContext;
95             }
96             else
97             {
98                DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclKeyHandleOpen: error - handleId out of bounds:"), DLT_INT(handle));
99             }
100          }
101       }
102       else
103       {
104          DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclKeyHandleOpen: error - no database context or resource is not a key "));
105       }
106    }
107
108
109    return handle;
110 }
111
112
113
114 int pclKeyHandleClose(int key_handle)
115 {
116    int rval = EPERS_NOT_INITIALIZED;
117
118    //DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclKeyHandleClose: "),
119    //                DLT_INT(gKeyHandleArray[key_handle].info.context.ldbid), DLT_STRING(gKeyHandleArray[key_handle].resourceID) );
120
121    if(gPclInitialized >= PCLinitialized)
122    {
123       if(key_handle < MaxPersHandle && key_handle > 0)
124       {
125          if(PersistenceStorage_custom == gKeyHandleArray[key_handle].info.configKey.storage )
126          {
127             int idx =  custom_client_name_to_id(gKeyHandleArray[key_handle].dbPath, 1);
128
129             if( (idx < PersCustomLib_LastEntry) && (gPersCustomFuncs[idx].custom_plugin_handle_close != NULL) )
130             {
131                rval = gPersCustomFuncs[idx].custom_plugin_handle_close(key_handle);
132             }
133             else
134             {
135                rval = EPERS_NOPLUGINFUNCT;
136             }
137          }
138
139          if(rval != EPERS_NOPLUGINFUNCT)
140          {
141             set_persistence_handle_close_idx(key_handle);
142             rval = 1;
143
144             // invalidate entries
145             memset(gKeyHandleArray[key_handle].dbPath, 0, DbPathMaxLen);
146             memset(gKeyHandleArray[key_handle].dbKey  ,0, DbKeyMaxLen);
147             gKeyHandleArray[key_handle].info.configKey.storage = -1;
148          }
149       }
150       else
151       {
152          rval = EPERS_MAXHANDLE;
153       }
154    }
155
156    return rval;
157 }
158
159
160
161 int pclKeyHandleGetSize(int key_handle)
162 {
163    int size = EPERS_NOT_INITIALIZED;
164
165    //DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclKeyHandleGetSize: "),
166    //                DLT_INT(gKeyHandleArray[key_handle].info.context.ldbid), DLT_STRING(gKeyHandleArray[key_handle].resourceID) );
167
168    if(gPclInitialized >= PCLinitialized)
169    {
170       if(key_handle < MaxPersHandle && key_handle > 0)
171       {
172          if(PersistenceStorage_custom ==  gKeyHandleArray[key_handle].info.configKey.storage)
173          {
174             int idx =  custom_client_name_to_id(gKeyHandleArray[key_handle].dbPath, 1);
175
176             if( (idx < PersCustomLib_LastEntry) && (gPersCustomFuncs[idx].custom_plugin_get_size != NULL) )
177             {
178                size = gPersCustomFuncs[idx].custom_plugin_get_size(gKeyHandleArray[key_handle].dbPath);
179             }
180             else
181             {
182                size = EPERS_NOPLUGINFUNCT;
183             }
184          }
185          else
186          {
187             size = pers_db_get_key_size(gKeyHandleArray[key_handle].dbPath, gKeyHandleArray[key_handle].dbKey,
188                                              &gKeyHandleArray[key_handle].info);
189          }
190       }
191       else
192       {
193          size = EPERS_MAXHANDLE;
194       }
195    }
196
197    return size;
198 }
199
200
201
202 int pclKeyHandleReadData(int key_handle, unsigned char* buffer, int buffer_size)
203 {
204    int size = EPERS_NOT_INITIALIZED;
205
206    //DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclKeyHandleReadData: "),
207    //             DLT_INT(gKeyHandleArray[key_handle].info.context.ldbid), DLT_STRING(gKeyHandleArray[key_handle].resourceID) );
208
209    if(gPclInitialized >= PCLinitialized)
210    {
211       if(key_handle < MaxPersHandle && key_handle > 0)
212       {
213          if(PersistenceStorage_custom ==  gKeyHandleArray[key_handle].info.configKey.storage)
214          {
215             int idx =  custom_client_name_to_id(gKeyHandleArray[key_handle].dbPath, 1);
216
217             if( (idx < PersCustomLib_LastEntry) && (gPersCustomFuncs[idx].custom_plugin_handle_get_data != NULL) )
218             {
219                size = gPersCustomFuncs[idx].custom_plugin_handle_get_data(key_handle, (char*)buffer, buffer_size-1);
220             }
221             else
222             {
223                size = EPERS_NOPLUGINFUNCT;
224             }
225          }
226          else
227          {
228             size = pers_db_read_key(gKeyHandleArray[key_handle].dbPath, gKeyHandleArray[key_handle].dbKey,
229                                         &gKeyHandleArray[key_handle].info, buffer, buffer_size);
230          }
231       }
232       else
233       {
234          size = EPERS_MAXHANDLE;
235       }
236    }
237
238    return size;
239 }
240
241
242
243 int pclKeyHandleRegisterNotifyOnChange(int key_handle, pclChangeNotifyCallback_t callback)
244 {
245    //DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclKeyHandleRegisterNotifyOnChange: "),
246    //            DLT_INT(gKeyHandleArray[key_handle].info.context.ldbid), DLT_STRING(gKeyHandleArray[key_handle].resourceID) );
247
248    return handleRegNotifyOnChange(key_handle, callback, Notify_register);
249 }
250
251 int pclKeyHandleUnRegisterNotifyOnChange(int key_handle, pclChangeNotifyCallback_t callback)
252 {
253    //DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclKeyHandleUnRegisterNotifyOnChange: "),
254    //         DLT_INT(gKeyHandleArray[key_handle].info.context.ldbid), DLT_STRING(gKeyHandleArray[key_handle].resourceID) );
255
256    return handleRegNotifyOnChange(key_handle, callback, Notify_unregister);
257 }
258
259
260
261 int handleRegNotifyOnChange(int key_handle, pclChangeNotifyCallback_t callback, PersNotifyRegPolicy_e regPolicy)
262 {
263    int rval = EPERS_NOT_INITIALIZED;
264
265    if(gPclInitialized >= PCLinitialized)
266    {
267       if(key_handle < MaxPersHandle && key_handle > 0)
268       {
269          rval = regNotifyOnChange(gKeyHandleArray[key_handle].info.context.ldbid,
270                                   gKeyHandleArray[key_handle].resourceID,
271                                   gKeyHandleArray[key_handle].info.context.user_no,
272                                   gKeyHandleArray[key_handle].info.context.seat_no,
273                                   callback,
274                                   regPolicy);
275       }
276       else
277       {
278          rval = EPERS_MAXHANDLE;
279       }
280    }
281    return rval;
282 }
283
284
285
286 int pclKeyHandleWriteData(int key_handle, unsigned char* buffer, int buffer_size)
287 {
288    int size = EPERS_NOT_INITIALIZED;
289
290    //DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclKeyHandleWriteData: "),
291    //                DLT_INT(gKeyHandleArray[key_handle].info.context.ldbid), DLT_STRING(gKeyHandleArray[key_handle].resourceID) );
292
293    if(gPclInitialized >= PCLinitialized)
294    {
295       if(AccessNoLock != isAccessLocked() )     // check if access to persistent data is locked
296       {
297          if(buffer_size <= gMaxKeyValDataSize)  // check data size
298          {
299             if(key_handle < MaxPersHandle && key_handle > 0)
300             {
301                if(gKeyHandleArray[key_handle].info.configKey.permission != PersistencePermission_ReadOnly)  // don't write to a read only resource
302                {
303                   if(PersistenceStorage_custom ==  gKeyHandleArray[key_handle].info.configKey.storage)
304                   {
305                      int idx =  custom_client_name_to_id(gKeyHandleArray[key_handle].dbPath, 1);
306
307                      if( (idx < PersCustomLib_LastEntry) && (gPersCustomFuncs[idx].custom_plugin_handle_set_data != NULL) )
308                      {
309                         size = gPersCustomFuncs[idx].custom_plugin_handle_set_data(key_handle, (char*)buffer, buffer_size-1);
310
311                         if(size >= 0) // success ==> send change notification
312                         {
313                            int rval = pers_send_Notification_Signal(gKeyHandleArray[key_handle].dbKey,
314                                                                   &(gKeyHandleArray[key_handle].info.context), pclNotifyStatus_changed);
315
316                            if(rval <= 0)
317                            {
318                               DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclKeyHandleWriteData: error - failed to send notification"));
319                               size = rval;
320                            }
321                         }
322                      }
323                      else
324                      {
325                         size = EPERS_NOPLUGINFUNCT;
326                      }
327                   }
328                   else
329                   {
330                      size = pers_db_write_key(gKeyHandleArray[key_handle].dbPath, gKeyHandleArray[key_handle].dbKey,
331                                               &gKeyHandleArray[key_handle].info, buffer, buffer_size);
332                   }
333                }
334                else
335                {
336                   size = EPERS_RESOURCE_READ_ONLY;
337                }
338
339             }
340             else
341             {
342                size = EPERS_MAXHANDLE;
343             }
344          }
345          else
346          {
347             DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclKeyHandleWriteData: error - buffer_size to big, limit is [bytes]:"), DLT_INT(gMaxKeyValDataSize));
348             size = EPERS_MAX_BUFF_SIZE;
349          }
350       }
351       else
352       {
353          size = EPERS_LOCKFS;
354       }
355    }
356
357    return size;
358 }
359
360
361
362
363
364 // ----------------------------------------------------------------------------
365 // ----------------------------------------------------------------------------
366 // functions to be used directly without a handle
367 // ----------------------------------------------------------------------------
368 // ----------------------------------------------------------------------------
369
370 int pclKeyDelete(unsigned int ldbid, const char* resource_id, unsigned int user_no, unsigned int seat_no)
371 {
372    int rval = EPERS_NOT_INITIALIZED;
373
374    //DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclKeyDelete: "), DLT_INT(ldbid), DLT_STRING(resource_id) );
375
376    if(gPclInitialized >= PCLinitialized)
377    {
378       if(AccessNoLock != isAccessLocked() ) // check if access to persistent data is locked
379       {
380          PersistenceInfo_s dbContext;
381
382         char dbKey[DbKeyMaxLen]   = {0};      // database key
383         char dbPath[DbPathMaxLen] = {0};    // database location
384
385         dbContext.context.ldbid   = ldbid;
386         dbContext.context.seat_no = seat_no;
387         dbContext.context.user_no = user_no;
388
389         // get database context: database path and database key
390         rval = get_db_context(&dbContext, resource_id, ResIsNoFile, dbKey, dbPath);
391         if(   (rval >= 0)
392            && (dbContext.configKey.type == PersistenceResourceType_key) )  // check if type is matching
393         {
394            if(   dbContext.configKey.storage < PersistenceStorage_LastEntry
395               && dbContext.configKey.storage >= PersistenceStorage_local)   // check if store policy is valid
396            {
397               rval = pers_db_delete_key(dbPath, dbKey, &dbContext);
398            }
399            else
400            {
401              rval = EPERS_BADPOL;
402            }
403         }
404       }
405       else
406       {
407          rval = EPERS_LOCKFS;
408       }
409    }
410
411    return rval;
412 }
413
414
415
416 // status: OK
417 int pclKeyGetSize(unsigned int ldbid, const char* resource_id, unsigned int user_no, unsigned int seat_no)
418 {
419    int data_size = EPERS_NOT_INITIALIZED;
420
421    if(gPclInitialized >= PCLinitialized)
422    {
423       PersistenceInfo_s dbContext;
424
425       char dbKey[DbKeyMaxLen]   = {0};      // database key
426       char dbPath[DbPathMaxLen] = {0};    // database location
427
428       dbContext.context.ldbid   = ldbid;
429       dbContext.context.seat_no = seat_no;
430       dbContext.context.user_no = user_no;
431
432       //DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclKeyGetSize: "), DLT_INT(ldbid), DLT_STRING(resource_id) );
433
434       // get database context: database path and database key
435       data_size = get_db_context(&dbContext, resource_id, ResIsNoFile, dbKey, dbPath);
436       if(   (data_size >= 0)
437          && (dbContext.configKey.type == PersistenceResourceType_key) )    // check if type matches
438       {
439          if(   dbContext.configKey.storage < PersistenceStorage_LastEntry
440             && dbContext.configKey.storage >= PersistenceStorage_local)   // check if store policy is valid
441          {
442             data_size = pers_db_get_key_size(dbPath, dbKey, &dbContext);
443          }
444          else
445          {
446            data_size = EPERS_BADPOL;
447          }
448       }
449       else
450       {
451         data_size = EPERS_BADPOL;
452       }
453    }
454
455    return data_size;
456 }
457
458
459
460 // status: OK
461 int pclKeyReadData(unsigned int ldbid, const char* resource_id, unsigned int user_no, unsigned int seat_no,
462                   unsigned char* buffer, int buffer_size)
463 {
464    int data_size = EPERS_NOT_INITIALIZED;
465
466    //DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclKeyReadData: "), DLT_INT(ldbid), DLT_STRING(resource_id) );
467
468    if(gPclInitialized >= PCLinitialized)
469    {
470       if(AccessNoLock != isAccessLocked() ) // check if access to persistent data is locked
471       {
472          PersistenceInfo_s dbContext;
473
474          char dbKey[DbKeyMaxLen]   = {0};      // database key
475          char dbPath[DbPathMaxLen] = {0};    // database location
476
477          dbContext.context.ldbid   = ldbid;
478          dbContext.context.seat_no = seat_no;
479          dbContext.context.user_no = user_no;
480
481          // get database context: database path and database key
482          data_size = get_db_context(&dbContext, resource_id, ResIsNoFile, dbKey, dbPath);
483          if(   (data_size >= 0)
484             && (dbContext.configKey.type == PersistenceResourceType_key) )
485          {
486
487             if(   dbContext.configKey.storage <  PersistenceStorage_LastEntry
488                && dbContext.configKey.storage >= PersistenceStorage_local)   // check if store policy is valid
489             {
490                   data_size = pers_db_read_key(dbPath, dbKey, &dbContext, buffer, buffer_size);
491             }
492             else
493             {
494                data_size = EPERS_BADPOL;
495             }
496          }
497          else
498          {
499             DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclKeyReadData - error - no database context or resource is not a key"));
500          }
501       }
502       else
503       {
504          data_size = EPERS_LOCKFS;
505       }
506    }
507
508    return data_size;
509 }
510
511
512
513 int pclKeyWriteData(unsigned int ldbid, const char* resource_id, unsigned int user_no, unsigned int seat_no,
514                    unsigned char* buffer, int buffer_size)
515 {
516    int data_size = EPERS_NOT_INITIALIZED;
517
518    //DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclKeyWriteData: "), DLT_INT(ldbid), DLT_STRING(resource_id) );
519
520    if(gPclInitialized >= PCLinitialized)
521    {
522       if(AccessNoLock != isAccessLocked() )     // check if access to persistent data is locked
523       {
524          if(buffer_size <= gMaxKeyValDataSize)  // check data size
525          {
526             PersistenceInfo_s dbContext;
527
528             unsigned int hash_val_data = 0;
529
530             char dbKey[DbKeyMaxLen]   = {0};      // database key
531             char dbPath[DbPathMaxLen] = {0};    // database location
532
533             dbContext.context.ldbid   = ldbid;
534             dbContext.context.seat_no = seat_no;
535             dbContext.context.user_no = user_no;
536
537             // get database context: database path and database key
538             data_size = get_db_context(&dbContext, resource_id, ResIsNoFile, dbKey, dbPath);
539             if(   (data_size >= 0)
540                && (dbContext.configKey.type == PersistenceResourceType_key))
541             {
542                if(dbContext.configKey.permission != PersistencePermission_ReadOnly)  // don't write to a read only resource
543                {
544                   // get hash value of data to verify storing
545                   hash_val_data = pclCrc32(hash_val_data, buffer, buffer_size);
546
547                   // store data
548                   if(   dbContext.configKey.storage <  PersistenceStorage_LastEntry
549                      && dbContext.configKey.storage >= PersistenceStorage_local)   // check if store policy is valid
550                   {
551                      data_size = pers_db_write_key(dbPath, dbKey, &dbContext, buffer, buffer_size);
552                   }
553                   else
554                   {
555                      data_size = EPERS_BADPOL;
556                   }
557                }
558                else
559                {
560                   data_size = EPERS_RESOURCE_READ_ONLY;
561                }
562             }
563             else
564             {
565                DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclKeyWriteData - error - no database context or resource is not a key"));
566             }
567          }
568          else
569          {
570             data_size = EPERS_BUFLIMIT;
571             DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclKeyWriteData: error - buffer_size to big, limit is [bytes]:"), DLT_INT(gMaxKeyValDataSize));
572          }
573       }
574       else
575       {
576          data_size = EPERS_LOCKFS;
577       }
578    }
579
580    return data_size;
581 }
582
583
584
585 int pclKeyUnRegisterNotifyOnChange( unsigned int  ldbid, const char *  resource_id, unsigned int  user_no, unsigned int  seat_no, pclChangeNotifyCallback_t  callback)
586 {
587    //DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclKeyUnRegisterNotifyOnChange: "),
588    //            DLT_INT(ldbid), DLT_STRING(resource_id) );
589
590    return regNotifyOnChange(ldbid, resource_id, user_no, seat_no, callback, Notify_unregister);
591 }
592
593
594 int pclKeyRegisterNotifyOnChange(unsigned int ldbid, const char* resource_id, unsigned int user_no, unsigned int seat_no, pclChangeNotifyCallback_t callback)
595 {
596    //DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclKeyRegisterNotifyOnChange: "),
597    //            DLT_INT(ldbid), DLT_STRING(resource_id) );
598
599    return regNotifyOnChange(ldbid, resource_id, user_no, seat_no, callback, Notify_register);
600 }
601
602
603
604
605 int regNotifyOnChange(unsigned int ldbid, const char* resource_id, unsigned int user_no, unsigned int seat_no, pclChangeNotifyCallback_t callback, PersNotifyRegPolicy_e regPolicy)
606 {
607    int rval = EPERS_NOT_INITIALIZED;
608
609    if(gPclInitialized >= PCLinitialized)
610    {
611       PersistenceInfo_s dbContext;
612
613       //   unsigned int hash_val_data = 0;
614       char dbKey[DbKeyMaxLen]   = {0};      // database key
615       char dbPath[DbPathMaxLen] = {0};    // database location
616
617       //DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclKeyRegisterNotifyOnChange: "), DLT_INT(ldbid), DLT_STRING(resource_id) );
618
619       dbContext.context.ldbid   = ldbid;
620       dbContext.context.seat_no = seat_no;
621       dbContext.context.user_no = user_no;
622
623       // get database context: database path and database key
624       rval = get_db_context(&dbContext, resource_id, ResIsNoFile, dbKey, dbPath);
625
626       // registration is only on shared and custom keys possible
627       if(   (dbContext.configKey.storage != PersistenceStorage_local)
628         && (dbContext.configKey.type    == PersistenceResourceType_key) )
629       {
630          rval = persistence_notify_on_change(dbKey, ldbid, user_no, seat_no, callback, regPolicy);
631       }
632       else
633       {
634          DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclKeyRegisterNotifyOnChange: error - resource is not a shared resource or resource is not a key"));
635          rval = EPERS_NOTIFY_NOT_ALLOWED;
636       }
637    }
638
639    return rval;
640 }
641
642
643
644
645
646
647