Missing files for prevoius commitID; updated header documentation
[profile/ivi/persistence-client-library.git] / src / persistence_client_library_dbus_cmd.c
index a380685..89c019c 100644 (file)
 #include "persistence_client_library_data_organization.h"
 #include "persistence_client_library_db_access.h"
 
+#if USE_FILECACHE
+   #include <persistence_file_cache.h>
+
+
+       /**
+        * write back from cache to non volatile memory device
+        * ATTENTION:
+        * THIS FUNCTION IS NOT INTENDED TO BE USED BY A NORMAL APPLICATION.
+        * ONLY SPECIAL APPLICATION ARE ALLOWED TO USING USE THIS FUNCTION
+        **/
+        extern int pfcWriteBackAndSync(int handle);
+#endif
+
 
 // function prototype
 void msg_pending_func(DBusPendingCall *call, void *data);
@@ -115,10 +128,10 @@ void process_send_notification_signal(DBusConnection* conn, unsigned int notifyL
       snprintf(userArray,  DbusSubMatchSize, "%u", notifyUserNo);
       snprintf(seatArray,  DbusSubMatchSize, "%u", notifySeatNo);
 
-      //printf("process_send_Notification_Signal => key: %s | lbid: %d | gUserNo: %d | gSeatNo: %d | gReason: %d \n", gNotifykey, gLdbid, gUserNo, gSeatNo, gReason);
-      message = dbus_message_new_signal("/org/genivi/persistence/adminconsumer",    // const char *path,
-                                        "org.genivi.persistence.adminconsumer",     // const char *interface,
-                                        notifyReasonString);                                 // const char *name
+      //printf("process_send_Notification_Signal => key: %s | lbid: %d | gUserNo: %d | gSeatNo: %d | gReason: %d \n", notifyKey, notifyLdbid, notifyUserNo, notifySeatNo, notifyReason);
+      message = dbus_message_new_signal(gPersAdminConsumerPath,
+                                           gDbusPersAdminConsInterface,
+                                        notifyReasonString);
 
       ret = dbus_message_append_args(message, DBUS_TYPE_STRING, &pnotifyKey,
                                               DBUS_TYPE_STRING, &pldbidArra,
@@ -137,22 +150,22 @@ void process_send_notification_signal(DBusConnection* conn, unsigned int notifyL
             }
             else
             {
-               DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("process_send_Notification_Signal ==> failed to send dbus message!!"));
+               DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("process_send_Notification_Signal - failed to send dbus message!!"));
             }
          }
          else
          {
-            DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("process_send_Notification_Signal ==> E R R O R  C O N E C T I O N  NULL!!"));
+            DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("process_send_Notification_Signal - C O N E C T I O N  NULL!!"));
          }
       }
       else
       {
-         DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("process_send_Notification_Signal ==> ERROR dbus_message_append_args"));
+         DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("process_send_Notification_Signal - dbus_message_append_args"));
       }
    }
    else
    {
-      DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("process_send_Notification_Signal ==> ERROR invalid notification reason"));
+      DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("process_send_Notification_Signal - invalid notification reason"));
    }
 }
 
@@ -173,6 +186,8 @@ void process_prepare_shutdown(int complete)
 {
    int i = 0, rval = 0;
 
+   DLT_LOG(gPclDLTContext, DLT_LOG_INFO, DLT_STRING("process_prepare_shutdown - writing down all changed data and closing all handles"));
+
    // block write
    pers_lock_access();
 
@@ -203,7 +218,7 @@ void process_prepare_shutdown(int complete)
 #endif
          if(rval == -1)
          {
-               DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("process_prepare_shutdown => failed to close file: "), DLT_STRING(strerror(errno)) );
+               DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("process_prepare_shutdown - failed to close file: "), DLT_STRING(strerror(errno)) );
          }
 
       }
@@ -246,9 +261,9 @@ void process_send_pas_request(DBusConnection* conn, unsigned int requestID, int
    DBusError error;
    dbus_error_init (&error);
 
-   DBusMessage* message = dbus_message_new_method_call("org.genivi.persistence.admin",       // destination
-                                                      "/org/genivi/persistence/admin",       // path
-                                                       "org.genivi.persistence.admin",       // interface
+   DBusMessage* message = dbus_message_new_method_call(gDbusPersAdminInterface,                        // destination
+                                                             gDbusPersAdminPath,               // path
+                                                             gDbusPersAdminInterface,          // interface
                                                        "PersistenceAdminRequestCompleted");  // method
    if(conn != NULL)
    {
@@ -260,7 +275,7 @@ void process_send_pas_request(DBusConnection* conn, unsigned int requestID, int
 
          if(!dbus_connection_send(conn, message, 0))
          {
-            DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("send_lifecycle_register => Access denied"), DLT_STRING(error.message) );
+            DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("send_lifecycle_register - Access denied"), DLT_STRING(error.message) );
          }
 
          dbus_connection_flush(conn);
@@ -268,12 +283,12 @@ void process_send_pas_request(DBusConnection* conn, unsigned int requestID, int
       }
       else
       {
-         DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("send_pas_request => ERROR: Invalid message") );
+         DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("send_pas_request - Invalid message") );
       }
    }
    else
    {
-      DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("send_pas_request => ERROR: Invalid connection") );
+      DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("send_pas_request - Invalid connection") );
    }
 }
 
@@ -293,20 +308,19 @@ void process_send_pas_register(DBusConnection* conn, int regType, int notificati
 
    if(conn != NULL)
    {
-      const char* objName = "/org/genivi/persistence/adminconsumer";
       const char* busName = dbus_bus_get_unique_name(conn);
 
       if(busName != NULL)
       {
-         DBusMessage* message = dbus_message_new_method_call("org.genivi.persistence.admin",    // destination
-                                                            "/org/genivi/persistence/admin",    // path
-                                                             "org.genivi.persistence.admin",    // interface
-                                                             method);                           // method
+         DBusMessage* message = dbus_message_new_method_call(gDbusPersAdminInterface,   // destination
+                                                                     gDbusPersAdminPath,               // path
+                                                                     gDbusPersAdminInterface,   // interface
+                                                             method);               // method
 
          if(message != NULL)
          {
             dbus_message_append_args(message, DBUS_TYPE_STRING, &busName,  // bus name
-                                              DBUS_TYPE_STRING, &objName,
+                                              DBUS_TYPE_STRING, &gPersAdminConsumerPath,
                                               DBUS_TYPE_INT32,  &notificationFlag,
                                               DBUS_TYPE_UINT32, &gTimeoutMs,
                                               DBUS_TYPE_INVALID);
@@ -320,24 +334,24 @@ void process_send_pas_register(DBusConnection* conn, int regType, int notificati
 
             if(!dbus_pending_call_set_notify(pending, msg_pending_func, method, NULL))
             {
-               DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("process_send_pas_register => dbus_pending_call_set_notify: FAILED\n") );
+               DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("process_send_pas_register - dbus_pending_call_set_notify: FAILED\n") );
             }
             dbus_pending_call_unref(pending);
          }
          else
          {
-            DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("send_pas_register =>  ERROR: Invalid message") );
+            DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("send_pas_register - Invalid message") );
          }
          dbus_message_unref(message);
       }
       else
       {
-         DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("send_pas_register =>  ERROR: Invalid busname") );
+         DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("send_pas_register - Invalid busname") );
       }
    }
    else
    {
-      DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("send_pas_register =>  ERROR: Invalid connection") );
+      DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("send_pas_register - Invalid connection") );
    }
 }
 
@@ -356,44 +370,43 @@ void process_send_lifecycle_register(DBusConnection* conn, int regType, int shut
 
    if(conn != NULL)
    {
-      const char* objName = "/org/genivi/NodeStateManager/LifeCycleConsumer";
       const char* busName = dbus_bus_get_unique_name(conn);
 
-      DBusMessage* message = dbus_message_new_method_call("org.genivi.NodeStateManager",           // destination
-                                                          "/org/genivi/NodeStateManager/Consumer", // path
-                                                          "org.genivi.NodeStateManager.Consumer",  // interface
+      DBusMessage* message = dbus_message_new_method_call(gDbusLcConsDest,           // destination
+                                                             gDbusLcCons, // path
+                                                             gDbusLcInterface,  // interface
                                                           method);                                 // method
       if(message != NULL)
       {
          if(regType == 1)   // register
          {
             dbus_message_append_args(message, DBUS_TYPE_STRING, &busName,
-                                              DBUS_TYPE_STRING, &objName,
+                                              DBUS_TYPE_STRING, &gDbusLcConsPath,
                                               DBUS_TYPE_UINT32, &shutdownMode,
                                               DBUS_TYPE_UINT32, &gTimeoutMs, DBUS_TYPE_INVALID);
          }
          else           // unregister
          {
             dbus_message_append_args(message, DBUS_TYPE_STRING, &busName,
-                                              DBUS_TYPE_STRING, &objName,
+                                              DBUS_TYPE_STRING, &gDbusLcConsPath,
                                               DBUS_TYPE_UINT32, &shutdownMode, DBUS_TYPE_INVALID);
          }
 
                   if(!dbus_connection_send(conn, message, 0))
                   {
-                     DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("send_lifecycle_register => Access denied"), DLT_STRING(error.message) );
+                     DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("send_lifecycle_register - Access denied"), DLT_STRING(error.message) );
                   }
                   dbus_connection_flush(conn);
          dbus_message_unref(message);
       }
       else
       {
-         DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("send_lifecycle_register => ERROR: Invalid message"));
+         DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("send_lifecycle_register - Invalid message"));
       }
    }
    else
    {
-      DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("send_lifecycle_register => ERROR: connection isn NULL"));
+      DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("send_lifecycle_register - connection isn NULL"));
    }
 }
 
@@ -406,9 +419,9 @@ void process_send_lifecycle_request(DBusConnection* conn, unsigned int requestId
 
    if(conn != NULL)
    {
-      DBusMessage* message = dbus_message_new_method_call("org.genivi.NodeStateManager",           // destination
-                                                         "/org/genivi/NodeStateManager/Consumer",  // path
-                                                          "org.genivi.NodeStateManager.Consumer",  // interface
+      DBusMessage* message = dbus_message_new_method_call(gDbusLcConsDest,           // destination
+                                                             gDbusLcCons,  // path
+                                                             gDbusLcInterface,  // interface
                                                           "LifecycleRequestComplete");             // method
       if(message != NULL)
       {
@@ -419,7 +432,7 @@ void process_send_lifecycle_request(DBusConnection* conn, unsigned int requestId
 
          if(!dbus_connection_send(conn, message, 0))
          {
-            DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("send_lifecycle_request => Access denied"), DLT_STRING(error.message) );
+            DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("send_lifecycle_request - Access denied"), DLT_STRING(error.message) );
           }
 
           dbus_connection_flush(conn);
@@ -427,12 +440,12 @@ void process_send_lifecycle_request(DBusConnection* conn, unsigned int requestId
       }
       else
       {
-         DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("send_lifecycle_request => ERROR: Invalid message"));
+         DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("send_lifecycle_request - Invalid message"));
       }
    }
    else
    {
-      DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("send_lifecycle_request => ERROR: connection isn NULL"));
+      DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("send_lifecycle_request - connection isn NULL"));
    }
 }
 
@@ -450,7 +463,7 @@ void msg_pending_func(DBusPendingCall *call, void *data)
 
    if (dbus_set_error_from_message(&err, message))
    {
-      DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("msg_pending_func ==> Access denied") );
+      DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("msg_pending_func - Access denied") );
    }
    else
    {