- Manual object creation implemented on server and client library levels
authorVictor Kirhenshtein <victor@netxms.org>
Tue, 27 Jul 2004 15:11:25 +0000 (15:11 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Tue, 27 Jul 2004 15:11:25 +0000 (15:11 +0000)
- Started work on PNG image support for objects

14 files changed:
.gitattributes
images/generic_printer.png [new file with mode: 0644]
images/interface.png [new file with mode: 0644]
images/node_group.png [new file with mode: 0644]
include/nxclapi.h
sql/schema.in
src/console/win32/nxcon.clw
src/console/win32/nxcon.rc
src/console/win32/resource.h
src/libnxcl/main.cpp
src/libnxcl/objects.cpp
src/server/core/nms_core.h
src/server/core/np.cpp
src/server/core/session.cpp

index 53b5e50..a8439a0 100644 (file)
@@ -15,6 +15,9 @@ contrib/dct/generic_object.dct -text
 contrib/logo.jpg -text
 doc/Makefile.am -text
 doc/internals.rtf -text
+images/generic_printer.png -text svneol=unset#application/octet-stream
+images/interface.png -text svneol=unset#application/octet-stream
+images/node_group.png -text svneol=unset#application/octet-stream
 include/Makefile.am -text
 include/getopt.h -text
 include/nms_agent.h -text
diff --git a/images/generic_printer.png b/images/generic_printer.png
new file mode 100644 (file)
index 0000000..f1ad755
--- /dev/null
@@ -0,0 +1 @@
+\89PNG
diff --git a/images/interface.png b/images/interface.png
new file mode 100644 (file)
index 0000000..f1ad755
--- /dev/null
@@ -0,0 +1 @@
+\89PNG
diff --git a/images/node_group.png b/images/node_group.png
new file mode 100644 (file)
index 0000000..f1ad755
--- /dev/null
@@ -0,0 +1 @@
+\89PNG
index 2dbf085..c9df248 100644 (file)
@@ -182,6 +182,8 @@ typedef unsigned long HREQUEST;
 #define RCC_OUT_OF_MEMORY           ((DWORD)15)
 #define RCC_IO_ERROR                ((DWORD)16)
 #define RCC_INCOMPATIBLE_OPERATION  ((DWORD)17)
+#define RCC_OBJECT_CREATION_FAILED  ((DWORD)18)
+#define RCC_OBJECT_LOOP             ((DWORD)19)
 
 
 //
@@ -606,6 +608,31 @@ typedef struct
 } NXC_EPP;
 
 
+//
+// Object creation information structure
+//
+
+typedef struct
+{
+   int iClass;
+   DWORD dwParentId;
+   char *pszName;
+   union
+   {
+      struct
+      {
+         DWORD dwIpAddr;
+         DWORD dwNetMask;
+      } node;
+      struct
+      {
+         DWORD dwCategory;
+         char *pszDescription;
+      } container;
+   } cs;
+} NXC_OBJECT_CREATE_INFO;
+
+
 //
 // Functions
 //
@@ -635,7 +662,7 @@ void LIBNXCL_EXPORTABLE NXCLockObjectIndex(void);
 void LIBNXCL_EXPORTABLE NXCUnlockObjectIndex(void);
 DWORD LIBNXCL_EXPORTABLE NXCModifyObject(NXC_OBJECT_UPDATE *pData);
 DWORD LIBNXCL_EXPORTABLE NXCSetObjectMgmtStatus(DWORD dwObjectId, BOOL bIsManaged);
-DWORD LIBNXCL_EXPORTABLE NXCCreateObject(int iClass, DWORD dwParentObject);
+DWORD LIBNXCL_EXPORTABLE NXCCreateObject(NXC_OBJECT_CREATE_INFO *pCreateInfo, DWORD *pdwObjectId);
 DWORD LIBNXCL_EXPORTABLE NXCBindObject(DWORD dwParentObject, DWORD dwChildObject);
 DWORD LIBNXCL_EXPORTABLE NXCUnbindObject(DWORD dwParentObject, DWORD dwChildObject);
 
index 25912c1..3141da0 100644 (file)
@@ -463,3 +463,17 @@ CREATE TABLE alarm_notes
        note_text DT_TEXT,
        PRIMARY KEY(note_id)
 );
+
+
+/*
+** Image catalog
+*/
+
+CREATE TABLE images
+(
+       image_id integer not null,
+       name varchar(64),
+       file_name varchar(255),
+       file_hash varchar(32),
+       PRIMARY KEY(image_id)
+);
index 92e3dcb..fcd656b 100644 (file)
@@ -16,9 +16,9 @@ Class7=CEventBrowser
 Class9=CMapView
 
 ResourceCount=60
-Resource1=IDD_ABOUTBOX (English (U.S.))
+Resource1=IDA_MDI_DEFAULT (English (U.S.))
 Resource2=IDD_LOGIN
-Resource3=IDD_THRESHOLD (English (U.S.))
+Resource3=IDD_SET_PASSWORD (English (U.S.))
 Resource4=IDM_CONTEXT
 Resource5=IDD_OBJECT_GENERAL
 Class2=CChildView
@@ -30,11 +30,11 @@ Resource6=IDD_MIB_BROWSER
 Class11=CProgressDialog
 Resource7=IDD_EDIT_RULE_COMMENT
 Class12=CObjectBrowser
-Resource8=IDD_EDIT_RULE_COMMENT (English (U.S.))
+Resource8=IDD_THRESHOLD (English (U.S.))
 Class13=CObjectPropDlg
-Resource9=IDD_DCI_COLLECTION (English (U.S.))
-Resource10=IDD_NEW_USER (English (U.S.))
-Resource11=IDA_MDI_DEFAULT (English (U.S.))
+Resource9=IDD_USER_PROPERTIES (English (U.S.))
+Resource10=IDD_OBJECT_GENERAL (English (U.S.))
+Resource11=IDM_VIEW_SPECIFIC (English (U.S.))
 Resource12=IDR_CTRLPANEL (English (U.S.))
 Resource13=IDR_EVENTS (English (U.S.))
 Resource14=IDR_MAPFRAME (English (U.S.))
@@ -42,33 +42,33 @@ Resource15=IDR_OBJECTS (English (U.S.))
 Resource16=IDD_DUMMY (English (U.S.))
 Class14=CEventEditor
 Class15=CEditEventDlg
-Resource17=IDM_CONTEXT (English (U.S.))
+Resource17=IDD_SELECT_OBJECT (English (U.S.))
 Class16=CDebugFrame
-Resource18=IDD_SET_PASSWORD (English (U.S.))
+Resource18=IDD_NEW_USER (English (U.S.))
 Resource19=IDD_OBJECT_PROPERTIES (English (U.S.))
 Resource20=IDD_DCI_COLLECTION
 Class17=CObjectPreview
-Resource21=IDD_EDIT_EVENT (English (U.S.))
+Resource21=IDA_EPP (English (U.S.))
 Class18=CToolBox
 Class19=CObjectInfoBox
 Class20=CObjectSearchBox
-Resource22=IDD_OBJECT_SECURITY (English (U.S.))
+Resource22=IDD_OBJECT_CAPS (English (U.S.))
 Class21=CEditBox
 Class22=COPGeneral
 Class23=CNodePropsGeneral
-Resource23=IDD_SELECT_OBJECT (English (U.S.))
+Resource23=IDD_DCI_THRESHOLDS (English (U.S.))
 Class24=CObjectPropCaps
 Class25=CObjectPropSheet
 Resource24=IDD_ABOUTBOX
 Class26=CRequestProcessingDlg
-Resource25=IDM_VIEW_SPECIFIC (English (U.S.))
+Resource25=IDM_CONTEXT (English (U.S.))
 Resource26=IDD_PROGRESS (English (U.S.))
 Resource27=IDD_DCI_THRESHOLDS
-Resource28=IDA_EPP (English (U.S.))
+Resource28=IDR_MAINFRAME (English (U.S.))
 Class27=CObjectPropsGeneral
-Resource29=IDD_OBJECT_GENERAL (English (U.S.))
+Resource29=IDD_OBJECT_NODE_GENERAL (English (U.S.))
 Class28=CObjectPropsSecurity
-Resource30=IDD_USER_PROPERTIES (English (U.S.))
+Resource30=IDD_OBJECT_SECURITY (English (U.S.))
 Resource31=IDD_OBJECT_NODE_GENERAL
 Resource32=IDD_THRESHOLD
 Class29=CUserSelectDlg
@@ -79,30 +79,30 @@ Class31=CNewUserDlg
 Resource35=IDR_MAINFRAME
 Resource36=IDD_SELECT_OBJECT
 Class32=CUserPropDlg
-Resource37=IDR_MAINFRAME (English (U.S.))
+Resource37=IDD_MIB_BROWSER (English (U.S.))
 Resource38=IDD_NEW_USER
 Class33=CGroupPropDlg
 Resource39=IDA_OBJECT_BROWSER
 Resource40=IDD_EDIT_EVENT
 Resource41=IDA_MDI_DEFAULT
-Resource42=IDD_OBJECT_NODE_GENERAL (English (U.S.))
+Resource42=IDD_ABOUTBOX (English (U.S.))
 Class34=CPasswordChangeDlg
 Class35=CNodeSummary
 Class36=CNetSummaryFrame
 Class37=CDataCollectionEditor
-Resource43=IDD_OBJECT_CAPS (English (U.S.))
+Resource43=IDD_LOGIN (English (U.S.))
 Class38=CDCIPropPage
-Resource44=IDD_LOGIN (English (U.S.))
+Resource44=IDA_OBJECT_BROWSER (English (U.S.))
 Class39=CDCIDataView
-Resource45=IDA_OBJECT_BROWSER (English (U.S.))
+Resource45=IDD_EDIT_RULE_COMMENT (English (U.S.))
 Class40=CGraph
 Class41=CGraphFrame
 Class42=CDCIThresholdsPage
-Resource46=IDD_GROUP_PROPERTIES (English (U.S.))
+Resource46=IDD_SELECT_USER (English (U.S.))
 Resource47=IDD_SET_PASSWORD
 Resource48=IDD_OBJECT_CAPS
 Class43=CThresholdDlg
-Resource49=IDD_MIB_BROWSER (English (U.S.))
+Resource49=IDD_DCI_COLLECTION (English (U.S.))
 Resource50=IDD_GROUP_PROPERTIES
 Class44=CMIBBrowserDlg
 Class45=CEventPolicyEditor
@@ -117,9 +117,9 @@ Class49=CRuleCommentDlg
 Resource55=IDD_SELECT_USER
 Class50=CEventSelDlg
 Resource56=IDD_SELECT_EVENT
-Resource57=IDD_SELECT_USER (English (U.S.))
-Resource58=IDD_DCI_THRESHOLDS (English (U.S.))
-Resource59=IDD_REQUEST_PROCESSING (English (U.S.))
+Resource57=IDD_REQUEST_PROCESSING (English (U.S.))
+Resource58=IDD_GROUP_PROPERTIES (English (U.S.))
+Resource59=IDD_EDIT_EVENT (English (U.S.))
 Resource60=IDD_SELECT_EVENT (English (U.S.))
 
 [CLS:CConsoleApp]
@@ -598,39 +598,40 @@ Command7=ID_OBJECT_VIEW_SELECTION
 Command8=ID_OBJECT_VIEW_VIEWASTREE
 Command9=ID_OBJECT_VIEW_VIEWASLIST
 Command10=ID_OBJECT_FIND
-Command11=ID_OBJECT_CREATE
-Command12=ID_OBJECT_BIND
-Command13=ID_OBJECT_RENAME
-Command14=ID_OBJECT_DELETE
-Command15=ID_OBJECT_MANAGE
-Command16=ID_OBJECT_UNMANAGE
-Command17=ID_OBJECT_DATACOLLECTION
-Command18=ID_OBJECT_PROPERTIES
-Command19=ID_USER_CREATE_USER
-Command20=ID_USER_CREATE_GROUP
-Command21=ID_USER_DELETE
-Command22=ID_USER_SETPASSWORD
-Command23=ID_USER_PROPERTIES
-Command24=ID_ITEM_NEW
-Command25=ID_ITEM_EDIT
-Command26=ID_ITEM_DELETE
-Command27=ID_ITEM_ACTIVATE
-Command28=ID_ITEM_DISABLE
-Command29=ID_ITEM_SHOWDATA
-Command30=ID_ITEM_GRAPH
-Command31=ID_POLICY_ADD
-Command32=ID_POLICY_DELETE
-Command33=ID_POLICY_EDIT
-Command34=ID_POLICY_NEGATECELL
-Command35=ID_POLICY_INSERTRULE_ABOVE
-Command36=ID_POLICY_INSERTRULE_BELOW
-Command37=ID_POLICY_INSERTRULE_TOP
-Command38=ID_POLICY_INSERTRULE_BOTTOM
-Command39=ID_POLICY_DELETERULE
-Command40=ID_POLICY_ENABLERULE
-Command41=ID_POLICY_DISABLERULE
-Command42=ID_UPDATE_EVENT_LIST
-CommandCount=42
+Command11=ID_OBJECT_CREATE_NODE
+Command12=ID_OBJECT_CREATE_CONTAINER
+Command13=ID_OBJECT_BIND
+Command14=ID_OBJECT_RENAME
+Command15=ID_OBJECT_DELETE
+Command16=ID_OBJECT_MANAGE
+Command17=ID_OBJECT_UNMANAGE
+Command18=ID_OBJECT_DATACOLLECTION
+Command19=ID_OBJECT_PROPERTIES
+Command20=ID_USER_CREATE_USER
+Command21=ID_USER_CREATE_GROUP
+Command22=ID_USER_DELETE
+Command23=ID_USER_SETPASSWORD
+Command24=ID_USER_PROPERTIES
+Command25=ID_ITEM_NEW
+Command26=ID_ITEM_EDIT
+Command27=ID_ITEM_DELETE
+Command28=ID_ITEM_ACTIVATE
+Command29=ID_ITEM_DISABLE
+Command30=ID_ITEM_SHOWDATA
+Command31=ID_ITEM_GRAPH
+Command32=ID_POLICY_ADD
+Command33=ID_POLICY_DELETE
+Command34=ID_POLICY_EDIT
+Command35=ID_POLICY_NEGATECELL
+Command36=ID_POLICY_INSERTRULE_ABOVE
+Command37=ID_POLICY_INSERTRULE_BELOW
+Command38=ID_POLICY_INSERTRULE_TOP
+Command39=ID_POLICY_INSERTRULE_BOTTOM
+Command40=ID_POLICY_DELETERULE
+Command41=ID_POLICY_ENABLERULE
+Command42=ID_POLICY_DISABLERULE
+Command43=ID_UPDATE_EVENT_LIST
+CommandCount=43
 
 [ACL:IDA_MDI_DEFAULT (English (U.S.))]
 Type=1
@@ -1151,47 +1152,48 @@ Command3=ID_USER_CREATE_GROUP
 Command4=ID_USER_RENAME
 Command5=ID_USER_DELETE
 Command6=ID_USER_PROPERTIES
-Command7=ID_OBJECT_CREATE
-Command8=ID_OBJECT_BIND
-Command9=ID_OBJECT_RENAME
-Command10=ID_OBJECT_DELETE
-Command11=ID_OBJECT_MANAGE
-Command12=ID_OBJECT_UNMANAGE
-Command13=ID_OBJECT_DATACOLLECTION
-Command14=ID_OBJECT_PROPERTIES
-Command15=ID_ITEM_NEW
-Command16=ID_ITEM_EDIT
-Command17=ID_ITEM_DELETE
-Command18=ID_ITEM_ACTIVATE
-Command19=ID_ITEM_DISABLE
-Command20=ID_ITEM_SHOWDATA
-Command21=ID_ITEM_GRAPH
-Command22=ID_POLICY_INSERTRULE_ABOVE
-Command23=ID_POLICY_INSERTRULE_BELOW
-Command24=ID_POLICY_INSERTRULE_TOP
-Command25=ID_POLICY_INSERTRULE_BOTTOM
-Command26=ID_POLICY_DELETERULE
-Command27=ID_POLICY_ENABLERULE
-Command28=ID_POLICY_DISABLERULE
-Command29=ID_POLICY_ADD
-Command30=ID_POLICY_DELETE
-Command31=ID_POLICY_NEGATECELL
-Command32=ID_POLICY_INSERTRULE_ABOVE
-Command33=ID_POLICY_INSERTRULE_BELOW
-Command34=ID_POLICY_INSERTRULE_TOP
-Command35=ID_POLICY_INSERTRULE_BOTTOM
-Command36=ID_POLICY_DELETERULE
-Command37=ID_POLICY_ENABLERULE
-Command38=ID_POLICY_DISABLERULE
-Command39=ID_POLICY_EDIT
-Command40=ID_POLICY_INSERTRULE_ABOVE
-Command41=ID_POLICY_INSERTRULE_BELOW
-Command42=ID_POLICY_INSERTRULE_TOP
-Command43=ID_POLICY_INSERTRULE_BOTTOM
-Command44=ID_POLICY_DELETERULE
-Command45=ID_POLICY_ENABLERULE
-Command46=ID_POLICY_DISABLERULE
-CommandCount=46
+Command7=ID_OBJECT_CREATE_NODE
+Command8=ID_OBJECT_CREATE_CONTAINER
+Command9=ID_OBJECT_BIND
+Command10=ID_OBJECT_RENAME
+Command11=ID_OBJECT_DELETE
+Command12=ID_OBJECT_MANAGE
+Command13=ID_OBJECT_UNMANAGE
+Command14=ID_OBJECT_DATACOLLECTION
+Command15=ID_OBJECT_PROPERTIES
+Command16=ID_ITEM_NEW
+Command17=ID_ITEM_EDIT
+Command18=ID_ITEM_DELETE
+Command19=ID_ITEM_ACTIVATE
+Command20=ID_ITEM_DISABLE
+Command21=ID_ITEM_SHOWDATA
+Command22=ID_ITEM_GRAPH
+Command23=ID_POLICY_INSERTRULE_ABOVE
+Command24=ID_POLICY_INSERTRULE_BELOW
+Command25=ID_POLICY_INSERTRULE_TOP
+Command26=ID_POLICY_INSERTRULE_BOTTOM
+Command27=ID_POLICY_DELETERULE
+Command28=ID_POLICY_ENABLERULE
+Command29=ID_POLICY_DISABLERULE
+Command30=ID_POLICY_ADD
+Command31=ID_POLICY_DELETE
+Command32=ID_POLICY_NEGATECELL
+Command33=ID_POLICY_INSERTRULE_ABOVE
+Command34=ID_POLICY_INSERTRULE_BELOW
+Command35=ID_POLICY_INSERTRULE_TOP
+Command36=ID_POLICY_INSERTRULE_BOTTOM
+Command37=ID_POLICY_DELETERULE
+Command38=ID_POLICY_ENABLERULE
+Command39=ID_POLICY_DISABLERULE
+Command40=ID_POLICY_EDIT
+Command41=ID_POLICY_INSERTRULE_ABOVE
+Command42=ID_POLICY_INSERTRULE_BELOW
+Command43=ID_POLICY_INSERTRULE_TOP
+Command44=ID_POLICY_INSERTRULE_BOTTOM
+Command45=ID_POLICY_DELETERULE
+Command46=ID_POLICY_ENABLERULE
+Command47=ID_POLICY_DISABLERULE
+CommandCount=47
 
 [DLG:IDD_SET_PASSWORD (English (U.S.))]
 Type=1
index 670f63c..dfa7282 100644 (file)
@@ -196,7 +196,12 @@ BEGIN
         MENUITEM SEPARATOR
         MENUITEM "&Find...\tCtrl+F",            ID_OBJECT_FIND
         MENUITEM SEPARATOR
-        MENUITEM "&Create...",                  ID_OBJECT_CREATE
+        POPUP "&Create..."
+        BEGIN
+            MENUITEM "&Node...",                    ID_OBJECT_CREATE_NODE
+            MENUITEM "&Container",                  ID_OBJECT_CREATE_CONTAINER
+
+        END
         MENUITEM "&Bind...\tCtrl+B",            ID_OBJECT_BIND
         MENUITEM "&Rename",                     ID_OBJECT_RENAME
         MENUITEM "&Delete",                     ID_OBJECT_DELETE
@@ -278,7 +283,12 @@ BEGIN
     END
     POPUP "Object"
     BEGIN
-        MENUITEM "&Create...",                  ID_OBJECT_CREATE
+        POPUP "&Create"
+        BEGIN
+            MENUITEM "&Node...",                    ID_OBJECT_CREATE_NODE
+            MENUITEM "&Container",                  ID_OBJECT_CREATE_CONTAINER
+
+        END
         MENUITEM "&Bind...",                    ID_OBJECT_BIND
         MENUITEM "&Rename",                     ID_OBJECT_RENAME
         MENUITEM "&Delete",                     ID_OBJECT_DELETE
index 04f7295..dfb862e 100644 (file)
 #define ID_POLICY_ENABLERULE            32852
 #define ID_POLICY_EDIT                  32853
 #define ID_UPDATE_EVENT_LIST            32855
-#define ID_OBJECT_CREATE                32856
 #define ID_OBJECT_BIND                  32857
+#define ID_OBJECT_CREATE_NODE           32860
+#define ID_OBJECT_CREATE_CONTAINER      32861
 #define IDS_GETFOLDERPATH_FAILED        61216
 #define IDS_WORKDIR_CREATION_FAILED     61217
 
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_3D_CONTROLS                     1
 #define _APS_NEXT_RESOURCE_VALUE        191
-#define _APS_NEXT_COMMAND_VALUE         32858
+#define _APS_NEXT_COMMAND_VALUE         32864
 #define _APS_NEXT_CONTROL_VALUE         1105
 #define _APS_NEXT_SYMED_VALUE           119
 #endif
index 7dd4ab9..84c0fa3 100644 (file)
@@ -99,9 +99,11 @@ const char LIBNXCL_EXPORTABLE *NXCGetErrorText(DWORD dwError)
       "Invalid DCI ID",
       "Out of memory",
       "Input/Output error",
-      "Incompatible operation"
+      "Incompatible operation",
+      "Object creation failed",
+      "Loop in object relationship detected"
    };
-   return ((dwError >= 0) && (dwError <= RCC_INCOMPATIBLE_OPERATION)) ? pszErrorText[dwError] : "Unknown error code";
+   return ((dwError >= 0) && (dwError <= RCC_OBJECT_LOOP)) ? pszErrorText[dwError] : "Unknown error code";
 }
 
 
index e5d81aa..2601c1e 100644 (file)
@@ -494,27 +494,56 @@ DWORD LIBNXCL_EXPORTABLE NXCSetObjectMgmtStatus(DWORD dwObjectId, BOOL bIsManage
 
 
 //
-// Create new container object
+// Create new object
 //
 
-DWORD LIBNXCL_EXPORTABLE NXCCreateObject(int iClass, DWORD dwParentObject)
+DWORD LIBNXCL_EXPORTABLE NXCCreateObject(NXC_OBJECT_CREATE_INFO *pCreateInfo, DWORD *pdwObjectId)
 {
-   CSCPMessage msg;
-   DWORD dwRqId;
+   CSCPMessage msg, *pResponce;
+   DWORD dwRqId, dwRetCode;
 
    dwRqId = g_dwMsgId++;
 
    // Build request message
    msg.SetCode(CMD_CREATE_OBJECT);
    msg.SetId(dwRqId);
-   msg.SetVariable(VID_PARENT_ID, dwParentObject);
-   msg.SetVariable(VID_OBJECT_CLASS, (WORD)iClass);
+   msg.SetVariable(VID_PARENT_ID, pCreateInfo->dwParentId);
+   msg.SetVariable(VID_OBJECT_CLASS, (WORD)pCreateInfo->iClass);
+   msg.SetVariable(VID_OBJECT_NAME, pCreateInfo->pszName);
+   switch(pCreateInfo->iClass)
+   {
+      case OBJECT_NODE:
+         msg.SetVariable(VID_IP_ADDRESS, pCreateInfo->cs.node.dwIpAddr);
+         msg.SetVariable(VID_IP_ADDRESS, pCreateInfo->cs.node.dwNetMask);
+         break;
+      case OBJECT_CONTAINER:
+         msg.SetVariable(VID_CATEGORY, pCreateInfo->cs.container.dwCategory);
+         msg.SetVariable(VID_DESCRIPTION, pCreateInfo->cs.container.pszDescription);
+         break;
+      default:
+         break;
+   }
 
    // Send request
    SendMsg(&msg);
 
-   // Wait for reply
-   return WaitForRCC(dwRqId);
+   // Wait for responce
+   pResponce = WaitForMessage(CMD_REQUEST_COMPLETED, dwRqId, 60000);
+   if (pResponce != NULL)
+   {
+      dwRetCode = pResponce->GetVariableLong(VID_RCC);
+      if (dwRetCode == RCC_SUCCESS)
+      {
+         *pdwObjectId = pResponce->GetVariableLong(VID_OBJECT_ID);
+      }
+      delete pResponce;
+   }
+   else
+   {
+      dwRetCode = RCC_TIMEOUT;
+   }
+
+   return dwRetCode;
 }
 
 
index ab180f5..aa51ffe 100644 (file)
@@ -423,6 +423,7 @@ void WatchdogNotify(DWORD dwId);
 void WatchdogPrintStatus(void);
 
 void CheckForMgmtNode(void);
+NetObj *PollNewNode(DWORD dwIpAddr, DWORD dwNetMask, DWORD dwFlags);
 
 void EnumerateClientSessions(void (*pHandler)(ClientSession *, void *), void *pArg);
 void NotifyClient(ClientSession *pSession, void *pArg);
index 3ae3b63..3cee634 100644 (file)
 
 //
 // Poll new node for configuration
+// Returns pointer to new node object on success or NULL on failure
 //
 
-static void PollNode(DWORD dwIpAddr, DWORD dwNetMask, DWORD dwFlags)
+NetObj *PollNewNode(DWORD dwIpAddr, DWORD dwNetMask, DWORD dwFlags)
 {
    Node *pNode;
    char szIpAddr1[32], szIpAddr2[32];
@@ -40,7 +41,7 @@ static void PollNode(DWORD dwIpAddr, DWORD dwNetMask, DWORD dwFlags)
    {
       DbgPrintf(AF_DEBUG_DISCOVERY, "PollNode: Node %s already exist in database\n", 
                 IpToStr(dwIpAddr, szIpAddr1));
-      return;
+      return NULL;
    }
 
    pNode = new Node(dwIpAddr, 0, dwFlags);
@@ -53,11 +54,12 @@ static void PollNode(DWORD dwIpAddr, DWORD dwNetMask, DWORD dwFlags)
       NetObjDelete(pNode);
       ObjectsGlobalUnlock();
       delete pNode;     // Node poll failed, delete it
-      return;
+      return NULL;
    }
 
    // DEBUG
    pNode->AddItem(new DCItem(CreateUniqueId(IDG_ITEM), "Status", DS_INTERNAL, DTYPE_INTEGER, 60, 30, pNode));
+   return pNode;
 }
 
 
@@ -99,7 +101,7 @@ void NodePoller(void *arg)
             dwNetMask = DBGetFieldULong(hResult, i, 2);
             dwFlags = DBGetFieldULong(hResult, i, 3);
 
-            PollNode(dwIpAddr, dwNetMask, dwFlags);
+            PollNewNode(dwIpAddr, dwNetMask, dwFlags);
 
             // Delete processed node
             sprintf(szQuery, "DELETE FROM new_nodes WHERE id=%ld", dwId);
index 5daafcd..1df312e 100644 (file)
@@ -1814,7 +1814,7 @@ void ClientSession::CreateObject(CSCPMessage *pRequest)
    CSCPMessage msg;
    NetObj *pObject, *pParent;
    int iClass;
-   char szObjectName[MAX_OBJECT_NAME];
+   char *pDescription, szObjectName[MAX_OBJECT_NAME];
 
    // Prepare responce message
    msg.SetCode(CMD_REQUEST_COMPLETED);
@@ -1835,18 +1835,36 @@ void ClientSession::CreateObject(CSCPMessage *pRequest)
             pRequest->GetVariableStr(VID_OBJECT_NAME, szObjectName, MAX_OBJECT_NAME);
             if ((iClass == OBJECT_NODE) || (iClass == OBJECT_CONTAINER))
             {
+               // Create new object
                switch(iClass)
                {
                   case OBJECT_NODE:
-                     pObject = new Node;
+                     pObject = PollNewNode(pRequest->GetVariableLong(VID_IP_ADDRESS),
+                                           pRequest->GetVariableLong(VID_IP_NETMASK),
+                                           DF_DEFAULT);
                      break;
                   case OBJECT_CONTAINER:
-                     pObject = new Container;
+                     pDescription = pRequest->GetVariableStr(VID_DESCRIPTION);
+                     pObject = new Container(szObjectName, 
+                                             pRequest->GetVariableLong(VID_CATEGORY),
+                                             pDescription);
+                     MemFree(pDescription);
+                     NetObjInsert(pObject, TRUE);
                      break;
                }
-               NetObjInsert(pObject, TRUE);
-               pParent->AddChild(pObject);
-               pObject->AddParent(pParent);
+
+               // If creation was successful do binding
+               if (pObject != NULL)
+               {
+                  pParent->AddChild(pObject);
+                  pObject->AddParent(pParent);
+                  msg.SetVariable(VID_RCC, RCC_SUCCESS);
+                  msg.SetVariable(VID_OBJECT_ID, pObject->Id());
+               }
+               else
+               {
+                  msg.SetVariable(VID_RCC, RCC_OBJECT_CREATION_FAILED);
+               }
             }
             else
             {
@@ -1903,15 +1921,24 @@ void ClientSession::ChangeObjectBinding(CSCPMessage *pRequest, BOOL bBind)
          {
             if (bBind)
             {
-               pParent->AddChild(pChild);
-               pChild->AddParent(pParent);
+               // Prevent loops
+               if (!pChild->IsChild(pParent->Id()))
+               {
+                  pParent->AddChild(pChild);
+                  pChild->AddParent(pParent);
+                  msg.SetVariable(VID_RCC, RCC_SUCCESS);
+               }
+               else
+               {
+                  msg.SetVariable(VID_RCC, RCC_OBJECT_LOOP);
+               }
             }
             else
             {
                pParent->DeleteChild(pChild);
                pChild->DeleteParent(pParent);
+               msg.SetVariable(VID_RCC, RCC_SUCCESS);
             }
-            msg.SetVariable(VID_RCC, RCC_SUCCESS);
          }
          else
          {