1 #include "dmt.hpp" 2 3 #include <stdlib.h> 4 #include <string> 5 #include <map> 6 #include <stdio.h> 7 8 #include "plugin/dmtCommitPlugin.hpp" 9 #include "plugin/dmtPlugin.hpp" 10 11 12 #define DIM(array) (sizeof(array)/sizeof((array)[0])) 13 14 15 extern "C" 16 void DMT_PluginLib_OnCommit(const DmtEventMap & updatedNodes, 17 DMStringMap & mapParameters, 18 PDmtTree tree ) 19 { 20 21 DMString strParam; 22 int bPrint = (mapParameters.lookup("print", strParam) && strParam == "on" ); 23 24 if ( !bPrint ) 25 return; 26 27 mapParameters.lookup("id", strParam); 28 printf( "Commit plug-in: OnCommit [%s]<START> \n", strParam.c_str() ); 29 30 for (DmtEventMap::POS nPos = 0; nPos < updatedNodes.end(); nPos++ ) 31 { 32 const DMString & eventPath = updatedNodes.get_key(nPos); 33 const DmtEventDataVector & aVector = updatedNodes.get_value(nPos); 34 35 for (INT32 index=0; index<aVector.size(); index++) 36 { 37 38 DMString szActions; 39 if ( (aVector[index]->GetAction() & SYNCML_DM_EVENT_ADD) == SYNCML_DM_EVENT_ADD ) 40 { 41 szActions = "ADD"; 42 printf( "notification for uri [%s/%s], [%s]\n", 43 eventPath.c_str(), (aVector[index]->GetName()).c_str(), szActions.c_str() ); 44 } 45 46 if ( (aVector[index]->GetAction() & SYNCML_DM_EVENT_REPLACE) == SYNCML_DM_EVENT_REPLACE ) 47 { 48 szActions = "REPLACE"; 49 printf( "notification for uri [%s/%s], [%s]\n", 50 eventPath.c_str(), (aVector[index]->GetName()).c_str(), szActions.c_str() ); 51 } 52 53 if ( (aVector[index]->GetAction() & SYNCML_DM_EVENT_DELETE) == SYNCML_DM_EVENT_DELETE ) 54 { 55 szActions = "DELETE"; 56 printf( "notification for uri [%s/%s], [%s]\n", 57 eventPath.c_str(), (aVector[index]->GetName()).c_str(), szActions.c_str() ); 58 } 59 60 if ( (aVector[index]->GetAction() & SYNCML_DM_EVENT_RENAME) == SYNCML_DM_EVENT_RENAME ) 61 { 62 szActions = "RENAME"; 63 printf( "notification for uri [%s/%s], [%s]\n", 64 eventPath.c_str(), (aVector[index]->GetName()).c_str(), szActions.c_str() ); 65 } 66 67 if ( (aVector[index]->GetAction() & SYNCML_DM_EVENT_INDIRECT) == SYNCML_DM_EVENT_INDIRECT ) 68 { 69 szActions = "INDIRECT UPDATE"; 70 printf( "notification for uri [%s/%s], [%s]\n", 71 eventPath.c_str(), (aVector[index]->GetName()).c_str(), szActions.c_str() ); 72 } 73 74 }; 75 76 77 } 78 printf( "Commit plug-in: OnCommit <END> \n"); 79 } 80 81 82 extern "C" 83 int DMT_PluginLib_GetAPIVersion(void) 84 { 85 return DMT_PLUGIN_VERSION_1_1; 86 } 87 88 89